我创建了一个Activity
,其中包含ViewPager
四个Fragment
。我正试图从realm
中加载每个不同的fragment
中的用户数据。我想在切换tab
或Fragment
时保存用户数据。 我正在加载数据在@AfterViews
或onViewCreated
。试图将数据保存在onDestroyView
中executeTransactionAsync
。保存并从碎片生命周期中检索领域数据?
问题尝试切换tab
时,tab indicator
滑动非常缓慢并伴有暂停。如果我从onDestroyView
中删除代码executeTransactionAsync
,那么tab indicator
平滑滑动。
我想看到的是tab indicator
在尝试切换片段时滑动减慢。
更新1onDestroy
@Override
public void onDestroy() {
Timber.d("onDestroy() called");
super.onDestroy();
// Do not send event after activity or fragment has been destroyed
mCompositeDisposable.clear();
RefWatcher refWatcher =
MyApplication.getRefWatcher(getActivity());
refWatcher.watch(this);
}
您在片段中显示此数据? –
@RodrigoGontijo我在ViewPager中的Fragment中显示这些数据。 –
请发布您的onDestroy和任何其他相关的代码。 –