feat:fix nested slider

This commit is contained in:
pengfei.zhou 2019-12-07 11:08:34 +08:00
parent a2be39dbe3
commit 84e8a6e86d
4 changed files with 43 additions and 12 deletions

View File

@ -16,6 +16,8 @@
package pub.doric.shader.flowlayout; package pub.doric.shader.flowlayout;
import android.graphics.Rect; import android.graphics.Rect;
import android.os.SystemClock;
import android.view.MotionEvent;
import android.view.View; import android.view.View;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
@ -41,7 +43,26 @@ public class FlowLayoutNode extends SuperNode<RecyclerView> {
private final FlowAdapter flowAdapter; private final FlowAdapter flowAdapter;
private final StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager( private final StaggeredGridLayoutManager staggeredGridLayoutManager = new StaggeredGridLayoutManager(
2, 2,
StaggeredGridLayoutManager.VERTICAL); StaggeredGridLayoutManager.VERTICAL) {
@Override
public int scrollVerticallyBy(int dy, RecyclerView.Recycler recycler, RecyclerView.State state) {
try {
return super.scrollVerticallyBy(dy, recycler, state);
} catch (Exception e) {
e.printStackTrace();
return 0;
}
}
@Override
public void onScrollStateChanged(int state) {
try {
super.onScrollStateChanged(state);
} catch (Exception e) {
e.printStackTrace();
}
}
};
private int columnSpace = 0; private int columnSpace = 0;
private int rowSpace = 0; private int rowSpace = 0;
private Rect padding = new Rect(); private Rect padding = new Rect();
@ -92,10 +113,13 @@ public class FlowLayoutNode extends SuperNode<RecyclerView> {
this.flowAdapter.itemCount = prop.asNumber().toInt(); this.flowAdapter.itemCount = prop.asNumber().toInt();
break; break;
case "renderItem": case "renderItem":
this.flowAdapter.renderItemFuncId = prop.asString().value(); String funcId = prop.asString().value();
// If reset renderItem,should reset native cache. if (!funcId.equals(this.flowAdapter.renderItemFuncId)) {
this.flowAdapter.itemValues.clear(); this.flowAdapter.renderItemFuncId = funcId;
clearSubModel(); // If reset renderItem,should reset native cache.
this.flowAdapter.itemValues.clear();
clearSubModel();
}
break; break;
case "batchCount": case "batchCount":
this.flowAdapter.batchCount = prop.asNumber().toInt(); this.flowAdapter.batchCount = prop.asNumber().toInt();

View File

@ -85,10 +85,13 @@ public class ListNode extends SuperNode<RecyclerView> {
this.listAdapter.itemCount = prop.asNumber().toInt(); this.listAdapter.itemCount = prop.asNumber().toInt();
break; break;
case "renderItem": case "renderItem":
this.listAdapter.renderItemFuncId = prop.asString().value(); String funcId = prop.asString().value();
// If reset renderItem,should reset native cache. if (!funcId.equals(this.listAdapter.renderItemFuncId)) {
this.listAdapter.itemValues.clear(); this.listAdapter.renderItemFuncId = funcId;
clearSubModel(); // If reset renderItem,should reset native cache.
this.listAdapter.itemValues.clear();
clearSubModel();
}
break; break;
case "batchCount": case "batchCount":
this.listAdapter.batchCount = prop.asNumber().toInt(); this.listAdapter.batchCount = prop.asNumber().toInt();

View File

@ -43,7 +43,7 @@ class SlideAdapter extends RecyclerView.Adapter<SlideAdapter.DoricViewHolder> {
int itemCount = 0; int itemCount = 0;
int batchCount = 3; int batchCount = 3;
SparseArray<String> itemValues = new SparseArray<>(); SparseArray<String> itemValues = new SparseArray<>();
String renderPageFuncId;
SlideAdapter(SliderNode sliderNode) { SlideAdapter(SliderNode sliderNode) {
this.sliderNode = sliderNode; this.sliderNode = sliderNode;
} }

View File

@ -137,8 +137,12 @@ public class SliderNode extends SuperNode<RecyclerView> {
break; break;
case "renderPage": case "renderPage":
// If reset renderItem,should reset native cache. // If reset renderItem,should reset native cache.
this.slideAdapter.itemValues.clear(); String funcId = prop.asString().value();
clearSubModel(); if (!funcId.equals(this.slideAdapter.renderPageFuncId)) {
this.slideAdapter.itemValues.clear();
clearSubModel();
this.slideAdapter.renderPageFuncId = funcId;
}
break; break;
case "batchCount": case "batchCount":
this.slideAdapter.batchCount = prop.asNumber().toInt(); this.slideAdapter.batchCount = prop.asNumber().toInt();