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 65a1d282
authored
Sep 02, 2021
by
amateur
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
5cbe8a75
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
94 additions
and
22 deletions
app/build.gradle
app/src/main/java/com/polysoft/nafmii/database/ObjectBox.java
app/src/main/java/com/polysoft/nafmii/fragment/WebViewFragment.java
app/src/main/java/com/polysoft/nafmii/fragment/home/ModuleUrlHandle.java
app/src/main/java/com/polysoft/nafmii/jpush/JPushMgr.java
app/src/main/java/com/polysoft/nafmii/jpush/JPushReceiver.java
app/src/main/java/com/polysoft/nafmii/utils/IntentUtils.java
app/src/main/java/com/polysoft/nafmii/webview/NativeApi.java
app/src/main/java/com/whaty/nafmii/activity/InputUrlActivity.java
app/src/main/java/com/whaty/nafmii/activity/MainActivity.java
app/src/main/res/layout/fragment_webview.xml
app/src/main/res/mipmap-mdpi/splash1.png
app/build.gradle
View file @
65a1d28
...
...
@@ -102,6 +102,7 @@ dependencies {
implementation
'androidx.constraintlayout:constraintlayout:2.0.1'
implementation
'ren.yale.android:cachewebviewlib:2.1.8'
implementation
'com.alibaba:fastjson:1.2.75'
implementation
'com.wang.avi:library:2.1.3'
implementation
'com.tencent.mm.opensdk:wechat-sdk-android-without-mta:6.7.0'
implementation
'com.squareup.okhttp3:okhttp:5.0.0-alpha.2'
implementation
'com.github.bumptech.glide:glide:4.12.0'
...
...
app/src/main/java/com/polysoft/nafmii/database/ObjectBox.java
View file @
65a1d28
...
...
@@ -9,8 +9,6 @@ import java.util.List;
import
io.objectbox.Box
;
import
io.objectbox.BoxStore
;
import
io.objectbox.EntityInfo
;
import
io.objectbox.Property
;
import
io.objectbox.query.QueryBuilder
;
public
abstract
class
ObjectBox
<
T
>
{
...
...
@@ -40,6 +38,9 @@ public abstract class ObjectBox<T> {
public
static
DataEntity
findByName
(
String
name
)
{
return
newQuery
().
equal
(
DataEntity_
.
name
,
name
).
build
().
findFirst
();
}
public
static
List
<
DataEntity
>
findByNames
(
String
name
)
{
return
newQuery
().
equal
(
DataEntity_
.
name
,
name
).
build
().
find
();
}
public
static
List
<
DataEntity
>
findList
(
DataEntity
...
data
)
{
QueryBuilder
<
DataEntity
>
query
=
newQuery
();
...
...
@@ -52,7 +53,7 @@ public abstract class ObjectBox<T> {
return
query
.
build
().
find
();
}
public
static
void
put
(
DataEntity
...
data
)
{
public
static
synchronized
void
put
(
DataEntity
...
data
)
{
for
(
DataEntity
item
:
data
)
{
DataEntity
entity
=
findByName
(
item
.
getName
());
if
(
null
!=
entity
)
{
...
...
@@ -63,11 +64,16 @@ public abstract class ObjectBox<T> {
}
}
public
static
void
delete
(
long
...
ids
)
{
public
static
synchronized
void
delete
(
long
...
ids
)
{
getDataBox
().
remove
(
ids
);
}
public
static
void
delete
(
DataEntity
...
data
)
{
getDataBox
().
remove
(
data
);
public
static
synchronized
void
delete
(
DataEntity
...
data
)
{
for
(
DataEntity
datum
:
data
)
{
List
<
DataEntity
>
byNames
=
findByNames
(
datum
.
getName
());
for
(
DataEntity
byName
:
byNames
)
{
delete
(
byName
.
getId
());
}
}
}
}
app/src/main/java/com/polysoft/nafmii/fragment/WebViewFragment.java
View file @
65a1d28
...
...
@@ -27,6 +27,7 @@ import com.polysoft.nafmii.webview.WebviewHandler;
import
com.polysoft.nafmii.webview.WebviewLoadListener
;
import
com.polysoft.nafmii.webview.X5WebviewUtils
;
import
com.tencent.smtt.sdk.WebView
;
import
com.wang.avi.AVLoadingIndicatorView
;
import
com.whaty.nafmii.R
;
import
java.io.File
;
...
...
@@ -36,6 +37,7 @@ public class WebViewFragment extends Fragment implements WebviewLoadListener {
protected
WebView
mWebview
;
private
ViewGroup
mWebviewLayout
;
private
AVLoadingIndicatorView
mLoading
;
private
WebviewHandler
mWebviewHandler
;
private
ValueCallback
<
Uri
[]>
filePathCallback
;
...
...
@@ -58,6 +60,7 @@ public class WebViewFragment extends Fragment implements WebviewLoadListener {
public
void
onViewCreated
(
@NonNull
View
view
,
@Nullable
Bundle
savedInstanceState
)
{
super
.
onViewCreated
(
view
,
savedInstanceState
);
this
.
mWebviewLayout
=
view
.
findViewById
(
R
.
id
.
webview_layout
);
this
.
mLoading
=
view
.
findViewById
(
R
.
id
.
webview_loading
);
this
.
initWebView
();
}
...
...
@@ -76,7 +79,9 @@ public class WebViewFragment extends Fragment implements WebviewLoadListener {
@Override
public
void
onWebviewLoad
(
int
type
,
Object
param
)
{
if
(
type
==
WebviewLoadListener
.
TYPE_FINISH
)
{
this
.
mLoading
.
hide
();
}
}
@Override
...
...
app/src/main/java/com/polysoft/nafmii/fragment/home/ModuleUrlHandle.java
View file @
65a1d28
...
...
@@ -48,14 +48,16 @@ public class ModuleUrlHandle {
private
String
getInputUrl
(
ModulesEnum
module
)
{
Intent
intent
=
activity
.
getIntent
();
if
(
module
==
ModulesEnum
.
HOME
||
module
==
ModulesEnum
.
MEMBER
||
module
==
ModulesEnum
.
MY
)
{
String
urlStr
=
intent
.
getStringExtra
(
ModulesEnum
.
HOME
.
name
);
if
(
TextUtils
.
isEmpty
(
urlStr
))
{
return
null
;
}
Uri
uri
=
Uri
.
parse
(
urlStr
);
return
uri
.
getScheme
()
+
":"
+
uri
.
getSchemeSpecificPart
()
+
module
.
webUrl
;
// String urlStr = intent.getStringExtra(ModulesEnum.HOME.name);
// if (TextUtils.isEmpty(urlStr)) {
// return null;
// }
// Uri uri = Uri.parse(urlStr);
// return uri.getScheme() +":"+ uri.getSchemeSpecificPart() + module.webUrl;
// return "http://10.10.81.189/h5/?"+System.currentTimeMillis() + module.webUrl;
return
"http://192.168.137.1:8080/"
+
System
.
currentTimeMillis
()
+
module
.
webUrl
;
}
return
intent
.
getStringExtra
(
ModulesEnum
.
HOME
.
name
);
return
intent
.
getStringExtra
(
module
.
name
);
}
public
interface
IModuleHandle
{
...
...
app/src/main/java/com/polysoft/nafmii/jpush/JPushMgr.java
View file @
65a1d28
...
...
@@ -38,6 +38,9 @@ public class JPushMgr {
}
public
static
void
deleteAlias
()
{
JPushInterface
.
deleteAlias
(
CtxUtils
.
getApplication
(),
100
);
String
millis
=
String
.
valueOf
(
System
.
currentTimeMillis
());
String
val
=
millis
.
substring
(
millis
.
length
()
-
5
,
millis
.
length
());
int
code
=
0
-
Integer
.
parseInt
(
val
);
JPushInterface
.
deleteAlias
(
CtxUtils
.
getApplication
(),
code
);
}
}
app/src/main/java/com/polysoft/nafmii/jpush/JPushReceiver.java
View file @
65a1d28
...
...
@@ -4,6 +4,9 @@ import android.content.Context;
import
android.content.Intent
;
import
android.util.Log
;
import
java.util.HashMap
;
import
java.util.Map
;
import
cn.jpush.android.api.CmdMessage
;
import
cn.jpush.android.api.CustomMessage
;
import
cn.jpush.android.api.JPushInterface
;
...
...
@@ -15,12 +18,13 @@ public class JPushReceiver extends JPushMessageReceiver {
private
static
final
String
TAG
=
"PushMessageReceiver"
;
private
Map
<
String
,
String
>
aliasStatusMap
=
new
HashMap
<>();
// private static Map<String, >
@Override
public
void
onMessage
(
Context
context
,
CustomMessage
customMessage
)
{
Log
.
e
(
TAG
,
"[onMessage] "
+
customMessage
);
Intent
intent
=
new
Intent
(
"com.jiguang.demo.message"
);
intent
.
putExtra
(
"msg"
,
customMessage
.
message
);
context
.
sendBroadcast
(
intent
);
}
@Override
...
...
@@ -74,8 +78,6 @@ public class JPushReceiver extends JPushMessageReceiver {
@Override
public
void
onRegister
(
Context
context
,
String
registrationId
)
{
Log
.
e
(
TAG
,
"[onRegister] "
+
registrationId
);
Intent
intent
=
new
Intent
(
"com.jiguang.demo.register"
);
context
.
sendBroadcast
(
intent
);
}
@Override
...
...
@@ -104,6 +106,12 @@ public class JPushReceiver extends JPushMessageReceiver {
public
void
onAliasOperatorResult
(
Context
context
,
JPushMessage
jPushMessage
)
{
super
.
onAliasOperatorResult
(
context
,
jPushMessage
);
Log
.
d
(
TAG
,
"onAliasOperatorResult: "
+
jPushMessage
.
toString
());
String
alias
=
jPushMessage
.
getAlias
();
int
errorCode
=
jPushMessage
.
getErrorCode
();
if
(
errorCode
==
0
)
{
aliasStatusMap
.
clear
();
aliasStatusMap
.
put
(
alias
,
"1"
);
}
}
//
// @Override
...
...
app/src/main/java/com/polysoft/nafmii/utils/IntentUtils.java
View file @
65a1d28
...
...
@@ -62,7 +62,7 @@ public class IntentUtils {
public
static
void
toHomeActivity
(
Activity
activity
)
{
if
(
BuildConfig
.
DEBUG
)
{
startActivity
(
activity
,
InputUrl
Activity
.
class
);
startActivity
(
activity
,
Home
Activity
.
class
);
}
else
{
startActivity
(
activity
,
HomeActivity
.
class
);
}
...
...
app/src/main/java/com/polysoft/nafmii/webview/NativeApi.java
View file @
65a1d28
...
...
@@ -18,6 +18,7 @@ import com.polysoft.nafmii.database.entity.DataEntity;
import
com.polysoft.nafmii.enums.DatabaseEnum
;
import
com.polysoft.nafmii.fragment.dialog.FingerprintDialog
;
import
com.polysoft.nafmii.jpush.JPushMgr
;
import
com.polysoft.nafmii.net.OkhttpApi
;
import
com.polysoft.nafmii.utils.CtxUtils
;
import
com.polysoft.nafmii.utils.IntentUtils
;
import
com.polysoft.nafmii.utils.PermissionUtils
;
...
...
@@ -126,7 +127,15 @@ public class NativeApi {
}
DataEntity
[]
arrays
=
list
.
toArray
(
new
DataEntity
[]{});
if
(
DatabaseEnum
.
GET
.
name
.
equals
(
type
))
{
js
.
success
(
ObjectBox
.
findList
(
arrays
));
List
<
DataEntity
>
findList
=
ObjectBox
.
findList
(
arrays
);
List
<
Map
<
String
,
Object
>>
result
=
new
ArrayList
<>();
for
(
DataEntity
entity
:
findList
)
{
Map
<
String
,
Object
>
item
=
new
HashMap
<>();
item
.
put
(
"name"
,
entity
.
getName
());
item
.
put
(
"value"
,
JSONObject
.
parse
(
entity
.
getValue
()));
result
.
add
(
item
);
}
js
.
success
(
result
);
return
;
}
if
(
DatabaseEnum
.
SAVE
.
name
.
equals
(
type
))
{
...
...
@@ -156,6 +165,17 @@ public class NativeApi {
}
@JavascriptInterface
public
void
nativeDownload
(
String
params
)
{
new
JsInterfaceHandler
(
handler
).
parse
(
params
,
(
data
,
js
)
->
{
String
url
=
data
.
getString
(
"url"
);
// OkhttpApi.doDownload(url, );
js
.
success
(
null
);
});
}
@JavascriptInterface
public
void
nativeCamera
(
String
params
)
{
new
JsInterfaceHandler
(
handler
).
parse
(
params
,
(
data
,
js
)
->
{
...
...
app/src/main/java/com/whaty/nafmii/activity/InputUrlActivity.java
View file @
65a1d28
...
...
@@ -33,6 +33,7 @@ public class InputUrlActivity extends AppCompatActivity {
private
void
init
()
{
EditText
input
=
findViewById
(
R
.
id
.
input_url
);
input
.
setText
(
SpUtils
.
getString
(
KEY_URL
,
""
));
input
.
setText
(
"http://192.168.137.1:8080"
);
String
channel
=
SpUtils
.
getString
(
KEY_CHANNEL
,
""
);
RadioButton
button1
=
findViewById
(
R
.
id
.
input_channel_1
);
...
...
app/src/main/java/com/whaty/nafmii/activity/MainActivity.java
View file @
65a1d28
...
...
@@ -7,6 +7,8 @@ import androidx.annotation.NonNull;
import
androidx.fragment.app.Fragment
;
import
androidx.fragment.app.FragmentTransaction
;
import
com.polysoft.nafmii.database.ObjectBox
;
import
com.polysoft.nafmii.database.entity.DataEntity
;
import
com.polysoft.nafmii.fragment.AdvertisementFragment
;
import
com.polysoft.nafmii.fragment.GuideFragment
;
import
com.polysoft.nafmii.utils.CtxUtils
;
...
...
@@ -19,6 +21,8 @@ import com.polysoft.nafmii.viewmodel.AdvertisementViewModel;
import
com.polysoft.nafmii.webview.X5Core
;
import
com.whaty.nafmii.R
;
import
java.util.List
;
import
cn.jpush.android.api.JPushInterface
;
public
class
MainActivity
extends
BaseActivity
{
...
...
@@ -53,6 +57,13 @@ public class MainActivity extends BaseActivity {
SpUtils
.
putBoolean
(
FIRST_RUN_KEY
,
true
);
}
else
if
(
IActivityEvent
.
EVENT_ADVERTISEMENT
.
equals
(
event
))
{
}
List
<
DataEntity
>
info
=
ObjectBox
.
findByNames
(
"UserInfo"
);
// if (null != info && !info.isEmpty()) {
// for (DataEntity entity : info) {
// ObjectBox.delete(entity.getId());
// }
// }
// List<DataEntity> info2 = ObjectBox.findByNames("UserInfo");
IntentUtils
.
toHomeActivity
(
this
);
}
...
...
app/src/main/res/layout/fragment_webview.xml
View file @
65a1d28
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
...
...
@@ -26,4 +27,18 @@
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
></LinearLayout>
<com.wang.avi.AVLoadingIndicatorView
android:id=
"@+id/webview_loading"
style=
"@style/AVLoadingIndicatorView"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:visibility=
"visible"
app:indicatorColor=
"#4880ff"
app:indicatorName=
"BallSpinFadeLoaderIndicator"
app:layout_constraintBottom_toBottomOf=
"@+id/webview_layout"
app:layout_constraintEnd_toEndOf=
"@+id/webview_layout"
app:layout_constraintStart_toStartOf=
"@+id/webview_layout"
app:layout_constraintTop_toTopOf=
"@+id/webview_layout"
tools:ignore=
"MissingConstraints"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
app/src/main/res/mipmap-mdpi/splash1.png
View file @
65a1d28
1.37 MB
|
W:
|
H:
1.22 MB
|
W:
|
H:
2-up
Swipe
Onion skin
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