當前位置: 首頁>>代碼示例>>Java>>正文


Java FragmentManager.executePendingTransactions方法代碼示例

本文整理匯總了Java中android.support.v4.app.FragmentManager.executePendingTransactions方法的典型用法代碼示例。如果您正苦於以下問題:Java FragmentManager.executePendingTransactions方法的具體用法?Java FragmentManager.executePendingTransactions怎麽用?Java FragmentManager.executePendingTransactions使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.app.FragmentManager的用法示例。


在下文中一共展示了FragmentManager.executePendingTransactions方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onEventMainThread

import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
public void onEventMainThread(ThrowableFailureEvent event) {
    if (!isInExecutionScope(executionScope, event)) {
        return;
    }
    checkLogException(event);
    // Execute pending commits before finding to avoid multiple error fragments being shown
    FragmentManager fm = getFragmentManager();
    fm.executePendingTransactions();

    DialogFragment existingFragment = (DialogFragment) fm.findFragmentByTag(TAG_ERROR_DIALOG);
    if (existingFragment != null) {
        // Just show the latest error
        existingFragment.dismiss();
    }

    android.support.v4.app.DialogFragment errorFragment = (android.support.v4.app.DialogFragment) factory
            .prepareErrorFragment(event, finishAfterDialog, argumentsForErrorDialog);
    if (errorFragment != null) {
        errorFragment.show(fm, TAG_ERROR_DIALOG);
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:22,代碼來源:ErrorDialogManager.java

示例2: onEventMainThread

import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
public void onEventMainThread(ThrowableFailureEvent event) {
    if (!isInExecutionScope(executionScope, event)) {
        return;
    }
    checkLogException(event);
    // Execute pending commits before finding to avoid multiple error fragments being shown
    FragmentManager fm = getFragmentManager();
    fm.executePendingTransactions();

    DialogFragment existingFragment = (DialogFragment) fm.findFragmentByTag(TAG_ERROR_DIALOG);
    if (existingFragment != null) {
        // Just show the latest error
        existingFragment.dismiss();
    }

    DialogFragment errorFragment = (DialogFragment) factory
            .prepareErrorFragment(event, finishAfterDialog, argumentsForErrorDialog);
    if (errorFragment != null) {
        errorFragment.show(fm, TAG_ERROR_DIALOG);
    }
}
 
開發者ID:devzwy,項目名稱:KUtils,代碼行數:22,代碼來源:ErrorDialogManager.java

示例3: startLogin

import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
/***
 * 跳轉到登錄
 * requestCode=1111
 */
public static void startLogin(FragmentActivity context, ActivityResultListner listener) {
    //先看activity是否添加過該fragment, 添加根據Tag找出 ,沒有就添加
    FragmentManager manager = context.getSupportFragmentManager();
    MyFragment myFragment = null;
    Fragment loginf = manager.findFragmentByTag(MyFragment.LOGIN + "");
    if (loginf == null) {
        myFragment = new MyFragment();
        manager.beginTransaction().add(myFragment, MyFragment.LOGIN + "").commit();
        //這句是讓commit立即生效,不然運行會報錯,fragment還沒有被attach
        manager.executePendingTransactions();
    } else {
        myFragment = (MyFragment) loginf;
    }
    //設置監聽
    myFragment.setListener(listener);
    Intent intent = new Intent(context, loginActivity.class);
    myFragment.startActivityForResult(intent, MyFragment.LOGIN);
}
 
開發者ID:While1true,項目名稱:JSSample,代碼行數:23,代碼來源:ActivityUtils.java

示例4: startWithPop

import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
void startWithPop(final FragmentManager fragmentManager, SupportFragment from, SupportFragment to, String toFragmentTag) {
    fragmentManager.executePendingTransactions();
    if (from.isHidden()) {
        Log.e(TAG, from.getClass().getSimpleName() + " is hidden, " + "the transaction of startWithPop() is invalid!");
        return;
    }

    SupportFragment preFragment = getPreFragment(from);
    handlePopAnim(preFragment, from, to);

    FragmentTransaction removeFt = fragmentManager.beginTransaction().remove(from);
    supportCommit(fragmentManager, removeFt);
    debouncePop(from, fragmentManager);

    FragmentTransaction ft = fragmentManager.beginTransaction()
            .setTransition(FragmentTransaction.TRANSIT_FRAGMENT_OPEN)
            .add(from.getContainerId(), to, toFragmentTag)
            .addToBackStack(toFragmentTag);

    if (preFragment != null) {
        ft.hide(preFragment);
    }

    supportCommit(fragmentManager, ft);
    fragmentManager.executePendingTransactions();
}
 
開發者ID:LonelyMushroom,項目名稱:aarLibrary,代碼行數:27,代碼來源:FragmentationDelegate.java

示例5: popToFix

import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
/**
 * To fix the FragmentManagerImpl.mAvailIndices incorrect ordering when pop() multiple Fragments
 * on pre-support-v4-25.4.0
 */
private void popToFix(String fragmentTag, int flag, final FragmentManager fragmentManager) {
    if (FragmentationHack.getActiveFragments(fragmentManager) == null) return;

    mSupport.getSupportDelegate().mPopMultipleNoAnim = true;
    fragmentManager.popBackStackImmediate(fragmentTag, flag);
    fragmentManager.executePendingTransactions();
    mSupport.getSupportDelegate().mPopMultipleNoAnim = false;

    mHandler.post(new Runnable() {
        @Override
        public void run() {
            FragmentationHack.reorderIndices(fragmentManager);
        }
    });
}
 
開發者ID:wzx54321,項目名稱:XinFramework,代碼行數:20,代碼來源:TransactionDelegate.java

示例6: changeFragment

import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
public static void changeFragment(FragmentActivity activity, Fragment nextFragment, boolean addToBackStack) {
        String name = nextFragment.getClass().getSimpleName();

        final FragmentManager fragmentManager = activity.getSupportFragmentManager();

        final FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
        fragmentTransaction.setCustomAnimations(R.anim.slide_left_in, R.anim.slide_right_in, R.anim.slide_left_out, R.anim.slide_right_out);

        fragmentTransaction.replace(R.id.frame_content, nextFragment);

        if (addToBackStack) {
            fragmentTransaction.addToBackStack(name);
        }
        try {
            fragmentTransaction.commitAllowingStateLoss();
            fragmentManager.executePendingTransactions();
        } catch (IllegalStateException e) {
        }

}
 
開發者ID:Ubudu,項目名稱:GoogleMapsLayout-Android,代碼行數:21,代碼來源:FragmentUtils.java

示例7: getRxFacebookAuthFragment

import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
/**
 * Get instance of RxSmartLockPasswordsFragment
 *
 * @return a RxSmartLockPasswordsFragment
 */
private RxSmartLockPasswordsFragment getRxFacebookAuthFragment(Builder builder) {
    FragmentManager fragmentManager = mActivity.getSupportFragmentManager();

    // prevent fragment manager already executing transaction
    int stackCount = fragmentManager.getBackStackEntryCount();
    if( fragmentManager.getFragments() != null )
        fragmentManager = fragmentManager.getFragments().get( stackCount > 0 ? stackCount-1 : stackCount ).getChildFragmentManager();

    RxSmartLockPasswordsFragment rxSmartLockPasswordsFragment = (RxSmartLockPasswordsFragment)
            fragmentManager.findFragmentByTag(RxSmartLockPasswordsFragment.TAG);

    if (rxSmartLockPasswordsFragment == null) {
        rxSmartLockPasswordsFragment = RxSmartLockPasswordsFragment.newInstance(builder);
        fragmentManager
                .beginTransaction()
                .add(rxSmartLockPasswordsFragment, RxSmartLockPasswordsFragment.TAG)
                .commit();
        fragmentManager.executePendingTransactions();
    }
    return rxSmartLockPasswordsFragment;
}
 
開發者ID:pchmn,項目名稱:RxSocialAuth,代碼行數:27,代碼來源:RxSmartLockPasswords.java

示例8: getRxGoogleAuthFragment

import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
/**
 * Get instance of RxGoogleAuthFragment
 *
 * @return a RxGoogleAuthFragment
 */
private RxGoogleAuthFragment getRxGoogleAuthFragment(Builder builder) {
    FragmentManager fragmentManager = mActivity.getSupportFragmentManager();

    // prevent fragment manager already executing transaction
    int stackCount = fragmentManager.getBackStackEntryCount();
    if( fragmentManager.getFragments() != null )
        fragmentManager = fragmentManager.getFragments().get( stackCount > 0 ? stackCount-1 : stackCount ).getChildFragmentManager();

    RxGoogleAuthFragment rxGoogleAuthFragment = (RxGoogleAuthFragment)
            mActivity.getSupportFragmentManager().findFragmentByTag(RxGoogleAuthFragment.TAG);

    if (rxGoogleAuthFragment == null) {
        rxGoogleAuthFragment = RxGoogleAuthFragment.newInstance(builder);
        fragmentManager
                .beginTransaction()
                .add(rxGoogleAuthFragment, RxGoogleAuthFragment.TAG)
                .commit();
        fragmentManager.executePendingTransactions();
    }
    return rxGoogleAuthFragment;
}
 
開發者ID:pchmn,項目名稱:RxSocialAuth,代碼行數:27,代碼來源:RxGoogleAuth.java

示例9: attachTo

import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
public static void attachTo(Activity activity, Object executionScope, boolean finishAfterDialog,
        Bundle argumentsForErrorDialog) {
    FragmentManager fm = ((FragmentActivity) activity).getSupportFragmentManager();
    SupportManagerFragment fragment = (SupportManagerFragment) fm.findFragmentByTag(TAG_ERROR_DIALOG_MANAGER);
    if (fragment == null) {
        fragment = new SupportManagerFragment();
        fm.beginTransaction().add(fragment, TAG_ERROR_DIALOG_MANAGER).commit();
        fm.executePendingTransactions();
    }
    fragment.finishAfterDialog = finishAfterDialog;
    fragment.argumentsForErrorDialog = argumentsForErrorDialog;
    fragment.executionScope = executionScope;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:14,代碼來源:ErrorDialogManager.java

示例10: onCreate

import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.simple_scroll_activity);
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    FragmentManager fm = getSupportFragmentManager();
    if (fm.findFragmentByTag(ViewPagerTabFragmentParentFragment.FRAGMENT_TAG) == null) {
        FragmentTransaction ft = fm.beginTransaction();
        ft.add(R.id.fragment, new ViewPagerTabFragmentParentFragment(),
                ViewPagerTabFragmentParentFragment.FRAGMENT_TAG);
        ft.commit();
        fm.executePendingTransactions();
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:ScrollObservablesActivity.java

示例11: from

import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
@NonNull
static ResolutionFragment from(@NonNull FragmentManager fragmentManager) {
  ResolutionFragment resolutionFragment = (ResolutionFragment) fragmentManager.findFragmentByTag(TAG);
  if (resolutionFragment == null) {
    resolutionFragment = new ResolutionFragment();
    fragmentManager
        .beginTransaction()
        .add(resolutionFragment, TAG)
        .commit();
    fragmentManager.executePendingTransactions();
  }
  return resolutionFragment;
}
 
開發者ID:JetradarMobile,項目名稱:android-rxlocationsettings,代碼行數:14,代碼來源:RxLocationSettings.java

示例12: openDialogInternal

import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
@Override
protected DialogFragment openDialogInternal(FragmentManager fm) {
    if (fm.findFragmentByTag(DIALOG_FRAGMENT_TAG) != null) return null;

    Fragment fragment = new Fragment(this);
    MediaRouteSelector selector = mediaSource().buildRouteSelector();
    if (selector == null) return null;

    fragment.setRouteSelector(selector);
    fragment.show(fm, DIALOG_FRAGMENT_TAG);
    fm.executePendingTransactions();

    return fragment;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:15,代碼來源:MediaRouteChooserDialogManager.java

示例13: openDialogInternal

import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
@Override
protected DialogFragment openDialogInternal(FragmentManager fm) {
    if (fm.findFragmentByTag(DIALOG_FRAGMENT_TAG) != null) return null;

    Fragment fragment = new Fragment(this, mCallback);
    MediaRouteSelector selector = mediaSource().buildRouteSelector();
    if (selector == null) return null;

    androidMediaRouter().addCallback(selector, mCallback);

    fragment.show(fm, DIALOG_FRAGMENT_TAG);
    fm.executePendingTransactions();

    return fragment;
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:16,代碼來源:MediaRouteControllerDialogManager.java

示例14: getDetatchedValuesFragment

import android.support.v4.app.FragmentManager; //導入方法依賴的package包/類
private ValuesFragment getDetatchedValuesFragment(boolean popBackStack) {
    FragmentManager fm = getSupportFragmentManager();
    ValuesFragment valuesFragment = (ValuesFragment) getSupportFragmentManager().findFragmentByTag(VALUES_FRAGMENT);
    if (valuesFragment == null) {
        valuesFragment = new ValuesFragment();
    } else {
        if (popBackStack) {
            fm.popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
        }
        fm.beginTransaction().remove(valuesFragment).commit();
        fm.executePendingTransactions();
    }
    return valuesFragment;
}
 
開發者ID:rjaros87,項目名稱:pm-home-station,代碼行數:15,代碼來源:MainActivity.java


注:本文中的android.support.v4.app.FragmentManager.executePendingTransactions方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。