本文整理汇总了Java中com.trello.rxlifecycle.android.RxLifecycleAndroid类的典型用法代码示例。如果您正苦于以下问题:Java RxLifecycleAndroid类的具体用法?Java RxLifecycleAndroid怎么用?Java RxLifecycleAndroid使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RxLifecycleAndroid类属于com.trello.rxlifecycle.android包,在下文中一共展示了RxLifecycleAndroid类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.trello.rxlifecycle.android.RxLifecycleAndroid; //导入依赖的package包/类
@Override protected void onCreate(Bundle savedInstanceState) {
AndroidInjection.inject(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
ButterKnife.bind(this);
setSupportActionBar(mToolbar);
getDelegate().getSupportActionBar().setDisplayHomeAsUpEnabled(true);
mToolbar.setNavigationOnClickListener(v -> onBackPressed());
getSupportFragmentManager().beginTransaction()
.replace(R.id.container_fragment_settings, new SettingsFragment())
.commit();
mNightModePreference.asObservable()
.skip(1)
.compose(RxLifecycleAndroid.bindActivity(lifecycle()))
.subscribe(mode -> recreate());
}
示例2: onStart
import com.trello.rxlifecycle.android.RxLifecycleAndroid; //导入依赖的package包/类
@Override
protected void onStart() {
super.onStart();
// schedule a sync operation every minute
Observable.interval(0, 1, TimeUnit.MINUTES, mainThread())
.compose(RxLifecycleAndroid.bindActivity(lifecycle()))
.subscribe(event -> SyncBroadcastReceiver.syncNow(MainActivity.this));
}
示例3: onAttachedToRecyclerView
import com.trello.rxlifecycle.android.RxLifecycleAndroid; //导入依赖的package包/类
/**
* Attaches source {@link Observable} subscription lifecycle.<p>
* Should be called from {@link Adapter#onAttachedToRecyclerView(RecyclerView)}
*
* @param recyclerView to bind source {@link Observable} to
*/
public final void onAttachedToRecyclerView(RecyclerView recyclerView) {
if (subscription != null) unsubscribe();
subscription = bindObservable()
.observeOn(AndroidSchedulers.mainThread())
.compose(RxLifecycleAndroid.<O>bindView(recyclerView))
.subscribe(subscriber());
}
示例4: getPhotos
import com.trello.rxlifecycle.android.RxLifecycleAndroid; //导入依赖的package包/类
public void getPhotos() {
Timber.d("Starting loading local photos...");
checkViewAttached();
RxUtils.unsubscribe(mLoadPhotosSubscription);
mLoadPhotosSubscription = mDataManager.getPhotos()
.compose(RxLifecycleAndroid.bindActivity(getMvpView().getLifecycle()))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
this::showPhotos,
this::showError
);
}
示例5: syncPhotos
import com.trello.rxlifecycle.android.RxLifecycleAndroid; //导入依赖的package包/类
public void syncPhotos() {
Timber.d("Starting loading remote photos...");
checkViewAttached();
if (checkNetwork()) {
RxUtils.unsubscribe(mLoadPhotosSubscription);
mLoadPhotosSubscription = mDataManager.syncPhotos()
.compose(RxLifecycleAndroid.bindActivity(getMvpView().getLifecycle()))
.observeOn(AndroidSchedulers.mainThread())
.subscribe(
this::showPhotos,
this::showError
);
}
}
示例6: bindToLifecycle
import com.trello.rxlifecycle.android.RxLifecycleAndroid; //导入依赖的package包/类
@NonNull
public final <T> LifecycleTransformer<T> bindToLifecycle() {
if (view != null) {
return RxLifecycleAndroid.bindView(view);
}
throw new IllegalStateException("No view attached");
}
示例7: bindActivity
import com.trello.rxlifecycle.android.RxLifecycleAndroid; //导入依赖的package包/类
@NonNull
@CheckResult
public static <T> LifecycleTransformer2x<T> bindActivity(
@NonNull final Observable<ActivityEvent> lifecycle,
@NonNull final BackpressureStrategy strategy) {
LifecycleTransformer<T> rxTransformer =
RxLifecycleAndroid.bindActivity(RxJavaInterop.toV1Observable(lifecycle, strategy));
return new LifecycleTransformer2xBehaviour<>(rxTransformer, rxTransformer.forSingle(),
strategy);
}
示例8: bindFragment
import com.trello.rxlifecycle.android.RxLifecycleAndroid; //导入依赖的package包/类
@NonNull
@CheckResult
public static <T> LifecycleTransformer2x<T> bindFragment(
@NonNull final Observable<FragmentEvent> lifecycle,
@NonNull final BackpressureStrategy strategy) {
LifecycleTransformer<T> rxTransformer =
RxLifecycleAndroid.bindFragment(RxJavaInterop.toV1Observable(lifecycle, strategy));
return new LifecycleTransformer2xBehaviour<>(rxTransformer, rxTransformer.forSingle(),
strategy);
}
示例9: onCreate
import com.trello.rxlifecycle.android.RxLifecycleAndroid; //导入依赖的package包/类
@Override protected void onCreate(Bundle savedInstanceState) {
AndroidInjection.inject(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_appwidget_config);
ButterKnife.bind(this);
setupToolbar();
Intent intent = getIntent();
Bundle extras = intent.getExtras();
if (extras != null) {
mAppWidgetId =
extras.getInt(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
}
mResultIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, mAppWidgetId);
setResult(mResult, mResultIntent);
if (mAppWidgetId == AppWidgetManager.INVALID_APPWIDGET_ID) {
finish();
}
getSupportFragmentManager().beginTransaction()
.replace(R.id.container_fragment_settings,
AppWidgetConfigFragment.newInstance(mAppWidgetId))
.commit();
mNightModePreference.asObservable()
.skip(1)
.compose(RxLifecycleAndroid.bindActivity(lifecycle()))
.subscribe(mode -> recreate());
}
示例10: onCreate
import com.trello.rxlifecycle.android.RxLifecycleAndroid; //导入依赖的package包/类
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(getLayoutRes());
ButterKnife.bind(this);
if (!mIsFamEnabled) {
mFloatingActionMenu.setVisibility(View.GONE);
}
mFloatingActionMenu.getBackground().setAlpha(0);
addStorageFragment();
setupNavigationView();
mDrawerPresenter.attachView(this);
mDrawerPresenter.onCreate();
mSchedulePresenter.attachView(this);
if (savedInstanceState == null) {
mSchedulePresenter.setSyncId(mSyncIdPreference.get(), mIsGroupSchedulePreference.get());
RateAppDialog.newInstance(this).show();
} else {
showContent();
}
mLocalBroadcastManager = LocalBroadcastManager.getInstance(this);
initializeAnimations();
mNightModePreference.asObservable()
.skip(1)
.compose(RxLifecycleAndroid.bindActivity(lifecycle()))
.subscribe(mode -> recreate());
}
示例11: onCreate
import com.trello.rxlifecycle.android.RxLifecycleAndroid; //导入依赖的package包/类
@Override protected void onCreate(Bundle savedInstanceState) {
AndroidInjection.inject(this);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lesson);
ButterKnife.bind(this);
setupToolbar();
Lesson lesson = Parcels.unwrap(getIntent().getParcelableExtra(EXTRA_LESSON));
getDelegate().getSupportActionBar().setTitle(lesson.getSubjectWithSubgroup());
getDelegate().getSupportActionBar().setSubtitle(lesson.getLessonType());
mAdapter = new DetailItemAdapter(this, new ArrayList<>());
mRecyclerView.setAdapter(mAdapter);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.addItemDecoration(new DetailItemDecoration(this));
mPresenter.attachView(this);
mPresenter.setLesson(lesson);
mNightModePreference.asObservable()
.skip(1)
.compose(RxLifecycleAndroid.bindActivity(lifecycle()))
.subscribe(mode -> recreate());
}
示例12: onCreate
import com.trello.rxlifecycle.android.RxLifecycleAndroid; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
setTheme(theme().translucentStatus);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Bitmap icon = BitmapFactory.decodeResource(getApplicationContext().getResources(),
R.drawable.ic_stat_name);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
setTaskDescription(
new ActivityManager.TaskDescription(
"Burning Series",
icon,
getApplicationContext().getResources().getColor(theme().primaryColor)
));
}
setSupportActionBar(toolbar);
if (getApplicationContext().getResources().getBoolean(R.bool.isTablet))
isTablet = true;
Settings settings = Settings.of(this);
userName = settings.getUserName();
userSession = settings.getUserSession();
navigationView.setNavigationItemSelectedListener(this);
if (!isTablet) {
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
toggle.syncState();
}
//Update check
Observable.just(null)
.delay(10, TimeUnit.SECONDS, mainThread())
.compose(RxLifecycleAndroid.bindActivity(lifecycle()))
.subscribe(o -> UpdateDialog.checkForUpdates(MainActivity.this, false));
TextView userTextView = (TextView) navigationView.getHeaderView(0).findViewById(R.id.nav_username_text);
userTextView.setText(userName);
if (userSession.equals("")) {
Crashlytics.setUserIdentifier(userName);
navigationView.getMenu().findItem(R.id.login_menu_item).setVisible(true);
navigationView.getMenu().findItem(R.id.logout_menu_item).setVisible(false);
} else {
navigationView.getMenu().findItem(R.id.login_menu_item).setVisible(false);
navigationView.getMenu().findItem(R.id.logout_menu_item).setVisible(true);
}
}
示例13: bindToLifecycle
import com.trello.rxlifecycle.android.RxLifecycleAndroid; //导入依赖的package包/类
@Override
@NonNull
@CheckResult
public final <T> LifecycleTransformer<T> bindToLifecycle() {
return RxLifecycleAndroid.bindActivity(lifecycleSubject);
}
示例14: bindToLifecycle
import com.trello.rxlifecycle.android.RxLifecycleAndroid; //导入依赖的package包/类
@Override
@NonNull
@CheckResult
public final <T> LifecycleTransformer<T> bindToLifecycle() {
return RxLifecycleAndroid.bindFragment(lifecycleSubject);
}
示例15: bindToLifecycle
import com.trello.rxlifecycle.android.RxLifecycleAndroid; //导入依赖的package包/类
@Override
@NonNull
@CheckResult
public final <T> LifecycleTransformer<T> bindToLifecycle() {
return RxLifecycleAndroid.bindFragment(fragmentLifecycleEvent);
}