use of ca.etsmtl.applets.etsmobile.model.applets_events.SourceEvenementList in project ETSMobile-Android2 by ApplETS.
the class EventsFragment method onResume.
@Override
public void onResume() {
super.onResume();
expandableListAdapter.clearEvents();
progressBar.setVisibility(View.VISIBLE);
countSourcesLoaded = 0;
nbSources = 0;
progressBar.setProgress(0);
AppletsApiSourcesRequest requestSources = new AppletsApiSourcesRequest(getActivity());
String cacheKey = requestSources.createCacheKey();
spiceManager.execute(requestSources, cacheKey, DurationInMillis.ONE_MINUTE * 10, new RequestListener<SourceEvenementList>() {
@Override
public void onRequestFailure(SpiceException spiceException) {
spiceException.printStackTrace();
Toast.makeText(getActivity(), getString(R.string.SupportKit_errorCouldNotConnect), Toast.LENGTH_SHORT).show();
}
@Override
public void onRequestSuccess(SourceEvenementList sourceEvenements) {
progressBar.setMax(sourceEvenements.size());
EventsFragment.this.nbSources = sourceEvenements.size();
for (SourceEvenement source : sourceEvenements) {
AppletsApiEvenementsRequest requestEvents = new AppletsApiEvenementsRequest(getActivity(), source);
String cacheKey = requestEvents.createCacheKey();
spiceManager.execute(requestEvents, cacheKey, DurationInMillis.ONE_MINUTE * 10, EventsFragment.this);
}
}
});
}
use of ca.etsmtl.applets.etsmobile.model.applets_events.SourceEvenementList in project ETSMobile-Android2 by ApplETS.
the class AppletsApiSourcesRequest method loadDataFromNetwork.
@Override
public SourceEvenementList loadDataFromNetwork() throws Exception {
String sourceAddress = context.getString(R.string.applets_api_events_sources);
OkHttpClient client = new OkHttpClient();
Request request = new Request.Builder().url(sourceAddress).get().build();
Response response = client.newCall(request).execute();
String result = response.body().string();
SourceEvenementList sources = new Gson().fromJson(result, SourceEvenementList.class);
return sources;
}
Aggregations