Example usage for android.os Bundle getParcelable

List of usage examples for android.os Bundle getParcelable

Introduction

In this page you can find the example usage for android.os Bundle getParcelable.

Prototype

@Nullable
public <T extends Parcelable> T getParcelable(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:com.commonsware.android.rotation.fragbundle.RotationFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle state) {
    View result = inflater.inflate(R.layout.main, parent, false);

    result.findViewById(R.id.pick).setOnClickListener(this);

    View v = result.findViewById(R.id.view);

    v.setOnClickListener(this);

    if (state != null) {
        contact = (Uri) state.getParcelable("contact");
    }//from  w ww.j  ava  2 s. c  om

    v.setEnabled(contact != null);

    return (result);
}

From source file:com.android.messaging.ui.FixedViewPagerAdapter.java

@Override
public void restoreState(final Parcelable state, final ClassLoader loader) {
    if (state instanceof Bundle) {
        final Bundle restoredViewHolderState = (Bundle) state;
        ((Bundle) state).setClassLoader(Factory.get().getApplicationContext().getClassLoader());
        for (int i = 0; i < mViewHolders.length; i++) {
            final Parcelable pageState = restoredViewHolderState.getParcelable(getInstanceStateKeyForPage(i));
            getViewHolder(i).restoreState(pageState);
        }/*from  ww  w.  j ava 2  s  .com*/
    } else {
        super.restoreState(state, loader);
    }
}

From source file:com.duguang.baseanimation.ui.listivew.listviews.ListViewsMainActivity.java

private void buy(String sku) {
    try {/*w  ww.  j a  v  a  2s  .c om*/
        Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "inapp",
                "bGoa+V7g/ysDXvKwqq+JTFn4uQZbPiQJo4pf9RzJ");
        PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
        if (pendingIntent != null) {
            startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0),
                    Integer.valueOf(0), Integer.valueOf(0));
        }
    } catch (RemoteException e) {
        e.printStackTrace();
    } catch (SendIntentException e) {
        e.printStackTrace();
    }
}

From source file:com.haarman.listviewanimations.MainActivity.java

private void buy(final String sku) {
    try {/*from   w  w  w .  jav a  2s.c o m*/
        Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "inapp",
                "bGoa+V7g/ysDXvKwqq+JTFn4uQZbPiQJo4pf9RzJ");
        PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
        if (pendingIntent != null) {
            startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), 0, 0, 0);
        }
    } catch (RemoteException | SendIntentException ignored) {
        Toast.makeText(this, getString(R.string.exception), Toast.LENGTH_LONG).show();
    }
}

From source file:com.facebook.GraphRequestTest.java

@Test
public void testCreateUploadPhotoRequest() {
    Bitmap image = Bitmap.createBitmap(128, 128, Bitmap.Config.ALPHA_8);

    GraphRequest request = GraphRequest.newUploadPhotoRequest(null, ShareInternalUtility.MY_PHOTOS, image, null,
            null, null);//w ww  .j  av  a2s  .com
    assertTrue(request != null);

    Bundle parameters = request.getParameters();
    assertTrue(parameters != null);

    assertTrue(parameters.containsKey("picture"));
    assertEquals(image, parameters.getParcelable("picture"));
    assertEquals("me/photos", request.getGraphPath());
}

From source file:com.blueverdi.rosietheriveter.PhotoViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle b = getIntent().getExtras();
    try {//from   w  w w.j  a  va  2s.c  o m
        details = b.getParcelable(SiteDetails.PARCEL_NAME);
    } catch (Exception e) {
        MyLog.d(TAG, "exception retrieving site info");
        finish();
    }
    if (details == null) {
        MyLog.d(TAG, "no details");
        finish();
    }
    setContentView(R.layout.activity_photo_view);
    View view = findViewById(R.id.photoView);
    view.setOnTouchListener(new OnSwipeTouchListener(this) {
        @Override
        public void onSwipeLeft() {
            nextPhoto();
        }

        @Override
        public void onSwipeRight() {
            lastPhoto();
        }

        @Override
        public void onTap() {
            zoomIn();
        }
    });
    view = findViewById(R.id.leftArrow);
    view.setOnClickListener(this);
    view = findViewById(R.id.rightArrow);
    view.setOnClickListener(this);
    TextView tv = (TextView) findViewById(R.id.name);
    tv.setText(details.name);
    caption = (TextView) findViewById(R.id.caption);
    photoView = (ImageView) findViewById(R.id.photoView);
    imageSource = PHOTO_BASE + File.separator + details.photoDirectory;
    try {
        imageFiles = this.getAssets().list(imageSource);
    } catch (Exception e) {
        MyLog.d(TAG, e.toString());
        e.printStackTrace();
        imageFiles = new String[0];
    }
    if (imageFiles.length == 0) {
        MyLog.d(TAG, "no photos to display");
        finish();
    }
    captions = getResources().getStringArray(details.captionArrayID);
    if (savedInstanceState != null) {
        index = savedInstanceState.getInt(INDEX);
    }
    displayImage(index);
    rosieHelpMenu = new RosieHelpMenu(this);
    hintScreen();
}

From source file:com.bilibili.boxing.utils.CameraPickerHelper.java

public CameraPickerHelper(@Nullable Bundle savedInstance) {
    if (savedInstance != null) {
        SavedState state = savedInstance.getParcelable(STATE_SAVED_KEY);
        if (state != null) {
            mOutputFile = state.mOutputFile;
            mSourceFilePath = state.mSourceFilePath;
        }//from  ww w  . j a v  a  2s  . c  o m
    }
}

From source file:com.andrewchelladurai.simplebible.ChapterFragment.java

@Override
public void init() {
    // prepare to set all these values
    isAllSet = false;/*from  www.  j  a  v  a 2  s.c om*/
    mBookItem = null;
    mChapterItem = null;
    if (null == mPresenter) {
        mPresenter = new ChapterFragmentPresenter(this);
        mPresenter.init();
    }

    Bundle args = getArguments();

    if (args.containsKey(ARG_BOOK_ITEM)) { // Book Item was passed
        mBookItem = args.getParcelable(ARG_BOOK_ITEM);
        // required for display purposes
        String prependText = getString(R.string.chapter);
        // populate List based on Book Item
        isAllSet = ChapterList.populateListItems(mBookItem.getChapterCount(), prependText);
        // get Chapter Item
        int chapterNumber = (isAllSet && args.containsKey(ARG_CHAPTER_NUMBER)) ? args.getInt(ARG_CHAPTER_NUMBER)
                : 1;
        mChapterItem = ChapterList.getChapterItem(chapterNumber);
    }
    List<VerseItem> list = mPresenter.getAllVersesForChapter(mBookItem, mChapterItem);
    if (list != null) {
        mListAdapter = new VerseListAdapter(list, this);
    }

    isAllSet = (mChapterItem != null & mBookItem != null & list != null);
}

From source file:com.arrata.user.cameratest.AspectRatioFragment.java

@NonNull
@Override/* w  ww  . j  av  a  2  s  .  co  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Bundle args = getArguments();
    final AspectRatio[] ratios = (AspectRatio[]) args.getParcelableArray(ARG_ASPECT_RATIOS);
    if (ratios == null) {
        throw new RuntimeException("No ratios");
    }
    final AspectRatio current = args.getParcelable(ARG_CURRENT_ASPECT_RATIO);
    final AspectRatioAdapter adapter = new AspectRatioAdapter(ratios, current);
    return new AlertDialog.Builder(getActivity()).setAdapter(adapter, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int position) {
            mListener.onAspectRatioSelected(ratios[position]);
        }
    }).create();
}

From source file:com.alboteanu.android.sunshine.app.DetailFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

    Bundle arguments = getArguments();
    if (arguments != null) {
        mUri = arguments.getParcelable(DetailFragment.DETAIL_URI);
        mTransitionAnimation = arguments.getBoolean(DetailFragment.DETAIL_TRANSITION_ANIMATION, false);
    }/*from   ww w.  j a va 2s. c o  m*/

    View rootView = inflater.inflate(R.layout.fragment_detail_start, container, false);
    //        rootView.setBackgroundColor(Color.TRANSPARENT);
    mIconView = (ImageView) rootView.findViewById(R.id.detail_icon);
    mDateView = (TextView) rootView.findViewById(R.id.detail_date_textview);
    mDescriptionView = (TextView) rootView.findViewById(R.id.detail_forecast_textview);
    mHighTempView = (TextView) rootView.findViewById(R.id.detail_high_textview);
    mLowTempView = (TextView) rootView.findViewById(R.id.detail_low_textview);
    mHumidityView = (TextView) rootView.findViewById(R.id.detail_humidity_textview);
    mHumidityLabelView = (TextView) rootView.findViewById(R.id.detail_humidity_label_textview);
    mWindView = (TextView) rootView.findViewById(R.id.detail_wind_textview);
    mWindLabelView = (TextView) rootView.findViewById(R.id.detail_wind_label_textview);
    mPressureView = (TextView) rootView.findViewById(R.id.detail_pressure_textview);
    mPressureLabelView = (TextView) rootView.findViewById(R.id.detail_pressure_label_textview);
    //        adView = (AdView) rootView.findViewById(R.id.adView_med_rect);

    return rootView;
}