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:
parent
385d53a23a
commit
932544b6aa
@ -49,6 +49,9 @@ public class MainActivity extends Activity {
|
|||||||
// We're back on the main thread at this point, so it's legal.
|
// We're back on the main thread at this point, so it's legal.
|
||||||
((TextView)findViewById(R.id.txtNoLocations)).setVisibility(View.GONE);
|
((TextView)findViewById(R.id.txtNoLocations)).setVisibility(View.GONE);
|
||||||
((ListView)findViewById(R.id.listLocations)).setVisibility(View.VISIBLE);
|
((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();
|
}.execute();
|
||||||
}
|
}
|
||||||
|
@ -3,13 +3,11 @@ package edu.uncc.scavenger.rest;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.ExecutionException;
|
|
||||||
|
|
||||||
import edu.uncc.scavenger.R;
|
import retrofit.RestAdapter;
|
||||||
import edu.uncc.scavenger.database.LocationDatabaseHelper;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.AsyncTask;
|
import android.os.AsyncTask;
|
||||||
import retrofit.RestAdapter;
|
import edu.uncc.scavenger.R;
|
||||||
|
|
||||||
public class LocationClient {
|
public class LocationClient {
|
||||||
|
|
||||||
@ -30,7 +28,7 @@ public class LocationClient {
|
|||||||
|
|
||||||
public static class LocationsDownloader extends
|
public static class LocationsDownloader extends
|
||||||
AsyncTask<Void, Void, List<RestLocation>> {
|
AsyncTask<Void, Void, List<RestLocation>> {
|
||||||
Context ctx;
|
private Context ctx;
|
||||||
|
|
||||||
public LocationsDownloader(Context ctx) {
|
public LocationsDownloader(Context ctx) {
|
||||||
this.ctx = ctx;
|
this.ctx = ctx;
|
||||||
@ -41,14 +39,4 @@ public class LocationClient {
|
|||||||
return getAdapter(ctx).listLocations();
|
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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user