Created
May 13, 2017 15:01
-
-
Save parahall/33f73eb5fa41e866fe3557bbf20791b1 to your computer and use it in GitHub Desktop.
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 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