March 2013
Beginner to intermediate
580 pages
16h 11m
English
For your last trick, you need to get the loading of the last location off of the main thread. This work will be almost identical to what you just did for loading the run, except that you will work with the run’s last location as the data. First, create the LastLocationLoader class to do the work.
Listing 35.9 LastLocationLoader (LastLocationLoader.java)
public class LastLocationLoader extends DataLoader<Location> {
private long mRunId;
public LastLocationLoader(Context context, long runId) {
super(context);
mRunId = runId;
}
@Override
public Location loadInBackground() {
return RunManager.get(getContext()).getLastLocationForRun(mRunId);
}
}This class is almost exactly like RunLoader, except that it calls RunManager ...
Read now
Unlock full access