YorkShen closed pull request #1439: [WEEX-568][Android]Add Scan Delay Interface For AutoScanConfigRegister URL: https://github.com/apache/incubator-weex/pull/1439
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/config/AutoScanConfigRegister.java b/android/sdk/src/main/java/com/taobao/weex/ui/config/AutoScanConfigRegister.java index 597fb4d89b..b8b5805f88 100644 --- a/android/sdk/src/main/java/com/taobao/weex/ui/config/AutoScanConfigRegister.java +++ b/android/sdk/src/main/java/com/taobao/weex/ui/config/AutoScanConfigRegister.java @@ -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; @@ -39,6 +40,7 @@ public class AutoScanConfigRegister { + private static long scanDelay = 0; public static final String TAG = "WeexScanConfigRegister"; @@ -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(); @@ -77,8 +92,8 @@ public void run() { } } }); - thread.setName("AutoScanConfigRegister"); - thread.start(); + thread.setName("AutoScanConfigRegister"); + thread.start(); } private static void doScanConfigSync(){ @@ -146,4 +161,7 @@ private static void doScanConfigSync(){ } } + public static void setScanDelay(long scanDelay) { + AutoScanConfigRegister.scanDelay = scanDelay; + } } ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services