Back to project page mobile-android.
The source code is released under:
MIT License
If you think the Android project mobile-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.manyconf.conference; //from w ww . ja v a 2 s .c om import android.app.Application; import android.content.Context; import android.content.Intent; import android.support.v4.content.LocalBroadcastManager; import android.util.Log; import java.util.ArrayList; import java.util.LinkedHashMap; /** * This class extends the (by default present) Application class, which is a singleton. We use * it here to store global variables. */ public class ConferenceApplication extends Application implements ConferenceBuilderDelegate { public static Context context; private ConferenceBuilder cachedConfBuilder; private ConferenceBuilder confBuilder; private LinkedHashMap<Integer, ConferenceModel> conferenceList; private String lastError; public static final String mod = "manyconf.appl"; @Override public void onCreate() { super.onCreate(); context = getApplicationContext(); } public void fetchCachedConferences() { Log.d(mod, "fetchCachedConferences()"); if(cachedConfBuilder != null) { cachedConfBuilder.cancel(true); } cachedConfBuilder = new ConferenceBuilder(this, getBaseContext(), true); cachedConfBuilder.execute(); Log.d(mod, "kicked off async task to show cache"); } public void fetchConferences() { Log.d(mod, "fetchConferences()"); if(confBuilder != null) { confBuilder.cancel(true); } confBuilder = new ConferenceBuilder(this, getBaseContext(), false); confBuilder.execute(); Log.d(mod, "kicked off async task to retrieve from network"); } public LinkedHashMap<Integer, ConferenceModel> getConferenceList() { return this.conferenceList; } public String getLastError() { return lastError; } @Override public void retrievedConferenceList(LinkedHashMap<Integer, ConferenceModel> conferenceList, String errorMsg) { Log.d(mod, "retrievedConferenceList()"); this.conferenceList = conferenceList; this.lastError = errorMsg; this.sendMessage(); } @Override public void retrievedCachedConferenceList(LinkedHashMap<Integer, ConferenceModel> conferenceList, String errorMsg) { Log.d(mod, "retrievedCachedConferenceList()"); this.conferenceList = conferenceList; this.lastError = errorMsg; if(this.lastError != null) { Log.w(mod, "last error not null"); } this.sendMessage(); } // Broadcasts an intent that any result (succes or error) is available. // See also: // http://stackoverflow.com/questions/3947641 // and for destroying, use onPause(): // http://stackoverflow.com/questions/8802157 private void sendMessage() { Log.d(mod, "Broadcasting message"); Intent intent = new Intent("SERVICE_HANDLER_RESULT"); // You can also include some extra data. intent.putExtra("message", "This is my message!"); LocalBroadcastManager.getInstance(context).sendBroadcast(intent); } }