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;
}
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();
}
}
}
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);
}
}
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);
}
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();
}
}
Aggregations