fire node
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/699da8f6 Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/699da8f6 Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/699da8f6 Branch: refs/heads/0.16-dev Commit: 699da8f611d9f2eb790cee2df4f9a89c555e0ab9 Parents: 08abc8c Author: jianbai.gbj <jianbai....@alibaba-inc.com> Authored: Wed Sep 20 21:07:17 2017 +0800 Committer: jianbai.gbj <jianbai....@alibaba-inc.com> Committed: Wed Sep 20 21:07:17 2017 +0800 ---------------------------------------------------------------------- .../list/template/CellLifecycleManager.java | 22 ++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/699da8f6/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/CellLifecycleManager.java ---------------------------------------------------------------------- diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/CellLifecycleManager.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/CellLifecycleManager.java index 2f54f9e..80880c2 100644 --- a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/CellLifecycleManager.java +++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/template/CellLifecycleManager.java @@ -125,9 +125,8 @@ public class CellLifecycleManager { || slotWatchAttachRefs.get(cell.getRef()).size() == 0){ return; } - Map<String, Object> params = new HashMap<>(8); - params.put("position", position); - cell.fireEvent(Constants.Event.SLOT_LIFECYCLE.ATTACH, params); + List<String> refs = slotWatchAttachRefs.get(cell.getRef()); + fireChildEvent(Constants.Event.SLOT_LIFECYCLE.ATTACH, cell, refs, position); } /** @@ -143,9 +142,8 @@ public class CellLifecycleManager { || slotWatchDetachRefs.get(cell.getRef()).size() == 0){ return; } - Map<String, Object> params = new HashMap<>(8); - params.put("position", position); - cell.fireEvent(Constants.Event.SLOT_LIFECYCLE.DETACH, params); + List<String> refs = slotWatchDetachRefs.get(cell.getRef()); + fireChildEvent(Constants.Event.SLOT_LIFECYCLE.DETACH, cell, refs, position); } /** @@ -174,4 +172,16 @@ public class CellLifecycleManager { } eventSlotWatchRefs.clear(); } + + private final void fireChildEvent(String event, WXCell cell, List<String> refs, int position){ + for(String ref : refs){ + WXComponent component = recyclerTemplateList.findChildByRef(cell, ref); + if(component == null){ + continue; + } + Map<String, Object> params = new HashMap<>(8); + params.put("position", position); + component.fireEvent(event, params); + } + } }