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


Java ActivityEvent类代码示例

本文整理汇总了Java中com.trello.rxlifecycle2.android.ActivityEvent的典型用法代码示例。如果您正苦于以下问题:Java ActivityEvent类的具体用法?Java ActivityEvent怎么用?Java ActivityEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ActivityEvent类属于com.trello.rxlifecycle2.android包,在下文中一共展示了ActivityEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getExpressInfo

import com.trello.rxlifecycle2.android.ActivityEvent; //导入依赖的package包/类
/**
 * 获取快递信息
 *
 * @param type   快递类型
 * @param postid 快递单号
 */
public void getExpressInfo(String type, String postid) {
    isShowLoading.set(true);

    dataManager.getExpressInfo(type, postid)
            .subscribeOn(Schedulers.io()) // 在子线程中进行Http访问
            .observeOn(AndroidSchedulers.mainThread()) // UI线程处理返回接口
            .compose(getProvider().<ExpressInfo>bindUntilEvent(ActivityEvent.DESTROY)) // onDestroy取消订阅
            .subscribe(new DefaultObserver<ExpressInfo>() {  // 订阅
                @Override
                public void onNext(@NonNull ExpressInfo expressInfo) {
                    ExpressViewModel.this.expressInfo.setExpressInfo(expressInfo);
                }

                @Override
                public void onError(@NonNull Throwable e) {
                    errorMessage.set(e.getMessage());
                    isShowLoading.set(false);
                }

                @Override
                public void onComplete() {
                    isShowLoading.set(false);
                }
            });
}
 
开发者ID:alidili,项目名称:Demos,代码行数:32,代码来源:ExpressViewModel.java

示例2: onCreate

import com.trello.rxlifecycle2.android.ActivityEvent; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    button = (Button) findViewById(R.id.button2);

    RetrofitHelper.creatApi(ApiService.class).getMessage("yuantong","200382770316")
            .compose(MainActivity.this.<Result<List<Message>>>bindUntilEvent(ActivityEvent.DESTROY))
            .compose(SchedulerTransformer.<Result<List<Message>>>transformer())
            .map(new ServerResponseFun<List<Message>>())
            .onErrorResumeNext(new HttpResponseFunc<List<Message>>())
            .subscribe(new ApiSubscriber<List<Message>>(MainActivity.this,true,false) {
                @Override
                public void onNext(@NonNull List<Message> messages) {
                    button.setText(messages.toString());
                }
            });


}
 
开发者ID:qiaop,项目名称:basicapp,代码行数:21,代码来源:MainActivity.java

示例3: getExpressInfo

import com.trello.rxlifecycle2.android.ActivityEvent; //导入依赖的package包/类
/**
 * 获取快递信息
 *
 * @param type   快递类型
 * @param postid 快递单号
 */
public void getExpressInfo(String type, String postid) {
    expressView.showProgressDialog();

    dataManager.getExpressInfo(type, postid)
            .subscribeOn(Schedulers.io()) // 在子线程中进行Http访问
            .observeOn(AndroidSchedulers.mainThread()) // UI线程处理返回接口
            .compose(getProvider().<ExpressInfo>bindUntilEvent(ActivityEvent.DESTROY)) // onDestroy取消订阅
            .subscribe(new DefaultObserver<ExpressInfo>() {  // 订阅
                @Override
                public void onNext(@NonNull ExpressInfo expressInfo) {
                    expressView.updateView(expressInfo);
                }

                @Override
                public void onError(@NonNull Throwable e) {
                    expressView.showError(e.getMessage());
                    expressView.hideProgressDialog();
                }

                @Override
                public void onComplete() {
                    expressView.hideProgressDialog();
                }
            });
}
 
开发者ID:alidili,项目名称:Demos,代码行数:32,代码来源:ExpressPresenter.java

示例4: getObservable

import com.trello.rxlifecycle2.android.ActivityEvent; //导入依赖的package包/类
/**
 * 获取被监听者
 * 备注:网络请求Observable构建
 * data:网络请求参数
 * <h1>补充说明</h1>
 * 传入LifecycleProvider<ActivityEvent>手动管理生命周期,避免内存溢出
 * 备注:需要继承RxActivity,RxAppCompatActivity,RxFragmentActivity
 *
 * @author ZhongDaFeng
 */
public static Observable getObservable(Observable<HttpResponse> apiObservable, LifecycleProvider<ActivityEvent> lifecycle, ActivityEvent event) {
   // showLog(request);
    Observable observable;
    if (lifecycle != null) {
        //手动管理移除监听生命周期.eg:ActivityEvent.STOP
        observable = apiObservable
                .map(new ServerResultFunction())
                .compose(lifecycle.bindUntilEvent(event))//需要在这个位置添加
                .onErrorResumeNext(new HttpResultFunction<>())
                .subscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread());
    } else {
        observable = getObservable(apiObservable);
    }
    return observable;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:HttpRxObservable.java

示例5: onCreate

import com.trello.rxlifecycle2.android.ActivityEvent; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    lifecycleSubject.onNext(ActivityEvent.CREATE);
    super.onCreate(savedInstanceState);

    //兼容DataBinding的方式的时候就不需要设置了
    if (getLayoutId() != 0) {
        setContentView(getLayoutId());
    }

    // base setup
    Bundle extras = getIntent().getExtras();
    if (null != extras) {
        getBundleExtras(extras);
    }

    mHandler = new MyHandler(this);

    initSpecialView(savedInstanceState);
    initViews(savedInstanceState);
}
 
开发者ID:chenzj-king,项目名称:RetrofitSample,代码行数:22,代码来源:BaseCompatActivity.java

示例6: onResume

import com.trello.rxlifecycle2.android.ActivityEvent; //导入依赖的package包/类
@Override
protected void onResume() {
    super.onResume();
    lifecycleSubject.onNext(ActivityEvent.RESUME);
    if (isRequestPermissionOnResume()) {
        checkPermission();
    } else {
        if (!isFirstResume) {
            checkPermission();
        } else {
            isFirstResume = false;
        }
    }

    if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
}
 
开发者ID:chenzj-king,项目名称:RetrofitSample,代码行数:19,代码来源:BaseCompatActivity.java

示例7: refreshProfile

import com.trello.rxlifecycle2.android.ActivityEvent; //导入依赖的package包/类
private void refreshProfile() {
    mDataManager.profile().compose(this.<Response<Me>>bindUntilEvent(ActivityEvent.DESTROY)).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new SubscriberCallBack<Me>() {
        @Override
        public void onSuccess(Me me) {
            Hawk.put("ME_PROFILE", me);
            TCAgent.onLogin(me.uid, TDAccount.AccountType.REGISTERED, me.username);

            Intent intent = new Intent(LoginActivity.this, MainActivity.class);
            intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
            startActivity(intent);
            supportFinishAfterTransition();
        }

        @Override
        public void onFailure(Throwable t) {

        }

        @Override
        public void onCompleted() {
            mLoginProgress.setVisibility(View.GONE);
        }
    });
}
 
开发者ID:alphater,项目名称:garras,代码行数:25,代码来源:LoginActivity.java

示例8: initView

import com.trello.rxlifecycle2.android.ActivityEvent; //导入依赖的package包/类
@Override
public void initView(Bundle savedInstanceState) {
    if (!isTaskRoot()) {
        return;
    }
    if (!StatusBarUtil.isSupportStatusBarFontChange()) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); //隐藏状态栏
    }
    mContentView.setBackgroundColor(Color.WHITE);
    tvVersion.setText("V" + FastUtil.getVersionName(mContext));
    RxJavaManager.getInstance().setTimer(2000, new RxJavaManager.TimerListener() {
        @Override
        public void timeEnd() {
            FastUtil.startActivity(mContext, MainActivity.class);
            finish();
        }
    }).compose(bindUntilEvent(ActivityEvent.DESTROY));
}
 
开发者ID:AriesHoo,项目名称:FastLib,代码行数:19,代码来源:SplashActivity.java

示例9: apply

import com.trello.rxlifecycle2.android.ActivityEvent; //导入依赖的package包/类
@Override
@NonNull
public ActivityEvent apply(Event.Type type) throws Exception {
    switch (type) {
        case CREATE:
            return ActivityEvent.CREATE;
        case START:
            return ActivityEvent.START;
        case RESUME:
            return ActivityEvent.RESUME;
        case PAUSE:
            return ActivityEvent.PAUSE;
        case STOP:
            return ActivityEvent.STOP;
        case DESTROY:
            return ActivityEvent.DESTROY;
        default:
            throw new IllegalArgumentException("Cannot map " + type + " to a ActivityEvent.");
    }
}
 
开发者ID:xufreshman,项目名称:RxLifeCycle,代码行数:21,代码来源:NaviLifecycleMaps.java

示例10: testLifecycle

import com.trello.rxlifecycle2.android.ActivityEvent; //导入依赖的package包/类
@Test
public void testLifecycle() {
    NaviEmitter activity = NaviEmitter.createActivityEmitter();
    LifecycleProvider<ActivityEvent> provider = NaviLifecycle.createActivityLifecycleProvider(activity);

    TestObserver<ActivityEvent> testObserver = provider.lifecycle().test();

    activity.onCreate(null);
    activity.onStart();
    activity.onResume();
    activity.onPause();
    activity.onStop();
    activity.onDestroy();

    testObserver.assertValues(
        ActivityEvent.CREATE,
        ActivityEvent.START,
        ActivityEvent.RESUME,
        ActivityEvent.PAUSE,
        ActivityEvent.STOP,
        ActivityEvent.DESTROY
    );
}
 
开发者ID:xufreshman,项目名称:RxLifeCycle,代码行数:24,代码来源:NaviActivityLifecycleTest.java

示例11: testBindUntilEvent

import com.trello.rxlifecycle2.android.ActivityEvent; //导入依赖的package包/类
@Test
public void testBindUntilEvent() {
    NaviEmitter activity = createActivityEmitter();
    LifecycleProvider<ActivityEvent> provider = createActivityLifecycleProvider(activity);

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

    activity.onCreate(null);
    testObserver.assertNotComplete();
    activity.onStart();
    testObserver.assertNotComplete();
    activity.onResume();
    testObserver.assertNotComplete();
    activity.onPause();
    testObserver.assertNotComplete();
    activity.onStop();
    testObserver.assertComplete();
}
 
开发者ID:xufreshman,项目名称:RxLifeCycle,代码行数:20,代码来源:NaviActivityLifecycleTest.java

示例12: testLeakFree

import com.trello.rxlifecycle2.android.ActivityEvent; //导入依赖的package包/类
@Test
public void testLeakFree() {
    NaviEmitter activity = NaviEmitter.createActivityEmitter();
    LifecycleProvider<ActivityEvent> provider = NaviLifecycle.createActivityLifecycleProvider(activity);
    WeakReference<NaviEmitter> activityRef = new WeakReference<>(activity);
    WeakReference<LifecycleProvider<ActivityEvent>> providerRef = new WeakReference<>(provider);

    Observable<Object> observable = PublishSubject.create().hide();
    TestObserver<Object> testObserver = observable.compose(provider.bindUntilEvent(ActivityEvent.STOP)).test();

    activity.onCreate(null);
    activity.onStart();
    activity.onResume();
    activity.onPause();
    activity.onStop();
    activity.onDestroy();

    activity = null;
    provider = null;
    TestUtil.cleanGarbage();

    assertNull(activityRef.get());
    assertNull(providerRef.get());
}
 
开发者ID:xufreshman,项目名称:RxLifeCycle,代码行数:25,代码来源:NaviActivityLifecycleTest.java

示例13: testLifecycle

import com.trello.rxlifecycle2.android.ActivityEvent; //导入依赖的package包/类
private void testLifecycle(ActivityController<? extends LifecycleProvider<ActivityEvent>> controller) {
    LifecycleProvider<ActivityEvent> activity = controller.get();

    TestObserver<ActivityEvent> testObserver = activity.lifecycle().test();

    controller.create();
    controller.start();
    controller.resume();
    controller.pause();
    controller.stop();
    controller.destroy();

    testObserver.assertValues(
        ActivityEvent.CREATE,
        ActivityEvent.START,
        ActivityEvent.RESUME,
        ActivityEvent.PAUSE,
        ActivityEvent.STOP,
        ActivityEvent.DESTROY
    );
}
 
开发者ID:xufreshman,项目名称:RxLifeCycle,代码行数:22,代码来源:RxActivityLifecycleTest.java

示例14: testBindUntilEvent

import com.trello.rxlifecycle2.android.ActivityEvent; //导入依赖的package包/类
private void testBindUntilEvent(ActivityController<? extends LifecycleProvider<ActivityEvent>> controller) {
    LifecycleProvider<ActivityEvent> activity = controller.get();

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

    controller.create();
    testObserver.assertNotComplete();
    controller.start();
    testObserver.assertNotComplete();
    controller.resume();
    testObserver.assertNotComplete();
    controller.pause();
    testObserver.assertNotComplete();
    controller.stop();
    testObserver.assertComplete();
}
 
开发者ID:xufreshman,项目名称:RxLifeCycle,代码行数:17,代码来源:RxActivityLifecycleTest.java

示例15: testBindUntilActivityEvent

import com.trello.rxlifecycle2.android.ActivityEvent; //导入依赖的package包/类
@Test
public void testBindUntilActivityEvent() {
    BehaviorSubject<ActivityEvent> lifecycle = BehaviorSubject.create();

    TestObserver<Object> testObserver =
        observable.compose(RxLifecycle.bindUntilEvent(lifecycle, ActivityEvent.STOP)).test();

    lifecycle.onNext(ActivityEvent.CREATE);
    testObserver.assertNotComplete();
    lifecycle.onNext(ActivityEvent.START);
    testObserver.assertNotComplete();
    lifecycle.onNext(ActivityEvent.RESUME);
    testObserver.assertNotComplete();
    lifecycle.onNext(ActivityEvent.PAUSE);
    testObserver.assertNotComplete();
    lifecycle.onNext(ActivityEvent.STOP);
    testObserver.assertComplete();
}
 
开发者ID:xufreshman,项目名称:RxLifeCycle,代码行数:19,代码来源:RxLifecycleTest.java


注:本文中的com.trello.rxlifecycle2.android.ActivityEvent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。