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

[Android] Revert WeexFrame #2912

Merged
merged 2 commits into from
Sep 17, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@
import android.os.Build;
import android.util.Log;
import android.view.Choreographer;
import com.taobao.weex.bridge.WXBridgeManager;
import com.taobao.weex.common.WXErrorCode;
import java.lang.ref.WeakReference;

public class WeexFrameRateControl {
private static final long VSYNC_FRAME = 1000 / 60;
private WeakReference<VSyncListener> mListener;
private Choreographer mChoreographer;
private Choreographer.FrameCallback mVSyncFrameCallback;
private final Choreographer mChoreographer;
private final Choreographer.FrameCallback mVSyncFrameCallback;
private final Runnable runnable;

public interface VSyncListener {
Expand All @@ -44,32 +43,27 @@ public interface VSyncListener {
public WeexFrameRateControl(VSyncListener listener) {
mListener = new WeakReference<>(listener);
if (Build.VERSION.SDK_INT > Build.VERSION_CODES.ICE_CREAM_SANDWICH_MR1) {
WXBridgeManager.getInstance().post(new Runnable() {
@Override
public void run() {
mChoreographer = Choreographer.getInstance();
mVSyncFrameCallback = new Choreographer.FrameCallback() {
@SuppressLint("NewApi")
@Override
public void doFrame(long frameTimeNanos) {
VSyncListener vSyncListener;
if (mListener != null && (vSyncListener=mListener.get()) != null) {
try {
vSyncListener.OnVSync();
mChoreographer.postFrameCallback(mVSyncFrameCallback);
}catch (UnsatisfiedLinkError e){
if(vSyncListener instanceof WXSDKInstance){
((WXSDKInstance) vSyncListener).onRenderError(
WXErrorCode.WX_DEGRAD_ERR_INSTANCE_CREATE_FAILED.getErrorCode(),
Log.getStackTraceString(e));
}
}
}
}
};
}
});
runnable = null;
mChoreographer = Choreographer.getInstance();
mVSyncFrameCallback = new Choreographer.FrameCallback() {
@SuppressLint("NewApi")
@Override
public void doFrame(long frameTimeNanos) {
VSyncListener vSyncListener;
if (mListener != null && (vSyncListener=mListener.get()) != null) {
try {
vSyncListener.OnVSync();
mChoreographer.postFrameCallback(mVSyncFrameCallback);
}catch (UnsatisfiedLinkError e){
if(vSyncListener instanceof WXSDKInstance){
((WXSDKInstance) vSyncListener).onRenderError(
WXErrorCode.WX_DEGRAD_ERR_INSTANCE_CREATE_FAILED.getErrorCode(),
Log.getStackTraceString(e));
}
}
}
}
};
runnable = null;
} else {
// For API 15 or lower
runnable = new Runnable() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
import android.support.annotation.RestrictTo.Scope;
import android.support.annotation.WorkerThread;
import android.support.annotation.UiThread;
import android.support.v4.util.ArrayMap;
import android.text.TextUtils;
import android.util.Log;
Expand Down Expand Up @@ -3461,15 +3461,15 @@ public void bindMeasurementToRenderObject(long ptr){
* @param instanceId
* @return
*/
@WorkerThread
@UiThread
public boolean notifyLayout(String instanceId) {
if (isSkipFrameworkInit(instanceId) || isJSFrameworkInit()) {
return mWXBridge.notifyLayout(instanceId);
}
return false;
}

@WorkerThread
@UiThread
public void forceLayout(String instanceId) {
if (isSkipFrameworkInit(instanceId) || isJSFrameworkInit()) {
mWXBridge.forceLayout(instanceId);
Expand Down