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


Java Fragment.onPause方法代碼示例

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


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

示例1: testBind

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private void testBind(Fragment fragment) {
  fragment.onAttach(null);
  fragment.onCreate(null);

  //before view created null
  assertTrue(this.presenter.view == null);

  fragment.onCreateView(null, null, null);
  fragment.onViewCreated(null, null);

  //after view created, the view has been bound automatically
  assertTrue(this.presenter.view != null);

  fragment.onStart();
  fragment.onResume();
  fragment.onPause();
  fragment.onStop();
  fragment.onDestroy();

  //after on destroy the view has been released automatically
  assertTrue(this.presenter.view == null);
}
 
開發者ID:ezhome,項目名稱:Android-RxPresenter,代碼行數:23,代碼來源:RxPresenterTest.java

示例2: testBindUntilEvent

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private void testBindUntilEvent(LifecycleProvider<FragmentEvent> provider) {
    Fragment fragment = (Fragment) provider;
    startFragment(fragment);

    TestObserver<Object> testObserver = observable.compose(provider.bindUntilEvent(STOP)).test();

    fragment.onAttach(null);
    testObserver.assertNotComplete();
    fragment.onCreate(null);
    testObserver.assertNotComplete();
    fragment.onViewCreated(null, null);
    testObserver.assertNotComplete();
    fragment.onStart();
    testObserver.assertNotComplete();
    fragment.onResume();
    testObserver.assertNotComplete();
    fragment.onPause();
    testObserver.assertNotComplete();
    fragment.onStop();
    testObserver.assertComplete();
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:22,代碼來源:RxSupportFragmentLifecycleTest.java

示例3: onCheckedChanged

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
@Override
public void onCheckedChanged(RadioGroup radioGroup, int checkId) {
    for (int i = 0; i < radioGroup.getChildCount(); i++) {
        if (radioGroup.getChildAt(i).getId() == checkId) {
            //  即將要展示的Fragment
            Fragment target = mFragmentList.get(i);
            Fragment currentFragment = getCurrentFragment();
            currentFragment.onPause();

            FragmentTransaction fragmentTransaction = getFragmentTransaction();
            if (target.isAdded()) {
                target.onResume();
                fragmentTransaction.show(target).hide(currentFragment);

            } else {
                fragmentTransaction.add(mContentId, target).show(target).hide(currentFragment);
            }
            fragmentTransaction.commit();
            currentTab = i;

            if (mFragmentToogleListener != null) {
                mFragmentToogleListener.onToogleChange(target, currentTab);
            }

        }
    }

}
 
開發者ID:zuoni1018,項目名稱:CoordinatorLayoutExample-master,代碼行數:29,代碼來源:ZhiHuAdapter.java

示例4: testLifecycle

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private void testLifecycle(LifecycleProvider<FragmentEvent> provider) {
    Fragment fragment = (Fragment) provider;
    startFragment(fragment);

    TestObserver<FragmentEvent> testObserver = provider.lifecycle().skip(1).test();

    fragment.onAttach(null);
    fragment.onCreate(null);
    fragment.onViewCreated(null, null);
    fragment.onStart();
    fragment.onResume();
    fragment.onPause();
    fragment.onStop();
    fragment.onDestroyView();
    fragment.onDestroy();
    fragment.onDetach();

    testObserver.assertValues(
        FragmentEvent.ATTACH,
        FragmentEvent.CREATE,
        FragmentEvent.CREATE_VIEW,
        FragmentEvent.START,
        FragmentEvent.RESUME,
        FragmentEvent.PAUSE,
        FragmentEvent.STOP,
        FragmentEvent.DESTROY_VIEW,
        FragmentEvent.DESTROY,
        FragmentEvent.DETACH
    );
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:31,代碼來源:RxSupportFragmentLifecycleTest.java

示例5: testBindToLifecycle

import android.support.v4.app.Fragment; //導入方法依賴的package包/類
private void testBindToLifecycle(LifecycleProvider<FragmentEvent> provider) {
    Fragment fragment = (Fragment) provider;
    startFragment(fragment);

    fragment.onAttach(null);
    TestObserver<Object> attachObserver = observable.compose(provider.bindToLifecycle()).test();

    fragment.onCreate(null);
    attachObserver.assertNotComplete();
    TestObserver<Object> createObserver = observable.compose(provider.bindToLifecycle()).test();

    fragment.onViewCreated(null, null);
    attachObserver.assertNotComplete();
    createObserver.assertNotComplete();
    TestObserver<Object> createViewObserver = observable.compose(provider.bindToLifecycle()).test();

    fragment.onStart();
    attachObserver.assertNotComplete();
    createObserver.assertNotComplete();
    createViewObserver.assertNotComplete();
    TestObserver<Object> startObserver = observable.compose(provider.bindToLifecycle()).test();

    fragment.onResume();
    attachObserver.assertNotComplete();
    createObserver.assertNotComplete();
    createViewObserver.assertNotComplete();
    startObserver.assertNotComplete();
    TestObserver<Object> resumeObserver = observable.compose(provider.bindToLifecycle()).test();

    fragment.onPause();
    attachObserver.assertNotComplete();
    createObserver.assertNotComplete();
    createViewObserver.assertNotComplete();
    startObserver.assertNotComplete();
    resumeObserver.assertComplete();
    TestObserver<Object> pauseObserver = observable.compose(provider.bindToLifecycle()).test();

    fragment.onStop();
    attachObserver.assertNotComplete();
    createObserver.assertNotComplete();
    createViewObserver.assertNotComplete();
    startObserver.assertComplete();
    pauseObserver.assertComplete();
    TestObserver<Object> stopObserver = observable.compose(provider.bindToLifecycle()).test();

    fragment.onDestroyView();
    attachObserver.assertNotComplete();
    createObserver.assertNotComplete();
    createViewObserver.assertComplete();
    stopObserver.assertComplete();
    TestObserver<Object> destroyViewObserver = observable.compose(provider.bindToLifecycle()).test();

    fragment.onDestroy();
    attachObserver.assertNotComplete();
    createObserver.assertComplete();
    destroyViewObserver.assertComplete();
    TestObserver<Object> destroyObserver = observable.compose(provider.bindToLifecycle()).test();

    fragment.onDetach();
    attachObserver.assertComplete();
    destroyObserver.assertComplete();
}
 
開發者ID:xufreshman,項目名稱:RxLifeCycle,代碼行數:63,代碼來源:RxSupportFragmentLifecycleTest.java


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