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

Commit

Permalink
[WEEX-568][Android]Add Scan Delay Interface For AutoScanConfigRegister (
Browse files Browse the repository at this point in the history
  • Loading branch information
gubaojian authored and YorkShen committed Aug 16, 2018
1 parent 642dbf0 commit 2e42876
Showing 1 changed file with 21 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import com.alibaba.fastjson.JSONObject;
import com.taobao.weex.WXEnvironment;
import com.taobao.weex.WXSDKEngine;
import com.taobao.weex.WXSDKManager;
import com.taobao.weex.bridge.JavascriptInvokable;
import com.taobao.weex.utils.WXFileUtils;
import com.taobao.weex.utils.WXLogUtils;
Expand All @@ -39,6 +40,7 @@

public class AutoScanConfigRegister {

private static long scanDelay = 0;

public static final String TAG = "WeexScanConfigRegister";

Expand All @@ -61,7 +63,20 @@ public static void preLoad(JavascriptInvokable invokable){
* auto scan config files and do auto config from files, none need center register
* */
public static void doScanConfig(){
Thread thread = new Thread(new Runnable() {
if(scanDelay > 0){
WXSDKManager.getInstance().getWXRenderManager().postOnUiThread(new Runnable() {
@Override
public void run() {
doScanConfigAsync();
}
}, scanDelay);
}else{
doScanConfigAsync();
}
}

public static void doScanConfigAsync(){
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
doScanConfigSync();
Expand All @@ -77,8 +92,8 @@ public void run() {
}
}
});
thread.setName("AutoScanConfigRegister");
thread.start();
thread.setName("AutoScanConfigRegister");
thread.start();
}

private static void doScanConfigSync(){
Expand Down Expand Up @@ -146,4 +161,7 @@ private static void doScanConfigSync(){
}
}

public static void setScanDelay(long scanDelay) {
AutoScanConfigRegister.scanDelay = scanDelay;
}
}

0 comments on commit 2e42876

Please sign in to comment.