List of usage examples for android.os Bundle putInt
public void putInt(@Nullable String key, int value)
From source file:com.example.alvarpao.popularmovies.MovieGridFragment.java
@Override public void onSaveInstanceState(Bundle savedInstanceState) { mSavedMovies.clear();/*from w ww . j a v a2 s. co m*/ for (int index = 0; index < mMovieAdapter.getCount(); index++) mSavedMovies.add(mMovieAdapter.getItem(index)); //Toast.makeText(getActivity(), "Number of movies saved: " + mSavedMovies.size(), // Toast.LENGTH_SHORT).show(); savedInstanceState.putParcelableArrayList(LOADED_MOVIES, mSavedMovies); savedInstanceState.putInt(PAGE_TO_FETCH, mPageToFetch); savedInstanceState.putInt(LOADED_PREVIOUS_ITEMS, mPreviousTotalItems); // The user actually selected a movie, it was not pre-selected by the app to keep the // details fragment from being empty in the two-pane layout if ((mSelectedMovie != -1) && (mSelectionOccurred)) savedInstanceState.putInt(SELECTED_MOVIE, mSelectedMovie); else { // No movie selected save the position of the first visible item //Toast.makeText(getActivity(), "No position selected, select first visible", // Toast.LENGTH_SHORT).show(); savedInstanceState.putInt(SELECTED_MOVIE, mMoviesGridView.getFirstVisiblePosition()); } savedInstanceState.putBoolean(SELECTION_OCCURRED, mSelectionOccurred); savedInstanceState.putInt(CURRENT_SCROLL_POSITION, mMoviesGridView.getFirstVisiblePosition()); super.onSaveInstanceState(savedInstanceState); }
From source file:com.heightechllc.breakify.MainActivity.java
/** * Skips to the next timer state// w ww .j a v a 2 s. co m */ private void skipToNextState() { int oldWorkState = getWorkState(); // Record the state we're about to skip from, in case the user chooses to undo Bundle undoStateBundle = new Bundle(); undoStateBundle.putLong("totalTime", circleTimer.getTotalTime()); undoStateBundle.putLong("remainingTime", circleTimer.getRemainingTime()); undoStateBundle.putInt("workState", oldWorkState); String toastMessage = getString(R.string.skip_toast); // Get duration from preferences, in minutes long duration; if (oldWorkState == WORK_STATE_WORKING) { // Means we're skipping to break duration = sharedPref.getInt(TimerDurationsSettingsFragment.KEY_BREAK_DURATION, 0); toastMessage += " break"; } else { // Means we're skipping to work duration = sharedPref.getInt(TimerDurationsSettingsFragment.KEY_WORK_DURATION, 0); toastMessage += " work"; } // Create and show the undo bar showUndoBar(toastMessage, undoStateBundle, new UndoBarController.UndoListener() { @Override public void onUndo(Parcelable parcelable) { if (parcelable == null) return; // Extract the saved state from the Parcelable Bundle undoStateBundle = (Bundle) parcelable; long prevTotalTime = undoStateBundle.getLong("totalTime"); long prevRemainingTime = undoStateBundle.getLong("remainingTime"); int prevWorkState = undoStateBundle.getInt("workState"); // Cause startTimer() to treat it like we're resuming (b/c we are) timerState = TIMER_STATE_PAUSED; setWorkState(prevWorkState); // Restore to the previous timer state, similar to how we restore a // running timer from SharedPreferences in onCreate() circleTimer.setTotalTime(prevTotalTime); circleTimer.updateTimeLbl(prevRemainingTime); // Record the total duration, so we can resume if the activity is destroyed sharedPref.edit().putLong("schedTotalTime", prevTotalTime).apply(); startTimer(prevRemainingTime); // Analytics if (mixpanel != null) mixpanel.track("Skip undone", null); } }); // Set the new state if (oldWorkState == WORK_STATE_WORKING) setWorkState(WORK_STATE_BREAKING); else setWorkState(WORK_STATE_WORKING); // We want to start the timer from scratch, not from a paused state timerState = TIMER_STATE_STOPPED; // Start the timer startTimer(duration * 60000); // Multiply into milliseconds // Analytics if (mixpanel != null) { JSONObject props = new JSONObject(); try { props.put("Duration", duration); } catch (JSONException e) { e.printStackTrace(); } String eventName = getWorkState() == WORK_STATE_WORKING ? "Skipped to work" : "Skipped to break"; mixpanel.track(eventName, props); } }
From source file:com.teleca.jamendo.activity.SearchActivity.java
@Override protected void onSaveInstanceState(Bundle outState) { if (mSearchMode != null) { outState.putSerializable("mode", mSearchMode); if (mSearchMode.equals(SearchMode.Artist) || mSearchMode.equals(SearchMode.Tag) || mSearchMode.equals(SearchMode.UserStarredAlbums)) { AlbumAdapter adapter = (AlbumAdapter) mSearchListView.getAdapter(); outState.putSerializable("values", adapter.getList()); }//ww w . j ava 2 s .c o m if (mSearchMode.equals(SearchMode.UserPlaylist)) { PlaylistRemoteAdapter adapter = (PlaylistRemoteAdapter) mSearchListView.getAdapter(); outState.putSerializable("values", adapter.getList()); } outState.putInt("flipper_page", mViewFlipper.getDisplayedChild()); } super.onSaveInstanceState(outState); }
From source file:com.hackensack.umc.activity.ProfileSelfiewithCropActivity.java
private void startRegistrationActivity(DataForAutoRegistration dataTosend) { Intent intent = new Intent(ProfileSelfiewithCropActivity.this, RegistrationDetailsActivity.class); Bundle b = new Bundle(); b.putSerializable(Constant.REG_REQUIRED_DATA, dataTosend); b.putInt(Constant.REGISTRATION_MODE, Constant.AUTO); b = putUrlValuesInBundle(b);/*w ww .j av a 2 s. co m*/ intent.putExtra(Constant.BUNDLE, b); startActivity(intent); }
From source file:com.hackensack.umc.activity.ProfileSelfieActivity.java
private void startRegistrationActivity(DataForAutoRegistration dataTosend) { Intent intent = new Intent(ProfileSelfieActivity.this, RegistrationDetailsActivity.class); Bundle b = new Bundle(); b.putSerializable(Constant.REG_REQUIRED_DATA, dataTosend); b.putInt(Constant.REGISTRATION_MODE, Constant.AUTO); b = putUrlValuesInBundle(b);//w w w. j a va 2s . c o m intent.putExtra(Constant.BUNDLE, b); startActivity(intent); }
From source file:org.anhonesteffort.flock.SubscriptionGoogleFragment.java
private void handleCancelSubscription() { if (asyncTask != null) return;/*from ww w. j a v a 2 s . c o m*/ asyncTask = new AsyncTask<Void, Void, Bundle>() { @Override protected void onPreExecute() { Log.d(TAG, "handleCancelSubscription()"); subscriptionActivity.setProgressBarIndeterminateVisibility(true); subscriptionActivity.setProgressBarVisibility(true); } @Override protected Bundle doInBackground(Void... params) { Bundle result = new Bundle(); RegistrationApi registrationApi = new RegistrationApi(subscriptionActivity); try { registrationApi.cancelSubscription(subscriptionActivity.davAccount); AccountStore.setSubscriptionPlan(subscriptionActivity, SubscriptionPlan.PLAN_NONE); AccountStore.setAutoRenew(subscriptionActivity, false); result.putInt(ErrorToaster.KEY_STATUS_CODE, ErrorToaster.CODE_SUCCESS); } catch (RegistrationApiException e) { ErrorToaster.handleBundleError(e, result); } catch (JsonProcessingException e) { ErrorToaster.handleBundleError(e, result); } catch (IOException e) { ErrorToaster.handleBundleError(e, result); } return result; } @Override protected void onPostExecute(Bundle result) { asyncTask = null; subscriptionActivity.setProgressBarIndeterminateVisibility(false); subscriptionActivity.setProgressBarVisibility(false); if (result.getInt(ErrorToaster.KEY_STATUS_CODE) == ErrorToaster.CODE_SUCCESS) { Toast.makeText(subscriptionActivity, R.string.subscription_canceled, Toast.LENGTH_SHORT).show(); subscriptionActivity.updateFragmentWithPlanType(SubscriptionPlan.PLAN_TYPE_NONE); } else { ErrorToaster.handleDisplayToastBundledError(subscriptionActivity, result); handleUpdateUi(); } } }.execute(); }
From source file:com.test.onesignal.GenerateNotificationRunner.java
@Test public void shouldProcessRestore() throws Exception { Bundle bundle = createInternalPayloadBundle(getBaseNotifBundle()); bundle.putInt("android_notif_id", 0); bundle.putBoolean("restoring", true); NotificationBundleProcessor_ProcessFromGCMIntentService_NoWrap(blankActivity, bundle, null); Assert.assertEquals("UnitTestApp", ShadowRoboNotificationManager.getLastShadowNotif().getContentTitle()); }
From source file:org.dvbviewer.controller.ui.fragments.ChannelList.java
@Override public void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); outState.putInt(KEY_SELECTED_POSITION, selectedPosition); }
From source file:au.com.wallaceit.reddinator.MainActivity.java
public void openLink(int position, int openType) { // get the item JSONObject item = listAdapter.getItem(position); switch (openType) { case 1://from w w w .j a v a 2 s. c o m // open in the reddinator view Intent clickIntent1 = new Intent(context, ViewRedditActivity.class); Bundle extras = new Bundle(); try { extras.putString(WidgetProvider.ITEM_ID, item.getString("name")); extras.putInt("itemposition", position); extras.putString(WidgetProvider.ITEM_URL, item.getString("url")); extras.putString(WidgetProvider.ITEM_PERMALINK, item.getString("permalink")); } catch (JSONException e) { e.printStackTrace(); } clickIntent1.putExtras(extras); context.startActivity(clickIntent1); break; case 2: // open link in browser String url = null; try { url = item.getString("url"); } catch (JSONException e) { e.printStackTrace(); } Intent clickIntent2 = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); context.startActivity(clickIntent2); break; case 3: // open reddit comments page in browser String permalink = null; try { permalink = item.getString("permalink"); } catch (JSONException e) { e.printStackTrace(); } Intent clickIntent3 = new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.reddit.com" + permalink)); context.startActivity(clickIntent3); break; } }
From source file:org.dvbviewer.controller.ui.fragments.TimerList.java
@Override public void onListItemClick(ListView parent, View view, int position, long id) { if (UIUtils.isTablet(getActivity())) { Timer timer = mAdapter.getItem(position); TimerDetails timerdetails = TimerDetails.newInstance(); Bundle args = new Bundle(); args.putLong(TimerDetails.EXTRA_ID, timer.getId()); args.putString(TimerDetails.EXTRA_TITLE, timer.getTitle()); args.putString(TimerDetails.EXTRA_CHANNEL_NAME, timer.getChannelName()); args.putLong(TimerDetails.EXTRA_CHANNEL_ID, timer.getChannelId()); args.putLong(TimerDetails.EXTRA_START, timer.getStart().getTime()); args.putLong(TimerDetails.EXTRA_END, timer.getEnd().getTime()); args.putInt(TimerDetails.EXTRA_ACTION, timer.getTimerAction()); timerdetails.setArguments(args); timerdetails.show(getSherlockActivity().getSupportFragmentManager(), TimerDetails.class.getName()); onDestroyActionMode(mode);//from w w w .jav a 2 s .c o m } else { getListView().setItemChecked(position, !getListView().isItemChecked(position)); Timer timer = mAdapter.getItem(position); Intent i = new Intent(getActivity(), TimerDetailsActivity.class); i.putExtra(TimerDetails.EXTRA_ID, timer.getId()); i.putExtra(TimerDetails.EXTRA_TITLE, timer.getTitle()); i.putExtra(TimerDetails.EXTRA_CHANNEL_NAME, timer.getChannelName()); i.putExtra(TimerDetails.EXTRA_CHANNEL_ID, timer.getChannelId()); i.putExtra(TimerDetails.EXTRA_START, timer.getStart().getTime()); i.putExtra(TimerDetails.EXTRA_END, timer.getEnd().getTime()); i.putExtra(TimerDetails.EXTRA_ACTION, timer.getTimerAction()); startActivityForResult(i, TimerDetails.TIMER_CHANGED); } }