List of usage examples for android.os Bundle getParcelable
@Nullable public <T extends Parcelable> T getParcelable(@Nullable String key)
From source file:com.eutectoid.dosomething.picker.PlacePickerFragment.java
@Override public void setSettingsFromBundle(Bundle inState) { super.setSettingsFromBundle(inState); if (inState != null) { setRadiusInMeters(inState.getInt(RADIUS_IN_METERS_BUNDLE_KEY, radiusInMeters)); setResultsLimit(inState.getInt(RESULTS_LIMIT_BUNDLE_KEY, resultsLimit)); if (inState.containsKey(SEARCH_TEXT_BUNDLE_KEY)) { setSearchText(inState.getString(SEARCH_TEXT_BUNDLE_KEY)); }/* ww w. ja v a2s. c om*/ if (inState.containsKey(LOCATION_BUNDLE_KEY)) { Location location = inState.getParcelable(LOCATION_BUNDLE_KEY); setLocation(location); } showSearchBox = inState.getBoolean(SHOW_SEARCH_BOX_BUNDLE_KEY, showSearchBox); } }
From source file:com.android.gallery3d.gadget.WidgetConfigure.java
@Override protected void onCreate(Bundle savedState) { super.onCreate(savedState); mAppWidgetId = getIntent().getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, -1); if (mAppWidgetId == -1) { setResult(Activity.RESULT_CANCELED); finish();/*w w w . ja v a 2 s.c om*/ return; } if (savedState == null) { if (ApiHelper.HAS_REMOTE_VIEWS_SERVICE) { Intent intent = new Intent(this, WidgetTypeChooser.class); startActivityForResult(intent, REQUEST_WIDGET_TYPE); } else { // Choose the photo type widget setWidgetType(new Intent().putExtra(KEY_WIDGET_TYPE, R.id.widget_type_photo)); } } else { mPickedItem = savedState.getParcelable(KEY_PICKED_ITEM); } }
From source file:com.mohamnag.inappbilling.InAppBillingPlugin.java
/** * Buy an already loaded item.//from w ww . j av a2 s . c o m * * @param productId * @param callbackContext */ private void buy(final String productId, final CallbackContext callbackContext) throws JSONException { jsLog("buy called for productId: " + productId); SkuDetails product = myInventory.getSkuDetails(productId); if (product == null) { callbackContext .error(new Error(ERR_PRODUCT_NOT_LOADED, "Product intended to be bought has not been loaded.") .toJavaScriptJSON()); } else if (BILLING_ITEM_TYPE_SUBS.equals(product.getType()) && !subscriptionSupported) { callbackContext.error(new Error(ERR_SUBSCRIPTION_NOT_SUPPORTED, "Subscriptions are not supported") .toJavaScriptJSON()); } else { cordova.setActivityResultCallback(this); int requestCode = REQUEST_CODE_BASE++; try { jsLog("Preparing purchase flow"); Bundle buyIntentBundle = iabService.getBuyIntent(3, cordova.getActivity().getPackageName(), product.getSku(), product.getType(), null); int response = buyIntentBundle.getInt("RESPONSE_CODE"); if (response == BILLING_RESPONSE_RESULT_OK) { PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); pendingPurchaseCallbacks.put(requestCode, callbackContext); cordova.getActivity().startIntentSenderForResult(pendingIntent.getIntentSender(), requestCode, new Intent(), 0, 0, 0); jsLog("Purchase flow launched successfully"); } else if (response == BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED) { callbackContext.error( new Error(ERR_PURCHASE_OWNED_ITEM, "Item requested to be bought is already owned.") .toJavaScriptJSON()); } else { callbackContext.error( new Error(ERR_PURCHASE_FAILED, "Could not get buy intent. Response code: " + response) .toJavaScriptJSON()); } } catch (RemoteException ex) { Logger.getLogger(InAppBillingPlugin.class.getName()).log(Level.SEVERE, null, ex); callbackContext.error(new Error(ERR_PURCHASE_FAILED, ex.getMessage()).toJavaScriptJSON()); } catch (IntentSender.SendIntentException ex) { Logger.getLogger(InAppBillingPlugin.class.getName()).log(Level.SEVERE, null, ex); callbackContext.error(new Error(ERR_PURCHASE_FAILED, ex.getMessage()).toJavaScriptJSON()); } } }
From source file:com.avapira.bobroreader.BoardFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { Log.d(TAG, "activity created (open bundle)"); super.onActivityCreated(savedInstanceState); if (savedInstanceState != null) { boardKey = savedInstanceState.getString(ARG_KEY, null); page = savedInstanceState.getInt(ARG_PAGE, 0); recycler.getLayoutManager()//from w w w. jav a2s. c om .onRestoreInstanceState(savedInstanceState.getParcelable(ARG_RECYCLER_LAYOUT)); } }
From source file:com.futurologeek.smartcrossing.crop.CropImageActivity.java
private void loadInput() { Intent intent = getIntent();/* www . j a v a 2 s.com*/ Bundle extras = intent.getExtras(); if (extras != null) { aspectX = extras.getInt(Crop.Extra.ASPECT_X); aspectY = extras.getInt(Crop.Extra.ASPECT_Y); maxX = extras.getInt(Crop.Extra.MAX_X); maxY = extras.getInt(Crop.Extra.MAX_Y); saveUri = extras.getParcelable(MediaStore.EXTRA_OUTPUT); } sourceUri = intent.getData(); if (sourceUri != null) { exifRotation = CropUtil .getExifRotation(CropUtil.getFromMediaUri(this, getContentResolver(), sourceUri)); InputStream is = null; try { sampleSize = calculateBitmapSampleSize(sourceUri); is = getContentResolver().openInputStream(sourceUri); BitmapFactory.Options option = new BitmapFactory.Options(); option.inSampleSize = sampleSize; rotateBitmap = new RotateBitmap(BitmapFactory.decodeStream(is, null, option), exifRotation); } catch (IOException e) { Log.e("Error reading image: " + e.getMessage(), e); setResultException(e); } catch (OutOfMemoryError e) { Log.e("OOM reading image: " + e.getMessage(), e); setResultException(e); } finally { CropUtil.closeSilently(is); } } }
From source file:com.mindmeapp.extensions.ExtensionData.java
/** * Deserializes the given {@link Bundle} representation of extension data, populating this * object./*from w w w .jav a 2 s. co m*/ */ public void fromBundle(Bundle src) { this.mVisible = src.getBoolean(KEY_VISIBLE, true); this.mIcon = src.getInt(KEY_ICON); String iconUriString = src.getString(KEY_ICON_URI); this.mIconUri = TextUtils.isEmpty(iconUriString) ? null : Uri.parse(iconUriString); this.mStatusToDisplay = src.getString(KEY_STATUS_TO_DISPLAY); this.mStatusToSpeak = src.getString(KEY_STATUS_TO_SPEAK); this.mLanguageToSpeak = (Locale) src.getSerializable(KEY_LANGUAGE_TO_SPEAK); this.mViewsToDisplay = src.getParcelable(KEY_VIEWS_TO_DISPLAY); this.mContentDescription = src.getString(KEY_CONTENT_DESCRIPTION); this.mBackground = src.getInt(KEY_BACKGROUND); String backgroundUriString = src.getString(KEY_BACKGROUND_URI); this.mBackgroundUri = TextUtils.isEmpty(backgroundUriString) ? null : Uri.parse(backgroundUriString); }
From source file:com.buddi.client.dfu.DfuActivity.java
@Override protected void onActivityResult(final int requestCode, final int resultCode, final Intent data) { if (resultCode != RESULT_OK) return;/*ww w.jav a2 s . co m*/ switch (requestCode) { case SELECT_FILE_REQ: // clear previous data mFileType = mFileTypeTmp; mFilePath = null; mFileStreamUri = null; // and read new one final Uri uri = data.getData(); /* * The URI returned from application may be in 'file' or 'content' schema. * 'File' schema allows us to create a File object and read details from if directly. * Data from 'Content' schema must be read by Content Provider. To do that we are using a Loader. */ if (uri.getScheme().equals("file")) { // the direct path to the file has been returned final String path = uri.getPath(); final File file = new File(path); mFilePath = path; updateFileInfo(file.getName(), file.length(), mFileType); } else if (uri.getScheme().equals("content")) { // an Uri has been returned mFileStreamUri = uri; // if application returned Uri for streaming, let's us it. Does it works? // FIXME both Uris works with Google Drive app. Why both? What's the difference? How about other apps like DropBox? final Bundle extras = data.getExtras(); if (extras != null && extras.containsKey(Intent.EXTRA_STREAM)) mFileStreamUri = extras.getParcelable(Intent.EXTRA_STREAM); // file name and size must be obtained from Content Provider final Bundle bundle = new Bundle(); bundle.putParcelable(EXTRA_URI, uri); //getSupportLoaderManager().restartLoader(0, bundle, this); getLoaderManager().restartLoader(0, bundle, this); } break; default: break; } }
From source file:com.btmura.android.reddit.app.NavigationFragment.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState == null) { requestedSubreddit = getArguments().getString(ARG_REQUESTED_SUBREDDIT); requestedThingBundle = getArguments().getParcelable(ARG_REQUESTED_THING_BUNDLE); } else {//from ww w .j a va 2s . c o m requestedSubreddit = savedInstanceState.getString(STATE_REQUESTED_SUBREDDIT); requestedThingBundle = savedInstanceState.getParcelable(STATE_REQUESTED_THING_BUNDLE); accountName = savedInstanceState.getString(STATE_ACCOUNT_NAME); place = savedInstanceState.getInt(STATE_PLACE); subreddit = savedInstanceState.getString(STATE_SUBREDDIT); isRandom = savedInstanceState.getBoolean(STATE_IS_RANDOM); filter = savedInstanceState.getInt(STATE_FILTER); } accountAdapter = AccountResultAdapter.newNavigationFragmentInstance(getActivity()); accountAdapter.setOnAccountMessagesSelectedListener(this); placesAdapter = new AccountPlaceAdapter(getActivity(), this); subredditAdapter = AccountSubredditAdapter.newAccountInstance(getActivity()); mergeAdapter = new MergeAdapter(accountAdapter, placesAdapter, subredditAdapter); }
From source file:com.cerema.cloud2.ui.fragment.OCFileListFragment.java
/** * {@inheritDoc}//from w ww . j a v a2 s. co m */ @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Log_OC.e(TAG, "onActivityCreated() start"); if (savedInstanceState != null) { mFile = savedInstanceState.getParcelable(KEY_FILE); } if (mJustFolders) { setFooterEnabled(false); } else { setFooterEnabled(true); } Bundle args = getArguments(); mJustFolders = (args == null) ? false : args.getBoolean(ARG_JUST_FOLDERS, false); mAdapter = new FileListListAdapter(mJustFolders, getActivity(), mContainerActivity); setListAdapter(mAdapter); registerLongClickListener(); boolean hideFab = (args != null) && args.getBoolean(ARG_HIDE_FAB, false); if (hideFab) { setFabEnabled(false); } else { setFabEnabled(true); registerFabListeners(); // detect if a mini FAB has ever been clicked final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); if (prefs.getLong(KEY_FAB_EVER_CLICKED, 0) > 0) { miniFabClicked = true; } // add labels to the min FABs when none of them has ever been clicked on if (!miniFabClicked) { setFabLabels(); } else { removeFabLabels(); } } }
From source file:com.devgmail.mitroshin.totutu.controllers.StartFragment.java
@Nullable @Override/*from w w w.jav a2s. c om*/ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { // View view = inflater.inflate(R.layout.fragment_start, container, false); mSimpleDateFormat = new SimpleDateFormat("dd-MM-yyyy", Locale.US); // ? ?? ? findAllViewById(view); datePickerButton.setInputType(InputType.TYPE_NULL); setDateField(); // ? ?? ? setAllClickListener(); // ? ? ? ? ??. if (savedInstanceState != null) { if (savedInstanceState.getParcelable(SAVE_STATION_FROM) != null) { mCurrentStationFrom = savedInstanceState.getParcelable(SAVE_STATION_FROM); updateStationUI(mCurrentStationFrom, "From"); } if (savedInstanceState.getParcelable(SAVE_STATION_TO) != null) { mCurrentStationTo = savedInstanceState.getParcelable(SAVE_STATION_TO); updateStationUI(mCurrentStationTo, "To"); } } return view; }