List of usage examples for android.support.v4.app Fragment getClass
@HotSpotIntrinsicCandidate public final native Class<?> getClass();
From source file:r2b.apps.view.base.BaseFragment.java
/** * Switch between child fragments inner the base fragment. * WARNING: NOT TESTED!!/*from w w w.j a v a 2 s . co m*/ * @param fragment * @param tag * @param addToStack * @param frgContainerId */ protected void switchChildFragment(android.support.v4.app.Fragment fragment, String tag, boolean addToStack, int frgContainerId) { if (addToStack) { getChildFragmentManager().beginTransaction().add(frgContainerId, fragment, tag) .addToBackStack(fragment.getClass().getName()).commit(); // XXX LOGGER Logger.v(this.getClass().getSimpleName(), "Add child: " + tag + ", saving to stack"); } else { getChildFragmentManager().popBackStack(); getChildFragmentManager().beginTransaction().add(frgContainerId, fragment, tag) .addToBackStack(fragment.getClass().getName()).commit(); // XXX LOGGER Logger.v(this.getClass().getSimpleName(), "Add child: " + tag + ", without saving to stack"); } }
From source file:net.sarangnamu.common.frgmt.FrgmtManager.java
public void add(int id, Class<?> cls) { try {//from w w w . j av a 2 s. c o m Fragment frgmt = (Fragment) cls.newInstance(); if (frgmt == null) { DLog.e(TAG, "setBase frgmt == null"); return; } FragmentTransaction trans = fm.beginTransaction(); if (frgmt.isVisible()) { return; } trans.add(id, frgmt, frgmt.getClass().getName()); trans.commit(); } catch (Exception e) { DLog.e(TAG, "setBase", e); } }
From source file:com.umeng.comm.ui.activities.BaseFragmentActivity.java
/** * @param container//ww w .j ava 2 s . co m * @param fragment */ public void replaceFragment(int container, Fragment fragment) { checkContainer(); if (mCurrentFragment != fragment) { FragmentTransaction transaction = mFragmentManager.beginTransaction(); transaction.replace(container, fragment, fragment.getClass().getSimpleName()); transaction.commitAllowingStateLoss(); mCurrentFragment = fragment; } }
From source file:com.kasungunathilaka.sarigama.ui.HomeActivity.java
protected void setFragment(Fragment fragment) { String backStateName = fragment.getClass().getName(); String fragmentTag = backStateName; android.support.v4.app.FragmentManager manager = getSupportFragmentManager(); boolean fragmentPopped = manager.popBackStackImmediate(backStateName, 0); if (!fragmentPopped && manager.findFragmentByTag(fragmentTag) == null) { //fragment not in back stack, create it. android.support.v4.app.FragmentTransaction ft = manager.beginTransaction(); if (backStateName.contentEquals(PlayerFragment.class.getName())) { ft.setCustomAnimations(R.anim.slide_in_below, R.anim.slide_out_top, R.anim.slide_in_top, R.anim.slide_out_below); } else if (backStateName.contentEquals(MainFragment.class.getName())) { ft.setCustomAnimations(android.R.anim.fade_in, R.anim.slide_out_right); } else if (backStateName.contentEquals(ConnectionFailFragment.class.getName())) { ft.setCustomAnimations(android.R.anim.fade_in, android.R.anim.fade_out); } else {// w w w . j ava2 s .c o m ft.setCustomAnimations(R.anim.slide_in_right, R.anim.slide_out_left, R.anim.slide_in_left, R.anim.slide_out_right); } ft.replace(R.id.fragment_layout, fragment, fragmentTag); if (!backStateName.contentEquals(MainFragment.class.getName())) { ft.addToBackStack(backStateName); } ft.commit(); } }
From source file:com.dycody.android.idealnote.MainActivity.java
/** * Checks if allocated fragment is of the required type and then returns it or returns null *///from w w w. jav a 2 s.c o m private Fragment checkFragmentInstance(int id, Object instanceClass) { Fragment result = null; if (mFragmentManager != null) { Fragment fragment = mFragmentManager.findFragmentById(id); if (instanceClass.equals(fragment.getClass())) { result = fragment; } } return result; }
From source file:com.kayzook.bracediary.BaseActivity.java
@Override public void onAttachFragment(Fragment fragment) { super.onAttachFragment(fragment); String fragmentSimpleName = fragment.getClass().getSimpleName(); if (!fragmentSimpleName.equals("CustomDialogFragment")) { FragmentManager fm = getSupportFragmentManager(); for (int i = 0; i < fm.getBackStackEntryCount(); ++i) { fm.popBackStack();/*from www.j a va2s .co m*/ } } }
From source file:fr.mixit.android.ui.fragments.ImportStarredDialogFragment.java
protected ImportStarredDialogContract getListener() { final Fragment f = getTargetFragment(); if (f == null) { if (DEBUG_MODE) { Log.e(TAG, "No target fragment configured ! Requiered to get back the action of member click"); }/* ww w.j a va2 s . c o m*/ return null; } if (!(f instanceof WarningImportStarredSessionDialogContract)) { if (DEBUG_MODE) { Log.e(TAG, "The target fragment ( " + f.getClass().getName() + ") does not implement " + ImportStarredDialogContract.class.getName()); } return null; } final ImportStarredDialogContract contract = (ImportStarredDialogContract) f; return contract; }
From source file:yang.mobile.activity.MainActivity.java
@Override public void onItemClickNavigation(int position, int layoutContainerId) { FragmentManager mFragmentManager = getSupportFragmentManager(); if (position == getCurrentPosition() && ListUtils.size(mFragmentManager.getFragments()) > 0) { return;/* w w w .j a v a 2 s .c o m*/ } Class fragmentClass = fragmentList.get(position); String tag = fragmentClass.getName(); Fragment mFragment = mFragmentManager.findFragmentByTag(tag); if (mFragment == null) { Bundle mBundle = new Bundle(); mBundle.putString(TEXT_FRAGMENT, mListNameItem.get(position)); mFragment = Fragment.instantiate(getApplicationContext(), fragmentList.get(position).getName(), mBundle); } mFragmentManager.beginTransaction().replace(layoutContainerId, mFragment, mFragment.getClass().getName()) .commit(); }
From source file:edu.vuum.mocca.ui.tags.TagsActivityBase.java
/** * Logic required to open the appropriate View TagsData Fragment/Activity * combination to display properly on the phone or tablet. */// w w w . j a va 2 s .c o m public void openViewTagsFragment(long index) { Log.d(LOG_TAG, "openTagsViewFragment(" + index + ")"); if (determineDualPane()) { Fragment test = getSupportFragmentManager().findFragmentById(R.id.details); // Log.d(LOG_TAG, "open view class:" + test.getClass()); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); if (test != null && test.getClass() != TagsViewFragment.class) { TagsViewFragment details = TagsViewFragment.newInstance(index); // Execute a transaction, replacing any existing // fragment with this one inside the frame. ft.replace(R.id.details, details); } else { // Check what fragment is shown, replace if needed. TagsViewFragment details = (TagsViewFragment) getSupportFragmentManager() .findFragmentById(R.id.details); if (details == null || details.getUniqueKey() != index) { // Make new fragment to show this selection. details = TagsViewFragment.newInstance(index); } // Execute a transaction, replacing any existing // fragment with this one inside the frame. ft.replace(R.id.details, details); } ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.commit(); } else { // Otherwise we need to launch a new activity to display // the dialog fragment with selected text. Intent intent = newTagsViewIntent(this, index); startActivity(intent); } }
From source file:edu.vuum.mocca.ui.tags.TagsActivityBase.java
/** * Logic required to open the appropriate Edit TagsData Fragment/Activity * combination to display properly on the phone or tablet. *///from w w w .ja v a 2 s.c om public void openEditTagsFragment(final long index) { Log.d(LOG_TAG, "openEditTagsFragment(" + index + ")"); if (determineDualPane()) { Fragment test = getSupportFragmentManager().findFragmentById(R.id.details); // Log.d(LOG_TAG, "open view class:" + test.getClass()); FragmentTransaction ft = getSupportFragmentManager().beginTransaction(); if (test != null && test.getClass() != EditTagsFragment.class) { EditTagsFragment editor = EditTagsFragment.newInstance(index); // Execute a transaction, replacing any existing // fragment with this one inside the frame. ft.replace(R.id.details, editor); } else { // Check what fragment is shown, replace if needed. EditTagsFragment editor = (EditTagsFragment) getSupportFragmentManager() .findFragmentById(R.id.details); if (editor == null || editor.getUniqueKey() != index) { // Make new fragment to show this selection. editor = EditTagsFragment.newInstance(index); } // Execute a transaction, replacing any existing // fragment with this one inside the frame. ft.replace(R.id.details, editor); } ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE); ft.commit(); } else { // Otherwise we need to launch a new activity to display // the dialog fragment with selected text. Intent intent = newEditTagsIntent(this, index); startActivity(intent); } }