GridLayoutManager 布局自滚动
并且根据外层宽度自动计算item行数 不需要 isLayout 设置为false
public class LjGridLayoutManager extends GridLayoutManager {
private static final String TAG = LjGridLayoutManager.class.getName();
private final Handler handler = new Handler();
private RecyclerView recyclerView;
private boolean isLayout = true; //是否自动计算子布局数
private boolean isPageUp = true; //是否自动翻页
//private int pageUpTime = 12 * 1000;//翻页间隔时间
public LjGridLayoutManager(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
public LjGridLayoutManager(Context context, int spanCount) {
super(context, spanCount);
}
public LjGridLayoutManager(Context context, int spanCount, int orientation, boolean reverseLayout) {
super(context, spanCount, orientation, reverseLayout);
}
public void setLayout(boolean layout) {
isLayout = layout;
}
public void setPageUp(boolean pageUp) {
isPageUp = pageUp;
if (!isPageUp && pageUp) {
startPageUp();
}
}
// public void setPageUpTime(int pageUpTime) {
// this.pageUpTime = pageUpTime;
// }
private void startPageUp() {
handler.removeCallbacks(pageUpRunnable);
handler.postDelayed(pageUpRunnable, App.getAppConfig().getPageUpSecondMilli());
}
@Override
public void onItemsChanged(RecyclerView recyclerView) {
super.onItemsChanged(recyclerView);
this.recyclerView = recyclerView;
startPageUp();
}
private Runnable pageUpRunnable = new Runnable() {
@Override
public void run() {