Search in sources :

Example 1 with Glitch

use of com.tinyspeck.android.Glitch in project glitch-hq-android by tinyspeck.

the class C2DMReceiver method addRegistrationId.

public void addRegistrationId(Context context, String registrationId) {
    // save the pointer to the context so we can use it in the callback
    this.context = context;
    Map<String, String> params = new HashMap<String, String>();
    params.put("type", "android");
    params.put("id", registrationId);
    params.put("registration_id", registrationId);
    Glitch glitch = ((MyApplication) context.getApplicationContext()).glitch;
    GlitchRequest request = glitch.getRequest("users.devices.add", params);
    if (glitch.accessToken != null) {
        request.execute(this);
    } else {
        // We havent logged in yet so lets try this later
        requestFailed(request);
    }
}
Also used : HashMap(java.util.HashMap) Glitch(com.tinyspeck.android.Glitch) GlitchRequest(com.tinyspeck.android.GlitchRequest)

Example 2 with Glitch

use of com.tinyspeck.android.Glitch in project glitch-hq-android by tinyspeck.

the class MyApplication method init.

public void init(Activity act) {
    if (m_bInit)
        return;
    m_bInit = true;
    GlobalExceptionHandler handler = new GlobalExceptionHandler(Thread.getDefaultUncaughtExceptionHandler());
    Thread.setDefaultUncaughtExceptionHandler(handler);
    m_downloader = new ImageDownloader() {

        public void setImageViewBitmap(ImageView iv, Bitmap bm) {
            int nType = (Integer) iv.getTag();
            if (nType == DOWNLOAD_TYPE_MIRROR)
                bm = BitmapUtil.GetMirror(bm);
            else if (nType == DOWNLOAD_TYPEE_CROP) {
                bm = BitmapUtil.GetMirror(bm);
                bm = BitmapUtil.CreateOvalImage(bm);
            }
            iv.setVisibility(View.VISIBLE);
            iv.setImageBitmap(bm);
        }
    };
    // The VAG and VAG Light fonts are not in the public domain and are not
    // distributed in this repository.
    m_vagFont = Typeface.createFromAsset(getAssets(), "VAG.ttf");
    m_vagLightFont = Typeface.createFromAsset(getAssets(), "VAGLight.ttf");
    glitch = new Glitch("key-removed", "glitchhq://auth");
}
Also used : Bitmap(android.graphics.Bitmap) ImageView(android.widget.ImageView) Glitch(com.tinyspeck.android.Glitch)

Example 3 with Glitch

use of com.tinyspeck.android.Glitch in project glitch-hq-android by tinyspeck.

the class C2DMReceiver method requestFailed.

public void requestFailed(final GlitchRequest request) {
    Log.i(TAG, "We couldn't add this mobile device to Glitch. Will try again later");
    FlurryAgent.logEvent("C2DMReceiver: Request for " + request.method + " failed.\n\n" + request.params.toString() + "\n\n" + request.response.toString());
    final C2DMReceiver receiver = this;
    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {

        public void run() {
            Glitch glitch = ((MyApplication) context.getApplicationContext()).glitch;
            if (glitch.accessToken != null) {
                request.execute(receiver);
            } else {
                requestFailed(request);
            }
        }
    }, 30000);
}
Also used : Handler(android.os.Handler) Glitch(com.tinyspeck.android.Glitch)

Aggregations

Glitch (com.tinyspeck.android.Glitch)3 Bitmap (android.graphics.Bitmap)1 Handler (android.os.Handler)1 ImageView (android.widget.ImageView)1 GlitchRequest (com.tinyspeck.android.GlitchRequest)1 HashMap (java.util.HashMap)1