This commit is contained in:
hyb1996
2017-09-24 22:26:01 +08:00
parent 601019cab2
commit 8c9777c138
3 changed files with 21 additions and 5 deletions

View File

@@ -2,7 +2,9 @@ package com.stardust.widget;
import android.annotation.SuppressLint;
import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.net.Uri;
import android.os.Build;
import android.support.annotation.RequiresApi;
import android.support.v4.widget.SwipeRefreshLayout;
@@ -98,13 +100,16 @@ public class EWebView extends FrameLayout implements SwipeRefreshLayout.OnRefres
@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
view.loadUrl(request.getUrl().toString());
return true;
return shouldOverrideUrlLoading(view, request.getUrl().toString());
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
if (url.startsWith("http://") || url.startsWith("https://")) {
view.loadUrl(url);
} else {
getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
}
return true;
}
}

View File

@@ -18,6 +18,7 @@ import com.stardust.autojs.runtime.api.Console;
import com.stardust.autojs.script.JavaScriptSource;
import com.stardust.autojs.script.ScriptSource;
import com.stardust.lang.ThreadCompat;
import com.stardust.util.TextUtils;
import com.stardust.util.UiHandler;
import org.greenrobot.eventbus.EventBus;
@@ -248,7 +249,7 @@ public class ScriptEngineService {
writer.close();
BufferedReader bufferedReader = new BufferedReader(reader);
String line;
StringBuilder scriptTrace = new StringBuilder(e.getMessage());
StringBuilder scriptTrace = new StringBuilder(TextUtils.toEmptyIfNull(e.getMessage()));
while ((line = bufferedReader.readLine()) != null) {
if (line.trim().startsWith("at script"))
scriptTrace.append("\n").append(line);

View File

@@ -1,12 +1,22 @@
package com.stardust.util;
import android.support.annotation.NonNull;
/**
* Created by Stardust on 2017/5/3.
*/
public class TextUtils {
public static String join(CharSequence delimiter, Object... tokens){
public static String join(CharSequence delimiter, Object... tokens) {
return android.text.TextUtils.join(delimiter, tokens);
}
@NonNull
public static String toEmptyIfNull(String message) {
if (message == null)
return "";
return message;
}
}