Android: fix listItem cannot be animated

This commit is contained in:
pengfei.zhou 2021-12-03 17:33:07 +08:00 committed by osborn
parent 094a0936b9
commit c3093d9ff2
3 changed files with 39 additions and 34 deletions

View File

@ -236,14 +236,16 @@ public class FlowLayoutNode extends SuperNode<RecyclerView> implements IDoricScr
padding.top - rowSpace / 2, padding.top - rowSpace / 2,
padding.right - columnSpace / 2, padding.right - columnSpace / 2,
padding.bottom - rowSpace / 2); padding.bottom - rowSpace / 2);
if (mView != null) { if (jsObject.propertySet().size() > 1 || !jsObject.propertySet().contains("subviews")) {
mView.post(new Runnable() { if (mView != null) {
@Override mView.post(new Runnable() {
public void run() { @Override
flowAdapter.itemCount = itemCount; public void run() {
flowAdapter.notifyDataSetChanged(); flowAdapter.itemCount = itemCount;
} flowAdapter.notifyDataSetChanged();
}); }
});
}
} }
} }

View File

@ -168,16 +168,19 @@ public class ListNode extends SuperNode<RecyclerView> implements IDoricScrollabl
@Override @Override
public void blend(JSObject jsObject) { public void blend(JSObject jsObject) {
super.blend(jsObject); super.blend(jsObject);
if (mView != null) { if (jsObject.propertySet().size() > 1 || !jsObject.propertySet().contains("subviews")) {
mView.post(new Runnable() { if (mView != null) {
@SuppressLint("NotifyDataSetChanged") mView.post(new Runnable() {
@Override @SuppressLint("NotifyDataSetChanged")
public void run() { @Override
listAdapter.itemCount = itemCount; public void run() {
listAdapter.notifyDataSetChanged(); listAdapter.itemCount = itemCount;
} listAdapter.notifyDataSetChanged();
}); }
});
}
} }
} }
@Override @Override

View File

@ -162,24 +162,24 @@ public class SliderNode extends SuperNode<RecyclerView> {
} }
slideAdapter.loop = loop; slideAdapter.loop = loop;
if (jsObject.propertySet().size() > 1 || !jsObject.propertySet().contains("subviews")) {
if (mView != null) { if (mView != null) {
mView.post(new Runnable() { mView.post(new Runnable() {
@Override @Override
public void run() { public void run() {
slideAdapter.itemCount = itemCount; slideAdapter.itemCount = itemCount;
slideAdapter.notifyDataSetChanged(); slideAdapter.notifyDataSetChanged();
if (needToScroll) {
if (needToScroll) { mView.post(new Runnable() {
mView.post(new Runnable() { @Override
@Override public void run() {
public void run() { mView.scrollToPosition(1);
mView.scrollToPosition(1); }
} });
}); }
} }
} });
}); }
} }
} }