Commit c789005d by amateur

1

1 parent dbaa8116
package com.polysoft.nafmii.bean;
import com.alibaba.fastjson.annotation.JSONField;
public class JsLogin {
public static final String WECHAT = "1";
public static final String FINGERPRINT = "2";
@JSONField(name = "type")
private String type;
@JSONField(name = "phone")
private String phone;
public String getPhone() {
return phone;
}
public boolean isFingerprint() {
return FINGERPRINT.equals(this.type);
}
public boolean isWechat() {
return WECHAT.equals(this.type);
}
}
package com.polysoft.nafmii.bean;
import com.alibaba.fastjson.annotation.JSONField;
public class JsMenu {
public static final String SHOW = "1";
public static final String HIDE = "2";
public static final String CHANGE = "3";
@JSONField(name = "type")
private String type;
@JSONField(name = "name")
private String name;
@JSONField(name = "url")
private String url;
public String getName() {
return this.name;
}
public String getUrl() {
return this.url;
}
public boolean isShow() {
return SHOW.equals(this.type);
}
public boolean isHide() {
return HIDE.equals(this.type);
}
public boolean isChange() {
return CHANGE.equals(this.type);
}
}
package com.polysoft.nafmii.webview; package com.polysoft.nafmii.bean;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.annotation.JSONField; import com.alibaba.fastjson.annotation.JSONField;
......
...@@ -200,7 +200,15 @@ public class StatusBarUtils { ...@@ -200,7 +200,15 @@ public class StatusBarUtils {
if (resourceId > 0) { if (resourceId > 0) {
result = context.getResources().getDimensionPixelSize(resourceId); result = context.getResources().getDimensionPixelSize(resourceId);
} }
return result; return dip2px(context, result);
}
/**
* 根据手机的分辨率从 dp 的单位 转成为 px(像素)
*/
public static int dip2px(Context context, float pxValue) {
final float scale = context.getResources().getDisplayMetrics().density;
return (int) (pxValue / scale + 0.5f);
} }
} }
...@@ -4,11 +4,12 @@ import android.app.Activity; ...@@ -4,11 +4,12 @@ import android.app.Activity;
import android.text.TextUtils; import android.text.TextUtils;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.polysoft.nafmii.bean.JsResult;
public class JsInterfaceHandler { public class JsInterfaceHandler {
private Activity mActivity; private final Activity mActivity;
private JavaToJsinterface javaTojs; private final JavaToJsinterface javaTojs;
private String jsMethodName; private String jsMethodName;
public JsInterfaceHandler(Activity mActivity, JavaToJsinterface javaTojs) { public JsInterfaceHandler(Activity mActivity, JavaToJsinterface javaTojs) {
...@@ -24,8 +25,7 @@ public class JsInterfaceHandler { ...@@ -24,8 +25,7 @@ public class JsInterfaceHandler {
jsHandle.handle(data, new JsInterfaceImpl()); jsHandle.handle(data, new JsInterfaceImpl());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
String error = String.format("接口调用异常"); this.sendMessage2Js(JsResult.fail("接口调用异常").toString());
this.sendMessage2Js(JsResult.fail(error).toString());
} }
} }
...@@ -37,12 +37,7 @@ public class JsInterfaceHandler { ...@@ -37,12 +37,7 @@ public class JsInterfaceHandler {
javaTojs.callJs(jsMethodName, json); javaTojs.callJs(jsMethodName, json);
return; return;
} }
this.mActivity.runOnUiThread(new Runnable() { this.mActivity.runOnUiThread(() -> javaTojs.callJs(jsMethodName, json));
@Override
public void run() {
javaTojs.callJs(jsMethodName, json);
}
});
} }
......
...@@ -8,9 +8,9 @@ import android.webkit.JavascriptInterface; ...@@ -8,9 +8,9 @@ import android.webkit.JavascriptInterface;
import androidx.fragment.app.Fragment; import androidx.fragment.app.Fragment;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.util.TypeUtils; import com.alibaba.fastjson.util.TypeUtils;
import com.polysoft.nafmii.bean.JsResult;
import com.polysoft.nafmii.broadcast.Receiver; import com.polysoft.nafmii.broadcast.Receiver;
import com.polysoft.nafmii.broadcast.ReceiverListener; import com.polysoft.nafmii.broadcast.ReceiverListener;
import com.polysoft.nafmii.broadcast.ShareReceiver; import com.polysoft.nafmii.broadcast.ShareReceiver;
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!