Commit e86dea51 by 段启岩

优化刷新

parent 0d5603d1
......@@ -19,6 +19,7 @@ import java.util.List;
import javax.inject.Inject;
import cn.yunliyunwai.beyondclouds.R;
import cn.yunliyunwai.beyondclouds.base.BaseFragment;
import cn.yunliyunwai.beyondclouds.data.model.CommonCategory;
import cn.yunliyunwai.beyondclouds.databinding.SwipeRefreshListBinding;
......@@ -27,6 +28,7 @@ import cn.yunliyunwai.beyondclouds.viewmodel.common.PageableViewModel;
public abstract class RefreshableFragment<T, VM extends PageableViewModel<T>> extends BaseFragment<VM, SwipeRefreshListBinding> implements SwipeRefreshLayout.OnRefreshListener {
private boolean isRefreshing;
public interface Factory {
<T, VM extends PageableViewModel<T>> RefreshableFragment<T, VM> create();
......@@ -85,6 +87,7 @@ public abstract class RefreshableFragment<T, VM extends PageableViewModel<T>> ex
break;
}
binding.swipeRefreshLayout.setRefreshing(false);
isRefreshing = false;
}
});
recyclerViewAdapter.setLoadMoreView(new CustomLoadMoreView());
......@@ -96,6 +99,10 @@ public abstract class RefreshableFragment<T, VM extends PageableViewModel<T>> ex
}, binding.recyclerView);
binding.recyclerView.setAdapter(recyclerViewAdapter);
binding.swipeRefreshLayout.setColorSchemeColors(
getContext().getResources().getColor(R.color.colorPrimary),
getContext().getResources().getColor(R.color.colorAccent));
binding.swipeRefreshLayout.setOnRefreshListener(this);
}
......@@ -109,8 +116,11 @@ public abstract class RefreshableFragment<T, VM extends PageableViewModel<T>> ex
@Override
public void onRefresh() {
binding.swipeRefreshLayout.setRefreshing(true);
viewModel.loadFirstPage(category);
if (!isRefreshing) {
binding.swipeRefreshLayout.setRefreshing(true);
viewModel.loadFirstPage(category);
isRefreshing = true;
}
}
public void scrollToTop() {
......
......@@ -13,6 +13,7 @@
<ProgressBar
android:id="@+id/pb_footer"
android:indeterminateTint="@color/colorPrimary"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginLeft="16dp"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment