Skip to content

Instantly share code, notes, and snippets.

@parahall
Created May 13, 2017 15:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parahall/33f73eb5fa41e866fe3557bbf20791b1 to your computer and use it in GitHub Desktop.
Save parahall/33f73eb5fa41e866fe3557bbf20791b1 to your computer and use it in GitHub Desktop.
public class StarWarsService extends IntentService {
public StarWarsService() {
super("StarWarsService");
}
@Override protected void onHandleIntent(Intent intent) {
if (intent != null) {
String json = ResourcesUtil.loadJson(this);
Gson gson = new GsonBuilder().setDateFormat("MMM d, yyyy").create();
ArrayList<StarWarsMovie> moviesList =
gson.fromJson(json, new TypeToken<ArrayList<StarWarsMovie>>() {
}.getType());
Intent response = new Intent();
response.setAction(MainPresenter.LOAD_COMPLETE_ACTION);
response.putExtra(MainPresenter.DATA_KEY, moviesList);
LocalBroadcastManager.getInstance(this).sendBroadcast(response);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment