List of usage examples for android.os Bundle getBundle
@Nullable
public Bundle getBundle(@Nullable String key)
From source file:com.ichi2.anki.NoteEditor.java
@Override protected void onCreate(Bundle savedInstanceState) { Timber.d("onCreate()"); super.onCreate(savedInstanceState); setContentView(R.layout.note_editor); Intent intent = getIntent();// ww w . jav a2 s. co m if (savedInstanceState != null) { mCaller = savedInstanceState.getInt("caller"); mAddNote = savedInstanceState.getBoolean("addFact"); mCurrentDid = savedInstanceState.getLong("did"); mSelectedTags = new ArrayList<>(Arrays.asList(savedInstanceState.getStringArray("tags"))); mSavedFields = savedInstanceState.getBundle("editFields"); } else { mCaller = intent.getIntExtra(EXTRA_CALLER, CALLER_NOCALLER); if (mCaller == CALLER_NOCALLER) { String action = intent.getAction(); if (action != null && (ACTION_CREATE_FLASHCARD.equals(action) || ACTION_CREATE_FLASHCARD_SEND.equals(action))) { mCaller = CALLER_CARDEDITOR_INTENT_ADD; } } } startLoadingCollection(); }
From source file:com.folioreader.ui.folio.activity.FolioActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Need to add when vector drawables support library is used. AppCompatDelegate.setCompatVectorFromResourcesEnabled(true); handler = new Handler(); Display display = getWindowManager().getDefaultDisplay(); displayMetrics = getResources().getDisplayMetrics(); display.getRealMetrics(displayMetrics); density = displayMetrics.density;// w w w. j av a 2 s. c o m LocalBroadcastManager.getInstance(this).registerReceiver(closeBroadcastReceiver, new IntentFilter(FolioReader.ACTION_CLOSE_FOLIOREADER)); // Fix for screen get turned off while reading // TODO -> Make this configurable // getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setConfig(savedInstanceState); initDistractionFreeMode(savedInstanceState); setContentView(R.layout.folio_activity); this.savedInstanceState = savedInstanceState; if (savedInstanceState != null) { searchAdapterDataBundle = savedInstanceState.getBundle(SearchAdapter.DATA_BUNDLE); searchQuery = savedInstanceState.getCharSequence(SearchActivity.BUNDLE_SAVE_SEARCH_QUERY); } mBookId = getIntent().getStringExtra(FolioReader.INTENT_BOOK_ID); mEpubSourceType = (EpubSourceType) getIntent().getExtras() .getSerializable(FolioActivity.INTENT_EPUB_SOURCE_TYPE); if (mEpubSourceType.equals(EpubSourceType.RAW)) { mEpubRawId = getIntent().getExtras().getInt(FolioActivity.INTENT_EPUB_SOURCE_PATH); } else { mEpubFilePath = getIntent().getExtras().getString(FolioActivity.INTENT_EPUB_SOURCE_PATH); } initActionBar(); initMediaController(); if (ContextCompat.checkSelfPermission(FolioActivity.this, Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) { ActivityCompat.requestPermissions(FolioActivity.this, Constants.getWriteExternalStoragePerms(), Constants.WRITE_EXTERNAL_STORAGE_REQUEST); } else { setupBook(); } }
From source file:com.android.deskclock.AlarmClockFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedState) { // Inflate the layout for this fragment final View v = inflater.inflate(R.layout.alarm_clock, container, false); long expandedId = INVALID_ID; long[] repeatCheckedIds = null; long[] selectedAlarms = null; Bundle previousDayMap = null;/*from ww w .ja v a 2s . c o m*/ if (savedState != null) { expandedId = savedState.getLong(KEY_EXPANDED_ID); repeatCheckedIds = savedState.getLongArray(KEY_REPEAT_CHECKED_IDS); mRingtoneTitleCache = savedState.getBundle(KEY_RINGTONE_TITLE_CACHE); mDeletedAlarm = savedState.getParcelable(KEY_DELETED_ALARM); mUndoShowing = savedState.getBoolean(KEY_UNDO_SHOWING); selectedAlarms = savedState.getLongArray(KEY_SELECTED_ALARMS); previousDayMap = savedState.getBundle(KEY_PREVIOUS_DAY_MAP); mSelectedAlarm = savedState.getParcelable(KEY_SELECTED_ALARM); } mExpandInterpolator = new DecelerateInterpolator(EXPAND_DECELERATION); mCollapseInterpolator = new DecelerateInterpolator(COLLAPSE_DECELERATION); if (USE_TRANSITION_FRAMEWORK) { mAddRemoveTransition = new AutoTransition(); mAddRemoveTransition.setDuration(ANIMATION_DURATION); /// M: Scrap the views in ListView and request layout again, then alarm item will be /// attached correctly. This is to avoid the case when some items are not correctly /// attached after animation end @{ mAddRemoveTransition.addListener(new Transition.TransitionListenerAdapter() { @Override public void onTransitionEnd(Transition transition) { mAlarmsList.clearScrapViewsIfNeeded(); } }); /// @} mRepeatTransition = new AutoTransition(); mRepeatTransition.setDuration(ANIMATION_DURATION / 2); mRepeatTransition.setInterpolator(new AccelerateDecelerateInterpolator()); mEmptyViewTransition = new TransitionSet().setOrdering(TransitionSet.ORDERING_SEQUENTIAL) .addTransition(new Fade(Fade.OUT)).addTransition(new Fade(Fade.IN)) .setDuration(ANIMATION_DURATION); } boolean isLandscape = getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE; View menuButton = v.findViewById(R.id.menu_button); if (menuButton != null) { if (isLandscape) { menuButton.setVisibility(View.GONE); } else { menuButton.setVisibility(View.VISIBLE); setupFakeOverflowMenuButton(menuButton); } } mEmptyView = v.findViewById(R.id.alarms_empty_view); mMainLayout = (FrameLayout) v.findViewById(R.id.main); mAlarmsList = (ListView) v.findViewById(R.id.alarms_list); mUndoBar = (ActionableToastBar) v.findViewById(R.id.undo_bar); mUndoFrame = v.findViewById(R.id.undo_frame); mUndoFrame.setOnTouchListener(this); mFooterView = v.findViewById(R.id.alarms_footer_view); mFooterView.setOnTouchListener(this); mAdapter = new AlarmItemAdapter(getActivity(), expandedId, repeatCheckedIds, selectedAlarms, previousDayMap, mAlarmsList); mAdapter.registerDataSetObserver(new DataSetObserver() { private int prevAdapterCount = -1; @Override public void onChanged() { final int count = mAdapter.getCount(); if (mDeletedAlarm != null && prevAdapterCount > count) { showUndoBar(); } if (USE_TRANSITION_FRAMEWORK && ((count == 0 && prevAdapterCount > 0) || /* should fade in */ (count > 0 && prevAdapterCount == 0) /* should fade out */)) { TransitionManager.beginDelayedTransition(mMainLayout, mEmptyViewTransition); } mEmptyView.setVisibility(count == 0 ? View.VISIBLE : View.GONE); // Cache this adapter's count for when the adapter changes. prevAdapterCount = count; super.onChanged(); } }); if (mRingtoneTitleCache == null) { mRingtoneTitleCache = new Bundle(); } mAlarmsList.setAdapter(mAdapter); mAlarmsList.setVerticalScrollBarEnabled(true); mAlarmsList.setOnCreateContextMenuListener(this); if (mUndoShowing) { showUndoBar(); } return v; }
From source file:com.TagFu.facebook.Session.java
/** * Restores the saved session from a Bundle, if any. Returns the restored Session or null if it could not be * restored. This method is intended to be called from an Activity or Fragment's onCreate method when a Session has * previously been saved into a Bundle via saveState to preserve a Session across Activity lifecycle events. * * @param context the Activity or Service creating the Session, must not be null * @param cachingStrategy the TokenCachingStrategy to use to load and store the token. If this is null, a default * token cachingStrategy that stores data in SharedPreferences will be used * @param callback the callback to notify for Session state changes, can be null * @param bundle the bundle to restore the Session from * @return the restored Session, or null *//*from w w w . jav a 2 s. c o m*/ public static final Session restoreSession(final Context context, final TokenCachingStrategy cachingStrategy, final StatusCallback callback, final Bundle bundle) { if (bundle == null) { return null; } final byte[] data = bundle.getByteArray(SESSION_BUNDLE_SAVE_KEY); if (data != null) { final ByteArrayInputStream is = new ByteArrayInputStream(data); try { final Session session = (Session) (new ObjectInputStream(is)).readObject(); initializeStaticContext(context); if (cachingStrategy != null) { session.tokenCachingStrategy = cachingStrategy; } else { session.tokenCachingStrategy = new SharedPreferencesTokenCachingStrategy(context); } if (callback != null) { session.addCallback(callback); } session.authorizationBundle = bundle.getBundle(AUTH_BUNDLE_SAVE_KEY); return session; } catch (final ClassNotFoundException e) { Log.w(TAG, "Unable to restore session", e); } catch (final IOException e) { Log.w(TAG, "Unable to restore session.", e); } } return null; }
From source file:net.exclaimindustries.geohashdroid.activities.CentralMap.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); int mapType = -1; // Load up!//from w w w. j a v a 2 s.c om if (savedInstanceState != null) { mCurrentInfo = savedInstanceState.getParcelable(STATE_INFO); mAlreadyDidInitialZoom = savedInstanceState.getBoolean(STATE_WAS_ALREADY_ZOOMED, false); mSelectAGraticule = savedInstanceState.getBoolean(STATE_WAS_SELECT_A_GRATICULE, false); mGlobalhash = savedInstanceState.getBoolean(STATE_WAS_GLOBALHASH, false); mResolvingError = savedInstanceState.getBoolean(STATE_WAS_RESOLVING_CONNECTION_ERROR, false); mPermissionsDenied = savedInstanceState.getBoolean(STATE_WERE_PERMISSIONS_DENIED, false); mLastGraticule = savedInstanceState.getParcelable(STATE_LAST_GRATICULE); mLastCalendar = (Calendar) savedInstanceState.getSerializable(STATE_LAST_CALENDAR); // This will just get dropped right back into the mode wholesale. mLastModeBundle = savedInstanceState.getBundle(STATE_LAST_MODE_BUNDLE); // Map type? mapType = savedInstanceState.getInt(STATE_MAP_TYPE, -1); } // Finalize the map type. That's going into a callback. final int reallyMapType = mapType; setContentView(R.layout.centralmap); // We deal with locations, so we deal with the GoogleApiClient. It'll // connect during onStart. mGoogleClient = new GoogleApiClient.Builder(this).addConnectionCallbacks(this) .addOnConnectionFailedListener(this).addApi(LocationServices.API).build(); mBanner = (ErrorBanner) findViewById(R.id.error_banner); // Get a map ready. We'll know when we've got it. Oh, we'll know. MapFragment mapFrag = (MapFragment) getFragmentManager().findFragmentById(R.id.map); mapFrag.getMapAsync(new OnMapReadyCallback() { @Override public void onMapReady(GoogleMap googleMap) { mMap = googleMap; // I could swear you could do this in XML... UiSettings set = mMap.getUiSettings(); // The My Location button has to go off, as we're going to have the // infobox right around there. set.setMyLocationButtonEnabled(false); // Restore the map's type, if it was changed. if (reallyMapType >= 0) mMap.setMapType(reallyMapType); // Now, set the flag that tells everything else (especially the // doReadyChecks method) we're ready. Then, call doReadyChecks. // We might still be waiting on the API. mMapIsReady = true; doReadyChecks(); } }); // If at this point we don't have any mode bundle, we're starting in // ExpeditionMode with a flag set. This means that this overrides // the boolean. if (mLastModeBundle == null) { mLastModeBundle = new Bundle(); mLastModeBundle.putBoolean(ExpeditionMode.DO_INITIAL_START, true); mSelectAGraticule = false; } // Perform startup and cleanup work before the modes arrive. doStartupStuff(); // Now, we get our initial mode set up based on mSelectAGraticule. We // do NOT init it yet; we have to wait for both the map fragment and the // API to be ready first. if (mSelectAGraticule) mCurrentMode = new SelectAGraticuleMode(); else mCurrentMode = new ExpeditionMode(); }
From source file:com.djkim.slap.createGroup.CreateGroupActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.create_group_layout); FacebookSdk.sdkInitialize(this.getApplicationContext()); callbackManager = CallbackManager.Factory.create(); createAppGroupDialog = new CreateAppGroupDialog(this); createAppGroupDialog.registerCallback(callbackManager, new FacebookCallback<CreateAppGroupDialog.Result>() { public void onSuccess(CreateAppGroupDialog.Result result) { String id = result.getId(); group.set_facebookGroupId(id); group.saveInBackground(new GroupCallback() { @Override/*from ww w . j a v a 2 s .c o m*/ public void done() { Toast.makeText(CreateGroupActivity.this, "Successfully created the group!", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra(CREATE_GROUP_EXTRA, group); setResult(RESULT_OK, intent); finish(); } }); } public void onCancel() { group.saveInBackground(new GroupCallback() { @Override public void done() { Toast.makeText(CreateGroupActivity.this, "Failed to create the group!", Toast.LENGTH_SHORT) .show(); Intent intent = new Intent(); intent.putExtra(CREATE_GROUP_EXTRA, group); setResult(RESULT_OK, intent); finish(); } }); } public void onError(FacebookException error) { } }); if (savedInstanceState != null) { mWizardModel.load(savedInstanceState.getBundle("model")); } mWizardModel.registerListener(this); mPagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mPagerAdapter); mStepPagerStrip = (StepPagerStrip) findViewById(R.id.strip); mStepPagerStrip.setOnPageSelectedListener(new StepPagerStrip.OnPageSelectedListener() { @Override public void onPageStripSelected(int position) { position = Math.min(mPagerAdapter.getCount() - 1, position); if (mPager.getCurrentItem() != position) { mPager.setCurrentItem(position); } } }); mNextButton = (Button) findViewById(R.id.next_button); mPrevButton = (Button) findViewById(R.id.prev_button); mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { mStepPagerStrip.setCurrentPage(position); if (mConsumePageSelectedEvent) { mConsumePageSelectedEvent = false; return; } mEditingAfterReview = false; updateBottomBar(); } }); mNextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mPager.getCurrentItem() == mCurrentPageSequence.size()) { DialogFragment dg = new DialogFragment() { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity()) .setMessage(R.string.submit_confirm_message) .setPositiveButton(R.string.submit_confirm_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { createGroup(); onClickCreateButton(); } }) .setNegativeButton(android.R.string.cancel, null).create(); } }; dg.show(getSupportFragmentManager(), "place_order_dialog"); } else { if (mEditingAfterReview) { mPager.setCurrentItem(mPagerAdapter.getCount() - 1); } else { mPager.setCurrentItem(mPager.getCurrentItem() + 1); } } } }); mPrevButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mPager.getCurrentItem() == 0) { setResult(RESULT_CANCELED); finish(); } else { mPager.setCurrentItem(mPager.getCurrentItem() - 1); } } }); onPageTreeChanged(); updateBottomBar(); }
From source file:ru.tinkoff.acquiring.sdk.PayFormActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent = getIntent();//from w w w . java 2 s .c o m int theme = intent.getIntExtra(EXTRA_THEME, 0); if (theme != 0) { setTheme(theme); } fragmentsCommunicator.onCreate(savedInstanceState); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.acq_activity); getSupportActionBar().setDisplayHomeAsUpEnabled(true); TypedValue tv = new TypedValue(); getTheme().resolveAttribute(R.attr.acqPayFormTitle, tv, true); String title = getResources().getString(tv.resourceId); setTitle(title); dialogsManager = new DialogsManager(this); String terminalKey = intent.getStringExtra(EXTRA_TERMINAL_KEY); String password = intent.getStringExtra(EXTRA_PASSWORD); String publicKey = intent.getStringExtra(EXTRA_PUBLIC_KEY); chargeMode = intent.getBooleanExtra(EXTRA_CHARGE_MODE, false); sdk = new AcquiringSdk(terminalKey, password, publicKey); cardManager = new CardManager(sdk); useCustomKeyboard = intent.getBooleanExtra(EXTRA_CUSTOM_KEYBOARD, false); if (savedInstanceState == null) { isCardsReady = false; if (intent.hasExtra(EXTRA_PAYMENT_INFO)) { showRejected(); } else if (intent.hasExtra(EXTRA_THREE_DS)) { showThreeDsData(); } else { startFinishAuthorized(); if (isCardChooseEnable()) { String customerKey = intent.getStringExtra(EXTRA_CUSTOMER_KEY); showProgressDialog(); requestCards(customerKey, cardManager); } } } else { cards = new CardsArrayBundlePacker().unpack(savedInstanceState.getBundle(INSTANCE_KEY_CARDS)); int idx = savedInstanceState.getInt(INSTANCE_KEY_CARD_INDEX, -1); if (idx != -1) { sourceCard = cards[idx]; } } }
From source file:tobiass.statedebt.Main.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ActionBarSherlock abs = getSherlock(); abs.setContentView(R.layout.main);// w ww . ja v a 2 s.c om // Making sure the ActionBar is created before accessing the Spinner // navigation-related stuff. setTheme(R.style.Theme_Sherlock_Light_DarkActionBar); setTitle(null); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); if (prefs.getInt("version", 3) != 4) { deleteFile(LoadCountries.countriesFile); } prefs.edit().putInt("version", 4).commit(); // Looking up all Views t = (TextView) findViewById(R.id.text); stats = (LinearLayout) findViewById(R.id.stats); text1 = (TextView) findViewById(R.id.text1); text2 = (TextView) findViewById(R.id.text2); text3 = (TextView) findViewById(R.id.text3); text4 = (TextView) findViewById(R.id.text4); text5 = (TextView) findViewById(R.id.text5); text6 = (TextView) findViewById(R.id.text6); loading = (ViewSwitcher) findViewById(R.id.root); adView = (AdView) findViewById(R.id.adview); adView.loadAd(adRequest); // If 'text1' doesn't exist in the current layout, the device is in // portrait mode portrait = text1 == null; cache = new ArrayList<Country>(); if (savedInstanceState != null) { if (savedInstanceState.containsKey("cache")) { // Before the activity is destroyed, the country cache is // bundled into savedInstanceState. Bundle b = savedInstanceState.getBundle("cache"); Iterator<String> i = b.keySet().iterator(); while (i.hasNext()) { Country c = new Country(b.getBundle(i.next())); cache.add(c); } } // Variable defines which country should get selected as soon as // preperation is done. isConverted = savedInstanceState.getBoolean("isConverted", false); initToCountry = savedInstanceState.getInt("country", -1); } // Cache is empty? We need to get a list of all countries. if (cache.size() == 0) { // Run the asynchronous process of getting a list of countries. LoadCountries lc = new LoadCountries(); lc.execute(); } else { // Fill the navigation Spinner with countries setupActionbar(); } }
From source file:com.waz.zclient.pages.main.conversation.LocationFragment.java
@Nullable @Override/*from ww w. j av a 2 s. com*/ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup viewGroup, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_location, viewGroup, false); toolbar = ViewUtils.getView(view, R.id.t_location_toolbar); toolbar.setNavigationOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (getActivity() == null) { return; } getControllerFactory().getLocationController().hideShareLocation(null); } }); if (LayoutSpec.isTablet(getContext())) { toolbar.setNavigationIcon(R.drawable.action_back_dark); } toolbarTitle = ViewUtils.getView(view, R.id.tv__location_toolbar__title); selectedLocationBackground = ViewUtils.getView(view, R.id.iv__selected_location__background); selectedLocationPin = ViewUtils.getView(view, R.id.gtv__selected_location__pin); selectedLocationDetails = ViewUtils.getView(view, R.id.ll_selected_location_details); selectedLocationDetails.setVisibility(View.INVISIBLE); touchRegisteringFrameLayout = ViewUtils.getView(view, R.id.trfl_location_touch_registerer); touchRegisteringFrameLayout.setTouchCallback(this); requestCurrentLocationButton = ViewUtils.getView(view, R.id.gtv__location__current__button); requestCurrentLocationButton.setOnClickListener(this); sendCurrentLocationButton = ViewUtils.getView(view, R.id.ttv__location_send_button); sendCurrentLocationButton.setOnClickListener(this); selectedLocationAddress = ViewUtils.getView(view, R.id.ttv__location_address); final Bundle mapViewSavedInstanceState = savedInstanceState != null ? savedInstanceState.getBundle(MAP_VIEW_SAVE_STATE) : null; mapView = ViewUtils.getView(view, R.id.mv_map); mapView.onCreate(mapViewSavedInstanceState); mapView.getMapAsync(this); return view; }
From source file:com.djkim.slap.group.EditGroupActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.create_group_layout); group = (Group) getIntent().getExtras().getSerializable(EDIT_GROUP_EXTRA); mWizardModel = createWizardModel(group); FacebookSdk.sdkInitialize(this.getApplicationContext()); callbackManager = CallbackManager.Factory.create(); createAppGroupDialog = new CreateAppGroupDialog(this); createAppGroupDialog.registerCallback(callbackManager, new FacebookCallback<CreateAppGroupDialog.Result>() { public void onSuccess(CreateAppGroupDialog.Result result) { String id = result.getId(); group.set_facebookGroupId(id); group.saveInBackground(new GroupCallback() { @Override/*ww w.j av a 2 s . c o m*/ public void done() { Toast.makeText(EditGroupActivity.this, "Successfully created the group!", Toast.LENGTH_SHORT).show(); Intent intent = new Intent(); intent.putExtra(EDIT_GROUP_EXTRA, group); setResult(RESULT_OK, intent); finish(); } }); } public void onCancel() { group.saveInBackground(new GroupCallback() { @Override public void done() { Toast.makeText(EditGroupActivity.this, "Failed to create the group!", Toast.LENGTH_SHORT) .show(); Intent intent = new Intent(); intent.putExtra(EDIT_GROUP_EXTRA, group); setResult(RESULT_OK, intent); finish(); } }); } public void onError(FacebookException error) { } }); if (savedInstanceState != null) { mWizardModel.load(savedInstanceState.getBundle("model")); } mWizardModel.registerListener(this); mPagerAdapter = new MyPagerAdapter(getSupportFragmentManager()); mPager = (ViewPager) findViewById(R.id.pager); mPager.setAdapter(mPagerAdapter); mStepPagerStrip = (StepPagerStrip) findViewById(R.id.strip); mStepPagerStrip.setOnPageSelectedListener(new StepPagerStrip.OnPageSelectedListener() { @Override public void onPageStripSelected(int position) { position = Math.min(mPagerAdapter.getCount() - 1, position); if (mPager.getCurrentItem() != position) { mPager.setCurrentItem(position); } } }); mNextButton = (Button) findViewById(R.id.next_button); mPrevButton = (Button) findViewById(R.id.prev_button); mPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { mStepPagerStrip.setCurrentPage(position); if (mConsumePageSelectedEvent) { mConsumePageSelectedEvent = false; return; } mEditingAfterReview = false; updateBottomBar(); } }); mNextButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mPager.getCurrentItem() == mCurrentPageSequence.size()) { DialogFragment dg = new DialogFragment() { @Override public Dialog onCreateDialog(Bundle savedInstanceState) { return new AlertDialog.Builder(getActivity()) .setMessage(R.string.submit_confirm_message) .setPositiveButton(R.string.submit_confirm_button, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { createGroup(); if (group.get_facebookGroupId() == null) { onClickCreateButton(); } else { group.saveInBackground(new GroupCallback() { @Override public void done() { Intent intent = new Intent(); intent.putExtra(EDIT_GROUP_EXTRA, group); setResult(RESULT_OK, intent); finish(); } }); } } }) .setNegativeButton(android.R.string.cancel, null).create(); } }; dg.show(getSupportFragmentManager(), "place_order_dialog"); } else { if (mEditingAfterReview) { mPager.setCurrentItem(mPagerAdapter.getCount() - 1); } else { mPager.setCurrentItem(mPager.getCurrentItem() + 1); } } } }); mPrevButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { if (mPager.getCurrentItem() == 0) { setResult(RESULT_CANCELED); finish(); } else { mPager.setCurrentItem(mPager.getCurrentItem() - 1); } } }); onPageTreeChanged(); updateBottomBar(); }