Search in sources :

Example 1 with AppletsApiEvenementsRequest

use of ca.etsmtl.applets.etsmobile.http.AppletsApiEvenementsRequest 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);
            }
        }
    });
}
Also used : SourceEvenementList(ca.etsmtl.applets.etsmobile.model.applets_events.SourceEvenementList) SourceEvenement(ca.etsmtl.applets.etsmobile.model.applets_events.SourceEvenement) SpiceException(com.octo.android.robospice.persistence.exception.SpiceException) AppletsApiSourcesRequest(ca.etsmtl.applets.etsmobile.http.AppletsApiSourcesRequest) AppletsApiEvenementsRequest(ca.etsmtl.applets.etsmobile.http.AppletsApiEvenementsRequest)

Aggregations

AppletsApiEvenementsRequest (ca.etsmtl.applets.etsmobile.http.AppletsApiEvenementsRequest)1 AppletsApiSourcesRequest (ca.etsmtl.applets.etsmobile.http.AppletsApiSourcesRequest)1 SourceEvenement (ca.etsmtl.applets.etsmobile.model.applets_events.SourceEvenement)1 SourceEvenementList (ca.etsmtl.applets.etsmobile.model.applets_events.SourceEvenementList)1 SpiceException (com.octo.android.robospice.persistence.exception.SpiceException)1