当前位置: 首页>>代码示例>>Java>>正文


Java Fragment.onAttach方法代码示例

本文整理汇总了Java中android.support.v4.app.Fragment.onAttach方法的典型用法代码示例。如果您正苦于以下问题:Java Fragment.onAttach方法的具体用法?Java Fragment.onAttach怎么用?Java Fragment.onAttach使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v4.app.Fragment的用法示例。


在下文中一共展示了Fragment.onAttach方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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

示例4: 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.onAttach方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。