Skip to content

Commit

Permalink
optimize WanFindFragment
Browse files Browse the repository at this point in the history
  • Loading branch information
youlookwhat committed Feb 29, 2020
1 parent ce76416 commit eb6aa86
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ public static NavigationFragment newInstance() {
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
initRefreshView();

// 准备就绪
mIsPrepared = true;
Expand All @@ -73,6 +72,7 @@ protected void loadData() {
return;
}
showLoading();
initRefreshView();
viewModel.getNavigationJson();
mIsFirst = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public static TreeFragment newInstance() {
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
initRefreshView();
// 准备就绪
mIsPrepared = true;
/**
Expand Down Expand Up @@ -118,6 +117,7 @@ protected void loadData() {
return;
}
showLoading();
initRefreshView();
bindingView.srlWan.postDelayed(this::getTree, 150);
mIsFirst = false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import com.example.jingbin.cloudreader.utils.RefreshHelper;
import com.example.jingbin.cloudreader.utils.SPUtils;
import com.example.jingbin.cloudreader.utils.ToastUtil;
import com.example.jingbin.cloudreader.viewmodel.wan.WxArticleViewModel;
import com.example.jingbin.cloudreader.viewmodel.wan.WanFindViewModel;

import java.util.List;

Expand All @@ -35,7 +35,7 @@
* @date 2019/9/29.
* @description 发现订制
*/
public class WanFindFragment extends BaseFragment<WxArticleViewModel, FragmentWanFindBinding> {
public class WanFindFragment extends BaseFragment<WanFindViewModel, FragmentWanFindBinding> {

private boolean mIsPrepared;
private boolean mIsFirst = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
* @Description wanandroid公众号的ViewModel
*/

public class WxArticleViewModel extends BaseListViewModel {
public class WanFindViewModel extends BaseListViewModel {

// content数据
private final MutableLiveData<List<ArticlesBean>> data = new MutableLiveData<>();
Expand All @@ -42,7 +42,7 @@ public MutableLiveData<List<WxarticleItemBean>> getDataTitle() {
return dataTitle;
}

public WxArticleViewModel(@NonNull Application application) {
public WanFindViewModel(@NonNull Application application) {
super(application);
mPage = 1;
}
Expand Down Expand Up @@ -113,6 +113,8 @@ public boolean handleCustomData(TreeBean treeBean, int position) {
dataTitle.setValue(treeBean.getData().get(position).getChildren());
return true;
} else {
// 如果缓存失效清掉position值
SPUtils.remove(Constants.FIND_POSITION);
return false;
}
}
Expand Down

0 comments on commit eb6aa86

Please sign in to comment.