Android Open Source - savemypics A Authenticator Activity






From Project

Back to project page savemypics.

License

The source code is released under:

Copyright (c) 2014, KB Sriram All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. R...

If you think the Android project savemypics 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 org.savemypics.android.authenticator;
//from w  w w. ja v a2s  . com
import android.os.Bundle;
import android.app.Dialog;
import android.content.DialogInterface;
import android.accounts.AccountAuthenticatorActivity;
import org.savemypics.android.R;
import org.savemypics.android.event.CExceptionEvent;
import org.savemypics.android.util.CUtils;

public abstract class AAuthenticatorActivity
    extends AccountAuthenticatorActivity
    implements CExceptionEvent.Listener
{
    @Override
    protected void onPause()
    {
        CExceptionEvent.unsubscribe(this);
        super.onPause();
    }

    @Override
    protected void onResume()
    {
        super.onResume();
        CExceptionEvent.subscribe(this);
    }

    public void onException(CExceptionEvent ev)
    {
        StringBuilder sb = new StringBuilder();
        if (ev.getMessage() != null) {
            sb.append(ev.getMessage());
            sb.append("\n");
        }
        sb.append(ev.getCause().toString());
        showGeneralErrorDialog(sb.toString());
    }

    private void showGeneralErrorDialog(String msg)
    {
        final Bundle bundle = new Bundle();
        bundle.putString(ERROR_MESSAGE, msg);

        runOnUiThread(new Runnable() {
                public void run() {
                    showDialog(ERROR_DIALOG, bundle);
                }
            });
    }

    @Override
    protected Dialog onCreateDialog(int id, Bundle bundle)
    {
        switch (id) {

        case ERROR_WIFI_DIALOG:
            return CUtils.makeEnableWifiDialog
                (this, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface d, int id) {
                            d.cancel();
                            setResult(RESULT_CANCELED);
                            AAuthenticatorActivity.this.finish();
                        }
                    });

        case ERROR_DIALOG:
            String msg = bundle.getString(ERROR_MESSAGE);
            if (msg != null) {
                return CUtils.makeAlertDialog
                    (this, "Error", msg,
                     new DialogInterface.OnClickListener() {
                         public void onClick(DialogInterface d, int id) {
                             d.cancel();
                             removeDialog(id);
                         }
                     });
            }
            else {
                return super.onCreateDialog(id, bundle);
            }


        default:
            return super.onCreateDialog(id, bundle);
        }
    }

    protected final void showErrorDialog(Throwable issue)
    {
        CUtils.LOGW(TAG, "Issue", issue);
        showErrorDialog(issue.getMessage());
    }
    protected final void showErrorDialog(String msg)
    {
        final Bundle bundle = new Bundle();
        bundle.putString(ERROR_MESSAGE, msg);
        showDialog(ERROR_DIALOG, bundle);
    }

    protected final static int ERROR_DIALOG = 100;
    protected final static String ERROR_MESSAGE = "error_msg";
    protected final static int ERROR_WIFI_DIALOG = 101;
    private final static String TAG =
        CUtils.makeLogTag(AAuthenticatorActivity.class);
}




Java Source Code List

android.util.Base64.java
org.savemypics.android.activity.AActivity.java
org.savemypics.android.activity.ABaseSettingsActivity.java
org.savemypics.android.activity.CAccountInfoListAdapter.java
org.savemypics.android.activity.CFlickrSettingsActivity.java
org.savemypics.android.activity.CSnapfishSettingsActivity.java
org.savemypics.android.activity.CStartActivity.java
org.savemypics.android.authenticator.AAuthenticatorActivity.java
org.savemypics.android.authenticator.CAuthenticationService.java
org.savemypics.android.authenticator.CAuthenticator.java
org.savemypics.android.authenticator.CFlickrLoginHookActivity.java
org.savemypics.android.authenticator.CFlickrWebActivity.java
org.savemypics.android.authenticator.CSelectProviderActivity.java
org.savemypics.android.authenticator.CSnapfishLoginActivity.java
org.savemypics.android.db.CAccount.java
org.savemypics.android.db.CDb.java
org.savemypics.android.db.CLocalImage.java
org.savemypics.android.db.CMap.java
org.savemypics.android.db.CRemoteImage.java
org.savemypics.android.event.AEvent.java
org.savemypics.android.event.CEventBus.java
org.savemypics.android.event.CExceptionEvent.java
org.savemypics.android.glue.ABaseGlue.java
org.savemypics.android.glue.CFlickrGlue.java
org.savemypics.android.glue.CSnapfishGlue.java
org.savemypics.android.receiver.CNetworkChangeReceiver.java
org.savemypics.android.service.CTaskQueue.java
org.savemypics.android.sync.CMediaUtils.java
org.savemypics.android.sync.CSyncAdapter.java
org.savemypics.android.sync.CSyncService.java
org.savemypics.android.sync.CSyncUtils.java
org.savemypics.android.util.CBitmapUtils.java
org.savemypics.android.util.CFileCache.java
org.savemypics.android.util.CLruCache.java
org.savemypics.android.util.CUtils.java
org.savemypics.android.util.CUtils.java
org.savemypics.android.view.CMaximumWidthLayout.java
org.savemypics.android.view.CModularLayout.java
org.savemypics.android.view.CRefreshButton.java
org.savemypics.android.view.CRoundedBitmapView.java
org.savemypics.android.view.CStatusCounterView.java
org.savemypics.plugin.CIOUtils.java
org.savemypics.plugin.CPlugin.java
org.savemypics.plugin.flickr.CFlickrAlbum.java
org.savemypics.plugin.flickr.CFlickrUtils.java
org.savemypics.plugin.snapfish.CSnapfishAlbum.java
org.savemypics.plugin.snapfish.CSnapfishFeed.java
org.savemypics.plugin.snapfish.CSnapfishUser.java
org.savemypics.plugin.snapfish.CSnapfishUtils.java