List of usage examples for android.content Intent putExtras
public @NonNull Intent putExtras(@NonNull Bundle extras)
From source file:com.battlelancer.seriesguide.ui.MovieDetailsFragment.java
private void populateMovieViews() { /**/* w w w.j av a 2 s.com*/ * Take title, overview and poster from TMDb as they are localized. * Everything else from trakt. */ Movie traktMovie = mMovieDetails.traktMovie(); com.uwetrottmann.tmdb.entities.Movie tmdbMovie = mMovieDetails.tmdbMovie(); mMovieTitle.setText(tmdbMovie.title); mMovieDescription.setText(tmdbMovie.overview); // release date and runtime: "July 17, 2009 | 95 min" StringBuilder releaseAndRuntime = new StringBuilder(); if (traktMovie.released != null && traktMovie.released.getTime() != 0) { releaseAndRuntime.append(DateUtils.formatDateTime(getActivity(), traktMovie.released.getTime(), DateUtils.FORMAT_SHOW_DATE)); releaseAndRuntime.append(" | "); } releaseAndRuntime.append(getString(R.string.runtime_minutes, tmdbMovie.runtime)); mMovieReleaseDate.setText(releaseAndRuntime.toString()); // check-in button final String title = tmdbMovie.title; // fall back to local title for tvtag check-in if we currently don't have the original one final String originalTitle = TextUtils.isEmpty(tmdbMovie.original_title) ? title : tmdbMovie.original_title; mCheckinButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // display a check-in dialog MovieCheckInDialogFragment f = MovieCheckInDialogFragment.newInstance(mTmdbId, title, originalTitle); f.show(getFragmentManager(), "checkin-dialog"); fireTrackerEvent("Check-In"); } }); CheatSheet.setup(mCheckinButton); // watched button (only supported when connected to trakt) if (TraktCredentials.get(getActivity()).hasCredentials()) { final boolean isWatched = traktMovie.watched != null && traktMovie.watched; Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mWatchedButton, 0, isWatched ? Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableWatched) : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableWatch), 0, 0); mWatchedButton.setText(isWatched ? R.string.action_unwatched : R.string.action_watched); CheatSheet.setup(mWatchedButton, isWatched ? R.string.action_unwatched : R.string.action_watched); mWatchedButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // disable button, will be re-enabled on data reload once action completes v.setEnabled(false); if (isWatched) { MovieTools.unwatchedMovie(getActivity(), mTmdbId); fireTrackerEvent("Unwatched movie"); } else { MovieTools.watchedMovie(getActivity(), mTmdbId); fireTrackerEvent("Watched movie"); } } }); mWatchedButton.setEnabled(true); } else { mWatchedButton.setVisibility(View.GONE); } // collected button final boolean isInCollection = traktMovie.inCollection != null && traktMovie.inCollection; Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mCollectedButton, 0, isInCollection ? R.drawable.ic_collected : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableCollect), 0, 0); mCollectedButton .setText(isInCollection ? R.string.action_collection_remove : R.string.action_collection_add); CheatSheet.setup(mCollectedButton, isInCollection ? R.string.action_collection_remove : R.string.action_collection_add); mCollectedButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // disable button, will be re-enabled on data reload once action completes v.setEnabled(false); if (isInCollection) { MovieTools.removeFromCollection(getActivity(), mTmdbId); fireTrackerEvent("Uncollected movie"); } else { MovieTools.addToCollection(getActivity(), mTmdbId); fireTrackerEvent("Collected movie"); } } }); mCollectedButton.setEnabled(true); // watchlist button final boolean isInWatchlist = traktMovie.inWatchlist != null && traktMovie.inWatchlist; Utils.setCompoundDrawablesRelativeWithIntrinsicBounds(mWatchlistedButton, 0, isInWatchlist ? R.drawable.ic_listed : Utils.resolveAttributeToResourceId(getActivity().getTheme(), R.attr.drawableList), 0, 0); mWatchlistedButton.setText(isInWatchlist ? R.string.watchlist_remove : R.string.watchlist_add); CheatSheet.setup(mWatchlistedButton, isInWatchlist ? R.string.watchlist_remove : R.string.watchlist_add); mWatchlistedButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { // disable button, will be re-enabled on data reload once action completes v.setEnabled(false); if (isInWatchlist) { MovieTools.removeFromWatchlist(getActivity(), mTmdbId); fireTrackerEvent("Unwatchlist movie"); } else { MovieTools.addToWatchlist(getActivity(), mTmdbId); fireTrackerEvent("Watchlist movie"); } } }); mWatchlistedButton.setEnabled(true); // show button bar mButtonContainer.setVisibility(View.VISIBLE); // ratings mRatingsTmdbValue.setText(TmdbTools.buildRatingValue(tmdbMovie.vote_average)); mRatingsTraktUserValue.setText(TraktTools.buildUserRatingString(getActivity(), traktMovie.rating_advanced)); if (traktMovie.ratings != null) { mRatingsTraktVotes.setText(TraktTools.buildRatingVotesString(getActivity(), traktMovie.ratings.votes)); mRatingsTraktValue.setText(TraktTools.buildRatingPercentageString(traktMovie.ratings.percentage)); } mRatingsContainer.setVisibility(View.VISIBLE); // genres Utils.setValueOrPlaceholder(mMovieGenres, TmdbTools.buildGenresString(tmdbMovie.genres)); // trakt comments link mCommentsButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { Intent i = new Intent(getActivity(), TraktShoutsActivity.class); i.putExtras(TraktShoutsActivity.createInitBundleMovie(title, mTmdbId)); ActivityCompat.startActivity(getActivity(), i, ActivityOptionsCompat .makeScaleUpAnimation(v, 0, 0, v.getWidth(), v.getHeight()).toBundle()); fireTrackerEvent("Comments"); } }); // load poster, cache on external storage if (!TextUtils.isEmpty(tmdbMovie.poster_path)) { ServiceUtils.getPicasso(getActivity()).load(mImageBaseUrl + tmdbMovie.poster_path) .into(mMoviePosterBackground); } }
From source file:com.andybotting.tramhunter.activity.StopDetailsActivity.java
/** * On create of this class// w w w . ja va 2s . c om */ @Override public void onCreate(Bundle icicle) { super.onCreate(icicle); setContentView(R.layout.stop_details); // Home title button findViewById(R.id.title_btn_home).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { UIUtils.goHome(StopDetailsActivity.this); } }); // Refresh title button findViewById(R.id.title_btn_refresh).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mShowDialog = true; new GetNextTramTimes().execute(); } }); // Map title button findViewById(R.id.title_btn_map).setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Bundle bundle = new Bundle(); StopsList mStopList = new StopsList(); mStopList.add(mStop); bundle.putParcelable("stopslist", mStopList); Intent intent = new Intent(StopDetailsActivity.this, StopMapActivity.class); intent.putExtras(bundle); startActivityForResult(intent, 1); } }); // Set up our list mListAdapter = new NextTramsListAdapter(); mListView = getListView(); mListView.setVisibility(View.GONE); // Preferences mPreferenceHelper = new PreferenceHelper(); // Get bundle data int routeId = -1; Bundle extras = getIntent().getExtras(); if (extras != null) { mTramTrackerId = extras.getInt("tramTrackerId"); routeId = extras.getInt("routeId", -1); } // Get our favourite stops list mFavouriteList = new FavouriteList(); // Create out DB instance mDB = new TramHunterDB(); mStop = mDB.getStop(mTramTrackerId); if (routeId > -1) mRoute = mDB.getRoute(routeId); // Set the title String title = mStop.getStopName(); ((TextView) findViewById(R.id.title_text)).setText(title); // Display stop data displayStop(mStop); // Star button mStarButton = (CompoundButton) findViewById(R.id.stopStar); mStarButton.setChecked(mFavouriteList.isFavourite(new Favourite(mStop, mRoute))); mStarButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { mFavouriteList.setFavourite(new Favourite(mStop, mRoute), mStarButton.isChecked()); } }); // Get our TramTracker service, either SOAP (def) or JSON // if (mPreferenceHelper.isJSONAPIEnabled()) // ttService = new TramTrackerServiceJSON(); // else ttService = new TramTrackerServiceSOAP(); // Our thread for updating the stops every 60 secs mRefreshThread = new Thread(new CountDown()); mRefreshThread.setDaemon(true); mRefreshThread.start(); }
From source file:com.forum.fiend.osp.SettingsFragment.java
private void logOut() { application.getSession().logOutSession(); Intent intent = new Intent(getActivity(), IntroScreen.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); Bundle bundle = new Bundle(); bundle.putBoolean("reboot", true); intent.putExtras(bundle); startActivity(intent);/*w w w. j a va2 s. co m*/ }
From source file:com.pax.pay.PaymentActivity.java
/** * terminal setting/*from w w w . ja va 2 s . c o m*/ * * @param requestData */ private void doSetting(RequestData requestData) { ActionInputPassword inputPasswordAction = new ActionInputPassword(new ActionStartListener() { @Override public void onStart(AAction action) { ((ActionInputPassword) action).setParam(8, getString(R.string.prompt_sys_pwd), null); TransContext.getInstance().setCurrentAction(action); } }); inputPasswordAction.setEndListener(new ActionEndListener() { @Override public void onEnd(AAction action, ActionResult result) { if (result.getRet() != TransResult.SUCC) { transFinish(result); return; } String data = EncUtils.SHA1((String) result.getData()); if (!data.equals(SpManager.getSysParamSp().get(SysParamSp.SEC_SYSPWD))) { transFinish(new ActionResult(TransResult.ERR_PASSWORD, null)); return; } Intent intent = new Intent(PaymentActivity.this, SettingsActivity.class); Bundle bundle = new Bundle(); bundle.putString(EUIParamKeys.NAV_TITLE.toString(), getString(R.string.settings_title)); bundle.putBoolean(EUIParamKeys.NAV_BACK.toString(), true); intent.putExtras(bundle); startActivityForResult(intent, REQUEST_CODE); } }); inputPasswordAction.execute(); }
From source file:com.dsi.ant.antplus.pluginsampler.fitnessequipment.Dialog_ConfigSettings.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle("Settings Configuration"); // Get the layout inflater LayoutInflater inflater = getActivity().getLayoutInflater(); View detailsView = inflater.inflate(R.layout.dialog_fe_settings, null); // Inflate and set the layout for the dialog // Pass null as the parent view because its going in the dialog layout builder.setView(detailsView);/*from ww w . j a v a2 s . c o m*/ // Add action buttons builder.setPositiveButton("OK", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Intent i = new Intent(Dialog_ConfigSettings.this.getActivity(), Activity_FitnessEquipmentSampler.class); Bundle b = new Bundle(); b.putString(SETTINGS_NAME, et_friendlyName.getText().toString()); b.putShort(SETTINGS_AGE, Short.parseShort(et_age.getText().toString())); b.putFloat(SETTINGS_HEIGHT, Float.parseFloat(et_height.getText().toString()) / 100f); // Convert to m b.putFloat(SETTINGS_WEIGHT, Float.parseFloat(et_weight.getText().toString())); b.putBoolean(SETTINGS_GENDER, rb_male.isChecked()); b.putBoolean(INCLUDE_WORKOUT, cb_workout.isChecked()); i.putExtras(b); startActivity(i); } }); builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { //Let dialog dismiss } }); et_friendlyName = (EditText) detailsView.findViewById(R.id.editText_FriendlyName); et_age = (EditText) detailsView.findViewById(R.id.editText_Age); et_height = (EditText) detailsView.findViewById(R.id.editText_Height); et_weight = (EditText) detailsView.findViewById(R.id.editText_Weight); rb_female = (RadioButton) detailsView.findViewById(R.id.radioButton_Female); rb_male = (RadioButton) detailsView.findViewById(R.id.radioButton_Male); cb_workout = (CheckBox) detailsView.findViewById(R.id.checkBox_Workout); return builder.create(); }
From source file:com.antew.redditinpictures.library.ui.RedditImageAdapterViewFragment.java
/** * Callback method to be invoked when an item in this AdapterView has * been clicked./*w w w . jav a2s. c o m*/ * <p/> * Implementers can call getItemAtPosition(position) if they need * to access the data associated with the selected item. * * @param parent * The AdapterView where the click happened. * @param view * The view within the AdapterView that was clicked (this * will be a view provided by the adapter) * @param position * The position of the view in the adapter. * @param id * The row id of the item that was clicked. */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN) @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { EasyTracker.getInstance(getActivity()).send(MapBuilder.createEvent(Constants.Analytics.Category.UI_ACTION, Constants.Analytics.Action.OPEN_POST, mCurrentSubreddit, null).build()); final Intent i = new Intent(getActivity(), getImageDetailActivityClass()); Bundle b = new Bundle(); b.putString(Constants.Extra.EXTRA_SUBREDDIT, mCurrentSubreddit); b.putString(Constants.Extra.EXTRA_CATEGORY, mCategory.name()); b.putString(Constants.Extra.EXTRA_AGE, mAge.name()); i.putExtra(Constants.Extra.EXTRA_IMAGE, position); i.putExtras(b); if (AndroidUtil.hasJellyBean()) { ActivityOptions options = ActivityOptions.makeScaleUpAnimation(view, 0, 0, view.getWidth(), view.getHeight()); getActivity().startActivity(i, options.toBundle()); } else { startActivity(i); } }
From source file:com.bonsai.wallet32.SweepKeyActivity.java
public void sweepKey(View view) { if (mWalletService == null) { showErrorDialog(mRes.getString(R.string.sweep_error_nowallet)); return;// ww w . ja va 2 s. c om } // Fetch the private key. if (mKey == null) { showErrorDialog(mRes.getString(R.string.sweep_error_nokey)); return; } // Make sure we have fetched the unspent outputs. if (mUnspentOutputs == null) { showErrorDialog(mRes.getString(R.string.sweep_error_nooutputs)); return; } // Fetch the fee amount. long fee = 0; EditText feeEditText = (EditText) findViewById(R.id.fee_btc); String feeString = feeEditText.getText().toString(); if (feeString.length() == 0) { showErrorDialog(mRes.getString(R.string.sweep_error_nofee)); return; } try { fee = mBTCFmt.parse(feeString); } catch (NumberFormatException ex) { showErrorDialog(mRes.getString(R.string.sweep_error_badfee)); return; } // Which account was selected? if (mAccountId == -1) { showErrorDialog(mRes.getString(R.string.sweep_error_noaccount)); return; } // Sweep! mWalletService.sweepKey(mKey, fee, mAccountId, mUnspentOutputs); // Head to the transaction view for this account ... Intent intent = new Intent(this, ViewTransactionsActivity.class); Bundle bundle = new Bundle(); bundle.putInt("accountId", mAccountId); intent.putExtras(bundle); startActivity(intent); // We're done here ... finish(); }
From source file:com.facebook.android.friendsmash.GameFragment.java
void setLives(int lives) { this.lives = lives; if (getActivity() != null) { // Update the livesContainer livesContainer.removeAllViews(); for (int i = 0; i < lives; i++) { ImageView heartImageView = new ImageView(getActivity()); heartImageView.setImageResource(R.drawable.heart_red); livesContainer.addView(heartImageView); }// w w w . ja v a 2 s . com if (lives <= 0) { // User has no lives left, so end the game, passing back the score Bundle bundle = new Bundle(); bundle.putInt("score", getScore()); Intent i = new Intent(); i.putExtras(bundle); getActivity().setResult(Activity.RESULT_OK, i); getActivity().finish(); } } }
From source file:info.guardianproject.otr.app.im.app.WelcomeActivity.java
void handleIntentAPILaunch(Intent srcIntent) { Intent intent = new Intent(this, ImUrlActivity.class); intent.setAction(srcIntent.getAction()); if (srcIntent.getData() != null) intent.setData(srcIntent.getData()); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); if (srcIntent.getExtras() != null) intent.putExtras(srcIntent.getExtras()); startActivity(intent);//from ww w . ja v a 2s .c om setIntent(null); finish(); }
From source file:com.brandroidtools.filemanager.activities.PickerActivity.java
/** * {@inheritDoc}//from w ww.j a v a 2 s .c o m */ @Override public void onDismiss(DialogInterface dialog) { if (this.mFso != null) { File src = new File(this.mFso.getFullPath()); if (getIntent().getExtras() != null) { // Some AOSP applications use the gallery to edit and crop the selected image // with the Gallery crop editor. In this case pass the picked file to the // CropActivity with the requested parameters // Expected result is on onActivityResult Bundle extras = getIntent().getExtras(); String crop = extras.getString(EXTRA_CROP); if (Boolean.parseBoolean(crop)) { // We want to use the Gallery3d activity because we know about it, and his // parameters. At least we have a compatible one. Intent intent = new Intent(ACTION_CROP); if (getIntent().getType() != null) { intent.setType(getIntent().getType()); } intent.setData(Uri.fromFile(src)); intent.putExtras(extras); intent.setComponent(CROP_COMPONENT); startActivityForResult(intent, RESULT_CROP_IMAGE); return; } } // Return the picked file, as expected (this activity should fill the intent data // and return RESULT_OK result) Intent result = new Intent(); result.setData(getResultUriForFileFromIntent(src, getIntent())); setResult(Activity.RESULT_OK, result); finish(); } else { cancel(); } }