You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by ac...@apache.org on 2017/12/26 07:40:31 UTC
incubator-weex git commit: [WEEX-176][android] Appear Event not fired
when cell amount not changed close #948
Repository: incubator-weex
Updated Branches:
refs/heads/master e84d927be -> a7997f557
[WEEX-176][android] Appear Event not fired when cell amount not changed
close #948
Project: http://git-wip-us.apache.org/repos/asf/incubator-weex/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-weex/commit/a7997f55
Tree: http://git-wip-us.apache.org/repos/asf/incubator-weex/tree/a7997f55
Diff: http://git-wip-us.apache.org/repos/asf/incubator-weex/diff/a7997f55
Branch: refs/heads/master
Commit: a7997f557263a22d910f1401092f91b0053953a0
Parents: e84d927
Author: jianbai.gbj <ji...@alibaba-inc.com>
Authored: Wed Dec 20 16:10:31 2017 +0800
Committer: acton393 <zh...@gmail.com>
Committed: Tue Dec 26 15:38:15 2017 +0800
----------------------------------------------------------------------
.../ui/component/list/BasicListComponent.java | 26 ++++++++++++++++++++
1 file changed, 26 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-weex/blob/a7997f55/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java
----------------------------------------------------------------------
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java
index afaa2e7..4be169f 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/list/BasicListComponent.java
@@ -95,6 +95,8 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
private static final Pattern transformPattern = Pattern.compile("([a-z]+)\\(([0-9\\.]+),?([0-9\\.]+)?\\)");
private Map<String, AppearanceHelper> mAppearComponents = new HashMap<>();
+ private Runnable mAppearComponentsRunnable = null;
+ private long mAppearDelay = 50;
private boolean isScrollable = true;
private ArrayMap<String, Long> mRefToViewType;
@@ -217,6 +219,10 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
@Override
public void destroy() {
+ if(mAppearComponentsRunnable != null) {
+ getHostView().removeCallbacks(mAppearComponentsRunnable);
+ mAppearComponentsRunnable = null;
+ }
super.destroy();
if (mStickyMap != null)
mStickyMap.clear();
@@ -224,6 +230,7 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
mViewTypes.clear();
if (mRefToViewType != null)
mRefToViewType.clear();
+
}
@Override
@@ -255,6 +262,9 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
if(getDomObject().getAttrs().get(Constants.Name.KEEP_POSITION_LAYOUT_DELAY) != null){
keepPositionLayoutDelay = WXUtils.getNumberInt(getDomObject().getAttrs().get(Constants.Name.KEEP_POSITION_LAYOUT_DELAY), (int)keepPositionLayoutDelay);
}
+ if(getDomObject().getAttrs().get("appearActionDelay") != null){
+ mAppearDelay = WXUtils.getNumberInt(getDomObject().getAttrs().get("appearActionDelay"), (int)mAppearDelay);
+ }
mItemAnimator=bounceRecyclerView.getInnerView().getItemAnimator();
@@ -425,6 +435,18 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
@Override
public void bindAppearEvent(WXComponent component) {
setAppearanceWatch(component, AppearanceHelper.APPEAR, true);
+ if(mAppearComponentsRunnable == null){
+ mAppearComponentsRunnable = new Runnable() {
+ @Override
+ public void run() {
+ if(mAppearComponentsRunnable != null) {
+ notifyAppearStateChange(0, 0, 0, 0);
+ }
+ }
+ };
+ }
+ getHostView().removeCallbacks(mAppearComponentsRunnable);
+ getHostView().postDelayed(mAppearComponentsRunnable, mAppearDelay);
}
@Override
@@ -1151,6 +1173,10 @@ public abstract class BasicListComponent<T extends ViewGroup & ListComponentView
@Override
public void notifyAppearStateChange(int firstVisible, int lastVisible, int directionX, int directionY) {
+ if(mAppearComponentsRunnable != null) {
+ getHostView().removeCallbacks(mAppearComponentsRunnable);
+ mAppearComponentsRunnable = null;
+ }
//notify appear state
Iterator<AppearanceHelper> it = mAppearComponents.values().iterator();
String direction = directionY > 0 ? Constants.Value.DIRECTION_UP :