Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
polysoft-nafmii
/
polysoft-android
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c789005d
authored
May 13, 2021
by
amateur
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
dbaa8116
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
83 additions
and
13 deletions
app/src/main/java/com/polysoft/nafmii/bean/JsLogin.java
app/src/main/java/com/polysoft/nafmii/bean/JsMenu.java
app/src/main/java/com/polysoft/nafmii/webview/JsResult.java → app/src/main/java/com/polysoft/nafmii/bean/JsResult.java
app/src/main/java/com/polysoft/nafmii/utils/StatusBarUtils.java
app/src/main/java/com/polysoft/nafmii/webview/JsInterfaceHandler.java
app/src/main/java/com/polysoft/nafmii/webview/JsToJavaInterface.java
app/src/main/java/com/polysoft/nafmii/bean/JsLogin.java
0 → 100644
View file @
c789005
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
);
}
}
app/src/main/java/com/polysoft/nafmii/bean/JsMenu.java
0 → 100644
View file @
c789005
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
);
}
}
app/src/main/java/com/polysoft/nafmii/
webview
/JsResult.java
→
app/src/main/java/com/polysoft/nafmii/
bean
/JsResult.java
View file @
c789005
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
;
...
...
app/src/main/java/com/polysoft/nafmii/utils/StatusBarUtils.java
View file @
c789005
...
@@ -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
);
}
}
}
}
app/src/main/java/com/polysoft/nafmii/webview/JsInterfaceHandler.java
View file @
c789005
...
@@ -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
);
}
});
}
}
...
...
app/src/main/java/com/polysoft/nafmii/webview/JsToJavaInterface.java
View file @
c789005
...
@@ -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
;
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment