List of usage examples for android.os Bundle getParcelable
@Nullable public <T extends Parcelable> T getParcelable(@Nullable String key)
From source file:li.barter.fragments.EditProfileFragment.java
@Override public void onActivityResult(final int requestCode, final int resultCode, final Intent data) { super.onActivityResult(requestCode, resultCode, data); if (resultCode != Activity.RESULT_OK) { return;/*from w w w . j av a 2s . c o m*/ } switch (requestCode) { case PICK_FROM_CAMERA: // doCrop(PICK_FROM_CAMERA); setAndSaveImage(mCameraImageCaptureUri, PICK_FROM_CAMERA); break; case PICK_FROM_FILE: mGalleryImageCaptureUri = data.getData(); setAndSaveImage(mGalleryImageCaptureUri, PICK_FROM_FILE); // doCrop(PICK_FROM_FILE); break; case CROP_FROM_CAMERA: final Bundle extras = data.getExtras(); if (extras != null) { mCompressedPhoto = extras.getParcelable("data"); mProfileImageView.setImageBitmap(mCompressedPhoto); } PhotoUtils.saveImage(mCompressedPhoto, "barterli_avatar_small.png"); break; case AppConstants.RequestCodes.EDIT_PREFERRED_LOCATION: { loadPreferredLocation(); break; } } }
From source file:com.cerema.cloud2.ui.preview.PreviewImageFragment.java
/** * {@inheritDoc}//ww w.ja va 2 s .c o m */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle args = getArguments(); setFile((OCFile) args.getParcelable(ARG_FILE)); // TODO better in super, but needs to check ALL the class extending FileFragment; // not right now mIgnoreFirstSavedState = args.getBoolean(ARG_IGNORE_FIRST); setHasOptionsMenu(true); }
From source file:ca.ualberta.cmput301w14t08.geochan.fragments.MapViewFragment.java
/** * Initiates a location listener which immediately starts listening for * location updates. Gets the current location as well. Then unpacks the * bundle passed to the fragment. It then gets the map setup and prepares * the min and max latitude and longitude required to display the map * properly for calculation. Then finally sets the zoom level *//*www.java2 s . co m*/ @Override public void onStart() { super.onStart(); locationListenerService = new LocationListenerService(getActivity()); locationListenerService.startListening(); Bundle args = getArguments(); Comment topComment = (Comment) args.getParcelable("thread_comment"); markers = new ArrayList<CustomMarker>(); replyMarkers = new ArrayList<CustomMarker>(); setupClusterGroups(); GeoLocation geoLocation = topComment.getLocation(); if (geoLocation.getLocation() == null) { ErrorDialog.show(getActivity(), "Thread has no location"); FragmentManager fm = getFragmentManager(); fm.popBackStackImmediate(); } else { this.setupMap(topComment); this.setZoomLevel(topComment.getLocation()); } }
From source file:com.bilibili.boxing.AbsBoxingViewFragment.java
@Override public void onCreate(@Nullable Bundle savedInstanceState) { BoxingConfig config;//ww w .jav a2 s. c o m if (savedInstanceState != null) { config = savedInstanceState.getParcelable(Boxing.EXTRA_CONFIG); } else { config = BoxingManager.getInstance().getBoxingConfig(); } setPickerConfig(config); onCreateWithSelectedMedias(savedInstanceState, parseSelectedMedias(savedInstanceState, getArguments())); super.onCreate(savedInstanceState); initCameraPhotoPicker(savedInstanceState); }
From source file:app.com.timbuktu.fragment.ColorFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View v = inflater.inflate(R.layout.fragment_collectionview, container, false); Bundle bdl = getArguments(); mFragmentLayout = (FrameLayout) v.findViewById(R.id.fragment_layout); LayerDrawable bgDrawable = (LayerDrawable) mFragmentLayout.getBackground(); GradientDrawable shape = (GradientDrawable) bgDrawable.findDrawableByLayerId(R.id.background_shape); shape.setColor(bdl.getInt(EXTRA_COLOR)); TextView tv = (TextView) v.findViewById(R.id.header); Collection collection = bdl.getParcelable(EXTRA_COLLECTION); tv.setText("Position - " + bdl.getInt(EXTRA_POS)); if (collection != null) { tv.setText("Position - " + bdl.getInt(EXTRA_POS) + " # of Pics :" + collection.size()); ImageView imgView = (ImageView) v.findViewById(R.id.collage); mTask = new CollageWorkerTask(imgView, collection); mTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR); }// w w w .j a v a 2s . co m return v; }
From source file:com.afwsamples.testdpc.SetupManagementFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (savedInstanceState != null) { mLogoUri = (Uri) savedInstanceState.getParcelable(EXTRA_PROVISIONING_LOGO_URI); mCurrentColor = savedInstanceState.getInt(EXTRA_PROVISIONING_MAIN_COLOR); } else {/* w ww . jav a 2 s . c om*/ mLogoUri = resourceToUri(getActivity(), R.drawable.ic_launcher); mCurrentColor = getResources().getColor(R.color.teal); } // Use setupwizard theme final Context contextThemeWrapper = new ContextThemeWrapper(getActivity(), R.style.SetupTheme); LayoutInflater themeInflater = inflater.cloneInContext(contextThemeWrapper); View view = themeInflater.inflate(R.layout.setup_management_fragment, container, false); SetupWizardLayout layout = (SetupWizardLayout) view.findViewById(R.id.setup_wizard_layout); NavigationBar navigationBar = layout.getNavigationBar(); navigationBar.setNavigationBarListener(this); navigationBar.getBackButton().setText(R.string.exit); mNavigationNextButton = navigationBar.getNextButton(); mNavigationNextButton.setText(R.string.setup_label); mSetupManagementMessage = (TextView) view.findViewById(R.id.setup_management_message_id); mSetupOptions = (RadioGroup) view.findViewById(R.id.setup_options); mSetupOptions.setOnCheckedChangeListener(this); mSkipUserConsent = (CheckBox) view.findViewById(R.id.skip_user_consent); mKeepAccountMigrated = (CheckBox) view.findViewById(R.id.keep_account_migrated); mSkipEncryption = (CheckBox) view.findViewById(R.id.skip_encryption); mParamsView = view.findViewById(R.id.params); mParamsIndicator = (ImageButton) view.findViewById(R.id.params_indicator); mParamsIndicator.setOnClickListener(this); view.findViewById(R.id.color_select_button).setOnClickListener(this); mColorValue = (TextView) view.findViewById(R.id.selected_color_value); mColorValue.setText(String.format(ColorPicker.COLOR_STRING_FORMATTER, mCurrentColor)); mColorPreviewView = (ImageView) view.findViewById(R.id.preview_color); mColorPreviewView.setImageTintList(ColorStateList.valueOf(mCurrentColor)); Intent launchIntent = getActivity().getIntent(); if (LaunchIntentUtil.isSynchronousAuthLaunch(launchIntent)) { Account addedAccount = LaunchIntentUtil.getAddedAccount(launchIntent); if (addedAccount != null) { view.findViewById(R.id.managed_account_desc).setVisibility(View.VISIBLE); // Show the user which account needs management. TextView managedAccountName = (TextView) view.findViewById(R.id.managed_account_name); managedAccountName.setVisibility(View.VISIBLE); managedAccountName.setText(addedAccount.name); } else { // This is not an expected case, sync-auth is triggered by an account being added so // we expect to be told which account to migrate in the launch intent. We don't // finish() here as it's still technically feasible to continue. Toast.makeText(getActivity(), R.string.invalid_launch_intent_no_account, Toast.LENGTH_LONG).show(); } } return view; }
From source file:com.nokia.example.pepperfarm.iap.Payment.java
/** * Starts the payment process for the given product id. Application is suspended and the Npay service will complete the purchase. * * @param caller - The response from the purchase is sent to the caller activity. Caller activity must override "protected void onActivityResult(int requestCode, int resultCode, Intent data)" method to get the response. * @param product_id - The product id that is being purchased. * @throws Exception/*from w w w. j a v a 2s . c o m*/ */ public void startPayment(Activity caller, String product_id) throws Exception { if (!isBillingAvailable()) return; Bundle intentBundle = npay.getBuyIntent(API_VERSION, activity.getPackageName(), product_id, ITEM_TYPE_INAPP, ""); PendingIntent purchaseIntent = intentBundle.getParcelable("BUY_INTENT"); //Set purchase in progress setPurchaseInProgress(product_id); caller.startIntentSenderForResult(purchaseIntent.getIntentSender(), Integer.valueOf(0), new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); }
From source file:jp.alessandro.android.iab.PurchaseFlowLauncher.java
private PendingIntent getPendingIntent(Activity activity, Bundle bundle) throws BillingException { int response = ResponseExtractor.fromBundle(bundle, mLogger); if (response != Constants.BILLING_RESPONSE_RESULT_OK) { throw new BillingException(response, Constants.ERROR_MSG_UNABLE_TO_BUY); }// ww w . ja va 2 s .c om if (activity == null) { throw new BillingException(Constants.ERROR_LOST_CONTEXT, Constants.ERROR_MSG_LOST_CONTEXT); } PendingIntent pendingIntent = bundle.getParcelable(Constants.RESPONSE_BUY_INTENT); if (pendingIntent == null) { throw new BillingException(Constants.ERROR_PENDING_INTENT, Constants.ERROR_MSG_PENDING_INTENT); } return pendingIntent; }
From source file:com.appdynamics.demo.gasp.service.RESTIntentService.java
@Override protected void onHandleIntent(Intent intent) { Uri action = intent.getData();//from www .j a va 2 s. co m Bundle extras = intent.getExtras(); if (extras == null || action == null || !extras.containsKey(EXTRA_RESULT_RECEIVER)) { Log.e(TAG, "You did not pass extras or data with the Intent."); return; } int verb = extras.getInt(EXTRA_HTTP_VERB, GET); Bundle params = extras.getParcelable(EXTRA_PARAMS); Bundle headers = extras.getParcelable(EXTRA_HEADERS); ResultReceiver receiver = extras.getParcelable(EXTRA_RESULT_RECEIVER); try { HttpRequestBase request = null; // Get query params from Bundle and build URL switch (verb) { case GET: { request = new HttpGet(); attachUriWithQuery(request, action, params); } break; case DELETE: { request = new HttpDelete(); attachUriWithQuery(request, action, params); } break; case POST: { request = new HttpPost(); request.setURI(new URI(action.toString())); HttpPost postRequest = (HttpPost) request; if (params != null) { UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params)); postRequest.setEntity(formEntity); } } break; case PUT: { request = new HttpPut(); request.setURI(new URI(action.toString())); HttpPut putRequest = (HttpPut) request; if (params != null) { UrlEncodedFormEntity formEntity = new UrlEncodedFormEntity(paramsToList(params)); putRequest.setEntity(formEntity); } } break; } // Get Headers from Bundle for (BasicNameValuePair header : paramsToList(headers)) { request.setHeader(header.getName(), header.getValue()); } if (request != null) { HttpClient client = new DefaultHttpClient(); Log.d(TAG, "Executing request: " + verbToString(verb) + ": " + action.toString()); HttpResponse response = client.execute(request); HttpEntity responseEntity = response.getEntity(); StatusLine responseStatus = response.getStatusLine(); int statusCode = responseStatus != null ? responseStatus.getStatusCode() : 0; if ((responseEntity != null) && (responseStatus.getStatusCode() == 200)) { Bundle resultData = new Bundle(); resultData.putString(REST_RESULT, EntityUtils.toString(responseEntity)); receiver.send(statusCode, resultData); } else { receiver.send(statusCode, null); } } } catch (URISyntaxException e) { Log.e(TAG, "URI syntax was incorrect. " + verbToString(verb) + ": " + action.toString(), e); receiver.send(0, null); } catch (UnsupportedEncodingException e) { Log.e(TAG, "A UrlEncodedFormEntity was created with an unsupported encoding.", e); receiver.send(0, null); } catch (ClientProtocolException e) { Log.e(TAG, "There was a problem when sending the request.", e); receiver.send(0, null); } catch (IOException e) { Log.e(TAG, "There was a problem when sending the request.", e); receiver.send(0, null); } catch (Exception e) { e.printStackTrace(); } }
From source file:cn.com.caronwer.activity.CertificationActivity.java
/** * ?//ww w .jav a2 s.c om * * @param data */ private void setPicToView(Intent data) { Bundle extras = data.getExtras(); if (extras != null) { Bitmap bitmap = extras.getParcelable("data"); Drawable drawable = new BitmapDrawable(null, bitmap); String HeadPortrait = BitmapUtil.getImgStr(bitmap); switch (imgType) { case 0: mIv_sf.setImageDrawable(drawable); mJsonObject.addProperty("IDNumberImg", HeadPortrait);//? isimg0 = true; break; case 1: mIv_js.setImageDrawable(drawable); mJsonObject.addProperty("DriverLicenseImg", HeadPortrait);//? isimg1 = true; break; case 2: mIv_xs.setImageDrawable(drawable); mJsonObject.addProperty("TravelCardImg", HeadPortrait);//? isimg2 = true; break; case 3: mIv_che.setImageDrawable(drawable); mJsonObject.addProperty("VehImg", HeadPortrait);// isimg3 = true; break; } } }