Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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