1
0
mirror of https://github.com/bspeice/itcs4180 synced 2024-12-04 13:18:16 -05:00

More refactoring and streamlining of the API.

This commit is contained in:
Bradlee Speice 2014-04-15 21:46:38 -04:00
parent 385d53a23a
commit 932544b6aa
2 changed files with 6 additions and 15 deletions

View File

@ -49,6 +49,9 @@ public class MainActivity extends Activity {
// We're back on the main thread at this point, so it's legal.
((TextView)findViewById(R.id.txtNoLocations)).setVisibility(View.GONE);
((ListView)findViewById(R.id.listLocations)).setVisibility(View.VISIBLE);
// And we're even kind enough to update the database
LocationDatabaseHelper.getInstance(MainActivity.this).persistAll(result);
}
}.execute();
}

View File

@ -3,13 +3,11 @@ package edu.uncc.scavenger.rest;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ExecutionException;
import edu.uncc.scavenger.R;
import edu.uncc.scavenger.database.LocationDatabaseHelper;
import retrofit.RestAdapter;
import android.content.Context;
import android.os.AsyncTask;
import retrofit.RestAdapter;
import edu.uncc.scavenger.R;
public class LocationClient {
@ -30,7 +28,7 @@ public class LocationClient {
public static class LocationsDownloader extends
AsyncTask<Void, Void, List<RestLocation>> {
Context ctx;
private Context ctx;
public LocationsDownloader(Context ctx) {
this.ctx = ctx;
@ -41,14 +39,4 @@ public class LocationClient {
return getAdapter(ctx).listLocations();
}
}
public static AsyncTask<Void, Void, List<RestLocation>> updateDatabase(Context ctx) {
// Start the downloader and wait until it's finished.
return new LocationsDownloader(ctx) {
@Override
protected void onPostExecute(List<RestLocation> result) {
LocationDatabaseHelper.getInstance(ctx).persistAll(result);
}
}.execute();
}
}