android.app.FragmentTransaction.commitAllowingStateLoss()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.4k)|赞(0)|评价(0)|浏览(156)

本文整理了Java中android.app.FragmentTransaction.commitAllowingStateLoss()方法的一些代码示例,展示了FragmentTransaction.commitAllowingStateLoss()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。FragmentTransaction.commitAllowingStateLoss()方法的具体详情如下:
包路径:android.app.FragmentTransaction
类名称:FragmentTransaction
方法名:commitAllowingStateLoss

FragmentTransaction.commitAllowingStateLoss介绍

暂无

代码示例

代码示例来源:origin: Cleveroad/SlidingTutorial-Android

@Override
public void finishUpdate(@NonNull ViewGroup container) {
  if (mCurTransaction != null) {
    mCurTransaction.commitAllowingStateLoss();
    mCurTransaction = null;
  }
}

代码示例来源:origin: bumptech/glide

@SuppressWarnings("deprecation")
@NonNull
private RequestManagerFragment getRequestManagerFragment(
  @NonNull final android.app.FragmentManager fm,
  @Nullable android.app.Fragment parentHint,
  boolean isParentVisible) {
 RequestManagerFragment current = (RequestManagerFragment) fm.findFragmentByTag(FRAGMENT_TAG);
 if (current == null) {
  current = pendingRequestManagerFragments.get(fm);
  if (current == null) {
   current = new RequestManagerFragment();
   current.setParentFragmentHint(parentHint);
   if (isParentVisible) {
    current.getGlideLifecycle().onStart();
   }
   pendingRequestManagerFragments.put(fm, current);
   fm.beginTransaction().add(current, FRAGMENT_TAG).commitAllowingStateLoss();
   handler.obtainMessage(ID_REMOVE_FRAGMENT_MANAGER, fm).sendToTarget();
  }
 }
 return current;
}

代码示例来源:origin: iMeiji/Toutiao

private void setupFragment(String fragmentName, Bundle args) {
  Fragment fragment = Fragment.instantiate(this, fragmentName, args);
  FragmentTransaction transaction = getFragmentManager().beginTransaction();
  transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
  transaction.replace(R.id.container, fragment);
  transaction.commitAllowingStateLoss();
}

代码示例来源:origin: Cleveroad/SlidingTutorial-Android

@Override
public void removeCurrentFragment() {
  getActivity().getFragmentManager()
      .beginTransaction()
      .remove(TutorialFragment.this)
      .commitAllowingStateLoss();
}

代码示例来源:origin: huburt-Hu/NewbieGuide

private void removeListenerFragment() {
  //隐藏引导层时移除监听fragment
  if (fragment != null && Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN) {
    FragmentManager fm = fragment.getChildFragmentManager();
    ListenerFragment listenerFragment = (ListenerFragment) fm.findFragmentByTag(LISTENER_FRAGMENT);
    if (listenerFragment != null) {
      fm.beginTransaction().remove(listenerFragment).commitAllowingStateLoss();
    }
  }
  if (v4Fragment != null) {
    android.support.v4.app.FragmentManager v4Fm = v4Fragment.getChildFragmentManager();
    V4ListenerFragment v4ListenerFragment = (V4ListenerFragment) v4Fm.findFragmentByTag(LISTENER_FRAGMENT);
    if (v4ListenerFragment != null) {
      v4Fm.beginTransaction().remove(v4ListenerFragment).commitAllowingStateLoss();
    }
  }
}

代码示例来源:origin: huburt-Hu/NewbieGuide

if (listenerFragment == null) {
  listenerFragment = new ListenerFragment();
  fm.beginTransaction().add(listenerFragment, LISTENER_FRAGMENT).commitAllowingStateLoss();

代码示例来源:origin: bumptech/glide

@SuppressWarnings("deprecation")
 @Override
 public void addFragmentWithTag(String tag, RequestManager requestManager) {
  RequestManagerFragment fragment = new RequestManagerFragment();
  fragment.setRequestManager(requestManager);
  controller.get().getFragmentManager().beginTransaction()
    .add(fragment, RequestManagerRetriever.FRAGMENT_TAG).commitAllowingStateLoss();
  controller.get().getFragmentManager().executePendingTransactions();
 }
}

代码示例来源:origin: bumptech/glide

DefaultRetrieverHarness() {
 this.parent = new android.app.Fragment();
 controller.create();
 controller.get().getFragmentManager().beginTransaction().add(parent, PARENT_TAG)
   .commitAllowingStateLoss();
 controller.get().getFragmentManager().executePendingTransactions();
 controller.start().resume();
}

代码示例来源:origin: guolindev/giffun

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
RequestManagerFragment getRequestManagerFragment(final android.app.FragmentManager fm) {
  RequestManagerFragment current = (RequestManagerFragment) fm.findFragmentByTag(FRAGMENT_TAG);
  if (current == null) {
    current = pendingRequestManagerFragments.get(fm);
    if (current == null) {
      current = new RequestManagerFragment();
      pendingRequestManagerFragments.put(fm, current);
      fm.beginTransaction().add(current, FRAGMENT_TAG).commitAllowingStateLoss();
      handler.obtainMessage(ID_REMOVE_FRAGMENT_MANAGER, fm).sendToTarget();
    }
  }
  return current;
}

代码示例来源:origin: chrisk44/Hijacker

@Override
  public void onClick(View view){
    //Open editor for new
    FragmentTransaction ft = mFragmentManager.beginTransaction();
    ft.replace(R.id.fragment1, new CustomActionEditorFragment());
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    ft.addToBackStack(null);
    ft.commitAllowingStateLoss();
  }
});

代码示例来源:origin: chrisk44/Hijacker

@Override
  public boolean onPreferenceClick(Preference preference){
    long time = System.currentTimeMillis();
    if(time - lastVersionClick < 1000){
      if(versionClicks < 4){
        versionClicks++;
      }else{
        versionClicks = 0;
        FragmentTransaction ft = mFragmentManager.beginTransaction();
        ft.replace(R.id.fragment1, new DevOptionsFragment());
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
        ft.addToBackStack(null);
        ft.commitAllowingStateLoss();
      }
    }else versionClicks = 1;
    lastVersionClick = time;
    return false;
  }
});

代码示例来源:origin: chrisk44/Hijacker

public boolean onMenuItemClick(android.view.MenuItem item){
    if(item.getGroupId()==-1){
      //Open actions manager
      FragmentTransaction ft = mFragmentManager.beginTransaction();
      ft.replace(R.id.fragment1, new CustomActionManagerFragment());
      ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
      ft.addToBackStack(null);
      ft.commitAllowingStateLoss();
    }else{
      onActionSelected(cmds.get(item.getItemId()));
    }
    return true;
  }
});

代码示例来源:origin: chrisk44/Hijacker

void crackReaver(MainActivity activity){
  FragmentManager fragmentManager = activity.getFragmentManager();
  ReaverFragment.ap = this;
  FragmentTransaction ft = fragmentManager.beginTransaction();
  ft.replace(R.id.fragment1, activity.reaverFragment.setAutostart(true));
  ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
  ft.addToBackStack(null);
  ft.commitAllowingStateLoss();
  fragmentManager.executePendingTransactions();      //Wait for everything to be set up
}
void disconnectAll(){

代码示例来源:origin: chrisk44/Hijacker

static void isolate(String mac){
  is_ap = getAPByMac(mac);
  if(is_ap!=null){
    IsolatedFragment.exit_on = mFragmentManager.getBackStackEntryCount();
    FragmentTransaction ft = mFragmentManager.beginTransaction();
    ft.replace(R.id.fragment1, new IsolatedFragment());
    ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
    ft.addToBackStack(null);
    ft.commitAllowingStateLoss();
  }
  Tile.filter();
  if(debug){
    if(is_ap==null) Log.d("HIJACKER/Main", "No AP isolated");
    else Log.d("HIJACKER/Main", "AP with MAC " + mac + " isolated");
  }
}
static void refreshState(){

代码示例来源:origin: chrisk44/Hijacker

ft.commitAllowingStateLoss();
mFragmentManager.executePendingTransactions();

代码示例来源:origin: chrisk44/Hijacker

@Override
  protected void onPostExecute(final Boolean success){
    if(!success) return;
    loadingDialog.setText(getString(R.string.starting_hijacker));
    if(watchdog){
      watchdogTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
    }
    //Load default fragment (airodump)
    if(mFragmentManager.getBackStackEntryCount()==0){
      FragmentTransaction ft = mFragmentManager.beginTransaction();
      ft.replace(R.id.fragment1, new MyListFragment());
      ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
      ft.addToBackStack(null);
      ft.commitAllowingStateLoss();
    }
    loadingDialog.dismissAllowingStateLoss();
    //Start
    if(pref.getBoolean("disclaimerAccepted", false)) main();
  }
}

代码示例来源:origin: chrisk44/Hijacker

ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN);
ft.addToBackStack(null);
ft.commitAllowingStateLoss();

代码示例来源:origin: mthli/SugarTask

@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
private void registerHookToContext(@NonNull Fragment fragment) {
  FragmentManager manager = fragment.getChildFragmentManager();
  HookFragment hookFragment = (HookFragment) manager.findFragmentByTag(TAG_HOOK);
  if (hookFragment == null) {
    hookFragment = new HookFragment();
    manager.beginTransaction().add(hookFragment, TAG_HOOK).commitAllowingStateLoss();
  }
}

代码示例来源:origin: geniusgithub/AndroidDialer

private void removeVoicemailFragment() {
    if (mVoicemailFragment != null) {
      getChildFragmentManager().beginTransaction().remove(mVoicemailFragment)
          .commitAllowingStateLoss();
      mVoicemailFragment = null;
    }
  }
}

代码示例来源:origin: mthli/SugarTask

private void registerHookToContext(@NonNull Activity activity) {
  FragmentManager manager = activity.getFragmentManager();
  HookFragment hookFragment = (HookFragment) manager.findFragmentByTag(TAG_HOOK);
  if (hookFragment == null) {
    hookFragment = new HookFragment();
    manager.beginTransaction().add(hookFragment, TAG_HOOK).commitAllowingStateLoss();
  }
}

相关文章