Skip to content

Commit

Permalink
fix(android): recycle view event use low case name
Browse files Browse the repository at this point in the history
  • Loading branch information
siguangli2018 authored and zealotchen0 committed Jul 25, 2023
1 parent f02c1a7 commit a4f4cde
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ private View findViewFromPool(int rootId, int id, String className, PoolType poo
}
}

@SuppressWarnings({"rawtypes", "unchecked"})
@Nullable
public View createView(@NonNull RenderNode node, PoolType cachePoolType) {
final int rootId = node.getRootId();
Expand Down Expand Up @@ -325,6 +324,9 @@ public void updateProps(@NonNull RenderNode node, @Nullable Map<String, Object>
mControllerUpdateManger.updateProps(node, controller, view, total, skipComponentProps);
if (view != null) {
controller.onAfterUpdateProps(view);
// The purpose of calling the update events interface separately here is to
// handle those event that are not registered by controller annotation.
controller.updateEvents(view, events);
}
node.setNodeFlag(FLAG_ALREADY_UPDATED);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ public void onAfterUpdateProps(@NonNull T view) {
view.invalidate();
}

protected void updateEvents(@NonNull T view, @Nullable Map<String, Object> events) {

}

protected void updateExtra(@NonNull View view, @Nullable Object object) {
view.invalidate();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public void destroy() {
public void preCreateView(int rootId, int id, int pid, @NonNull String className,
@Nullable Map<String, Object> props) {
boolean isLazy = mControllerManager.checkLazy(className);
if (isLazy) {
if (isLazy || id == rootId) {
return;
}
if (pid != rootId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,21 @@ protected View createViewImpl(@NonNull Context context, @Nullable Map<String, Ob
initDefault(context, props, new HippyRecyclerView(context)));
}

public static HippyRecyclerView initDefault(@NonNull Context context,
protected HippyRecyclerView initDefault(@NonNull Context context,
@Nullable Map<String, Object> props, HippyRecyclerView recyclerView) {
LinearLayoutManager layoutManager = new HippyLinearLayoutManager(context);
recyclerView.setItemAnimator(null);
boolean enableScrollEvent = false;
boolean enableOverPull = true;
boolean hasStableIds = true;
if (props != null) {
if (MapUtils.getBooleanValue(props, HORIZONTAL)) {
layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
}
enableScrollEvent = MapUtils.getBooleanValue(props, "onScroll");
enableOverPull = MapUtils.getBooleanValue(props, NodeProps.OVER_PULL, true);
hasStableIds = MapUtils.getBooleanValue(props, NodeProps.HAS_STABLE_IDS, true);
}
recyclerView.setLayoutManager(layoutManager);
recyclerView.initRecyclerView(hasStableIds);
recyclerView.getRecyclerViewEventHelper().setOnScrollEventEnable(enableScrollEvent);
if (HippyListUtils.isVerticalLayout(recyclerView)) {
recyclerView.setEnableOverPull(enableOverPull);
}
Expand Down Expand Up @@ -174,27 +171,27 @@ public void setRowShouldSticky(HRW view, boolean enable) {
view.setRowShouldSticky(enable);
}

@HippyControllerProps(name = "onScrollBeginDrag", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
@HippyControllerProps(name = "scrollbegindrag", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
public void setScrollBeginDragEventEnable(HRW view, boolean flag) {
view.getRecyclerViewEventHelper().setScrollBeginDragEventEnable(flag);
}

@HippyControllerProps(name = "onScrollEndDrag", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
@HippyControllerProps(name = "scrollenddrag", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
public void setScrollEndDragEventEnable(HRW view, boolean flag) {
view.getRecyclerViewEventHelper().setScrollEndDragEventEnable(flag);
}

@HippyControllerProps(name = "onMomentumScrollBegin", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
@HippyControllerProps(name = "momentumscrollbegin", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
public void setMomentumScrollBeginEventEnable(HRW view, boolean flag) {
view.getRecyclerViewEventHelper().setMomentumScrollBeginEventEnable(flag);
}

@HippyControllerProps(name = "onMomentumScrollEnd", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
@HippyControllerProps(name = "momentumscrollend", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
public void setMomentumScrollEndEventEnable(HRW view, boolean flag) {
view.getRecyclerViewEventHelper().setMomentumScrollEndEventEnable(flag);
}

@HippyControllerProps(name = "onScrollEnable", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
@HippyControllerProps(name = "scroll", defaultType = HippyControllerProps.BOOLEAN, defaultBoolean = false)
public void setOnScrollEventEnable(HRW view, boolean flag) {
view.getRecyclerViewEventHelper().setOnScrollEventEnable(flag);
}
Expand Down

0 comments on commit a4f4cde

Please sign in to comment.