Created
March 24, 2011 04:42
-
-
Save codeswimmer/884591 to your computer and use it in GitHub Desktop.
Android: AsyncTaskLoader Fragment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class RetrievedDataFragment extends Fragment implements LoaderManager.LoaderCallbacks<D> { | |
public RetrievedDataFragment() { | |
} | |
@Override | |
public void onActivityCreated(Bundle savedInstanceState) { | |
super.onActivityCreated(savedInstanceState); | |
getLoaderManager().initLoader(0, null, this); | |
getLoaderManager().getLoader(0).startLoading(); | |
} | |
@Override | |
public Loader<String> onCreateLoader(int id, Bundle args) { | |
return new LoaderDrone(getActivity()); | |
} | |
@Override | |
public void onLoadFinished(Loader<String> arg0, String results) { | |
// TODO: Handle results | |
} | |
@Override | |
public void onLoaderReset(Loader<String> arg0) { | |
} | |
public static class LoaderDrone extends AsyncTaskLoader<D> { | |
public LoaderDrone(Context context) { | |
super(context); | |
onForceLoad(); | |
} | |
@Override | |
public D loadInBackground() { | |
D results = null; | |
// TODO: Retrieve results | |
return results; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment