Search in sources :

Example 61 with Parcelable

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

the class MenuBuilder method saveActionViewStates.

public void saveActionViewStates(Bundle outStates) {
    SparseArray<Parcelable> viewStates = null;
    final int itemCount = size();
    for (int i = 0; i < itemCount; i++) {
        final MenuItem item = getItem(i);
        final View v = item.getActionView();
        if (v != null && v.getId() != View.NO_ID) {
            if (viewStates == null) {
                viewStates = new SparseArray<Parcelable>();
            }
            v.saveHierarchyState(viewStates);
            if (item.isActionViewExpanded()) {
                outStates.putInt(EXPANDED_ACTION_VIEW_ID, item.getItemId());
            }
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.saveActionViewStates(outStates);
        }
    }
    if (viewStates != null) {
        outStates.putSparseParcelableArray(getActionViewStatesKey(), viewStates);
    }
}
Also used : Parcelable(android.os.Parcelable) MenuItem(android.view.MenuItem) View(android.view.View)

Example 62 with Parcelable

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

the class MenuBuilder method dispatchSaveInstanceState.

private void dispatchSaveInstanceState(Bundle outState) {
    if (mPresenters.isEmpty())
        return;
    SparseArray<Parcelable> presenterStates = new SparseArray<Parcelable>();
    for (WeakReference<MenuPresenter> ref : mPresenters) {
        final MenuPresenter presenter = ref.get();
        if (presenter == null) {
            mPresenters.remove(ref);
        } else {
            final int id = presenter.getId();
            if (id > 0) {
                final Parcelable state = presenter.onSaveInstanceState();
                if (state != null) {
                    presenterStates.put(id, state);
                }
            }
        }
    }
    outState.putSparseParcelableArray(PRESENTER_KEY, presenterStates);
}
Also used : SparseArray(android.util.SparseArray) Parcelable(android.os.Parcelable)

Example 63 with Parcelable

use of android.os.Parcelable in project ZI by yixia.

the class IntentHelper method getIntentUri.

public static Uri getIntentUri(Intent intent) {
    Uri result = null;
    if (intent != null) {
        result = intent.getData();
        if (result == null) {
            final String type = intent.getType();
            String sharedUrl = intent.getStringExtra(Intent.EXTRA_TEXT);
            if (!TextUtils.isEmpty(sharedUrl)) {
                if ("text/plain".equals(type) && sharedUrl != null) {
                    result = getTextUri(sharedUrl);
                } else if ("text/html".equals(type) && sharedUrl != null) {
                    result = getTextUri(Html.fromHtml(sharedUrl).toString());
                }
            } else {
                Parcelable parce = intent.getParcelableExtra(Intent.EXTRA_STREAM);
                if (parce != null)
                    result = (Uri) parce;
            }
        }
    }
    return result;
}
Also used : Parcelable(android.os.Parcelable) Uri(android.net.Uri)

Example 64 with Parcelable

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

the class Message method writeToParcel.

public void writeToParcel(Parcel dest, int flags) {
    if (callback != null) {
        throw new RuntimeException("Can't marshal callbacks across processes.");
    }
    dest.writeInt(what);
    dest.writeInt(arg1);
    dest.writeInt(arg2);
    if (obj != null) {
        try {
            Parcelable p = (Parcelable) obj;
            dest.writeInt(1);
            dest.writeParcelable(p, flags);
        } catch (ClassCastException e) {
            throw new RuntimeException("Can't marshal non-Parcelable objects across processes.");
        }
    } else {
        dest.writeInt(0);
    }
    dest.writeLong(when);
    dest.writeBundle(data);
    Messenger.writeMessengerOrNullToParcel(replyTo, dest);
}
Also used : Parcelable(android.os.Parcelable)

Example 65 with Parcelable

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

the class ProgressBar method onSaveInstanceState.

@Override
public Parcelable onSaveInstanceState() {
    // Force our ancestor class to save its state
    Parcelable superState = super.onSaveInstanceState();
    SavedState ss = new SavedState(superState);
    ss.progress = mProgress;
    ss.secondaryProgress = mSecondaryProgress;
    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