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.cerema.cloud2.ui.preview.PreviewTextFragment.java

/**
 * {@inheritDoc}/*ww w .ja  va 2 s .  co m*/
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    OCFile file = getFile();

    Bundle args = getArguments();

    if (file == null) {
        file = args.getParcelable(FileDisplayActivity.EXTRA_FILE);
    }

    if (mAccount == null) {
        mAccount = args.getParcelable(FileDisplayActivity.EXTRA_ACCOUNT);
    }

    if (savedInstanceState == null) {
        if (file == null) {
            throw new IllegalStateException("Instanced with a NULL OCFile");
        }
        if (mAccount == null) {
            throw new IllegalStateException("Instanced with a NULL ownCloud Account");
        }
    } else {
        file = savedInstanceState.getParcelable(EXTRA_FILE);
        mAccount = savedInstanceState.getParcelable(EXTRA_ACCOUNT);
    }
    setFile(file);
    setHasOptionsMenu(true);
}

From source file:com.whamads.nativecamera.NativeCameraLauncher.java

@Override
public void onRestoreStateForActivityResult(Bundle state, CallbackContext callbackContext) {
    this.callbackContext = callbackContext;

    this.mQuality = state.getInt("mQuality");
    this.targetWidth = state.getInt("targetWidth");
    this.targetHeight = state.getInt("targetHeight");

    this.imageUri = state.getParcelable("imageUri");
    this.photo = (File) state.getSerializable("photo");

    this.date = state.getString("date");

    super.onRestoreStateForActivityResult(state, callbackContext);
}

From source file:com.krayzk9s.imgurholo.ui.MessagingFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle bundle = getArguments();
    if (bundle != null && bundle.containsKey("data"))
        messageData = bundle.getParcelable("data");
    setHasOptionsMenu(true);/*  w w w .  j  a v a2  s  .  co m*/
}

From source file:me.henrytao.bootstrapandroidlibrarydemo.activity.BaseActivity.java

private void onDonate(PurchaseItem item) {
    if (item == null || !item.isValid() || mBillingService == null) {
        return;//from   w ww  .  jav  a 2 s  .  c om
    }
    try {
        Bundle buyIntentBundle = mBillingService.getBuyIntent(3, getPackageName(), item.getId(), "inapp", "");
        PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
        startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), 0, 0, 0);
    } catch (RemoteException e) {
        e.printStackTrace();
    } catch (IntentSender.SendIntentException e) {
        e.printStackTrace();
    }
}

From source file:com.sq.jzq.company.MyDataCompanyActivity.java

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    type = requestCode + "";
    switch (resultCode) {
    case 1:/* w  w  w .  j  av  a 2s  . c om*/
        if (data != null) {
            //?Uri,Uri???Uri??  
            Uri mImageCaptureUri = data.getData();
            //Uri???Uri???  
            if (mImageCaptureUri != null) {
                Bitmap image;
                try {
                    //?Uri?Bitmap??  
                    image = MediaStore.Images.Media.getBitmap(this.getContentResolver(), mImageCaptureUri);
                    if (image != null) {
                        //                             CacheImage.setImageForImageView(User.IconPath, ivIcon);
                        if ("7".equals(type)) {
                            iv_my_head.setImageBitmap(image);
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
            } else {
                Bundle extras = data.getExtras();
                if (extras != null) {
                    //??Bundle???Bitmap  
                    Bitmap image = extras.getParcelable("data");
                    if (image != null) {
                        if ("7".equals(type)) {
                            iv_my_head.setImageBitmap(image);
                        }
                    }
                }
            }

        }
        new UpdateIcon().update(type);
        break;
    default:
        break;
    }

}

From source file:com.android.contacts.common.list.PhoneNumberPickerFragment.java

@Override
public void restoreSavedState(Bundle savedState) {
    super.restoreSavedState(savedState);

    if (savedState == null) {
        return;/* w  w  w  .java2s.c om*/
    }

    mFilter = savedState.getParcelable(KEY_FILTER);
    mShortcutAction = savedState.getString(KEY_SHORTCUT_ACTION);
}

From source file:com.android.design.parallax.views.adapters.CacheFragmentStatePagerAdapter.java

public void restoreState(Parcelable state, ClassLoader loader) {
    final Bundle bundle = (Bundle) state;
    int pages = bundle.getInt(STATE_PAGES);
    if (0 < pages) {
        for (int i = 0; i < pages; i++) {
            final int position = bundle.getInt(createCacheIndex(i));
            final Fragment f = mFm.getFragment(bundle, createCacheKey(position));
            mPages.put(position, f);//  www  .  j  a  v a  2s  .com
        }
    }
    final Parcelable p = bundle.getParcelable(STATE_SUPER_STATE);
    super.restoreState(p, loader);
}

From source file:com.cerema.cloud2.ui.preview.FileDownloadFragment.java

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

    if (savedInstanceState != null) {
        if (!mIgnoreFirstSavedState) {
            setFile((OCFile) savedInstanceState.getParcelable(FileDownloadFragment.EXTRA_FILE));
            mAccount = savedInstanceState.getParcelable(FileDownloadFragment.EXTRA_ACCOUNT);
            mError = savedInstanceState.getBoolean(FileDownloadFragment.EXTRA_ERROR);
        } else {//ww  w. ja v  a  2  s .c om
            mIgnoreFirstSavedState = false;
        }
    }

    mView = inflater.inflate(R.layout.file_download_fragment, container, false);

    ProgressBar progressBar = (ProgressBar) mView.findViewById(R.id.progressBar);
    DisplayUtils.colorPreLollipopHorizontalProgressBar(progressBar);
    mProgressListener = new ProgressListener(progressBar);

    (mView.findViewById(R.id.cancelBtn)).setOnClickListener(this);

    (mView.findViewById(R.id.fileDownloadLL)).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            ((PreviewImageActivity) getActivity()).toggleFullScreen();
        }
    });

    if (mError) {
        setButtonsForRemote();
    } else {
        setButtonsForTransferring();
    }

    return mView;
}

From source file:com.akop.bach.fragment.playstation.GamesFragment.java

@Override
public void onCreate(Bundle state) {
    super.onCreate(state);

    mCp = new CachePolicy();
    mCp.resizeHeight = 96;//w w  w .j a  v  a2  s .  c om

    if (mAccount == null) {
        Bundle args = getArguments();
        ContentResolver cr = getActivity().getContentResolver();

        mAccount = (PsnAccount) args.getParcelable("account");
        mTitleId = getFirstTitleId(cr.query(Games.CONTENT_URI, new String[] { Games._ID, },
                Games.ACCOUNT_ID + "=" + mAccount.getId(), null, Games.DEFAULT_SORT_ORDER));
    }

    if (state != null && state.containsKey("account")) {
        mAccount = (PsnAccount) state.getParcelable("account");
        mTitleId = state.getLong("titleId");
    }

    setHasOptionsMenu(true);
}

From source file:co.carlosjimenez.android.currencyalerts.app.DetailActivityFragment.java

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

    View rootView = inflater.inflate(R.layout.fragment_detail, container, false);
    ButterKnife.bind(this, rootView);

    Bundle arguments = getArguments();
    if (arguments != null) {
        mUri = arguments.getParcelable(DETAIL_URI);
    }//w  w  w . ja v  a  2s  .  com

    mContext = (AppCompatActivity) getActivity();
    mFirebaseAnalytics = FirebaseAnalytics.getInstance(mContext);

    if (mToolbar != null) {
        mContext.setSupportActionBar(mToolbar);
        mContext.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        mContext.getSupportActionBar().setDisplayShowTitleEnabled(false);
    }

    // Ad is delayed some seconds as this affects the performance
    mHandler.postDelayed(new Runnable() {
        @Override
        public void run() {
            loadAd();
        }
    }, AD_DELAY_MILLISECONDS);

    return rootView;
}