Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_goodnews
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
android
android_goodnews
Commits
b914ae54
Commit
b914ae54
authored
Jun 03, 2021
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
优化代码
parent
c810c373
Pipeline
#213
canceled with stages
Changes
6
Pipelines
1
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
107 additions
and
607 deletions
+107
-607
MintsApplication.java
app/src/main/java/com/mints/goodnews/MintsApplication.java
+0
-2
HomePresenter.kt
...n/java/com/mints/goodnews/mvp/presenters/HomePresenter.kt
+0
-24
HomeView.kt
app/src/main/java/com/mints/goodnews/mvp/views/HomeView.kt
+0
-1
MainActivity.kt
...main/java/com/mints/goodnews/ui/activitys/MainActivity.kt
+68
-1
MainFragment.kt
.../main/java/com/mints/goodnews/ui/fragment/MainFragment.kt
+8
-468
MoneyFragment.kt
...main/java/com/mints/goodnews/ui/fragment/MoneyFragment.kt
+31
-111
No files found.
app/src/main/java/com/mints/goodnews/MintsApplication.java
View file @
b914ae54
...
...
@@ -109,7 +109,6 @@ public class MintsApplication extends MultiDexApplication {
// preInit预初始化函数耗时极少,不会影响App首次冷启动用户体验
UMConfigure
.
preInit
(
this
,
CommonUtils
.
getAppMetaData
(
MintsApplication
.
getContext
(),
"UMENG_KEY"
),
CommonUtils
.
getAppMetaData
(
MintsApplication
.
getContext
(),
"CHANNEL_NAME"
));
// 初始化toast
initToast
();
...
...
@@ -137,7 +136,6 @@ public class MintsApplication extends MultiDexApplication {
// 天卓珊瑚
TzManager
.
INSTANCE
.
initTz
(
this
);
// 猎豹游戏初始化
LiebaoManager
.
getInstance
().
initCmGameSdk
();
...
...
app/src/main/java/com/mints/goodnews/mvp/presenters/HomePresenter.kt
View file @
b914ae54
...
...
@@ -94,30 +94,6 @@ class HomePresenter : BasePresenter<HomeView>() {
})
}
fun
getHomeVedioMsg
()
{
AppHttpManager
.
getInstance
(
loanApplication
)
.
call
(
loanService
.
getHomeVedioMsg
(),
object
:
BaseSubscriber
<
BaseResponse
<
MainVideoMsgBean
>>()
{
override
fun
onCompleted
()
{
if
(
isLinkView
)
return
}
override
fun
onError
(
e
:
Throwable
)
{
if
(
isLinkView
)
return
}
override
fun
onNext
(
baseResponse
:
BaseResponse
<
MainVideoMsgBean
>)
{
if
(
isLinkView
)
return
val
code
=
baseResponse
.
getStatus
()
val
message
=
baseResponse
.
getMessage
()
when
(
code
)
{
200
->
view
.
getHomeVedioMsgSuc
(
baseResponse
.
getData
())
else
->
view
.
showToast
(
message
)
}
}
})
}
/**
* 游客登录
...
...
app/src/main/java/com/mints/goodnews/mvp/views/HomeView.kt
View file @
b914ae54
...
...
@@ -6,5 +6,4 @@ import com.mints.goodnews.mvp.model.UserTaskMsgBean
interface
HomeView
:
BaseView
{
fun
getHallBaseMsgSuc
(
data
:
UserTaskMsgBean
)
fun
getHomeVedioMsgSuc
(
data
:
MainVideoMsgBean
)
}
app/src/main/java/com/mints/goodnews/ui/activitys/MainActivity.kt
View file @
b914ae54
...
...
@@ -3,20 +3,27 @@ package com.mints.goodnews.ui.activitys
import
android.content.Context
import
android.media.AudioManager
import
android.os.Bundle
import
android.text.TextUtils
import
android.view.KeyEvent
import
android.view.View
import
androidx.fragment.app.Fragment
import
androidx.fragment.app.FragmentManager
import
androidx.fragment.app.FragmentTransaction
import
com.mints.goodnews.MintsApplication
import
com.mints.goodnews.R
import
com.mints.goodnews.ad.video.VideoAdingManager
import
com.mints.goodnews.common.AppConfig
import
com.mints.goodnews.common.Constant
import
com.mints.goodnews.ad.express.TTPreLoadCarrierExpressManager
import
com.mints.goodnews.manager.ShumeiManager
import
com.mints.goodnews.mvp.views.MainView
import
com.mints.goodnews.ui.activitys.base.BaseActivity
import
com.mints.goodnews.ui.fragment.*
import
com.mints.goodnews.ui.widgets.DialogListener
import
com.mints.goodnews.ui.widgets.PowerDialog
import
com.mints.library.utils.CommonUtils
import
kotlinx.android.synthetic.main.activity_main.*
import
net.grandcentrix.tray.AppPreferences
/**
* 描述:main
...
...
@@ -28,6 +35,9 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
private
val
audioManager
by
lazy
{
getSystemService
(
Context
.
AUDIO_SERVICE
)
as
AudioManager
}
private
val
ps
by
lazy
{
AppPreferences
(
context
)
}
private
var
powerDialog
:
PowerDialog
?
=
null
// 底部标签切换的Fragment
private
var
moneyFragment
:
Fragment
?
=
null
private
var
panFragment
:
Fragment
?
=
null
...
...
@@ -35,7 +45,6 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
private
var
friendsFragment
:
Fragment
?
=
null
private
var
myFragment
:
Fragment
?
=
null
private
var
channelFragment
:
Fragment
?
=
null
private
var
kuYinyueFragment
:
Fragment
?
=
null
private
var
wzFragment
:
Fragment
?
=
null
private
var
currentFragment
:
Fragment
?
=
null
...
...
@@ -80,6 +89,13 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
tab_rl_two
.
setOnClickListener
(
this
)
tab_rl_four
.
setOnClickListener
(
this
)
tab_rl_five
.
setOnClickListener
(
this
)
if
(
ps
.
getBoolean
(
Constant
.
LOAN_PERMISSION_FLAG
,
true
))
{
powerDialog
()
}
else
{
// 数美初始化
ShumeiManager
.
getInstance
().
initShumei
()
}
}
override
fun
isApplyKitKatTranslucency
()
=
false
...
...
@@ -301,4 +317,55 @@ class MainActivity : BaseActivity(), MainView, View.OnClickListener {
tab_rl_two
.
visibility
=
View
.
GONE
}
}
/**
* 权限弹窗
*/
private
fun
powerDialog
()
{
powerDialog
=
PowerDialog
(
this
,
object
:
DialogListener
()
{
override
fun
onClick
(
v
:
View
)
{
when
(
v
.
id
)
{
R
.
id
.
tv_dialogper_agreement
->
{
val
bundle
=
Bundle
()
bundle
.
putString
(
WebActivity
.
WEB_TITLE
,
getString
(
R
.
string
.
register_name
))
bundle
.
putString
(
WebActivity
.
WEB_URL
,
Constant
.
REGISTER_URL
)
readyGo
(
WebActivity
::
class
.
java
,
bundle
)
}
R
.
id
.
tv_dialogper_policy
->
{
val
bundle
=
Bundle
()
bundle
.
putString
(
WebActivity
.
WEB_TITLE
,
getString
(
R
.
string
.
privacy_name
))
bundle
.
putString
(
WebActivity
.
WEB_URL
,
Constant
.
PRIVACY_URL
)
readyGo
(
WebActivity
::
class
.
java
,
bundle
)
}
R
.
id
.
btn_dialogper_back
->
{
if
(
powerDialog
!=
null
&&
powerDialog
!!
.
isShowing
)
{
showToast
(
"请您同意授权,否则将无法使用APP功能"
)
}
}
R
.
id
.
btn_dialogper_next
->
{
if
(
powerDialog
!=
null
&&
powerDialog
!!
.
isShowing
)
{
powerDialog
!!
.
dismiss
()
ps
.
put
(
Constant
.
LOAN_PERMISSION_FLAG
,
false
)
// 数美初始化
ShumeiManager
.
getInstance
().
initShumei
()
// 游客首次提示1500新人奖励 且 不是分享包
val
channel
=
CommonUtils
.
getAppMetaData
(
MintsApplication
.
getContext
(),
"CHANNEL_NAME"
)
if
(!
TextUtils
.
equals
(
channel
,
Constant
.
CHANNEL_SHARE
)
&&
ps
.
getBoolean
(
Constant
.
FIRST_VISITOR_FLAG
,
true
))
{
ps
.
put
(
Constant
.
FIRST_VISITOR_FLAG
,
false
)
val
bundle
=
Bundle
()
bundle
.
putInt
(
Constant
.
MAIN_CUR_COIN
,
2000
)
bundle
.
putString
(
Constant
.
MAIN_CARRIER_TYPE
,
Constant
.
CARRIER_NEW_VISITOR
)
readyGo
(
AwardActivity
::
class
.
java
,
bundle
)
}
}
}
}
}
})
powerDialog
!!
.
show
()
}
}
\ No newline at end of file
app/src/main/java/com/mints/goodnews/ui/fragment/MainFragment.kt
View file @
b914ae54
This diff is collapsed.
Click to expand it.
app/src/main/java/com/mints/goodnews/ui/fragment/MoneyFragment.kt
View file @
b914ae54
...
...
@@ -27,11 +27,8 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
private
var
currentFragment
:
Fragment
?
=
null
private
var
mainFragment
:
Fragment
?
=
null
private
var
bookStoreFragment
:
Fragment
?
=
null
// private var newsFragment: Fragment? = null
private
var
xmlyGameFragment
:
Fragment
?
=
null
private
var
liebaoGameFragment
:
Fragment
?
=
null
// private var kuYinyueFragment: Fragment? = null
private
var
curPosition
=
0
//当前标签选中的下标
...
...
@@ -42,87 +39,43 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
}
override
fun
onHiddenChanged
(
hidden
:
Boolean
)
{
if
(
AppConfig
.
showAdFlag
)
{
// if (curPosition == 0) {
// mainFragment?.onHiddenChanged(hidden)
// } else if (curPosition == 3) {
// liebaoGameFragment?.onHiddenChanged(hidden)
// }
if
(
curPosition
==
0
)
{
mainFragment
?.
onHiddenChanged
(
hidden
)
}
else
if
(
curPosition
==
2
)
{
liebaoGameFragment
?.
onHiddenChanged
(
hidden
)
}
}
else
{
if
(
curPosition
==
1
)
{
liebaoGameFragment
?.
onHiddenChanged
(
hidden
)
}
}
// if (curPosition == 0) {
// mainFragment?.onHiddenChanged(hidden)
// } else if (curPosition == 2) {
// liebaoGameFragment?.onHiddenChanged(hidden)
// }
super
.
onHiddenChanged
(
hidden
)
}
override
fun
setUserVisibleHint
(
isVisibleToUser
:
Boolean
)
{
super
.
setUserVisibleHint
(
isVisibleToUser
)
if
(
curPosition
==
0
)
{
mainFragment
?.
userVisibleHint
=
isVisibleToUser
}
//
if (curPosition == 0) {
//
mainFragment?.userVisibleHint = isVisibleToUser
//
}
}
private
fun
initView
()
{
if
(
AppConfig
.
showAdFlag
)
{
if
(
mainFragment
==
null
)
{
mainFragment
=
MainFragment
()
}
if
(!
mainFragment
!!
.
isAdded
)
{
// 提交事务
childFragmentManager
.
beginTransaction
().
add
(
R
.
id
.
fragment_container
,
mainFragment
!!
).
commitAllowingStateLoss
()
// 记录当前Fragment
currentFragment
=
mainFragment
}
xtFragmentMoney
.
setxTabDisplayNum
(
3
)
val
newTab1
=
xtFragmentMoney
.
newTab
()
newTab1
.
text
=
"视频"
// val newTab2 = xtFragmentMoney.newTab()
// newTab2.text = "书城"
// val newTab3 = xtFragmentMoney.newTab()
// newTab3.text = "新闻"
val
newTab4
=
xtFragmentMoney
.
newTab
()
newTab4
.
text
=
"听书"
val
newTab5
=
xtFragmentMoney
.
newTab
()
newTab5
.
text
=
"游戏"
xtFragmentMoney
.
addTab
(
newTab1
)
// xtFragmentMoney.addTab(newTab2)
// xtFragmentMoney.addTab(newTab3)
xtFragmentMoney
.
addTab
(
newTab4
)
xtFragmentMoney
.
addTab
(
newTab5
)
xtFragmentMoney
.
addOnTabSelectedListener
(
this
)
}
else
{
if
(
xmlyGameFragment
==
null
)
{
xmlyGameFragment
=
XmlyFragment
()
}
if
(!
xmlyGameFragment
!!
.
isAdded
)
{
// 提交事务
childFragmentManager
.
beginTransaction
().
add
(
R
.
id
.
fragment_container
,
xmlyGameFragment
!!
).
commitAllowingStateLoss
()
// 记录当前Fragment
currentFragment
=
xmlyGameFragment
}
xtFragmentMoney
.
setxTabDisplayNum
(
2
)
val
newTab4
=
xtFragmentMoney
.
newTab
()
newTab4
.
text
=
"听书"
val
newTab5
=
xtFragmentMoney
.
newTab
()
newTab5
.
text
=
"游戏"
// xtFragmentMoney.addTab(newTab3)
xtFragmentMoney
.
addTab
(
newTab4
)
xtFragmentMoney
.
addTab
(
newTab5
)
xtFragmentMoney
.
addOnTabSelectedListener
(
this
)
if
(
mainFragment
==
null
)
{
mainFragment
=
MainFragment
()
}
if
(!
mainFragment
!!
.
isAdded
)
{
// 提交事务
childFragmentManager
.
beginTransaction
().
add
(
R
.
id
.
fragment_container
,
mainFragment
!!
).
commitAllowingStateLoss
()
// 记录当前Fragment
currentFragment
=
mainFragment
}
xtFragmentMoney
.
setxTabDisplayNum
(
3
)
val
newTab1
=
xtFragmentMoney
.
newTab
()
newTab1
.
text
=
"新闻"
val
newTab4
=
xtFragmentMoney
.
newTab
()
newTab4
.
text
=
"听书"
val
newTab5
=
xtFragmentMoney
.
newTab
()
newTab5
.
text
=
"游戏"
xtFragmentMoney
.
addTab
(
newTab1
)
xtFragmentMoney
.
addTab
(
newTab4
)
xtFragmentMoney
.
addTab
(
newTab5
)
xtFragmentMoney
.
addOnTabSelectedListener
(
this
)
}
/**
...
...
@@ -181,38 +134,11 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
override
fun
onTabSelected
(
tab
:
XTabLayout
.
Tab
)
{
when
(
tab
.
position
)
{
0
->
{
if
(
AppConfig
.
showAdFlag
)
{
if
(
mainFragment
==
null
)
{
mainFragment
=
MainFragment
()
}
addOrShowFragment
(
childFragmentManager
,
mainFragment
!!
,
FRAGMENT_TAG_VIDEO
)
}
else
{
if
(
xmlyGameFragment
==
null
)
{
xmlyGameFragment
=
XmlyFragment
()
}
addOrShowFragment
(
childFragmentManager
,
xmlyGameFragment
!!
,
FRAGMENT_TAG_XMLY
)
if
(
mainFragment
==
null
)
{
mainFragment
=
MainFragment
()
}
addOrShowFragment
(
childFragmentManager
,
mainFragment
!!
,
FRAGMENT_TAG_VIDEO
)
}
// 1 -> {
// if (AppConfig.showAdFlag) {
// if (bookStoreFragment == null) {
// bookStoreFragment = ZhangyueFragment()
// }
// addOrShowFragment(childFragmentManager, bookStoreFragment!!, FRAGMENT_TAG_BOOKSTORE)
// } else {
// if (liebaoGameFragment == null) {
// liebaoGameFragment = LiebaoGameFragment()
// }
// addOrShowFragment(childFragmentManager, liebaoGameFragment!!, FRAGMENT_TAG_GAME)
// }
// }
// 2 -> {
// if (newsFragment == null) {
// newsFragment = RsNewsFragment()
// }
// addOrShowFragment(childFragmentManager, newsFragment!!, FRAGMENT_TAG_NEWS)
// }
1
->
{
if
(
xmlyGameFragment
==
null
)
{
xmlyGameFragment
=
XmlyFragment
()
...
...
@@ -225,12 +151,6 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
}
addOrShowFragment
(
childFragmentManager
,
liebaoGameFragment
!!
,
FRAGMENT_TAG_GAME
)
}
// 3 -> {
// if (kuYinyueFragment == null) {
// kuYinyueFragment = KuYinYueFragment()
// }
// addOrShowFragment(childFragmentManager, kuYinyueFragment!!, FRAGMENT_TAG_KYL)
// }
}
curPosition
=
tab
.
position
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment