Skip to content

Instantly share code, notes, and snippets.

@galex
Last active December 10, 2015 08:08
Show Gist options
  • Save galex/4406148 to your computer and use it in GitHub Desktop.
Save galex/4406148 to your computer and use it in GitHub Desktop.
Skeleton of a map fragment
package com.example.fragment;
public class PlaceMapFragment extends RefreshMapFragment implements LoaderCallbacks<List<Category>> {
private static final int LOADER_ID = 613;
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
getSherlockActivity().getSupportLoaderManager().initLoader(LOADER_ID, null, this);
}
@Override
public Loader<List<Category>> onCreateLoader(int id, Bundle bundle) {
setRefreshing(true);
return new CategoryLoader(getSherlockActivity());
}
@Override
public void onLoadFinished(Loader<List<Category>> loader, List<Category> data) {
// WHEN GETTING DATA, we're going to put the places (contained by the Category model object) on our map
setRefreshing(false);
}
@Override
public void onLoaderReset(Loader<List<Category>> loader) {
}
@Override
public void onRefresh() {
getSherlockActivity().getSupportLoaderManager().restartLoader(LOADER_ID, null, this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment