Skip to content
This repository was archived by the owner on Jun 3, 2021. It is now read-only.

Commit dc1936e

Browse files
committed
[WEEX-465][Android]fix performance point interactionTime record bug
1 parent 939be31 commit dc1936e

File tree

6 files changed

+24
-27
lines changed

6 files changed

+24
-27
lines changed

android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public class WXSDKInstance implements IWXActivityStateListener,View.OnLayoutChan
106106

107107
//Performance
108108
public boolean mEnd = false;
109+
public boolean isJSCreateFinish =false;
109110
public static final String BUNDLE_URL = "bundleUrl";
110111
private IWXUserTrackAdapter mUserTrackAdapter;
111112
private IWXRenderListener mRenderListener;
@@ -1121,6 +1122,7 @@ public void runOnUiThread(Runnable action) {
11211122
}
11221123

11231124
public void onRenderSuccess(final int width, final int height) {
1125+
isJSCreateFinish = true;
11241126
firstScreenRenderFinished();
11251127

11261128
long time = System.currentTimeMillis() - mRenderStartTime;
@@ -1181,10 +1183,10 @@ public void run() {
11811183
}
11821184

11831185
/**
1184-
* when add/rm/mv element
1186+
* when add/rm element
11851187
*/
1186-
public void onElementChange(){
1187-
if (isDestroy() || !mEnd ||null == mRenderContainer || mRenderContainer.isPageHasEvent() ||
1188+
public void onElementChange(boolean afterJSCreateFinish){
1189+
if (isDestroy() || !afterJSCreateFinish ||null == mRenderContainer || mRenderContainer.isPageHasEvent() ||
11881190
mWXPerformance == null){
11891191
return;
11901192
}

android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionAddElement.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public class GraphicActionAddElement extends GraphicActionAbstractAddElement {
3939
private WXComponent child;
4040
private GraphicPosition layoutPosition;
4141
private GraphicSize layoutSize;
42+
private boolean isJSCreateFinish = false;
4243

4344
public GraphicActionAddElement(String pageId, String ref,
4445
String componentType, String parentRef,
@@ -72,6 +73,7 @@ public GraphicActionAddElement(String pageId, String ref,
7273
mParentRef);
7374
child = createComponent(instance, parent, basicComponentData);
7475
child.setTransition(WXTransition.fromMap(child.getStyles(), child));
76+
isJSCreateFinish = instance.isJSCreateFinish;
7577

7678
if (child == null || parent == null) {
7779
return;
@@ -122,7 +124,7 @@ public void executeAction() {
122124
child.bindData(child);
123125
WXSDKInstance instance = WXSDKManager.getInstance().getWXRenderManager().getWXSDKInstance(getPageId());
124126
if (null!=instance){
125-
instance.onElementChange();
127+
instance.onElementChange(isJSCreateFinish);
126128
// instance.setma
127129
}
128130
} catch (Exception e) {

android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionMoveElement.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
*/
1919
package com.taobao.weex.ui.action;
2020

21-
import com.taobao.weex.WXSDKInstance;
2221
import com.taobao.weex.WXSDKManager;
2322
import com.taobao.weex.ui.component.WXComponent;
2423
import com.taobao.weex.ui.component.WXVContainer;
@@ -49,9 +48,5 @@ public void executeAction() {
4948
if (!component.isVirtualComponent()) {
5049
((WXVContainer) newParent).addSubView(component.getHostView(), mIndex);
5150
}
52-
WXSDKInstance instance = WXSDKManager.getInstance().getWXRenderManager().getWXSDKInstance(getPageId());
53-
if (null!=instance){
54-
instance.onElementChange();
55-
}
5651
}
5752
}

android/sdk/src/main/java/com/taobao/weex/ui/action/GraphicActionRemoveElement.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,15 @@
2525

2626
public class GraphicActionRemoveElement extends BasicGraphicAction {
2727

28+
private boolean isJSCreateFinish = false;
29+
2830
public GraphicActionRemoveElement(String pageId, String ref) {
2931
super(pageId, ref);
32+
WXSDKInstance instance = WXSDKManager.getInstance().getWXRenderManager().getWXSDKInstance(getPageId());
33+
if (null != instance){
34+
isJSCreateFinish = instance.isJSCreateFinish;
35+
}
36+
3037
}
3138

3239
@Override
@@ -55,7 +62,7 @@ private void clearRegistryForComponent(WXComponent component) {
5562
}
5663
WXSDKInstance instance = WXSDKManager.getInstance().getWXRenderManager().getWXSDKInstance(getPageId());
5764
if (null!=instance){
58-
instance.onElementChange();
65+
instance.onElementChange(isJSCreateFinish);
5966
}
6067
}
6168
}

android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
import com.taobao.weex.ui.animation.WXAnimationModule;
8686
import com.taobao.weex.ui.component.basic.WXBasicComponent;
8787
import com.taobao.weex.ui.component.binding.Statements;
88+
import com.taobao.weex.ui.component.list.WXCell;
8889
import com.taobao.weex.ui.component.list.template.jni.NativeRenderObjectUtils;
8990
import com.taobao.weex.ui.component.pesudo.OnActivePseudoListner;
9091
import com.taobao.weex.ui.component.pesudo.PesudoStatus;
@@ -929,7 +930,7 @@ public final void setLayout(WXComponent component) {
929930
return;
930931
}
931932

932-
if (realHeight >= WXPerformance.VIEW_LIMIT_HEIGHT && realWidth>=WXPerformance.VIEW_LIMIT_WIDTH){
933+
if (this instanceof WXCell && realHeight >= WXPerformance.VIEW_LIMIT_HEIGHT && realWidth>=WXPerformance.VIEW_LIMIT_WIDTH){
933934
mInstance.getWXPerformance().cellExceedNum++;
934935
}
935936

android/sdk/src/main/java/com/taobao/weex/ui/module/WXTimerModule.java

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -69,29 +69,19 @@ public WXTimerModule() {
6969
public void setTimeout(@IntRange(from = 1) int funcId, @FloatRange(from = 0) float delay) {
7070
if(mWXSDKInstance != null) {
7171
postOrHoldMessage(MODULE_TIMEOUT, funcId, (int) delay, WXUtils.parseInt(mWXSDKInstance.getInstanceId()));
72-
WXSDKManager.getInstance().postOnUiThread(new Runnable() {
73-
@Override
74-
public void run() {
75-
if (null != mWXSDKInstance){
76-
mWXSDKInstance.getWXPerformance().timerInvokeCount++;
77-
}
78-
}
79-
},0);
72+
if (null != mWXSDKInstance.getWXPerformance()){
73+
mWXSDKInstance.getWXPerformance().timerInvokeCount++;
74+
}
8075
}
8176
}
8277

8378
@JSMethod(uiThread = false)
8479
public void setInterval(@IntRange(from = 1) int funcId, @FloatRange(from = 0) float interval) {
8580
if(mWXSDKInstance != null) {
8681
postOrHoldMessage(MODULE_INTERVAL, funcId, (int) interval, WXUtils.parseInt(mWXSDKInstance.getInstanceId()));
87-
WXSDKManager.getInstance().postOnUiThread(new Runnable() {
88-
@Override
89-
public void run() {
90-
if (null != mWXSDKInstance){
91-
mWXSDKInstance.getWXPerformance().timerInvokeCount++;
92-
}
93-
}
94-
},0);
82+
if (null != mWXSDKInstance.getWXPerformance()){
83+
mWXSDKInstance.getWXPerformance().timerInvokeCount++;
84+
}
9585
}
9686
}
9787

0 commit comments

Comments
 (0)