List of usage examples for android.app Fragment getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:org.dmfs.android.retentionmagic.RetentionMagic.java
public static void init(final android.support.v4.app.Fragment fragment, final SharedPreferences prefs) { try {//from w w w . ja va 2 s. c om init(fragment.getClass(), fragment, prefs); } catch (IllegalAccessException e) { e.printStackTrace(); } }
From source file:org.dmfs.android.retentionmagic.RetentionMagic.java
/** * Store all retainable fields of a {@link android.support.v4.app.Fragment} in a {@link Bundle}. * /* w w w . ja v a2 s.c o m*/ * @param fragment * The {@link android.support.v4.app.Fragment}. * @param instanceState * The {@link Bundle} to store the state in. */ public static void store(final android.support.v4.app.Fragment fragment, final Bundle instanceState) { try { storeAndRestore(fragment.getClass(), fragment, instanceState, true /* store */); } catch (IllegalAccessException e) { e.printStackTrace(); } }
From source file:org.dmfs.android.retentionmagic.RetentionMagic.java
/** * Restore all retainable fields of a {@link android.support.v4.app.Fragment} from a {@link Bundle}. * /*from w w w . ja va2 s . c om*/ * @param fragment * The {@link android.support.v4.app.Fragment}. * @param instanceState * The {@link Bundle} to store the state in. */ public static void restore(final android.support.v4.app.Fragment fragment, final Bundle instanceState) { try { storeAndRestore(fragment.getClass(), fragment, instanceState, false /* restore */); } catch (IllegalAccessException e) { e.printStackTrace(); } }
From source file:org.dmfs.android.retentionmagic.RetentionMagic.java
public static void persist(final android.support.v4.app.Fragment fragment, final SharedPreferences.Editor editor) { try {/*w ww . j a v a 2s . c om*/ persist(fragment.getClass(), fragment, editor); } catch (IllegalAccessException e) { e.printStackTrace(); } }
From source file:com.frostwire.android.gui.activities.TransferDetailActivity.java
/** * Fragment rotation ends up with initialized detail fragments not added, * it seems the SectionsPageAdapter doesn't properly tag the fragments * and we have to manually find the corresponding added fragment * in the list keep by AbstractFragment's getFragments() * * We receive a fragment whose .isAdded() method returns false and we * look into our tracked list of fragments for an equivalent instance that * is marked as added and return it./*from w ww.ja va 2 s .c om*/ * * We'll then replace that instance in our detailFragments[] array */ private Fragment getCorrespondingActiveFragment(AbstractTransferDetailFragment currentFragment) { List<Fragment> fragments = getFragments(); if (fragments.size() > 1) { for (Fragment f : fragments) { if (f.isAdded() && currentFragment.getClass() == f.getClass()) { return f; } } } return null; }
From source file:com.ezhuk.cast.MainActivity.java
private void updateDevicesFragment() { Fragment fragment = getFragmentManager().findFragmentById(R.id.drawer_frame); if (fragment.getClass() == DevicesFragment.class) { DevicesFragment devicesFragment = (DevicesFragment) fragment; mDeviceNames.clear();/*from w ww .jav a 2 s .co m*/ mDeviceNames.addAll(mRouteInfos.values()); devicesFragment.updateDevicesList(); } }
From source file:de.azapps.mirakel.settings.SettingsActivity.java
@Override public void startPreferenceFragment(final Fragment fragment, final boolean push) { if (isValidFragment(fragment.getClass().getName())) { super.startPreferenceFragment(fragment, push); }//from w w w . j av a2s.co m }
From source file:org.iota.wallet.ui.activity.MainActivity.java
/** * Shows a fragment and hides the old one if there was a fragment previously visible *///from ww w. j ava 2 s . com private void showFragment(Fragment fragment, boolean addToBackStack, boolean killFragments) { if (fragment == null) { // Do nothing return; } FragmentManager fragmentManager = getFragmentManager(); Fragment currentFragment = fragmentManager.findFragmentByTag(currentFragmentTag); if (currentFragment != null && currentFragment.getClass().getName().equals(fragment.getClass().getName())) { // Fragment already shown, do nothing return; } FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); if (killFragments) { Class[] fragmentsToKill = { AboutFragment.class, GenerateQRCodeFragment.class, NeighborsFragment.class, NodeInfoFragment.class, PasswordLoginFragment.class, QRScannerFragment.class, SeedLoginFragment.class, SettingsFragment.class, TangleExplorerTabFragment.class, NewTransferFragment.class, WalletAddressesFragment.class, WalletTabFragment.class, WalletTransfersFragment.class }; for (Class fragmentClass : fragmentsToKill) { String tag = fragmentClass.getSimpleName(); if (tag.equals(fragment.getClass().getSimpleName())) { continue; } Fragment fragmentToKill = fragmentManager.findFragmentByTag(tag); if (fragmentToKill != null) { fragmentTransaction.remove(fragmentToKill); } } } fragmentTransaction.setCustomAnimations(R.animator.fade_in, R.animator.fade_out, R.animator.fade_in, R.animator.fade_out); if (currentFragment != null) { // Hide old fragment fragmentTransaction.hide(currentFragment); } String tag = fragment.getClass().getSimpleName(); Fragment cachedFragment = fragmentManager.findFragmentByTag(tag); if (cachedFragment != null) { // Cached fragment available fragmentTransaction.show(cachedFragment); } else { fragmentTransaction.add(FRAGMENT_CONTAINER_ID, fragment, tag); } if (addToBackStack) { fragmentTransaction.addToBackStack(null); } fragmentTransaction.commit(); if (fragment instanceof OnBackPressedClickListener) { onBackPressedClickListener = (OnBackPressedClickListener) fragment; } else onBackPressedClickListener = null; // setChecked if open from WalletItemDialog if (fragment instanceof TangleExplorerTabFragment) navigationView.getMenu().findItem(R.id.nav_tangle_explorer).setChecked(true); currentFragmentTag = tag; }
From source file:com.notriddle.budget.EnvelopesActivity.java
private void configureFragment(Fragment frag) { ActionBar ab = getActionBar();// w w w. j a v a2 s . c o m if (frag instanceof TitleFragment) { TitleFragment tFrag = (TitleFragment) frag; setTitle(tFrag.getTitle()); ab.setTitle(getTitle()); boolean isTopLevel = false; for (int i = 0; i != mNavAdapter.getCount(); ++i) { if (mNavAdapter.getItem(i) == frag.getClass()) { mNavDrawer.setItemChecked(i, true); isTopLevel = true; break; } else { mNavDrawer.setItemChecked(i, false); } } mNavToggle.setDrawerIndicatorEnabled(isTopLevel); } else { throw new Error("Top-level fragment must be a TitleFragment"); } if (frag instanceof DialogFragment) { DialogFragment dFrag = (DialogFragment) frag; dFrag.setShowsDialog(false); } if (frag instanceof ColorFragment) { ColorFragment cFrag = (ColorFragment) frag; onColorChange(cFrag.getColor()); } else { onColorChange(0); } if (frag instanceof CustomActionBarFragment) { CustomActionBarFragment cFrag = (CustomActionBarFragment) frag; mCustomActionBarView = cFrag.onCreateActionBarView(getLayoutInflater()); ab.setCustomView(mCustomActionBarView); ab.setDisplayShowTitleEnabled(false); ab.setDisplayShowCustomEnabled(true); } else { mCustomActionBarView = null; ab.setDisplayShowTitleEnabled(true); ab.setDisplayShowCustomEnabled(false); ab.setCustomView(null); } }
From source file:org.noorganization.instalist.view.activity.MainShoppingListView.java
@Override public void registerFragment(Fragment fragment) { try {/* w w w . j a v a 2 s.com*/ mFragments.add((IFragment) fragment); } catch (ClassCastException e) { throw new ClassCastException(fragment.getClass().toString() + " has no IFragment implemented"); } }