Search in sources :

Example 11 with Parcelable

use of android.os.Parcelable in project StaggeredGridView by chrisjenx.

the class StaggeredGridView method onSaveInstanceState.

@Override
public Parcelable onSaveInstanceState() {
    final Parcelable superState = super.onSaveInstanceState();
    final SavedState ss = new SavedState(superState);
    final int position = mFirstPosition;
    ss.position = position;
    if (position >= 0 && mAdapter != null && position < mAdapter.getCount()) {
        ss.firstId = mAdapter.getItemId(position);
    }
    if (getChildCount() > 0) {
        ss.topOffset = getChildAt(0).getTop() - mItemMargin - getPaddingTop();
    }
    return ss;
}
Also used : Parcelable(android.os.Parcelable)

Example 12 with Parcelable

use of android.os.Parcelable in project cw-omnibus by commonsguy.

the class MenuBuilder method restoreActionViewStates.

public void restoreActionViewStates(Bundle states) {
    if (states == null) {
        return;
    }
    SparseArray<Parcelable> viewStates = states.getSparseParcelableArray(getActionViewStatesKey());
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB && viewStates == null) {
        //Fixes Issue #652 with sdk <= 2.3.6
        return;
    }
    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) {
            v.restoreHierarchyState(viewStates);
        }
        if (item.hasSubMenu()) {
            final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu();
            subMenu.restoreActionViewStates(states);
        }
    }
    final int expandedId = states.getInt(EXPANDED_ACTION_VIEW_ID);
    if (expandedId > 0) {
        MenuItem itemToExpand = findItem(expandedId);
        if (itemToExpand != null) {
            itemToExpand.expandActionView();
        }
    }
}
Also used : Parcelable(android.os.Parcelable) MenuItem(com.actionbarsherlock.view.MenuItem) View(android.view.View)

Example 13 with Parcelable

use of android.os.Parcelable in project cw-omnibus by commonsguy.

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(com.actionbarsherlock.view.MenuItem) View(android.view.View)

Example 14 with Parcelable

use of android.os.Parcelable in project cw-omnibus by commonsguy.

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 15 with Parcelable

use of android.os.Parcelable in project OpenPanodroid by duerrfk.

the class PanoViewerActivity method onCreate.

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    Log.i(LOG_TAG, "Creating");
    super.onCreate(savedInstanceState);
    stateSaved = false;
    setupImageInfo();
    Bitmap front, back, top, bottom, left, right;
    front = back = top = bottom = left = right = null;
    if (savedInstanceState != null) {
        Parcelable parcelData;
        parcelData = savedInstanceState.getParcelable(FRONT_BITMAP_KEY);
        if (parcelData != null) {
            Assert.assertTrue(parcelData instanceof Bitmap);
            front = (Bitmap) parcelData;
        }
        parcelData = savedInstanceState.getParcelable(BACK_BITMAP_KEY);
        if (parcelData != null) {
            Assert.assertTrue(parcelData instanceof Bitmap);
            back = (Bitmap) parcelData;
        }
        parcelData = savedInstanceState.getParcelable(TOP_BITMAP_KEY);
        if (parcelData != null) {
            Assert.assertTrue(parcelData instanceof Bitmap);
            top = (Bitmap) parcelData;
        }
        parcelData = savedInstanceState.getParcelable(BOTTOM_BITMAP_KEY);
        if (parcelData != null) {
            Assert.assertTrue(parcelData instanceof Bitmap);
            bottom = (Bitmap) parcelData;
        }
        parcelData = savedInstanceState.getParcelable(LEFT_BITMAP_KEY);
        if (parcelData != null) {
            Assert.assertTrue(parcelData instanceof Bitmap);
            left = (Bitmap) parcelData;
        }
        parcelData = savedInstanceState.getParcelable(RIGHT_BITMAP_KEY);
        if (parcelData != null) {
            Assert.assertTrue(parcelData instanceof Bitmap);
            right = (Bitmap) parcelData;
        }
    }
    if (front == null || back == null || top == null || bottom == null || left == null || right == null) {
        if (front != null) {
            front.recycle();
            front = null;
        }
        if (back != null) {
            back.recycle();
            back = null;
        }
        if (top != null) {
            top.recycle();
            top = null;
        }
        if (bottom != null) {
            bottom.recycle();
            bottom = null;
        }
        if (left != null) {
            left.recycle();
            left = null;
        }
        if (right != null) {
            right.recycle();
            right = null;
        }
        downloadPano();
    } else {
        cubicPano = new CubicPanoNative(front, back, top, bottom, left, right);
        setupOpenGLView();
    }
}
Also used : Bitmap(android.graphics.Bitmap) Parcelable(android.os.Parcelable) CubicPanoNative(org.openpanodroid.panoutils.android.CubicPanoNative)

Aggregations

Parcelable (android.os.Parcelable)818 Bundle (android.os.Bundle)99 View (android.view.View)85 Intent (android.content.Intent)56 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