|
@@ -6,6 +6,7 @@ import androidx.recyclerview.widget.RecyclerView;
|
|
|
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
|
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
|
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
|
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
|
|
|
|
|
|
|
|
|
+import com.bumptech.glide.Glide;
|
|
|
import com.miekir.common.utils.ToastTool;
|
|
import com.miekir.common.utils.ToastTool;
|
|
|
import com.miekir.eden.R;
|
|
import com.miekir.eden.R;
|
|
|
import com.miekir.eden.base.ITopActionListener;
|
|
import com.miekir.eden.base.ITopActionListener;
|
|
@@ -67,6 +68,8 @@ public class TemplateFragment extends BaseMVPFragment implements ITemplateView<S
|
|
|
rv_template = rootView.findViewById(R.id.rv_template);
|
|
rv_template = rootView.findViewById(R.id.rv_template);
|
|
|
// 瀑布流。必须要设置LayoutManager,否则RecyclerView不知道要使用什么布局,从而在界面上不显示
|
|
// 瀑布流。必须要设置LayoutManager,否则RecyclerView不知道要使用什么布局,从而在界面上不显示
|
|
|
mLayoutManager = new StaggeredGridLayoutManager(SPAN_COUNT, StaggeredGridLayoutManager.VERTICAL);
|
|
mLayoutManager = new StaggeredGridLayoutManager(SPAN_COUNT, StaggeredGridLayoutManager.VERTICAL);
|
|
|
|
|
+ // 防止瀑布流图片位置变来变去
|
|
|
|
|
+ mLayoutManager.setGapStrategy(StaggeredGridLayoutManager.GAP_HANDLING_NONE);
|
|
|
rv_template.setLayoutManager(mLayoutManager);
|
|
rv_template.setLayoutManager(mLayoutManager);
|
|
|
|
|
|
|
|
// 分割线
|
|
// 分割线
|
|
@@ -96,6 +99,26 @@ public class TemplateFragment extends BaseMVPFragment implements ITemplateView<S
|
|
|
|
|
|
|
|
// 加载更多
|
|
// 加载更多
|
|
|
rv_template.addOnScrollListener(new OnRcvScrollListener() {
|
|
rv_template.addOnScrollListener(new OnRcvScrollListener() {
|
|
|
|
|
+ // 滑动时不要去加载图片
|
|
|
|
|
+ //RecyclerView.SCROLL_STATE_IDLE //空闲状态
|
|
|
|
|
+ //RecyclerView.SCROLL_STATE_FLING //滚动状态
|
|
|
|
|
+ //RecyclerView.SCROLL_STATE_TOUCH_SCROLL //触摸后状态
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void onScrollStateChanged(RecyclerView recyclerView, int newState) {
|
|
|
|
|
+ super.onScrollStateChanged(recyclerView, newState);
|
|
|
|
|
+ if (getActivity() == null) {
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
|
|
|
|
+ //恢复Glide加载图片
|
|
|
|
|
+ Glide.with(getActivity()).resumeRequests();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ //禁止Glide加载图片
|
|
|
|
|
+ Glide.with(getActivity()).pauseRequests();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public void onBottom() {
|
|
public void onBottom() {
|
|
|
super.onBottom();
|
|
super.onBottom();
|