Android: reset align to iOS implement

This commit is contained in:
pengfei.zhou 2021-11-03 13:42:24 +08:00 committed by osborn
parent 02ca1e5081
commit a257f8e8f7
10 changed files with 19 additions and 14 deletions

View File

@ -265,7 +265,7 @@ public class ScrollerNode extends SuperNode<HVScrollView> implements IDoricScrol
}
@Override
protected void reset() {
public void reset() {
super.reset();
onScrollFuncId = null;
onScrollEndFuncId = null;

View File

@ -150,4 +150,15 @@ public abstract class SuperNode<V extends View> extends ViewNode<V> {
return allKeys;
}
@Override
public void reset() {
super.reset();
for (String viewId : subNodes.keySet()) {
ViewNode<?> viewNode = getSubNodeById(viewId);
if (viewNode != null) {
viewNode.reset();
}
}
}
}

View File

@ -144,9 +144,6 @@ public abstract class ViewNode<T extends View> extends DoricContextHolder {
protected abstract T build();
public void blend(JSObject jsObject) {
if (mSuperNode != null && mSuperNode.mReusable) {
reset();
}
if (jsObject != null) {
JSValue value = jsObject.getProperty("layoutConfig");
if (value.isObject()) {

View File

@ -67,6 +67,7 @@ class FlowAdapter extends RecyclerView.Adapter<FlowAdapter.DoricViewHolder> {
JSObject jsObject = jsValue.asObject();
holder.flowLayoutItemNode.setId(jsObject.getProperty("id").asString().value());
JSObject props = jsObject.getProperty("props").asObject();
holder.flowLayoutItemNode.reset();
holder.flowLayoutItemNode.blend(props);
JSValue fullSpanValue = props.getProperty("fullSpan");
if (fullSpanValue.isBoolean()) {

View File

@ -20,7 +20,6 @@ import android.text.TextUtils;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
@ -30,11 +29,8 @@ import com.github.pengfeizhou.jscore.JSObject;
import com.github.pengfeizhou.jscore.JSValue;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.concurrent.Callable;
@ -385,7 +381,7 @@ public class FlowLayoutNode extends SuperNode<RecyclerView> implements IDoricScr
}
@Override
protected void reset() {
public void reset() {
super.reset();
scrollable = true;
loadMore = false;

View File

@ -63,6 +63,7 @@ class ListAdapter extends RecyclerView.Adapter<ListAdapter.DoricViewHolder> {
if (jsValue != null && jsValue.isObject()) {
JSObject jsObject = jsValue.asObject();
holder.listItemNode.setId(jsObject.getProperty("id").asString().value());
holder.listItemNode.reset();
holder.listItemNode.blend(jsObject.getProperty("props").asObject());
}
if (this.listNode.loadMore

View File

@ -26,7 +26,6 @@ import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.github.pengfeizhou.jscore.JSArray;
import com.github.pengfeizhou.jscore.JSDecoder;
import com.github.pengfeizhou.jscore.JSNumber;
import com.github.pengfeizhou.jscore.JSONBuilder;
@ -34,7 +33,6 @@ import com.github.pengfeizhou.jscore.JSObject;
import com.github.pengfeizhou.jscore.JSValue;
import org.json.JSONArray;
import org.json.JSONObject;
import java.util.HashSet;
import java.util.Set;
@ -350,7 +348,7 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
}
@Override
protected void reset() {
public void reset() {
super.reset();
scrollable = true;
loadMore = false;

View File

@ -254,7 +254,7 @@ public class NestedSliderNode extends GroupNode<ViewPager> implements ViewPager.
}
@Override
protected void reset() {
public void reset() {
super.reset();
onPageSlidedFuncId = null;
((CustomViewPager) mView).setScrollable(true);

View File

@ -65,6 +65,7 @@ class SlideAdapter extends RecyclerView.Adapter<SlideAdapter.DoricViewHolder> {
if (jsValue != null && jsValue.isObject()) {
JSObject jsObject = jsValue.asObject();
holder.slideItemNode.setId(jsObject.getProperty("id").asString().value());
holder.slideItemNode.reset();
holder.slideItemNode.blend(jsObject.getProperty("props").asObject());
}
}

View File

@ -250,7 +250,7 @@ public class SliderNode extends SuperNode<RecyclerView> {
}
@Override
protected void reset() {
public void reset() {
super.reset();
scrollable = true;
onPageSlidedFuncId = null;