Android Open Source - C2Framework Context Broadcast Receiver






From Project

Back to project page C2Framework.

License

The source code is released under:

Apache License

If you think the Android project C2Framework listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package gaia.c2.receivers;
/*  w  ww .  jav  a 2  s  .c  o m*/
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;

public class ContextBroadcastReceiver extends BroadcastReceiver {
    public static final String CONTENT_MESSAGE_OK = "gaia.c2.MESSAGE_OK";
    public static final String CONTENT_MESSAGE_FAILED = "gaia.c2.MESSAGE_FAILED";

    public static final String CONTENT_FIELD = "gaia.c2.Content";
    public static final String CONTENT_FIELD_ARRAY = "gaia.c2.ContentArray";
    public static final String CONTENT_MIME_TYPE = "gaia.c2.MimeType";
    public static final String EXCEPTION_FIELD = "gaia.c2.Exception";

    private ContextEventReceiver eventReceiver;

    public ContextBroadcastReceiver() {
        throw new UnsupportedOperationException("use ContextBroadcastReceiver(ContextEventReceiver) instead");
    }

    public ContextBroadcastReceiver(ContextEventReceiver eventReceiver) {
        this.eventReceiver = eventReceiver;
    }

    @Override
    public void onReceive(Context androidContext, Intent intent) {
        final String action = intent.getAction();
        if (action != null) {
            if (action.equals(CONTENT_MESSAGE_OK)) {
                eventReceiver.onSuccess(intent.getExtras());
            } else if (action.equals(CONTENT_MESSAGE_FAILED)) {
                eventReceiver.onFail(intent.getExtras(), (Exception) intent.getExtras().getSerializable(EXCEPTION_FIELD));
            } else {
                throw new UnsupportedOperationException("invalid action '" + action + "'");
            }
        } else {
            throw new UnsupportedOperationException("invalid action null");
        }
    }
}




Java Source Code List

gaia.c2.content.C2ContentProvider.java
gaia.c2.content.C2ContentService.java
gaia.c2.content.QueryHandler.java
gaia.c2.content.android.CallContentProvider.java
gaia.c2.content.android.DialContentProvider.java
gaia.c2.content.android.VibrationContentProvider.java
gaia.c2.content.android.model.Call.java
gaia.c2.content.android.model.Dial.java
gaia.c2.content.android.model.Vibration.java
gaia.c2.content.model.ContextDependentModel.java
gaia.c2.content.sqlite.C2SQLiteContentProvider.java
gaia.c2.content.sqlite.C2SQLiteHelper.java
gaia.c2.content.tools.C2DownloadsContentProvider.java
gaia.c2.content.tools.model.DownloadStatus.java
gaia.c2.context.C2Context.java
gaia.c2.context.DefaultC2Context.java
gaia.c2.context.view.C2Message.java
gaia.c2.context.view.C2View.java
gaia.c2.receivers.ContextBroadcastReceiver.java
gaia.c2.receivers.ContextEventReceiver.java