本文整理汇总了Java中android.support.v4.app.FragmentManager.popBackStack方法的典型用法代码示例。如果您正苦于以下问题:Java FragmentManager.popBackStack方法的具体用法?Java FragmentManager.popBackStack怎么用?Java FragmentManager.popBackStack使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v4.app.FragmentManager
的用法示例。
在下文中一共展示了FragmentManager.popBackStack方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeDebouncePop
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private void executeDebouncePop(FragmentManager fm) {
Fragment popF = fm.findFragmentByTag(fm.getBackStackEntryAt(fm.getBackStackEntryCount() - 1).getName());
if (popF instanceof ISupportFragment) {
ISupportFragment supportF = (ISupportFragment) popF;
if (supportF.getSupportDelegate().mIsSharedElement) {
long now = System.currentTimeMillis();
if (now < mShareElementDebounceTime) {
mShareElementDebounceTime = System.currentTimeMillis() + supportF.getSupportDelegate().mAnimHelper.exitAnim.getDuration();
return;
}
}
mShareElementDebounceTime = System.currentTimeMillis() + supportF.getSupportDelegate().mAnimHelper.exitAnim.getDuration();
}
fm.popBackStack();
}
示例2: switchToMainFragment
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public void switchToMainFragment(RxResponse<AppData> response){
if(response.status == RxStatus.SUCCESS) {
MainFragment mainFragment = new MainFragment();
if(getActivity() == null){
Log.wtf(CLASS_TAG, "Unable to get Activity");
return;
}
FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
fragmentManager.popBackStack();
fragmentManager.beginTransaction()
.setCustomAnimations(R.anim.fragment_fade_in, R.anim.fragment_fade_out)
.addToBackStack(null)
.replace(R.id.fragmentLayout, mainFragment)
.commit();
}
else {
Log.wtf(CLASS_TAG, "Unable to get repo data, fallback to login");
switchToLoginFragment();
}
}
示例3: switchToLoginFragment
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public void switchToLoginFragment(){
LoginFragment loginFragment = new LoginFragment();
if(getActivity() == null){
Log.wtf(CLASS_TAG, "Unable to get Activity");
return;
}
FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
fragmentManager.popBackStack();
fragmentManager.beginTransaction()
.setCustomAnimations(R.anim.fragment_fade_in, R.anim.fragment_fade_out)
.addToBackStack(null)
.replace(R.id.fragmentLayout, loginFragment)
.commit();
}
示例4: onNavigationItemSelected
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public boolean onNavigationItemSelected(final MenuItem item) {
final FragmentManager fragmentManager = getSupportFragmentManager();
if (fragmentManager.getBackStackEntryCount() > 0) {
fragmentManager.popBackStack(
fragmentManager.getBackStackEntryAt(0).getId(),
FragmentManager.POP_BACK_STACK_INCLUSIVE);
}
for (int i = 0; i < pageIds.length; i++) {
if (pageIds[i] == item.getItemId()) {
container.setCurrentItem(i);
return true;
}
}
return false;
}
示例5: onPostExecute
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
protected void onPostExecute(Void aVoid) {
super.onPostExecute(aVoid);
mSharedPreferences.edit().putBoolean(ValueHelper.TREES_TO_BE_DOWNLOADED_FIRST, false).commit();
updateData();
if (progressDialog != null) {
progressDialog.dismiss();
}
FragmentManager fm = getActivity().getSupportFragmentManager();
for(int entry = 0; entry < fm.getBackStackEntryCount(); entry++){
Log.d("CheckFragmentBackStack", "Found fragment: " + fm.getBackStackEntryAt(entry).getName());
}
if (fm.getBackStackEntryCount() > 1) {
fm.popBackStack();
}
}
示例6: clearBackStack
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
protected void clearBackStack() {
FragmentManager fm = getSupportFragmentManager();
final int backStackEntryCount = fm.getBackStackEntryCount();
for (int i = 0; i < backStackEntryCount; ++i) {
fm.popBackStack();
}
}
示例7: switchToFragment
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private void switchToFragment(int itemIid, Fragment fragment, String tag) {
currentItem = itemIid;
setSelectDateButtonVisible(fragment instanceof ProgramsTabsFragment);
FragmentManager fm = getSupportFragmentManager();
fm.popBackStack();
fm.beginTransaction().replace(R.id.frame_container, fragment, tag).commit();
}
示例8: clearBackStack
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
private void clearBackStack() {
FragmentManager manager = getSupportFragmentManager();
/*if (manager.getBackStackEntryCount() > 0) {
FragmentManager.BackStackEntry first = manager.getBackStackEntryAt(0);
manager.popBackStack(first.getId(), FragmentManager.POP_BACK_STACK_INCLUSIVE);
}*/
manager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
// TODO: 13.12.2017 Exception java.lang.IllegalStateException:Can not perform this action after onSaveInstanceState
Logger.d(TAG, "Back stack was cleared");
}
示例9: onSupportNavigateUp
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public boolean onSupportNavigateUp() {
FragmentManager fragmentManager = getSupportFragmentManager();
if (fragmentManager.getBackStackEntryCount() > 0) {
fragmentManager.popBackStack();
} else {
Intent intent = new Intent(this, ConversationListActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
finish();
}
return true;
}
示例10: onBackPressed
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
@SuppressWarnings("StatementWithEmptyBody")
public void onBackPressed() {
FragmentManager fragMgr = getSupportFragmentManager();
BaseFragment top = getCurrentVisibleFragment();
if (top != null) {
if (!top.onBackPressed()) {
if (fragMgr.getBackStackEntryCount() == 1) {
// Back action was not handled by fragment, handle in activity
} else if (fragMgr.getBackStackEntryCount() > 0) {
// Back action was to go one fragment back
fragMgr.popBackStack();
return;
}
} else {
// Was handled by child fragment
return;
}
}
if (_toolbarTitleEdit.hasFocus()) {
_toolbarTitleEdit.clearFocus();
return;
}
// Handle in this activity
finish();
}
示例11: popBackStackToTopWithFragment
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public Fragment popBackStackToTopWithFragment() {
final FragmentManager fm = getSupportFragmentManager();
fm.popBackStack();
List<Fragment> fragments = fm.getFragments();
if (fragments == null
|| fragments.size() == 0
|| fm.getBackStackEntryCount() == 0) {
return null;
}
return fragments.get(fm.getBackStackEntryCount() - 1);
}
示例12: skjulMenu
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
public void vælgMenu(FragmentActivity akt, int position) {
//new Exception().printStackTrace();
MenuElement e = elem.get(position);
skjulMenu();
if (e.runnable != null) {
e.runnable.run();
sætListemarkering(-1); // Ingen listemarkering
return;
}
sætListemarkering(position);
try {
FragmentManager fm = akt.getSupportFragmentManager();
// Fjern backstak - så vi starter forfra i 'roden'
fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
Log.d("Venstremenu viser " + e.fragKlasse);
Basisfragment f = e.fragKlasse.newInstance();
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.indhold_frag, f);
ft.addToBackStack("Venstremenu");
ft.commit();
Sidevisning.vist(f.getClass());
} catch (Exception e1) {
Log.rapporterFejl(e1);
}
}
示例13: onBackPressed
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public void onBackPressed() {
final FragmentManager lFragmentManager = getSupportFragmentManager();
if (lFragmentManager.getBackStackEntryCount() > 0) {
mSharedViewModel.safeTrigger(Events.backPressed);
lFragmentManager.popBackStack();
} else {
super.onBackPressed();
}
}
示例14: onCreateView
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.d("onCreateView " + this);
View rod = inflater.inflate(R.layout.udsendelser_vandret_skift_frag, container, false);
kanal = App.grunddata.kanalFraKode.get(getArguments().getString(P_KANALKODE));
startudsendelse = App.data.udsendelseFraSlug.get(getArguments().getString(P_UDSENDELSE));
if (startudsendelse == null) { // Fix for https://www.bugsense.com/dashboard/project/cd78aa05/errors/805598045
if (!App.PRODUKTION) { // https://www.bugsense.com/dashboard/project/cd78aa05/errors/822628124
App.langToast("startudsendelse==null for " + kanal);
}
Log.e(new IllegalStateException("startudsendelse==null"));
// Fjern backstak og hop ud
FragmentManager fm = getActivity().getSupportFragmentManager();
fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
FragmentTransaction ft = fm.beginTransaction();
ft.replace(R.id.indhold_frag, new Kanaler_frag());
ft.addToBackStack(null);
ft.commit();
return rod;
}
Log.d("onCreateView " + this + " viser " + " / " + startudsendelse);
viewPager = (ViewPager) rod.findViewById(R.id.pager);
//noinspection ResourceType
viewPager.setId(123); // TODO hvorfor? fjern eller forklar hvorfor R.id.pager ikke er god nok
pager_title_strip = rod.findViewById(R.id.pager_title_strip);
// Da ViewPager er indlejret i et fragment skal adapteren virke på den indlejrede (child)
// fragmentmanageren - ikke på aktivitens (getFragmentManager)
adapter = new UdsendelserAdapter(getChildFragmentManager());
Datoformater.opdateriDagIMorgenIGårDatoStr(App.serverCurrentTimeMillis());
udsendelser = new ArrayList<Udsendelse>();
udsendelser.add(startudsendelse);
adapter.setListe(udsendelser);
viewPager.setAdapter(adapter);
hentUdsendelser(0);
vispager_title_strip();
viewPager.setOnPageChangeListener(this);
// Nødvendigt fordi underfragmenter har optionsmenu
// - ellers nulstilles optionsmenuen ikke når man hopper ud igen!
setHasOptionsMenu(true);
return rod;
}
示例15: clear
import android.support.v4.app.FragmentManager; //导入方法依赖的package包/类
/**
* Return to original state.
* Removes all fragments except for the last one, displaying books.
*/
public static void clear(FragmentManager fragmentManager) {
/* Clear the back stack. */
fragmentManager.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
}