List of usage examples for android.support.v4.app FragmentManager findFragmentByTag
public abstract Fragment findFragmentByTag(String tag);
From source file:com.nextgis.ngm_clink_monitoring.fragments.ObjectTypesFragment.java
public void onButtonClick(int foclStructLayerType) { final FragmentManager fm = getActivity().getSupportFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); CreateObjectFragment createObjectFragment = (CreateObjectFragment) fm .findFragmentByTag(FoclConstants.FRAGMENT_CREATE_OBJECT); if (createObjectFragment == null) { createObjectFragment = new CreateObjectFragment(); }/* ww w . j av a 2s. c o m*/ createObjectFragment.setParams(mLineRemoteId, foclStructLayerType); ft.replace(R.id.main_fragment, createObjectFragment, FoclConstants.FRAGMENT_CREATE_OBJECT); ft.addToBackStack(null); ft.commit(); // TODO: for layer editing // final FragmentManager fm = getActivity().getSupportFragmentManager(); // FragmentTransaction ft = fm.beginTransaction(); // // ObjectListFragment objectListFragment = // (ObjectListFragment) fm.findFragmentByTag(FoclConstants.FRAGMENT_OBJECT_LIST); // // if (objectListFragment == null) { // objectListFragment = new ObjectListFragment(); // } // // objectListFragment.setParams(mLineRemoteId, foclStructLayerType); // // ft.replace(R.id.main_fragment, objectListFragment, FoclConstants.FRAGMENT_OBJECT_LIST); // ft.addToBackStack(null); // ft.commit(); }
From source file:com.app.blockydemo.ui.fragment.FormulaEditorScriptListFragment.java
public void showFragment(Context context) { FragmentActivity activity = (FragmentActivity) context; FragmentManager fragmentManager = activity.getSupportFragmentManager(); FragmentTransaction fragTransaction = fragmentManager.beginTransaction(); Fragment formulaEditorFragment = fragmentManager .findFragmentByTag(FormulaEditorFragment.FORMULA_EDITOR_FRAGMENT_TAG); fragTransaction.hide(formulaEditorFragment); BottomBar.showBottomBar(activity);/*from w ww .j av a2s . c om*/ BottomBar.hidePlayButton(activity); fragTransaction.show(this); fragTransaction.commit(); if (adapter != null) { initializeScriptAdapter(); } }
From source file:biz.easymenu.easymenung.EasymenuNGActivity.java
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.main);//from w w w . j a va 2 s .c o m emp = new EmPrefs(this); rpc = new Emrpc(this); try { ((ImageView) findViewById(R.id.logoImg)) .setImageBitmap(BitmapFactory.decodeStream(openFileInput("logo.img"))); } catch (FileNotFoundException e) { Log.e(EasymenuNGActivity.TAG, "Error image file not found: " + e.getMessage()); } this.findViewById(R.id.lblTable).setClickable(true); this.findViewById(R.id.lblTable).setOnLongClickListener(new OnLongClickListener() { @Override public boolean onLongClick(View v) { ((TextView) findViewById(R.id.lblTable)).setText(""); findViewById(R.id.btnMenu).setEnabled(false); findViewById(R.id.btnDrinks).setEnabled(false); findViewById(R.id.btnWaiter).setEnabled(false); findViewById(R.id.btnOrder).setEnabled(false); findViewById(R.id.btnBill).setEnabled(false); findViewById(R.id.btnConfig).setVisibility(View.GONE); FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft; Fragment f = null; f = new TableListFragment(); if (fm.findFragmentByTag("rightfragment") != null) { ft = fm.beginTransaction(); ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); ft.remove(fm.findFragmentByTag("rightfragment")); ft.commit(); } ft = fm.beginTransaction(); ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); ft.add(R.id.rightcontent, f, "rightfragment"); ft.commit(); return true; } }); FragmentManager fm = getSupportFragmentManager(); FragmentTransaction ft; Fragment f = null; f = new TableListFragment(); ft = fm.beginTransaction(); ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); ft.add(R.id.rightcontent, f, "rightfragment"); ft.commit(); }
From source file:com.goliathonline.android.kegbot.ui.HomeActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (!EulaHelper.hasAcceptedEula(this)) { EulaHelper.showEula(false, this); }//from w w w .j a va 2 s .c o m if (!PrefsHelper.hasAPIUrl(this)) { final Intent launchPreferencesIntent = new Intent().setClass(this, PreferencesActivity.class); AlertDialog.Builder eula = new AlertDialog.Builder(this).setTitle("Setup API URL") .setIcon(android.R.drawable.ic_dialog_info) .setMessage("The kegbot api url needs to be entered to continue.").setCancelable(false) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); // Make it a subactivity so we know when it returns startActivityForResult(launchPreferencesIntent, REQUEST_CODE_PREFERENCES); } }); eula.show(); } AnalyticsUtils.getInstance(this).trackPageView("/Home"); setContentView(R.layout.activity_home); getActivityHelper().setupActionBar(null, 0); FragmentManager fm = getSupportFragmentManager(); mTagStreamFragment = (TagStreamFragment) fm.findFragmentById(R.id.fragment_tag_stream); mSyncStatusUpdaterFragment = (SyncStatusUpdaterFragment) fm .findFragmentByTag(SyncStatusUpdaterFragment.TAG); if (mSyncStatusUpdaterFragment == null) { mSyncStatusUpdaterFragment = new SyncStatusUpdaterFragment(); fm.beginTransaction().add(mSyncStatusUpdaterFragment, SyncStatusUpdaterFragment.TAG).commit(); triggerRefresh(); } }
From source file:android.support.v17.leanback.app.GuidedStepSupportFragment.java
/** * Adds the specified GuidedStepSupportFragment as content of Activity; no backstack entry is added so * the activity will be dismissed when BACK key is pressed. The method is typically called in * Activity.onCreate() when savedInstanceState is null. When savedInstanceState is not null, * the Activity is being restored, do not call addAsRoot() to duplicate the Fragment restored * by FragmentManager.// w w w . j a v a 2s . c o m * {@link #UI_STYLE_ACTIVITY_ROOT} is assigned. * * Note: currently fragments added using this method must be created programmatically rather * than via XML. * @param activity The Activity to be used to insert GuidedstepFragment. * @param fragment The GuidedStepSupportFragment to be inserted into the fragment stack. * @param id The id of container to add GuidedStepSupportFragment, can be android.R.id.content. * @return The ID returned by the call FragmentTransaction.commit, or -1 there is already * GuidedStepSupportFragment. */ public static int addAsRoot(FragmentActivity activity, GuidedStepSupportFragment fragment, int id) { // Workaround b/23764120: call getDecorView() to force requestFeature of ActivityTransition. activity.getWindow().getDecorView(); FragmentManager fragmentManager = activity.getSupportFragmentManager(); if (fragmentManager.findFragmentByTag(TAG_LEAN_BACK_ACTIONS_FRAGMENT) != null) { Log.w(TAG, "Fragment is already exists, likely calling " + "addAsRoot() when savedInstanceState is not null in Activity.onCreate()."); return -1; } FragmentTransaction ft = fragmentManager.beginTransaction(); fragment.setUiStyle(UI_STYLE_ACTIVITY_ROOT); return ft.replace(id, fragment, TAG_LEAN_BACK_ACTIONS_FRAGMENT).commit(); }
From source file:com.google.android.gms.samples.plus.SignInActivity.java
@Override public void onConnectionFailed(ConnectionResult status) { resetAccountState();/*www . j av a2 s.com*/ if (mConnectionProgressDialog.isShowing()) { // The user clicked the button already and we are showing a spinner // progress dialog. We dismiss the progress dialog and start to // resolve connection errors. mConnectionProgressDialog.dismiss(); if (status.hasResolution()) { try { status.startResolutionForResult(this, REQUEST_CODE_RESOLVE_FAILURE); } catch (SendIntentException e) { mPlusClient.connect(); } } } // Save the intent so that we can start an activity when the user clicks // the button. mStatus = status; FragmentManager fragmentManager = getSupportFragmentManager(); if (!status.hasResolution() && GooglePlayServicesUtil.isUserRecoverableError(status.getErrorCode()) && fragmentManager.findFragmentByTag(TAG_ERROR_DIALOG_FRAGMENT) == null) { DialogFragment fragment = new GooglePlayServicesErrorDialogFragment(); Bundle args = new Bundle(); args.putInt(GooglePlayServicesErrorDialogFragment.ARG_ERROR_CODE, status.getErrorCode()); args.putInt(GooglePlayServicesErrorDialogFragment.ARG_REQUEST_CODE, REQUEST_CODE_RESOLVE_MISSING_GP); fragment.setArguments(args); fragment.show(fragmentManager, TAG_ERROR_DIALOG_FRAGMENT); } }
From source file:com.autoparts.buyers.action_content.ExamplesActivity.java
public void updateContent(Uri uri) { final Fragment fragment; final String tag; final FragmentManager fm = getSupportFragmentManager(); final FragmentTransaction tr = fm.beginTransaction(); if (!currentUri.equals(uri)) { final Fragment currentFragment = fm.findFragmentByTag(currentContentFragmentTag); if (currentFragment != null) tr.hide(currentFragment);//from ww w. j ava 2 s. c o m } if (ModelFragment.ABOUT_URI.equals(uri)) { tag = ModelFragment.TAG; final Fragment foundFragment = fm.findFragmentByTag(tag); if (foundFragment != null) { fragment = foundFragment; } else { fragment = new ModelFragment(null); } } else if (uri != null) { tag = WebViewFragment.TAG; final WebViewFragment webViewFragment; final Fragment foundFragment = fm.findFragmentByTag(tag); if (foundFragment != null) { fragment = foundFragment; webViewFragment = (WebViewFragment) fragment; } else { webViewFragment = new WebViewFragment(); fragment = webViewFragment; } webViewFragment.setUrl(uri.toString()); } else { return; } if (fragment.isAdded()) { tr.show(fragment); } else { tr.replace(R.id.content, fragment, tag); } tr.commit(); currentUri = uri; currentContentFragmentTag = tag; }
From source file:com.microsoft.rightsmanagement.sampleapp.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // instantiate/get reference on retain-able Fragment instance which hold IAsyncTask FragmentManager fragmentManager = getSupportFragmentManager(); mMsipcTaskFragment = (MsipcTaskFragment) fragmentManager.findFragmentByTag(MsipcTaskFragment.TAG); // If the Fragment is not null then it is retained across a configuration change. if (mMsipcTaskFragment == null) { mMsipcTaskFragment = new MsipcTaskFragment(); fragmentManager.beginTransaction().add(mMsipcTaskFragment, MsipcTaskFragment.TAG).commit(); }//from w w w .j a v a 2 s. co m mTextEditorFragment = (TextEditorFragment) getSupportFragmentManager() .findFragmentByTag(TextEditorFragment.TAG); if (savedInstanceState == null) { // handle incoming intent Intent incommingIntent = getIntent(); String action = incommingIntent.getAction(); if ((action.compareTo(Intent.ACTION_VIEW) == 0) || (action.compareTo(Intent.ACTION_EDIT) == 0)) { // Application state doesn't exist. intent is view. mUriOfFilePendingConsumption = incommingIntent.getData(); } else if (action.compareTo(Intent.ACTION_MAIN) == 0) { // Show Log dialog only on first launch showCustomerExperienceDataConsentDialogFragmentIfNeeded(new CompletionCallback<Void>() { @Override public void onSuccess(Void item) { setToShowCustomerExperienceDataConsentDialogFragmentAgainOnStart(false); } @Override public void onCancel() { setToShowCustomerExperienceDataConsentDialogFragmentAgainOnStart(true); finish(); } }); createTextEditorFragment(TextEditorMode.NotEnforced, null); } else { throw new RuntimeException("shouldn't reach here"); } } }
From source file:com.kubotaku.android.sample.sensordataviewer.MainActivity.java
private void showSetupApiTokenDialog() { final FragmentManager fragmentManager = getSupportFragmentManager(); if (fragmentManager.findFragmentByTag(FRAGMENT_TAG_API_TOKEN) == null) { ApiTokenSettingDialogFragment fragment = ApiTokenSettingDialogFragment.newInstance(); fragment.show(fragmentManager, FRAGMENT_TAG_API_TOKEN); }/*from w ww .j a v a 2 s .c om*/ }
From source file:com.kubotaku.android.sample.sensordataviewer.MainActivity.java
private void showSetupWeatherDialog() { final FragmentManager fragmentManager = getSupportFragmentManager(); if (fragmentManager.findFragmentByTag(FRAGMENT_TAG_WEATHER) == null) { final SelectWeatherPlaceFragment fragment = SelectWeatherPlaceFragment.newInstance(); fragment.show(fragmentManager, FRAGMENT_TAG_WEATHER); }/*from w ww .ja v a2 s . co m*/ }