List of usage examples for android.app FragmentManager findFragmentById
public abstract Fragment findFragmentById(int id);
From source file:com.sdspikes.fireworks.FireworksActivity.java
private void displayInitialState() { switchToScreen(R.id.screen_game);/*from w ww .j a v a 2 s. c o m*/ GameState.HandNode currentNode = mTurnData.state.hands.get(mMyId); FragmentManager fm = getFragmentManager(); fragments = new HashMap<>(); if (fm.findFragmentById(R.id.my_hand) == null) { if (currentNode != null) { addHandFragment(fm, currentNode, mMyId, mIdToName.get(mMyId), R.id.my_hand); } else { Log.d(TAG, mMyId); } } if (fm.findFragmentById(R.id.other_hands) == null) { while (true) { String currentId = currentNode.nextPlayerId; if (currentId.equals(mMyId)) { break; } currentNode = mTurnData.state.hands.get(currentId); addHandFragment(fm, currentNode, currentId, mIdToName.get(currentId), R.id.other_hands); } } LinearLayout played = (LinearLayout) findViewById(R.id.played_pile); played.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { LinearLayout played = (LinearLayout) findViewById(R.id.played_pile); mDiscardWidthR2 = played.getMeasuredWidth(); if (mDiscardWidthR2 != 0) { int usableWidth = mDiscardWidthR2 - findViewById(R.id.played_label).getMeasuredWidth(); mDiscardWidthR1 = mDiscardWidthR2 - findViewById(R.id.discarded_label).getMeasuredWidth(); for (int i = 1; i < played.getChildCount(); i++) { ViewGroup.LayoutParams params = played.getChildAt(i).getLayoutParams(); params.width = usableWidth / 5; played.getChildAt(i).setLayoutParams(params); } played.getViewTreeObserver().removeOnGlobalLayoutListener(this); LinearLayout chooseAttribute = (LinearLayout) findViewById(R.id.chooseAttribute); for (int i = 1; i <= 5; i++) { chooseAttribute.addView(makeAttributeTextView(i, null)); } for (GameState.CardColor color : GameState.CardColor.values()) { chooseAttribute.addView(makeAttributeTextView(-1, color)); } // In case all the data is ready already and was just waiting on this. updateDisplay(); } } }); createInitialLog(); ((TextView) findViewById(R.id.log)).setMovementMethod(new ScrollingMovementMethod()); }
From source file:com.google.samples.apps.iosched.ui.BaseActivity.java
private void setUpPresenter(PresenterFragmentImpl presenter, FragmentManager fragmentManager, int updatableViewResId, Model model, QueryEnum[] queries, UserActionEnum[] actions) { UpdatableView ui = (UpdatableView) fragmentManager.findFragmentById(updatableViewResId); presenter.setModel(model);/*from w w w . j a va2s . c om*/ presenter.setUpdatableView(ui); presenter.setInitialQueriesToLoad(queries); presenter.setValidUserActions(actions); }
From source file:android.support.v17.leanback.app.BrowseFragment.java
private void swapToMainFragment() { final VerticalGridView gridView = mHeadersFragment.getVerticalGridView(); if (isShowingHeaders() && gridView != null && gridView.getScrollState() != RecyclerView.SCROLL_STATE_IDLE) { // if user is scrolling HeadersFragment, swap to empty fragment and wait scrolling // finishes. getChildFragmentManager().beginTransaction().replace(R.id.scale_frame, new Fragment()).commit(); gridView.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override/* w w w . j a va 2 s .c o m*/ public void onScrollStateChanged(RecyclerView recyclerView, int newState) { if (newState == RecyclerView.SCROLL_STATE_IDLE) { gridView.removeOnScrollListener(this); FragmentManager fm = getChildFragmentManager(); Fragment currentFragment = fm.findFragmentById(R.id.scale_frame); if (currentFragment != mMainFragment) { fm.beginTransaction().replace(R.id.scale_frame, mMainFragment).commit(); } } } }); } else { // Otherwise swap immediately getChildFragmentManager().beginTransaction().replace(R.id.scale_frame, mMainFragment).commit(); } }
From source file:edu.oakland.festinfo.activities.MapPageActivity.java
@AfterViews void init() {/*from www. j a v a 2 s . c om*/ setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setTitle("Map"); colorUpArrow(); mapKeySpinner = (Spinner) findViewById(R.id.mapkey_spinner); mapKeySpinner.setAdapter(new MyAdapter(MapPageActivity.this, R.layout.row, strings)); ParseInstallation.getCurrentInstallation().saveInBackground(); FragmentManager fragmentManager = getFragmentManager(); mapFragment = (MapFragment) fragmentManager.findFragmentById(R.id.map); map = mapFragment.getMap(); map.setMyLocationEnabled(true); map.setMapType(GoogleMap.MAP_TYPE_HYBRID); map.setOnMapClickListener(this); map.setOnMapLongClickListener(this); map.setOnMarkerDragListener(this); map.setOnInfoWindowClickListener(new OnInfoWindowClickListener() { @Override public void onInfoWindowClick(final Marker marker) { //tvLocInfo.setText("Info Window Selected"); if (marker.getTitle().equals("Ranch Area") || marker.getTitle().equals("Sherwood Court") || marker.getTitle().equals("Tripolee") || marker.getTitle().equals("The Observatory") || marker.getTitle().equals("The Hangar") || marker.getTitle().equals("Jubilee") || marker.getTitle().equals("Forest Stage")) { AlertDialog.Builder infowindowBuilderGeofence = new AlertDialog.Builder(MapPageActivity.this); infowindowBuilderGeofence.setTitle(R.string.infowindow_geofence_click_options).setItems( R.array.infowindow_geofence_choices_array, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: //tvLocInfo.setText("Favorite Stage Selected"); ParseInstallation installationFavorite = ParseInstallation .getCurrentInstallation(); ParsePush push = new ParsePush(); if (marker.getTitle().equals("Ranch Area")) { installationFavorite.put("RanchAreaFavorited", true); push.subscribeInBackground("RanchArea"); installationFavorite.saveInBackground(); } else if (marker.getTitle().equals("Sherwood Court")) { installationFavorite.put("SherwoodCourtFavorited", true); push.subscribeInBackground("SherwoodCourt"); installationFavorite.saveInBackground(); } else if (marker.getTitle().equals("Tripolee")) { installationFavorite.put("TripoleeFavorited", true); push.subscribeInBackground("Tripolee"); installationFavorite.saveInBackground(); } else if (marker.getTitle().equals("The Hangar")) { installationFavorite.put("TheHangarFavorited", true); push.subscribeInBackground("TheHanagar"); installationFavorite.saveInBackground(); } else if (marker.getTitle().equals("Jubilee")) { installationFavorite.put("JubileeFavorited", true); push.subscribeInBackground("Jubilee"); installationFavorite.saveInBackground(); } else if (marker.getTitle().equals("Forest Stage")) { installationFavorite.put("ForestStageFavorited", true); push.subscribeInBackground("ForestStage"); installationFavorite.saveInBackground(); } else if (marker.getTitle().equals("The Observatory")) { installationFavorite.put("TheObservatoryFavorited", true); push.subscribeInBackground("TheObservatory"); installationFavorite.saveInBackground(); } break; case 1: //tvLocInfo.setText("Unfavorite Stage Selected"); ParseInstallation installationUnfavorite = ParseInstallation .getCurrentInstallation(); ParsePush pushRemove = new ParsePush(); if (marker.getTitle().equals("Ranch Area")) { installationUnfavorite.put("RanchAreaFavorited", false); pushRemove.unsubscribeInBackground("RanchArea"); installationUnfavorite.saveInBackground(); } else if (marker.getTitle().equals("Sherwood Court")) { installationUnfavorite.put("SherwoodCourtFavorited", false); pushRemove.unsubscribeInBackground("SherwoodCourt"); installationUnfavorite.saveInBackground(); } else if (marker.getTitle().equals("Tripolee")) { installationUnfavorite.put("TripoleeFavorited", false); pushRemove.unsubscribeInBackground("Tripolee"); installationUnfavorite.saveInBackground(); } else if (marker.getTitle().equals("The Hangar")) { installationUnfavorite.put("TheHangar", false); pushRemove.unsubscribeInBackground("TheHanagar"); installationUnfavorite.saveInBackground(); } else if (marker.getTitle().equals("Jubilee")) { installationUnfavorite.put("JubileeFavorited", false); pushRemove.unsubscribeInBackground("Jubilee"); installationUnfavorite.saveInBackground(); } else if (marker.getTitle().equals("Forest Stage")) { installationUnfavorite.put("ForestStageFavorited", false); pushRemove.unsubscribeInBackground("ForestStage"); installationUnfavorite.saveInBackground(); } else if (marker.getTitle().equals("The Observatory")) { installationUnfavorite.put("TheObservatoryFavorited", false); pushRemove.unsubscribeInBackground("TheObservatory"); installationUnfavorite.saveInBackground(); } break; } } } ); infowindowBuilderGeofence.show(); } else { AlertDialog.Builder infowindowBuilderNoGeofence = new AlertDialog.Builder(MapPageActivity.this); infowindowBuilderNoGeofence.setTitle(R.string.infowindow_nogeofence_click_options).setItems( R.array.infowindow_nogeofence_choices_array, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case 0: AlertDialog.Builder deleteConfirmation = new AlertDialog.Builder( MapPageActivity.this); deleteConfirmation.setTitle("Warning"); deleteConfirmation .setMessage("Are you sure you want to delete this marker?"); deleteConfirmation.setPositiveButton("Yes", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { ParseGeoPoint geoPoint = new ParseGeoPoint( marker.getPosition().latitude, marker.getPosition().longitude); currentMarkerTitle = marker.getTitle(); ParseQuery<ParseObject> query = ParseQuery .getQuery("MapMarkers"); query.whereEqualTo("Title", currentMarkerTitle); query.getFirstInBackground(new GetCallback<ParseObject>() { @Override public void done(ParseObject object, ParseException e) { try { for (int i = 0; i < combinedArray.size(); i++) { if (combinedArray.get(i).getIdentification() .equals(object .getString("GeofenceID"))) { combinedArray.get(i).getCircle() .setRadius(0); combinedArray.get(i).getCircle() .remove(); combinedArray.get(i).getMarker() .remove(); combinedArray.remove(i); object.delete(); } } } catch (ParseException e1) { e1.printStackTrace(); } object.saveInBackground(); } }); } }); deleteConfirmation.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); deleteConfirmation.show(); break; case 1: //tvLocInfo.setText("Change title selected"); AlertDialog.Builder changeTitleInput = new AlertDialog.Builder( MapPageActivity.this); changeTitleInput.setTitle("Enter new Title: "); final EditText changeInput = new EditText(MapPageActivity.this); changeInput.setInputType(InputType.TYPE_CLASS_TEXT); changeTitleInput.setView(changeInput); changeTitleInput.setPositiveButton("Ok", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (changeInput.getText().toString().matches("")) { Toast.makeText(getApplicationContext(), "No Input Entered!", Toast.LENGTH_SHORT).show(); } else { ParseQuery<ParseObject> query = ParseQuery .getQuery("MapMarkers"); query.findInBackground(new FindCallback<ParseObject>() { @Override public void done(List<ParseObject> objects, ParseException e) { if (e == null) { for (int i = 0; i < objects.size(); i++) { if (objects.get(i).getString("Title") .equals(marker.getTitle())) { objects.get(i) .put("Title", changeInput .getText() .toString()); objects.get(i).saveInBackground(); } } } else { Toast.makeText(getApplicationContext(), "Error!", Toast.LENGTH_SHORT) .show(); } } }); for (int i = 0; i < combinedArray.size(); i++) { if (combinedArray.get(i).getIdentification() .equals(marker.getId())) { combinedArray.get(i).getMarker().setTitle( changeInput.getText().toString()); } } } } }); changeTitleInput.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.cancel(); } }); changeTitleInput.show(); break; } } } ); infowindowBuilderNoGeofence.show(); } } }); focusCamera(); buildGoogleApiClient(); }
From source file:com.android.calendar.AllInOneActivity.java
private void setMainPane(FragmentTransaction ft, int viewId, int viewType, long timeMillis, boolean force) { if (mOnSaveInstanceStateCalled) { return;/*from www .j av a 2s.c o m*/ } if (!force && mCurrentView == viewType) { return; } // Remove this when transition to and from month view looks fine. boolean doTransition = viewType != ViewType.MONTH && mCurrentView != ViewType.MONTH; FragmentManager fragmentManager = getFragmentManager(); // Check if our previous view was an Agenda view // TODO remove this if framework ever supports nested fragments if (mCurrentView == ViewType.AGENDA) { // If it was, we need to do some cleanup on it to prevent the // edit/delete buttons from coming back on a rotation. Fragment oldFrag = fragmentManager.findFragmentById(viewId); if (oldFrag instanceof AgendaFragment) { ((AgendaFragment) oldFrag).removeFragments(fragmentManager); } } if (viewType != mCurrentView) { // The rules for this previous view are different than the // controller's and are used for intercepting the back button. if (mCurrentView != ViewType.EDIT && mCurrentView > 0) { mPreviousView = mCurrentView; } mCurrentView = viewType; } // Create new fragment Fragment frag = null; Fragment secFrag = null; switch (viewType) { case ViewType.AGENDA: mNavigationView.getMenu().findItem(R.id.agenda_menu_item).setChecked(true); frag = new AgendaFragment(timeMillis, false); if (mIsTabletConfig) { mToolbar.setTitle(R.string.agenda_view); } break; case ViewType.DAY: mNavigationView.getMenu().findItem(R.id.day_menu_item).setChecked(true); frag = new DayFragment(timeMillis, 1); if (mIsTabletConfig) { mToolbar.setTitle(R.string.day_view); } break; case ViewType.MONTH: mNavigationView.getMenu().findItem(R.id.month_menu_item).setChecked(true); frag = new MonthByWeekFragment(timeMillis, false); if (mShowAgendaWithMonth) { secFrag = new AgendaFragment(timeMillis, false); } if (mIsTabletConfig) { mToolbar.setTitle(R.string.month_view); } break; case ViewType.WEEK: default: mNavigationView.getMenu().findItem(R.id.week_menu_item).setChecked(true); frag = new DayFragment(timeMillis, Utils.getDaysPerWeek(this)); if (mIsTabletConfig) { mToolbar.setTitle(R.string.week_view); } break; } // Update the current view so that the menu can update its look according to the // current view. if (mCalendarToolbarHandler != null) { mCalendarToolbarHandler.setCurrentMainView(viewType); } if (!mIsTabletConfig) { refreshActionbarTitle(timeMillis); } // Show date only on tablet configurations in views different than Agenda if (!mIsTabletConfig) { mDateRange.setVisibility(View.GONE); } else if (viewType != ViewType.AGENDA) { mDateRange.setVisibility(View.VISIBLE); } else { mDateRange.setVisibility(View.GONE); } // Clear unnecessary buttons from the option menu when switching from the agenda view if (viewType != ViewType.AGENDA) { clearOptionsMenu(); } boolean doCommit = false; if (ft == null) { doCommit = true; ft = fragmentManager.beginTransaction(); } if (doTransition) { ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); } ft.replace(viewId, frag); if (mShowAgendaWithMonth) { // Show/hide secondary fragment if (secFrag != null) { ft.replace(R.id.secondary_pane, secFrag); mSecondaryPane.setVisibility(View.VISIBLE); } else { mSecondaryPane.setVisibility(View.GONE); Fragment f = fragmentManager.findFragmentById(R.id.secondary_pane); if (f != null) { ft.remove(f); } mController.deregisterEventHandler(R.id.secondary_pane); } } if (DEBUG) { Log.d(TAG, "Adding handler with viewId " + viewId + " and type " + viewType); } // If the key is already registered this will replace it mController.registerEventHandler(viewId, (EventHandler) frag); if (secFrag != null) { mController.registerEventHandler(viewId, (EventHandler) secFrag); } if (doCommit) { if (DEBUG) { Log.d(TAG, "setMainPane AllInOne=" + this + " finishing:" + this.isFinishing()); } ft.commit(); } }
From source file:org.opendatakit.survey.android.activities.MainMenuActivity.java
public void swapToFragmentView(ScreenList newFragment) { WebLogger.getLogger(getAppName()).i(t, "swapToFragmentView: " + newFragment.toString()); FragmentManager mgr = getFragmentManager(); Fragment f;// www .ja v a2s . c om if (newFragment == ScreenList.MAIN_SCREEN) { throw new IllegalStateException("unexpected reference to generic main screen"); } else if (newFragment == ScreenList.CUSTOM_VIEW) { WebLogger.getLogger(getAppName()).w(t, "swapToFragmentView: changing navigation to move to WebKit (was custom view)"); f = mgr.findFragmentById(WebViewFragment.ID); if (f == null) { f = new WebViewFragment(); } newFragment = ScreenList.WEBKIT; } else if (newFragment == ScreenList.FORM_CHOOSER) { f = mgr.findFragmentById(FormChooserListFragment.ID); if (f == null) { f = new FormChooserListFragment(); } } else if (newFragment == ScreenList.INITIALIZATION_DIALOG) { if (currentFragment == ScreenList.INITIALIZATION_DIALOG) { WebLogger.getLogger(getAppName()).e(t, "Unexpected: currentFragment == INITIALIZATION_DIALOG"); return; } else { f = mgr.findFragmentById(InitializationFragment.ID); if (f == null) { f = new InitializationFragment(); } ((InitializationFragment) f).setFragmentToShowNext( (currentFragment == null) ? ScreenList.FORM_CHOOSER.name() : currentFragment.name()); } } else if (newFragment == ScreenList.FORM_DELETER) { f = mgr.findFragmentById(FormDeleteListFragment.ID); if (f == null) { f = new FormDeleteListFragment(); } } else if (newFragment == ScreenList.FORM_DOWNLOADER) { f = mgr.findFragmentById(FormDownloadListFragment.ID); if (f == null) { f = new FormDownloadListFragment(); } } else if (newFragment == ScreenList.INSTANCE_UPLOADER_TABLE_CHOOSER) { f = mgr.findFragmentById(InstanceUploaderTableChooserListFragment.ID); if (f == null) { f = new InstanceUploaderTableChooserListFragment(); } } else if (newFragment == ScreenList.INSTANCE_UPLOADER) { f = mgr.findFragmentById(InstanceUploaderListFragment.ID); if (f == null) { f = new InstanceUploaderListFragment(); } ((InstanceUploaderListFragment) f).changeUploadTableId(); } else if (newFragment == ScreenList.WEBKIT) { f = mgr.findFragmentById(WebViewFragment.ID); if (f == null) { f = new WebViewFragment(); } } else if (newFragment == ScreenList.ABOUT_MENU) { f = mgr.findFragmentById(AboutMenuFragment.ID); if (f == null) { f = new AboutMenuFragment(); } } else { throw new IllegalStateException("Unrecognized ScreenList type"); } FrameLayout shadow = (FrameLayout) findViewById(R.id.shadow_content); View frags = findViewById(R.id.main_content); View wkt = findViewById(R.id.webkit_view); shadow.setVisibility(View.GONE); shadow.removeAllViews(); if (newFragment == ScreenList.WEBKIT) { frags.setVisibility(View.GONE); wkt.setVisibility(View.VISIBLE); wkt.invalidate(); } else { wkt.setVisibility(View.GONE); frags.setVisibility(View.VISIBLE); } currentFragment = newFragment; BackStackEntry entry = null; for (int i = 0; i < mgr.getBackStackEntryCount(); ++i) { BackStackEntry e = mgr.getBackStackEntryAt(i); if (e.getName().equals(currentFragment.name())) { entry = e; break; } } if (entry != null) { // flush backward, including the screen want to go back to mgr.popBackStackImmediate(currentFragment.name(), FragmentManager.POP_BACK_STACK_INCLUSIVE); } // add transaction to show the screen we want FragmentTransaction trans = mgr.beginTransaction(); trans.replace(R.id.main_content, f); trans.addToBackStack(currentFragment.name()); trans.commit(); // and see if we should re-initialize... if ((currentFragment != ScreenList.INITIALIZATION_DIALOG) && Survey.getInstance().shouldRunInitializationTask(getAppName())) { WebLogger.getLogger(getAppName()).i(t, "swapToFragmentView -- calling clearRunInitializationTask"); // and immediately clear the should-run flag... Survey.getInstance().clearRunInitializationTask(getAppName()); // OK we should swap to the InitializationFragment view swapToFragmentView(ScreenList.INITIALIZATION_DIALOG); } else { levelSafeInvalidateOptionsMenu(); } }
From source file:org.path.episample.android.activities.MainMenuActivity.java
public void swapToFragmentView(ScreenList newFragment) { WebLogger.getLogger(getAppName()).i(t, "swapToFragmentView: " + newFragment.toString()); String get = PropertiesSingleton.getProperty("survey", AdminPreferencesActivity.KEY_TURN_ON_OFF_WIFI_AUTOMATICALLY); if (!(get != null && get.equalsIgnoreCase("false"))) { if (mWifiManager.isWifiEnabled() && mWifiManager.getWifiState() != WifiManager.WIFI_STATE_DISABLED) { mWifiManager.setWifiEnabled(false); }/*from w w w . j a va 2 s . c om*/ } FragmentManager mgr = getFragmentManager(); Fragment f; if (newFragment == ScreenList.MAIN_SCREEN) { throw new IllegalStateException("unexpected reference to generic main screen"); } else if (newFragment == ScreenList.CUSTOM_VIEW) { WebLogger.getLogger(getAppName()).w(t, "swapToFragmentView: changing navigation to move to WebKit (was custom view)"); f = mgr.findFragmentById(WebViewFragment.ID); if (f == null) { f = new WebViewFragment(); } newFragment = ScreenList.WEBKIT; } else if (newFragment == ScreenList.MAIN_MENU) { f = mgr.findFragmentById(MainMenuFragment.ID); if (f == null) { f = new MainMenuFragment(); } } else if (newFragment == ScreenList.COLLECT_MODULE) { f = mgr.findFragmentById(CollectFragment.ID); if (f == null) { f = new CollectFragment(); } } else if (newFragment == ScreenList.SEND_RECEIVE_WIFI_DIRECT_MODULE) { f = mgr.findFragmentById(SendReceiveFragment.ID); if (f == null) { f = new SendReceiveFragment(); } } /*else if (newFragment == ScreenList.SEND_RECEIVE_BLUETOOTH_MODULE) { f = mgr.findFragmentById(SendReceiveFragmentBT.ID); if (f == null) { f = new SendReceiveFragmentBT(); } }*/ else if (newFragment == ScreenList.SELECT_MODULE) { f = mgr.findFragmentById(SelectFragment.ID); if (f == null) { f = new SelectFragment(); } } else if (newFragment == ScreenList.NAVIGATE_MODULE) { f = mgr.findFragmentById(NavigateFragment.ID); if (f == null) { f = new NavigateFragment(); } } else if (newFragment == ScreenList.RESTORE_MODULE) { f = mgr.findFragmentById(RestoreFragment.ID); if (f == null) { f = new RestoreFragment(); } } else if (newFragment == ScreenList.EDIT_CENSUS_MODULE) { f = mgr.findFragmentById(EditCensusFragment.ID); if (f == null) { f = new EditCensusFragment(); } } else if (newFragment == ScreenList.REMOVE_CENSUS_MODULE) { f = mgr.findFragmentById(RemoveCensusFragment.ID); if (f == null) { f = new RemoveCensusFragment(); } } else if (newFragment == ScreenList.INVALIDATE_CENSUS_MODULE) { f = mgr.findFragmentById(InvalidateCensusFragment.ID); if (f == null) { f = new InvalidateCensusFragment(); } } else if (newFragment == ScreenList.FORM_CHOOSER) { f = mgr.findFragmentById(FormChooserListFragment.ID); if (f == null) { f = new FormChooserListFragment(); } } else if (newFragment == ScreenList.INITIALIZATION_DIALOG) { if (currentFragment == ScreenList.INITIALIZATION_DIALOG) { WebLogger.getLogger(getAppName()).e(t, "Unexpected: currentFragment == INITIALIZATION_DIALOG"); return; } else { f = mgr.findFragmentById(InitializationFragment.ID); if (f == null) { f = new InitializationFragment(); } ((InitializationFragment) f).setFragmentToShowNext( (currentFragment == null) ? ScreenList.FORM_CHOOSER.name() : currentFragment.name()); } } else if (newFragment == ScreenList.FORM_DELETER) { f = mgr.findFragmentById(FormDeleteListFragment.ID); if (f == null) { f = new FormDeleteListFragment(); } } else if (newFragment == ScreenList.FORM_DOWNLOADER) { f = mgr.findFragmentById(FormDownloadListFragment.ID); if (f == null) { f = new FormDownloadListFragment(); } } else if (newFragment == ScreenList.INSTANCE_UPLOADER_TABLE_CHOOSER) { f = mgr.findFragmentById(InstanceUploaderTableChooserListFragment.ID); if (f == null) { f = new InstanceUploaderTableChooserListFragment(); } } else if (newFragment == ScreenList.INSTANCE_UPLOADER) { f = mgr.findFragmentById(InstanceUploaderListFragment.ID); if (f == null) { f = new InstanceUploaderListFragment(); } ((InstanceUploaderListFragment) f).changeUploadTableId(); } else if (newFragment == ScreenList.WEBKIT) { f = mgr.findFragmentById(WebViewFragment.ID); if (f == null) { f = new WebViewFragment(); } } else if (newFragment == ScreenList.ABOUT_MENU) { f = mgr.findFragmentById(AboutMenuFragment.ID); if (f == null) { f = new AboutMenuFragment(); } } else { throw new IllegalStateException("Unrecognized ScreenList type"); } FrameLayout shadow = (FrameLayout) findViewById(R.id.shadow_content); View frags = findViewById(R.id.main_content); View wkt = findViewById(R.id.webkit_view); shadow.setVisibility(View.GONE); shadow.removeAllViews(); if (newFragment == ScreenList.WEBKIT) { frags.setVisibility(View.GONE); wkt.setVisibility(View.VISIBLE); wkt.invalidate(); } else { wkt.setVisibility(View.GONE); frags.setVisibility(View.VISIBLE); } currentFragment = newFragment; BackStackEntry entry = null; for (int i = 0; i < mgr.getBackStackEntryCount(); ++i) { BackStackEntry e = mgr.getBackStackEntryAt(i); if (e.getName().equals(currentFragment.name())) { entry = e; break; } } if (entry != null) { // flush backward, including the screen want to go back to mgr.popBackStackImmediate(currentFragment.name(), FragmentManager.POP_BACK_STACK_INCLUSIVE); } // add transaction to show the screen we want FragmentTransaction trans = mgr.beginTransaction(); trans.replace(R.id.main_content, f); trans.addToBackStack(currentFragment.name()); trans.commit(); // and see if we should re-initialize... if ((currentFragment != ScreenList.INITIALIZATION_DIALOG) && Survey.getInstance().shouldRunInitializationTask(getAppName())) { WebLogger.getLogger(getAppName()).i(t, "swapToFragmentView -- calling clearRunInitializationTask"); // and immediately clear the should-run flag... Survey.getInstance().clearRunInitializationTask(getAppName()); // OK we should swap to the InitializationFragment view swapToFragmentView(ScreenList.INITIALIZATION_DIALOG); } else { levelSafeInvalidateOptionsMenu(); } }
From source file:com.lgallardo.youtorrentcontroller.RefreshListener.java
@Override public void onResume() { super.onResume(); activityIsVisible = true;// www .j a v a2 s . co m // Handle Item list empty due to Fragment stack try { FragmentManager fm = getFragmentManager(); FragmentTransaction fragmentTransaction = fm.beginTransaction(); if (fm.getBackStackEntryCount() == 0 && firstFragment.getSecondFragmentContainer() == R.id.one_frame && fm.findFragmentById( R.id.one_frame) instanceof com.lgallardo.youtorrentcontroller.ItemstFragment) { com.lgallardo.youtorrentcontroller.ItemstFragment fragment = (com.lgallardo.youtorrentcontroller.ItemstFragment) fm .findFragmentById(R.id.one_frame); if (fragment.getListView().getCount() == 0) { // Create the about fragment aboutFragment = new AboutFragment(); fragmentTransaction.replace(R.id.one_frame, aboutFragment, "firstFragment"); fragmentTransaction.commit(); // Se titile // setTitle(navigationDrawerItemTitles[drawerList.getCheckedItemPosition()]); setTitle(navigationDrawerItemTitles[DrawerItemRecyclerViewAdapter.actionPosition]); // Close Contextual Action Bar if (firstFragment != null && firstFragment.mActionMode != null) { firstFragment.mActionMode.finish(); } // Refresh current list refreshCurrent(); } } if (fm.getBackStackEntryCount() == 0 && firstFragment.getSecondFragmentContainer() == R.id.content_frame && (fm.findFragmentByTag("secondFragment") instanceof AboutFragment)) { // Create the about fragment aboutFragment = new AboutFragment(); fragmentTransaction.replace(R.id.content_frame, aboutFragment, "secondFragment"); fragmentTransaction.commit(); // Set title setTitle(navigationDrawerItemTitles[DrawerItemRecyclerViewAdapter.actionPosition]); // Close Contextual Action Bar if (firstFragment != null && firstFragment.mActionMode != null) { firstFragment.mActionMode.finish(); } // Refresh current list refreshCurrent(); } } catch (Exception e) { } }
From source file:com.xplink.android.carchecklist.CarCheckListActivity.java
public void menuToggle(int motionin, int motionout, int fragment) { /*//from ww w .jav a 2s . c o m * final Dialog settingdialog = new Dialog(CarCheckListActivity.this, * R.style.backgrounddialog); settingdialog.dismiss(); */ new Dialog(CarCheckListActivity.this, R.style.backgrounddialog).dismiss(); headsetting.setVisibility(ImageView.VISIBLE); TranslateAnimation slideoutheadsetting = new TranslateAnimation(0, 0, 0, -468); slideoutheadsetting.setDuration(500); slideoutheadsetting.setFillAfter(true); headsetting.startAnimation(slideoutheadsetting); int prefer = getSharedPreferences("mysettings", MODE_PRIVATE).getInt("already", 1); if (prefer == 1) { getSharedPreferences("mysettings", MODE_PRIVATE).edit().putInt("already", 0).commit(); FragmentTransaction ft = getFragmentManager().beginTransaction().setCustomAnimations(motionin, motionout); FragmentManager fm = getFragmentManager(); Fragment fmTarget = fm.findFragmentById(fragment); ft.show(fmTarget); ft.commit(); } else { getSharedPreferences("mysettings", MODE_PRIVATE).edit().putInt("already", 1).commit(); FragmentTransaction ft = getFragmentManager().beginTransaction().setCustomAnimations(motionin, motionout); FragmentManager fm = getFragmentManager(); final Fragment fmTarget = fm.findFragmentById(fragment); ft.hide(fmTarget); ft.commit(); } }
From source file:com.lgallardo.qbittorrentclient.RefreshListener.java
@Override public void onResume() { super.onResume(); activityIsVisible = true;//from w ww. j a v a 2s . com // Handle Item list empty due to Fragment stack try { FragmentManager fm = getFragmentManager(); FragmentTransaction fragmentTransaction = fm.beginTransaction(); if (fm.getBackStackEntryCount() == 0 && firstFragment.getSecondFragmentContainer() == R.id.one_frame && fm.findFragmentById( R.id.one_frame) instanceof com.lgallardo.qbittorrentclient.ItemstFragment) { com.lgallardo.qbittorrentclient.ItemstFragment fragment = (com.lgallardo.qbittorrentclient.ItemstFragment) fm .findFragmentById(R.id.one_frame); if (fragment.getListView().getCount() == 0) { // Create the about fragment aboutFragment = new AboutFragment(); fragmentTransaction.replace(R.id.one_frame, aboutFragment, "firstFragment"); fragmentTransaction.commit(); // Se title // setTitle(navigationDrawerItemTitles[drawerList.getCheckedItemPosition()]); // setTitle(navigationDrawerItemTitles[DrawerItemRecyclerViewAdapter.actionPosition]); setSelectionAndTitle(lastState); // Close Contextual Action Bar if (firstFragment != null && firstFragment.mActionMode != null) { firstFragment.mActionMode.finish(); } // Refresh current list refreshCurrent(); } } if (fm.getBackStackEntryCount() == 0 && firstFragment.getSecondFragmentContainer() == R.id.content_frame && (fm.findFragmentByTag("secondFragment") instanceof AboutFragment)) { // Create the about fragment aboutFragment = new AboutFragment(); fragmentTransaction.replace(R.id.content_frame, aboutFragment, "secondFragment"); fragmentTransaction.commit(); // Se title // setTitle(navigationDrawerItemTitles[drawerList.getCheckedItemPosition()]); // setTitle(navigationDrawerItemTitles[DrawerItemRecyclerViewAdapter.actionPosition]); setSelectionAndTitle(lastState); // Close Contextual Action Bar if (firstFragment != null && firstFragment.mActionMode != null) { firstFragment.mActionMode.finish(); } // Refresh current list refreshCurrent(); } } catch (Exception e) { } }