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 96ad7691
authored
May 18, 2021
by
amateur
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
1
1 parent
d52336cc
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
57 additions
and
30 deletions
app/build.gradle
app/src/main/java/com/polysoft/nafmii/activity/GuideActivity.java
app/src/main/java/com/polysoft/nafmii/activity/HomeActivity.java
app/src/main/java/com/polysoft/nafmii/activity/InputUrlActivity.java
app/src/main/java/com/polysoft/nafmii/fragment/ModulesFragmentMgr.java → app/src/main/java/com/polysoft/nafmii/activity/home/ModulesFragmentMgr.java
app/src/main/java/com/polysoft/nafmii/constants/JsApi.java
app/src/main/java/com/polysoft/nafmii/enums/ModulesEnum.java
app/src/main/java/com/polysoft/nafmii/fragment/AdvertisementFragment.java
app/src/main/java/com/polysoft/nafmii/webview/IWebview.java
app/src/main/java/com/polysoft/nafmii/webview/WebviewHandler.java
app/build.gradle
View file @
96ad769
...
@@ -16,6 +16,7 @@ android {
...
@@ -16,6 +16,7 @@ android {
buildConfigField
"String"
,
"API_HOST"
,
"\"http://new.ynyc6666.com/shop/server/\""
buildConfigField
"String"
,
"API_HOST"
,
"\"http://new.ynyc6666.com/shop/server/\""
buildConfigField
"String"
,
"WX_APPID"
,
"\"1234567890\""
buildConfigField
"String"
,
"WX_APPID"
,
"\"1234567890\""
buildConfigField
"boolean"
,
"SHOW_INPUT"
,
"true"
ndk
{
ndk
{
abiFilters
"armeabi"
,
"armeabi-v7a"
,
"x86"
,
"mips"
abiFilters
"armeabi"
,
"armeabi-v7a"
,
"x86"
,
"mips"
...
@@ -28,6 +29,7 @@ android {
...
@@ -28,6 +29,7 @@ android {
zipAlignEnabled
true
//是否设置zip对齐优化
zipAlignEnabled
true
//是否设置zip对齐优化
shrinkResources
true
// 移除无用的resource文件
shrinkResources
true
// 移除无用的resource文件
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
proguardFiles
getDefaultProguardFile
(
'proguard-android-optimize.txt'
),
'proguard-rules.pro'
buildConfigField
"boolean"
,
"SHOW_INPUT"
,
"false"
}
}
pro
{
// 预生产
pro
{
// 预生产
resValue
"string"
,
"app_name"
,
"Nafmii-pro"
resValue
"string"
,
"app_name"
,
"Nafmii-pro"
...
...
app/src/main/java/com/polysoft/nafmii/activity/GuideActivity.java
View file @
96ad769
...
@@ -11,6 +11,7 @@ import androidx.annotation.NonNull;
...
@@ -11,6 +11,7 @@ import androidx.annotation.NonNull;
import
androidx.viewpager.widget.PagerAdapter
;
import
androidx.viewpager.widget.PagerAdapter
;
import
androidx.viewpager.widget.ViewPager
;
import
androidx.viewpager.widget.ViewPager
;
import
com.polysoft.nafmii.BuildConfig
;
import
com.polysoft.nafmii.R
;
import
com.polysoft.nafmii.R
;
import
com.polysoft.nafmii.utils.IntentUtils
;
import
com.polysoft.nafmii.utils.IntentUtils
;
import
com.polysoft.nafmii.utils.SpUtils
;
import
com.polysoft.nafmii.utils.SpUtils
;
...
@@ -77,7 +78,11 @@ public class GuideActivity extends BaseActivity implements View.OnClickListener
...
@@ -77,7 +78,11 @@ public class GuideActivity extends BaseActivity implements View.OnClickListener
public
void
onClick
(
View
v
)
{
public
void
onClick
(
View
v
)
{
if
(
v
.
getId
()
==
R
.
id
.
guide_btn_gohome
)
{
if
(
v
.
getId
()
==
R
.
id
.
guide_btn_gohome
)
{
SpUtils
.
putBoolean
(
"isFirstRun"
,
true
);
SpUtils
.
putBoolean
(
"isFirstRun"
,
true
);
IntentUtils
.
startActivity
(
this
,
HomeActivity
.
class
);
if
(
BuildConfig
.
SHOW_INPUT
)
{
IntentUtils
.
startActivity
(
this
,
InputUrlActivity
.
class
);
}
else
{
IntentUtils
.
startActivity
(
this
,
HomeActivity
.
class
);
}
}
}
}
}
...
...
app/src/main/java/com/polysoft/nafmii/activity/HomeActivity.java
View file @
96ad769
...
@@ -10,7 +10,8 @@ import androidx.fragment.app.FragmentManager;
...
@@ -10,7 +10,8 @@ import androidx.fragment.app.FragmentManager;
import
com.polysoft.nafmii.R
;
import
com.polysoft.nafmii.R
;
import
com.polysoft.nafmii.bean.MenuBean
;
import
com.polysoft.nafmii.bean.MenuBean
;
import
com.polysoft.nafmii.enums.ModulesEnum
;
import
com.polysoft.nafmii.enums.ModulesEnum
;
import
com.polysoft.nafmii.fragment.ModulesFragmentMgr
;
import
com.polysoft.nafmii.activity.home.ModulesFragmentMgr
;
import
com.polysoft.nafmii.utils.SpUtils
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Iterator
;
import
java.util.Iterator
;
...
@@ -56,7 +57,7 @@ public class HomeActivity extends WebviewActivity implements View.OnClickListene
...
@@ -56,7 +57,7 @@ public class HomeActivity extends WebviewActivity implements View.OnClickListene
this
.
modulesMgr
.
showInitFragment
(
new
ModulesEnum
[]{
this
.
modulesMgr
.
showInitFragment
(
new
ModulesEnum
[]{
ModulesEnum
.
HOME
,
ModulesEnum
.
MEMBER
,
ModulesEnum
.
HOME
,
ModulesEnum
.
MEMBER
,
ModulesEnum
.
LEARN
,
ModulesEnum
.
MY
ModulesEnum
.
LEARN
,
ModulesEnum
.
MY
});
}
,
getIntent
().
getStringExtra
(
ModulesEnum
.
HOME
.
name
)
);
}
}
...
...
app/src/main/java/com/polysoft/nafmii/activity/InputUrlActivity.java
View file @
96ad769
...
@@ -48,8 +48,9 @@ public class InputUrlActivity extends AppCompatActivity {
...
@@ -48,8 +48,9 @@ public class InputUrlActivity extends AppCompatActivity {
private
void
jumpHome
()
{
private
void
jumpHome
()
{
EditText
input
=
findViewById
(
R
.
id
.
input_url
);
EditText
input
=
findViewById
(
R
.
id
.
input_url
);
String
url
=
input
.
getText
().
toString
();
String
url
=
input
.
getText
().
toString
();
if
(
!
TextUtils
.
isEmpty
(
url
))
{
if
(
TextUtils
.
isEmpty
(
url
))
{
ToastUtils
.
showLong
(
"url 不能为空"
);
ToastUtils
.
showLong
(
"url 不能为空"
);
return
;
}
}
RadioButton
button1
=
findViewById
(
R
.
id
.
input_channel_1
);
RadioButton
button1
=
findViewById
(
R
.
id
.
input_channel_1
);
...
...
app/src/main/java/com/polysoft/nafmii/
fragment
/ModulesFragmentMgr.java
→
app/src/main/java/com/polysoft/nafmii/
activity/home
/ModulesFragmentMgr.java
View file @
96ad769
package
com
.
polysoft
.
nafmii
.
fragment
;
package
com
.
polysoft
.
nafmii
.
activity
.
home
;
import
android.text.TextUtils
;
import
android.text.TextUtils
;
...
@@ -8,6 +8,7 @@ import androidx.fragment.app.FragmentTransaction;
...
@@ -8,6 +8,7 @@ import androidx.fragment.app.FragmentTransaction;
import
com.polysoft.nafmii.bean.MenuBean
;
import
com.polysoft.nafmii.bean.MenuBean
;
import
com.polysoft.nafmii.enums.ModulesEnum
;
import
com.polysoft.nafmii.enums.ModulesEnum
;
import
com.polysoft.nafmii.fragment.WebViewFragment
;
import
com.polysoft.nafmii.webview.IWebview
;
import
com.polysoft.nafmii.webview.IWebview
;
import
java.util.List
;
import
java.util.List
;
...
@@ -22,18 +23,22 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
...
@@ -22,18 +23,22 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
public
ModulesFragmentMgr
(
FragmentManager
manager
,
int
containerId
)
{
public
ModulesFragmentMgr
(
FragmentManager
manager
,
int
containerId
)
{
this
.
manager
=
manager
;
this
.
manager
=
manager
;
this
.
containerId
=
containerId
;
this
.
containerId
=
containerId
;
manager
.
addOnBackStackChangedListener
(
this
);
}
}
public
void
addChangeModuleLsitener
(
OnChangeModuleListener
listener
)
{
public
void
addChangeModuleLsitener
(
OnChangeModuleListener
listener
)
{
this
.
changeListener
=
listener
;
this
.
changeListener
=
listener
;
}
}
public
void
showInitFragment
(
ModulesEnum
[]
modules
)
{
public
void
showInitFragment
(
ModulesEnum
[]
modules
,
String
url
)
{
for
(
int
i
=
0
;
i
<
modules
.
length
;
i
++)
{
WebViewFragment
fragment
=
this
.
addModuleFragment
(
modules
[
0
],
url
);
for
(
int
i
=
1
;
i
<
modules
.
length
;
i
++)
{
this
.
addModuleFragment
(
modules
[
i
]);
this
.
addModuleFragment
(
modules
[
i
]);
}
}
WebViewFragment
fragment
=
this
.
findFragment
(
modules
[
0
]);
//
WebViewFragment fragment = this.findFragment(modules[0]);
FragmentTransaction
transaction
=
this
.
manager
.
beginTransaction
();
FragmentTransaction
transaction
=
this
.
manager
.
beginTransaction
();
transaction
.
show
(
fragment
).
commitNow
();
transaction
.
show
(
fragment
).
commitNow
();
this
.
setCurrentModule
(
modules
[
0
]);
this
.
setCurrentModule
(
modules
[
0
]);
...
@@ -44,15 +49,12 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
...
@@ -44,15 +49,12 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
}
}
public
boolean
onBackStack
()
{
public
boolean
onBackStack
()
{
WebViewFragment
fragment
=
getCurrentFragment
();
WebViewFragment
fragment
=
getCurrentFragment
();
IWebview
webview
=
fragment
.
getWebview
();
IWebview
webview
=
fragment
.
getWebview
();
if
(
null
!=
webview
&&
webview
.
canGoBack
())
{
if
(
null
!=
webview
&&
webview
.
canGoBack
())
{
return
false
;
return
false
;
}
}
if
(
this
.
manager
.
getBackStackEntryCount
()
>
0
)
{
if
(
this
.
manager
.
getBackStackEntryCount
()
>
0
)
{
this
.
manager
.
addOnBackStackChangedListener
(
this
);
this
.
manager
.
popBackStack
();
this
.
manager
.
popBackStack
();
return
false
;
return
false
;
}
}
...
@@ -61,7 +63,7 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
...
@@ -61,7 +63,7 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
public
void
showModule
(
ModulesEnum
module
)
{
public
void
showModule
(
ModulesEnum
module
)
{
if
(
module
==
this
.
currentModule
)
{
if
(
module
==
this
.
currentModule
)
{
return
;
return
;
}
}
WebViewFragment
fragment
=
this
.
findFragment
(
module
);
WebViewFragment
fragment
=
this
.
findFragment
(
module
);
if
(!
module
.
fmtKey
.
equals
(
this
.
currentModule
.
fmtKey
))
{
if
(!
module
.
fmtKey
.
equals
(
this
.
currentModule
.
fmtKey
))
{
...
@@ -69,10 +71,7 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
...
@@ -69,10 +71,7 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
transaction
.
hide
(
this
.
getCurrentFragment
());
transaction
.
hide
(
this
.
getCurrentFragment
());
transaction
.
addToBackStack
(
""
).
show
(
fragment
).
commit
();
transaction
.
addToBackStack
(
""
).
show
(
fragment
).
commit
();
}
else
{
}
else
{
IWebview
webview
=
fragment
.
getWebview
();
fragment
.
getWebview
().
loadUrl
(
module
.
webUrl
);
if
(
null
!=
webview
)
{
webview
.
loadUrl
(
module
.
webUrl
);
}
}
}
this
.
setCurrentModule
(
module
);
this
.
setCurrentModule
(
module
);
}
}
...
@@ -80,9 +79,9 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
...
@@ -80,9 +79,9 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
public
void
showModule
(
MenuBean
bean
)
{
public
void
showModule
(
MenuBean
bean
)
{
ModulesEnum
module
=
ModulesEnum
.
findModule
(
bean
.
getModuleName
());
ModulesEnum
module
=
ModulesEnum
.
findModule
(
bean
.
getModuleName
());
WebViewFragment
fragment
=
this
.
findFragment
(
module
);
WebViewFragment
fragment
=
this
.
findFragment
(
module
);
if
(!
TextUtils
.
isEmpty
(
bean
.
getUrl
()))
{
if
(!
TextUtils
.
isEmpty
(
bean
.
getUrl
()))
{
IWebview
webview
=
fragment
.
getWebview
();
fragment
.
getWebview
().
loadUrl
(
bean
.
getUrl
());
webview
.
loadUrl
(
bean
.
getUrl
());
}
}
if
(!
module
.
fmtKey
.
equals
(
this
.
currentModule
.
fmtKey
))
{
if
(!
module
.
fmtKey
.
equals
(
this
.
currentModule
.
fmtKey
))
{
FragmentTransaction
transaction
=
this
.
manager
.
beginTransaction
();
FragmentTransaction
transaction
=
this
.
manager
.
beginTransaction
();
...
@@ -93,18 +92,18 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
...
@@ -93,18 +92,18 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
}
}
public
WebViewFragment
findFragment
(
ModulesEnum
module
)
{
public
WebViewFragment
findFragment
(
ModulesEnum
module
)
{
WebViewFragment
fragment
=
(
WebViewFragment
)
this
.
manager
.
findFragmentByTag
(
module
.
fmtKey
);
return
this
.
addModuleFragment
(
module
);
if
(
null
==
fragment
)
{
return
this
.
addModuleFragment
(
module
);
}
return
fragment
;
}
}
private
WebViewFragment
addModuleFragment
(
ModulesEnum
module
)
{
private
WebViewFragment
addModuleFragment
(
ModulesEnum
module
)
{
return
addModuleFragment
(
module
,
null
);
}
private
WebViewFragment
addModuleFragment
(
ModulesEnum
module
,
String
url
)
{
WebViewFragment
fragment
=
(
WebViewFragment
)
this
.
manager
.
findFragmentByTag
(
module
.
fmtKey
);
WebViewFragment
fragment
=
(
WebViewFragment
)
this
.
manager
.
findFragmentByTag
(
module
.
fmtKey
);
if
(
null
==
fragment
)
{
if
(
null
==
fragment
)
{
FragmentTransaction
transaction
=
this
.
manager
.
beginTransaction
();
FragmentTransaction
transaction
=
this
.
manager
.
beginTransaction
();
fragment
=
WebViewFragment
.
newInstances
(
module
.
webUrl
);
fragment
=
WebViewFragment
.
newInstances
(
!
TextUtils
.
isEmpty
(
url
)
?
url
:
module
.
webUrl
);
transaction
.
add
(
this
.
containerId
,
fragment
,
module
.
fmtKey
).
hide
(
fragment
).
commitNow
();
transaction
.
add
(
this
.
containerId
,
fragment
,
module
.
fmtKey
).
hide
(
fragment
).
commitNow
();
}
}
return
fragment
;
return
fragment
;
...
@@ -124,7 +123,7 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
...
@@ -124,7 +123,7 @@ public class ModulesFragmentMgr implements FragmentManager.OnBackStackChangedLis
for
(
int
i
=
0
;
i
<
fragments
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
fragments
.
size
();
i
++)
{
Fragment
fragment
=
fragments
.
get
(
i
);
Fragment
fragment
=
fragments
.
get
(
i
);
if
(
fragment
.
isVisible
())
{
if
(
fragment
.
isVisible
())
{
setCurrentModule
(
ModulesEnum
.
findModule
(
fragment
.
getTag
()));
this
.
setCurrentModule
(
ModulesEnum
.
findModule
(
fragment
.
getTag
()));
return
;
return
;
}
}
}
}
...
...
app/src/main/java/com/polysoft/nafmii/constants/JsApi.java
0 → 100644
View file @
96ad769
package
com
.
polysoft
.
nafmii
.
constants
;
public
class
JsApi
{
public
static
final
String
API_ROUTE
=
"changeRoute"
;
}
app/src/main/java/com/polysoft/nafmii/enums/ModulesEnum.java
View file @
96ad769
...
@@ -2,10 +2,10 @@ package com.polysoft.nafmii.enums;
...
@@ -2,10 +2,10 @@ package com.polysoft.nafmii.enums;
public
enum
ModulesEnum
{
public
enum
ModulesEnum
{
HOME
(
"home"
,
"home"
,
"file:///android_asset/dist/index.html"
),
HOME
(
"home"
,
"home"
,
"file:///android_asset/dist/index.html
#/
"
),
MEMBER
(
"member"
,
"home"
,
"file:///android_asset/di
ct/index.html
"
),
MEMBER
(
"member"
,
"home"
,
"file:///android_asset/di
st/index.html#/home
"
),
LEARN
(
"learn"
,
"learn"
,
"http://debugtbs.qq.com"
),
LEARN
(
"learn"
,
"learn"
,
"http://debugtbs.qq.com"
),
MY
(
"my"
,
"home"
,
"file:///android_asset/dist/index.html
/
#/user/center"
);
MY
(
"my"
,
"home"
,
"file:///android_asset/dist/index.html#/user/center"
);
public
final
String
name
;
public
final
String
name
;
public
final
String
fmtKey
;
public
final
String
fmtKey
;
...
...
app/src/main/java/com/polysoft/nafmii/fragment/AdvertisementFragment.java
View file @
96ad769
...
@@ -19,8 +19,10 @@ import com.alibaba.fastjson.JSONObject;
...
@@ -19,8 +19,10 @@ import com.alibaba.fastjson.JSONObject;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.Glide
;
import
com.bumptech.glide.request.target.DrawableImageViewTarget
;
import
com.bumptech.glide.request.target.DrawableImageViewTarget
;
import
com.bumptech.glide.request.transition.Transition
;
import
com.bumptech.glide.request.transition.Transition
;
import
com.polysoft.nafmii.BuildConfig
;
import
com.polysoft.nafmii.R
;
import
com.polysoft.nafmii.R
;
import
com.polysoft.nafmii.activity.HomeActivity
;
import
com.polysoft.nafmii.activity.HomeActivity
;
import
com.polysoft.nafmii.activity.InputUrlActivity
;
import
com.polysoft.nafmii.utils.IntentUtils
;
import
com.polysoft.nafmii.utils.IntentUtils
;
public
class
AdvertisementFragment
extends
Fragment
implements
View
.
OnClickListener
{
public
class
AdvertisementFragment
extends
Fragment
implements
View
.
OnClickListener
{
...
@@ -69,7 +71,7 @@ public class AdvertisementFragment extends Fragment implements View.OnClickListe
...
@@ -69,7 +71,7 @@ public class AdvertisementFragment extends Fragment implements View.OnClickListe
String
picture
=
item
.
getString
(
"picture"
);
String
picture
=
item
.
getString
(
"picture"
);
String
url
=
item
.
getString
(
"url"
);
String
url
=
item
.
getString
(
"url"
);
Glide
.
with
(
getContext
()).
load
(
picture
).
into
(
new
DrawableImageViewTarget
(
this
.
mImgView
){
Glide
.
with
(
getContext
()).
load
(
picture
).
into
(
new
DrawableImageViewTarget
(
this
.
mImgView
)
{
@Override
@Override
public
void
onResourceReady
(
@NonNull
Drawable
resource
,
@Nullable
Transition
<?
super
Drawable
>
transition
)
{
public
void
onResourceReady
(
@NonNull
Drawable
resource
,
@Nullable
Transition
<?
super
Drawable
>
transition
)
{
super
.
onResourceReady
(
resource
,
transition
);
super
.
onResourceReady
(
resource
,
transition
);
...
@@ -98,7 +100,11 @@ public class AdvertisementFragment extends Fragment implements View.OnClickListe
...
@@ -98,7 +100,11 @@ public class AdvertisementFragment extends Fragment implements View.OnClickListe
private
synchronized
void
gotoHome
()
{
private
synchronized
void
gotoHome
()
{
if
(
null
!=
getActivity
()
&&
!
getActivity
().
isFinishing
())
{
if
(
null
!=
getActivity
()
&&
!
getActivity
().
isFinishing
())
{
IntentUtils
.
startActivity
(
getActivity
(),
HomeActivity
.
class
);
if
(
BuildConfig
.
SHOW_INPUT
)
{
IntentUtils
.
startActivity
(
getActivity
(),
InputUrlActivity
.
class
);
}
else
{
IntentUtils
.
startActivity
(
getActivity
(),
HomeActivity
.
class
);
}
}
}
}
}
}
}
app/src/main/java/com/polysoft/nafmii/webview/IWebview.java
View file @
96ad769
...
@@ -2,6 +2,8 @@ package com.polysoft.nafmii.webview;
...
@@ -2,6 +2,8 @@ package com.polysoft.nafmii.webview;
public
interface
IWebview
{
public
interface
IWebview
{
void
callJs
(
String
methodName
,
String
json
);
void
loadUrl
(
String
url
);
void
loadUrl
(
String
url
);
String
getUrl
();
String
getUrl
();
...
...
app/src/main/java/com/polysoft/nafmii/webview/WebviewHandler.java
View file @
96ad769
...
@@ -45,6 +45,11 @@ public class WebviewHandler implements IWebview {
...
@@ -45,6 +45,11 @@ public class WebviewHandler implements IWebview {
}
}
@Override
@Override
public
void
callJs
(
String
methodName
,
String
json
)
{
this
.
java2js
.
callJs
(
methodName
,
json
);
}
@Override
public
void
loadUrl
(
String
url
)
{
public
void
loadUrl
(
String
url
)
{
if
(
TextUtils
.
isEmpty
(
url
)
||
url
.
equals
(
this
.
getUrl
()))
{
if
(
TextUtils
.
isEmpty
(
url
)
||
url
.
equals
(
this
.
getUrl
()))
{
return
;
return
;
...
...
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