Search in sources :

Example 66 with Parcelable

use of android.os.Parcelable in project PhotoNoter by yydcdut.

the class FloatingActionsMenu method onSaveInstanceState.

@Override
public Parcelable onSaveInstanceState() {
    Parcelable superState = super.onSaveInstanceState();
    SavedState savedState = new SavedState(superState);
    savedState.mExpanded = mExpanded;
    return savedState;
}
Also used : Parcelable(android.os.Parcelable)

Example 67 with Parcelable

use of android.os.Parcelable in project XobotOS by xamarin.

the class Activity method onCreate.

/**
     * Called when the activity is starting.  This is where most initialization
     * should go: calling {@link #setContentView(int)} to inflate the
     * activity's UI, using {@link #findViewById} to programmatically interact
     * with widgets in the UI, calling
     * {@link #managedQuery(android.net.Uri , String[], String, String[], String)} to retrieve
     * cursors for data being displayed, etc.
     * 
     * <p>You can call {@link #finish} from within this function, in
     * which case onDestroy() will be immediately called without any of the rest
     * of the activity lifecycle ({@link #onStart}, {@link #onResume},
     * {@link #onPause}, etc) executing.
     * 
     * <p><em>Derived classes must call through to the super class's
     * implementation of this method.  If they do not, an exception will be
     * thrown.</em></p>
     * 
     * @param savedInstanceState If the activity is being re-initialized after
     *     previously being shut down then this Bundle contains the data it most
     *     recently supplied in {@link #onSaveInstanceState}.  <b><i>Note: Otherwise it is null.</i></b>
     * 
     * @see #onStart
     * @see #onSaveInstanceState
     * @see #onRestoreInstanceState
     * @see #onPostCreate
     */
protected void onCreate(Bundle savedInstanceState) {
    if (mLastNonConfigurationInstances != null) {
        mAllLoaderManagers = mLastNonConfigurationInstances.loaders;
    }
    if (savedInstanceState != null) {
        Parcelable p = savedInstanceState.getParcelable(FRAGMENTS_TAG);
        mFragments.restoreAllState(p, mLastNonConfigurationInstances != null ? mLastNonConfigurationInstances.fragments : null);
    }
    mFragments.dispatchCreate();
    getApplication().dispatchActivityCreated(this, savedInstanceState);
    mCalled = true;
}
Also used : Parcelable(android.os.Parcelable)

Example 68 with Parcelable

use of android.os.Parcelable in project XobotOS by xamarin.

the class Activity method onSaveInstanceState.

/**
     * Called to retrieve per-instance state from an activity before being killed
     * so that the state can be restored in {@link #onCreate} or
     * {@link #onRestoreInstanceState} (the {@link Bundle} populated by this method
     * will be passed to both).
     *
     * <p>This method is called before an activity may be killed so that when it
     * comes back some time in the future it can restore its state.  For example,
     * if activity B is launched in front of activity A, and at some point activity
     * A is killed to reclaim resources, activity A will have a chance to save the
     * current state of its user interface via this method so that when the user
     * returns to activity A, the state of the user interface can be restored
     * via {@link #onCreate} or {@link #onRestoreInstanceState}.
     *
     * <p>Do not confuse this method with activity lifecycle callbacks such as
     * {@link #onPause}, which is always called when an activity is being placed
     * in the background or on its way to destruction, or {@link #onStop} which
     * is called before destruction.  One example of when {@link #onPause} and
     * {@link #onStop} is called and not this method is when a user navigates back
     * from activity B to activity A: there is no need to call {@link #onSaveInstanceState}
     * on B because that particular instance will never be restored, so the
     * system avoids calling it.  An example when {@link #onPause} is called and
     * not {@link #onSaveInstanceState} is when activity B is launched in front of activity A:
     * the system may avoid calling {@link #onSaveInstanceState} on activity A if it isn't
     * killed during the lifetime of B since the state of the user interface of
     * A will stay intact.
     *
     * <p>The default implementation takes care of most of the UI per-instance
     * state for you by calling {@link android.view.View#onSaveInstanceState()} on each
     * view in the hierarchy that has an id, and by saving the id of the currently
     * focused view (all of which is restored by the default implementation of
     * {@link #onRestoreInstanceState}).  If you override this method to save additional
     * information not captured by each individual view, you will likely want to
     * call through to the default implementation, otherwise be prepared to save
     * all of the state of each view yourself.
     *
     * <p>If called, this method will occur before {@link #onStop}.  There are
     * no guarantees about whether it will occur before or after {@link #onPause}.
     * 
     * @param outState Bundle in which to place your saved state.
     * 
     * @see #onCreate
     * @see #onRestoreInstanceState
     * @see #onPause
     */
protected void onSaveInstanceState(Bundle outState) {
    outState.putBundle(WINDOW_HIERARCHY_TAG, mWindow.saveHierarchyState());
    Parcelable p = mFragments.saveAllState();
    if (p != null) {
        outState.putParcelable(FRAGMENTS_TAG, p);
    }
    getApplication().dispatchActivitySaveInstanceState(this, outState);
}
Also used : Parcelable(android.os.Parcelable)

Example 69 with Parcelable

use of android.os.Parcelable in project XobotOS by xamarin.

the class ChooseTypeAndAccountActivity method onActivityResult.

// Called when the choose account type activity (for adding an account) returns.
// If it was a success read the account and set it in the result. In all cases
// return the result and finish this activity.
@Override
protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) {
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        if (data != null && data.getExtras() != null)
            data.getExtras().keySet();
        Bundle extras = data != null ? data.getExtras() : null;
        Log.v(TAG, "ChooseTypeAndAccountActivity.onActivityResult(reqCode=" + requestCode + ", resCode=" + resultCode + ", extras=" + extras + ")");
    }
    // we got our result, so clear the fact that we had a pending request
    mPendingRequest = REQUEST_NULL;
    if (resultCode == RESULT_CANCELED) {
        return;
    }
    if (resultCode == RESULT_OK) {
        if (requestCode == REQUEST_CHOOSE_TYPE) {
            if (data != null) {
                String accountType = data.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE);
                if (accountType != null) {
                    runAddAccountForAuthenticator(accountType);
                    return;
                }
            }
            Log.d(TAG, "ChooseTypeAndAccountActivity.onActivityResult: unable to find account " + "type, pretending the request was canceled");
        } else if (requestCode == REQUEST_ADD_ACCOUNT) {
            String accountName = null;
            String accountType = null;
            if (data != null) {
                accountName = data.getStringExtra(AccountManager.KEY_ACCOUNT_NAME);
                accountType = data.getStringExtra(AccountManager.KEY_ACCOUNT_TYPE);
            }
            if (accountName == null || accountType == null) {
                Account[] currentAccounts = AccountManager.get(this).getAccounts();
                Set<Account> preExistingAccounts = new HashSet<Account>();
                for (Parcelable accountParcel : mExistingAccounts) {
                    preExistingAccounts.add((Account) accountParcel);
                }
                for (Account account : currentAccounts) {
                    if (!preExistingAccounts.contains(account)) {
                        accountName = account.name;
                        accountType = account.type;
                        break;
                    }
                }
            }
            if (accountName != null || accountType != null) {
                setResultAndFinish(accountName, accountType);
                return;
            }
        }
        Log.d(TAG, "ChooseTypeAndAccountActivity.onActivityResult: unable to find added " + "account, pretending the request was canceled");
    }
    if (Log.isLoggable(TAG, Log.VERBOSE)) {
        Log.v(TAG, "ChooseTypeAndAccountActivity.onActivityResult: canceled");
    }
    setResult(Activity.RESULT_CANCELED);
    finish();
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Bundle(android.os.Bundle) Parcelable(android.os.Parcelable)

Example 70 with Parcelable

use of android.os.Parcelable in project XobotOS by xamarin.

the class CompoundButton method onSaveInstanceState.

@Override
public Parcelable onSaveInstanceState() {
    // Force our ancestor class to save its state
    setFreezesText(true);
    Parcelable superState = super.onSaveInstanceState();
    SavedState ss = new SavedState(superState);
    ss.checked = isChecked();
    return ss;
}
Also used : Parcelable(android.os.Parcelable)

Aggregations

Parcelable (android.os.Parcelable)826 Bundle (android.os.Bundle)99 View (android.view.View)85 Intent (android.content.Intent)58 SparseArray (android.util.SparseArray)38 Test (org.junit.Test)31 ArrayList (java.util.ArrayList)26 MenuItem (android.view.MenuItem)23 ImageView (android.widget.ImageView)23 TextView (android.widget.TextView)17 MenuItem (com.actionbarsherlock.view.MenuItem)14 SuppressLint (android.annotation.SuppressLint)13 Dialog (android.app.Dialog)13 MediumTest (android.support.test.filters.MediumTest)13 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)12 Paint (android.graphics.Paint)12 MenuView (com.android.internal.view.menu.MenuView)12 RemoteException (android.os.RemoteException)11 Bitmap (android.graphics.Bitmap)10 ShortcutIconResource (android.content.Intent.ShortcutIconResource)9