/** * Hide list, show details and instruct the details view to show the selected book. */ @Override public void showDetails(Book book, Drawable thumb) { final FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction ft = fragmentManager.beginTransaction(); BookDetailsFragment details = (BookDetailsFragment) fragmentManager.findFragmentById(R.id.book_details); if (book != null) { // If null passed, we only configure fragment transaction here. details.showDetails(book, thumb); } ft.show(details); ft.hide(fragmentManager.findFragmentById(R.id.book_list)); ft.addToBackStack("details"); // Use the back button to return to the search list view. ft.commit(); }
@Override protected void onAttachView(@NonNull View view) { super.onAttachView(view); //noinspection ConstantConditions FragmentManager fm = getActivity().getFragmentManager(); Fragment fragment = fm.findFragmentByTag(getFragmentTag()); if (fragment == null) { fragment = onCreateFragment(); fm.beginTransaction().add(getContainerId(), fragment, getFragmentTag()).commit(); } else { FragmentTransaction transaction = fm.beginTransaction(); // transaction.attach() may not work if the the fragment isn't detached if (!fragment.isDetached()) { transaction.detach(fragment); } transaction.attach(fragment).commit(); } }
public void show(FragmentManager manager, String tag) { if (!mDismissed) { return; } mDismissed = false; FragmentTransaction ft = manager.beginTransaction(); ft.add(this, tag); ft.addToBackStack("actionSheet"); ft.commit(); }
/** * Create fragment instances if necessary. * * @see #findFragments() */ private void initializeFragments() { FragmentManager fragmentManager = getFragmentManager(); fragmentManager.addOnBackStackChangedListener(this); boolean hasMessageListFragment = (mMessageListFragment != null); if (!hasMessageListFragment) { FragmentTransaction ft = fragmentManager.beginTransaction(); mMessageListFragment = MessageListFragment.newInstance(mSearch, false, (QMail.isThreadedViewEnabled() && !mNoThreading)); ft.add(R.id.message_list_container, mMessageListFragment); ft.commit(); } // Check if the fragment wasn't restarted and has a MessageReference in the arguments. If // so, open the referenced message. if (!hasMessageListFragment && mMessageViewFragment == null && mMessageReference != null) { openMessage(mMessageReference); } }
@Override public void goBack() { FragmentManager fragmentManager = getFragmentManager(); if (mDisplayMode == DisplayMode.MESSAGE_VIEW) { showMessageList(); } else if (fragmentManager.getBackStackEntryCount() > 0) { fragmentManager.popBackStack(); } else if (mMessageListFragment.isManualSearch()) { finish(); } else if (!mSingleFolderMode) { onAccounts(); } else { onShowFolderList(); } }
private void openFragment(Fragment fragment) { this.fragment = fragment; FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.add(R.id.addParticipantContainer, fragment); fragmentTransaction.commit(); addParticipantContainer.setVisibility(View.VISIBLE); isFragmentOpen = true; }
/** * Setup a base dialog fragment transaction. Handles the removing of a * previous fragment if it exists and adds itself to the backstack. * * @return FragmentTransaction */ private FragmentTransaction setupTransaction(Activity activity) { FragmentManager manager = activity.getFragmentManager(); FragmentTransaction ft = manager.beginTransaction(); Fragment prev = manager.findFragmentByTag("dialog"); if (prev != null) ft.remove(prev); ft.addToBackStack(null); return ft; }
/** * The {@code fragment} is added to the container view with id {@code frameId}. The operation is * performed by the {@code fragmentManager}. */ public static void addFragmentToActivity(@NonNull FragmentManager fragmentManager, @NonNull Fragment fragment, int frameId) { checkNotNull(fragmentManager); checkNotNull(fragment); FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.add(frameId, fragment); transaction.commit(); }
/** * Retrieves the fragment with the given tag. If not exists then a new fragment will be created. * * @param fragmentManager The fragment manager used to find fragment. * @param tag Fragment tag. * @return The retrieved retained fragment or a its new instance. */ @NonNull public static Fragment findOrCreateFragment(@NonNull final FragmentManager fragmentManager, @NonNull final String tag) { checkNotNull(fragmentManager, "fragmentManager must not be null!"); checkNotNull(tag, "tag must not be null!"); checkArgument(!tag.isEmpty(), "tag string must not be empty!"); Fragment fragment = fragmentManager.findFragmentByTag(tag); if (fragment == null) { fragment = DiffRequestManagerHolderFragment.newInstance(DiffRequestManagerHolder.create()); addFragmentToActivity(fragmentManager, fragment, tag); } return fragment; }
/** * Droid Speech Constructor * * @param context The application context instance * * @param fragmentManager The fragment manager instance (Pass this "null" if Droid Speech doesn't * want to handle permissions) */ public DroidSpeech(Context context, FragmentManager fragmentManager) { this.context = context; dsProperties.listeningMsg = context.getResources().getString(R.string.ds_listening); if(fragmentManager != null) { // Initializing the Non-UI droid speech fragment and beginning transaction droidSpeechPermissions = new DroidSpeechPermissions(); fragmentManager.beginTransaction().add(droidSpeechPermissions, TAG).commit(); } // Initializing the recognition progress view initRecognitionProgressView(); // Starting the language receiver to get the device language details startLanguageReceiver(); }
private static void show(FragmentManager fm, int type, RootInfo root, DocumentInfo doc, String query, int anim) { final Bundle args = new Bundle(); args.putInt(EXTRA_TYPE, type); args.putParcelable(EXTRA_ROOT, root); args.putParcelable(EXTRA_DOC, doc); args.putString(EXTRA_QUERY, query); final FragmentTransaction ft = fm.beginTransaction(); switch (anim) { case ANIM_SIDE: args.putBoolean(EXTRA_IGNORE_STATE, true); break; case ANIM_DOWN: ft.setCustomAnimations(R.animator.dir_down, R.animator.dir_frozen); break; case ANIM_UP: ft.setCustomAnimations(R.animator.dir_frozen, R.animator.dir_up); break; } final DirectoryFragment fragment = new DirectoryFragment(); fragment.setArguments(args); ft.replace(R.id.container_directory, fragment); ft.commitAllowingStateLoss(); }
/** * Destroys fragment and resets UI after the user either cancels or finishes sending a story. */ public void OnComplete() { FragmentManager manager = getFragmentManager(); FragmentTransaction transaction = manager.beginTransaction(); transaction.remove(manager.findFragmentByTag("AddStoryFragment_1")); transaction.commit(); adapter.setcheck(false); supportInvalidateOptionsMenu(); findViewById(R.id.go_to_map).setVisibility(View.VISIBLE); findViewById(R.id.fab).setVisibility(View.VISIBLE); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar); DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout); ActionBarDrawerToggle toggle = new ActionBarDrawerToggle( this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close); drawer.setDrawerListener(toggle); toggle.syncState(); NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view); navigationView.setNavigationItemSelectedListener(this); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction() .replace(R.id.content_frame , new HomeFragment()) .commit(); }
private void showFragment(String name) { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); for (Fragment f : fragments.values()) { fragmentTransaction.hide(f); } if (fragments.containsKey(name)) { fragmentTransaction.show(fragments.get(name)); currentFragment = name; } fragmentTransaction.commit(); }
@Override public void onDocumentPicked(DocumentInfo doc) { final FragmentManager fm = getFragmentManager(); if (doc.isDirectory()) { mState.stack.push(doc); mState.stackTouched = true; onCurrentDirectoryChanged(ANIM_DOWN); } else { // Fall back to viewing final Intent view = new Intent(Intent.ACTION_VIEW); view.setFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); view.setData(doc.derivedUri); try { startActivity(view); } catch (ActivityNotFoundException ex2) { Toast.makeText(this, R.string.toast_no_application, Toast.LENGTH_SHORT).show(); } } }
private void closeFragment() { FragmentManager fm = getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); ft.remove(fragment); ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_CLOSE); ft.commit(); addParticipantContainer.setVisibility(View.GONE); isFragmentOpen = false; }
public static void showEula(Activity activity) { FragmentManager fm = activity.getFragmentManager(); FragmentTransaction ft = fm.beginTransaction(); Fragment prev = fm.findFragmentByTag("dialog_eula"); if (prev != null) { ft.remove(prev); } ft.addToBackStack(null); new EulaDialog().show(ft, "dialog_eula"); }
public static void show(FragmentManager fm, String mimeType, String displayName) { final Bundle args = new Bundle(); args.putString(EXTRA_MIME_TYPE, mimeType); args.putString(EXTRA_DISPLAY_NAME, displayName); final SaveFragment fragment = new SaveFragment(); fragment.setArguments(args); final FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.container_save, fragment, TAG); ft.commitAllowingStateLoss(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); findViewById(R.id.nav_drawer_layout).setSystemUiVisibility(View.SYSTEM_UI_FLAG_IMMERSIVE); // Navigation drawer mDrawerItems = getResources().getStringArray(R.array.drawer_items); mDrawerLayout = (DrawerLayout) findViewById(R.id.nav_drawer_layout); mDrawerList = (ListView) findViewById(R.id.left_navigation_drawer); // Set the adapter for the list view mDrawerList.setAdapter(new ArrayAdapter<>(this, R.layout.drawer_list_item, mDrawerItems)); // Set the list's click listener mDrawerList.setOnItemClickListener(new DrawerItemClickListener()); Init(); // Load the first segment FragmentManager fragmentManager = getFragmentManager(); currentFragment = new WifiModeFragment(); currentFragmentIndex = 0; fragmentManager.beginTransaction().replace(R.id.content_frame, currentFragment).commit(); ((WifiModeFragment) currentFragment).SetDataProvider(dataProvider, backgroundProcessManager); }
/** * * * @param position is the new fragment */ private void replaceFragment(int position) { FragmentManager fragmentManager = getFragmentManager(); Fragment fragment = null; String fragment_tag = ""; //Delete not initialized state if (position == -1) { position = 0; } switch (position) { case POSITION_MAIN: fragment_tag = MainFragment.class.getName(); fragment = fragmentManager.findFragmentByTag(fragment_tag); if (fragment == null) { fragment = new MainFragment(); } break; case POSITION_MAP: fragment_tag = MyMapFragment.class.getName(); fragment = fragmentManager.findFragmentByTag(fragment_tag); if (fragment == null) { fragment = new MyMapFragment(); } break; case POSITION_PREDICTION: fragment_tag = PredictionFragment.class.getName(); fragment = fragmentManager.findFragmentByTag(fragment_tag); if (fragment == null) { fragment = new PredictionFragment(); } break; case POSITION_PROTOCOLO: fragment_tag = ProtocolosFragment.class.getName(); fragment = fragmentManager.findFragmentByTag(fragment_tag); if (fragment == null) { fragment = new ProtocolosFragment(); } break; case POSITION_LAST_AVISO: DownloadFilesUtils.downloadPdf(this,this, DownloadFilesUtils.EXTERNAL_STORAGE_PERMISSION_REQUEST_CODE_BOLETIN_DIARIO); return; case POSITION_INFO: fragment_tag = InfoFragment.class.getName(); fragment = fragmentManager.findFragmentByTag(fragment_tag); if (fragment == null) { fragment = new InfoFragment(); } break; case POSITION_FEEDBACK: fragment_tag = FeedbackFragment.class.getName(); fragment = fragmentManager.findFragmentByTag(fragment_tag); if (fragment == null) { fragment = new FeedbackFragment(); } break; } FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.replace(R.id.content_frame, fragment, fragment_tag); if (position != 0 && fragmentManager.getBackStackEntryCount() == 0) { transaction.addToBackStack(null); } transaction.commit(); mCurrentDrawerItem = position; }
public CarouselRequestManager with(Fragment fragment) { FragmentManager fm = fragment.getFragmentManager(); CarouselFragment carouselFragment = new CarouselFragment(); carouselFragment.setCarouselLifecycleListener(carouselLifecycleListener); fm.beginTransaction().add(carouselFragment, CAROUSEL_FRAGMENT_TAG).commitAllowingStateLoss(); return new CarouselRequestManager(this); }
public static <T> RetainFragment<T> findOrCreate(FragmentManager fm, String tag) { // noinspection unchecked, we know this is the the right type RetainFragment<T> retainFragment = (RetainFragment<T>) fm.findFragmentByTag(tag); if (retainFragment == null || retainFragment.cleared) { retainFragment = new RetainFragment<>(); fm.beginTransaction() .add(retainFragment, tag) .commitAllowingStateLoss(); } return retainFragment; }
public void dismiss() { FragmentManager fragmentManager = getFragmentManager(); if (fragmentManager != null) { fragmentManager.beginTransaction().remove(BrowseErrorFragment.this).commit(); fragmentManager.popBackStack(); } }
/** * Get references to existing fragments if the activity was restarted. */ private void findFragments() { FragmentManager fragmentManager = getFragmentManager(); mMessageListFragment = (MessageListFragment) fragmentManager.findFragmentById( R.id.message_list_container); mMessageViewFragment = (MessageViewFragment) fragmentManager.findFragmentById( R.id.message_view_container); }
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.take_quiz_activity); setTitle("Personality Quiz"); FragmentManager fm = getFragmentManager(); if (fm.findFragmentById(R.id.take_quiz_activity_content_layout) == null) { Fragment fragment = QuestionsFragment.newInstance(); fm.beginTransaction() .replace(R.id.take_quiz_activity_content_layout, fragment, fragment.getClass().getCanonicalName()) .commit(); } }
@Override public void onBackPressed() { FragmentManager fm = getFragmentManager(); if (fm.getBackStackEntryCount() > 0) { fm.popBackStack(); mCurrentPath = FileUtils.cutLastSegmentOfPath(mCurrentPath); updateTitle(); } else { setResult(RESULT_CANCELED); super.onBackPressed(); } }
/** * The {@code fragment} is added to the container view with id {@code frameId}. The operation is * performed by the {@code fragmentManager}. * * @param fragmentManager {@link FragmentManager} associated with {@link android.app.Activity}. * @param fragment {@link Fragment} to add. * @param tag A string identifying the fragment. */ public static void addFragmentToActivity(@NonNull final FragmentManager fragmentManager, @NonNull final Fragment fragment, @NonNull final String tag) { checkNotNull(fragmentManager, "fragmentManager must not be null!"); checkNotNull(fragment, "fragment must not be null!"); checkNotNull(tag, "tag must not be null!"); checkArgument(!tag.isEmpty(), "tag string must not be empty!"); removeFragment(fragmentManager, tag); final FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.add(fragment, tag); transaction.commitAllowingStateLoss(); }
public static void remove(@NonNull FragmentManager fm, @NonNull String tag) { checkNotNull(fm); checkNotNull(tag); Fragment prev = fm.findFragmentByTag(tag); if (prev != null) { fm.beginTransaction().remove(prev).commit(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final String TAG = "EnabledApplicationsPreferenceFragment"; FragmentManager fm = getFragmentManager(); EnabledApplicationsPreferenceFragment fragment = (EnabledApplicationsPreferenceFragment) fm.findFragmentByTag(TAG); if (fragment == null) { fragment = new EnabledApplicationsPreferenceFragment(); fm.beginTransaction().replace(android.R.id.content, fragment, TAG).commit(); } }
@Override public View getView(final int position, View convertView, ViewGroup parent) { final BluetoothDevice device = getItem(position); // Check if an existing view is being reused, otherwise inflate the view if (convertView == null) { convertView = LayoutInflater.from(getContext()).inflate(R.layout.view_bluetooth_item, parent, false); } Button bluetoothEditBtn = (Button) convertView.findViewById(R.id.bluetoothEditBtn); TextView btDeviceNameText = (TextView) convertView.findViewById(R.id.btDeviceNameText); TextView btMacText = (TextView) convertView.findViewById(R.id.btMacText); btDeviceNameText.setText(device.getName()); btMacText.setText(device.getAddress()); bluetoothEditBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { FragmentManager manager = ((Activity) getContext()).getFragmentManager(); BluetoothDialogNew myDialog = BluetoothDialogNew.newInstance(device.getName(), device.getAddress()); myDialog.setCancelable(false); myDialog.show(manager, "bluetooth"); dialog.dismiss(); } }); return convertView; }
@Override public boolean onPrepareOptionsMenu(Menu menu) { super.onPrepareOptionsMenu(menu); final FragmentManager fm = getFragmentManager(); final RootInfo root = getCurrentRoot(); final DocumentInfo cwd = getCurrentDirectory(); final MenuItem createDir = menu.findItem(R.id.menu_create_dir); final MenuItem search = menu.findItem(R.id.menu_search); final MenuItem sort = menu.findItem(R.id.menu_sort); final MenuItem sortSize = menu.findItem(R.id.menu_sort_size); final MenuItem grid = menu.findItem(R.id.menu_grid); final MenuItem list = menu.findItem(R.id.menu_list); sort.setVisible(cwd != null); grid.setVisible(mState.derivedMode != State.MODE_GRID); list.setVisible(mState.derivedMode != State.MODE_LIST); if (mState.currentSearch != null) { // Search uses backend ranking; no sorting sort.setVisible(false); search.expandActionView(); mSearchView.setIconified(false); mSearchView.clearFocus(); mSearchView.setQuery(mState.currentSearch, false); } else { mIgnoreNextClose = true; mSearchView.setIconified(true); mSearchView.clearFocus(); mIgnoreNextCollapse = true; search.collapseActionView(); } // Only sort by size when visible sortSize.setVisible(mState.showSize); search.setVisible(true); createDir.setVisible(true); return true; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); SettingsFragment settingsFragment = new SettingsFragment(); FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); fragmentTransaction.replace(android.R.id.content, settingsFragment); fragmentTransaction.commit(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_show_siteswaps); setTitle(String.format(getString(R.string.show_siteswaps__title_generating))); Intent intent = getIntent(); if(intent != null) { mGenerator = (SiteswapGenerator) intent.getSerializableExtra(getString(R.string.intent__siteswap_generator)); } mSiteswapListView = (ListView) findViewById(R.id.siteswap_list); FragmentManager fm = getFragmentManager(); mSiteswapGenerationFragment = (SiteswapGenerationFragment) fm.findFragmentByTag(TAG_SITESWAP_GENERATION_TASK_FRAGMENT); // If the Fragment is non-null, then it is currently being // retained across a configuration change. if (mSiteswapGenerationFragment == null) { mSiteswapGenerationFragment = new SiteswapGenerationFragment(); fm.beginTransaction().add(mSiteswapGenerationFragment, TAG_SITESWAP_GENERATION_TASK_FRAGMENT).commit(); } else { mSiteswapGenerationFragment.getSiteswapGenerator(); } }
public static void show(FragmentManager fm, ArrayList<DocumentInfo> docs, boolean deleteAfter) { final Bundle args = new Bundle(); args.putParcelableArrayList(EXTRA_DOC_LIST, docs); args.putBoolean(EXTRA_DELETE_AFTER, deleteAfter); final MoveFragment fragment = new MoveFragment(); fragment.setArguments(args); final FragmentTransaction ft = fm.beginTransaction(); ft.replace(R.id.container_save, fragment, TAG); ft.commitAllowingStateLoss(); }
/** * The {@code fragment} is added to the container view with id {@code frameId}. The operation is * performed by the {@code fragmentManager}. * */ public static void addFragmentToActivity (FragmentManager fragmentManager, Fragment fragment, int frameId, String tag) { FragmentTransaction transaction = fragmentManager.beginTransaction(); transaction.replace(frameId, fragment, tag); transaction.commit(); }
public static void add(final FragmentManager fm) { Fragment fragment = fm.findFragmentByTag(FRAGMENT_TAG); if (fragment == null) { fragment = new AlertDialogsFragment(); fm.beginTransaction().add(fragment, FRAGMENT_TAG).commit(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); setAmbientEnabled(); drawer_itemArrayList = initializeScreenSystem(); mSelectedScreen = 0; // Register the local broadcast receiver IntentFilter messageFilter = new IntentFilter(Intent.ACTION_SEND); MessageReceiver messageReceiver = new MessageReceiver(); LocalBroadcastManager.getInstance(this).registerReceiver(messageReceiver, messageFilter); // Initialize content to first screen. mDrinkFragment = new DrinkWaterFragment(); FragmentManager fragmentManager = getFragmentManager(); fragmentManager.beginTransaction().replace(R.id.content_frame, mDrinkFragment).commit(); // Main Wearable Drawer Layout that holds all the content mWearableDrawerLayout = (WearableDrawerLayout) findViewById(R.id.drawer_layout); // Top Navigation Drawer mWearableNavigationDrawer = (WearableNavigationDrawer) findViewById(R.id.top_navigation_drawer); mWearableNavigationDrawer.setAdapter(new NavigationAdapter(this)); // Bottom Action Drawer mWearableActionDrawer = (WearableActionDrawer) findViewById(R.id.bottom_action_drawer); mWearableActionDrawer.setOnMenuItemClickListener(this); // Temporarily peeks the navigation and action drawers to ensure the user is aware of them. ViewTreeObserver observer = mWearableDrawerLayout.getViewTreeObserver(); observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { mWearableDrawerLayout.getViewTreeObserver().removeOnGlobalLayoutListener(this); mWearableDrawerLayout.peekDrawer(Gravity.TOP); mWearableDrawerLayout.peekDrawer(Gravity.BOTTOM); } }); }
@Override protected void onCreate(Bundle savedInstanceState) { ((QuranApplication) getApplication()).refreshLocale(this, false); super.onCreate(savedInstanceState); setContentView(R.layout.preferences); final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setTitle(R.string.prefs_category_advanced); setSupportActionBar(toolbar); final ActionBar ab = getSupportActionBar(); if (ab != null) { ab.setDisplayHomeAsUpEnabled(true); } AudioManagerUtils.clearCache(); if (savedInstanceState != null) { mLocationToWrite = savedInstanceState.getString(SI_LOCATION_TO_WRITE); } final FragmentManager fm = getFragmentManager(); final Fragment fragment = fm.findFragmentById(R.id.content); if (fragment == null) { fm.beginTransaction() .replace(R.id.content, new QuranAdvancedSettingsFragment()) .commit(); } }
@Override public void showHomeFragment() { FragmentManager fragmentManager = getFragmentManager(); FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); homeFragment = new HomeFragment(); fragmentTransaction.replace(R.id.main_container, homeFragment, HomeFragment.class.getSimpleName()); fragmentTransaction.commit(); }