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
bca1dd75
Commit
bca1dd75
authored
Jun 03, 2021
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
b914ae54
Pipeline
#216
canceled with stages
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
59 deletions
+78
-59
MainFragment.kt
.../main/java/com/mints/goodnews/ui/fragment/MainFragment.kt
+16
-20
MoneyFragment.kt
...main/java/com/mints/goodnews/ui/fragment/MoneyFragment.kt
+62
-39
No files found.
app/src/main/java/com/mints/goodnews/ui/fragment/MainFragment.kt
View file @
bca1dd75
...
@@ -32,6 +32,7 @@ import com.mints.goodnews.mvp.views.HomeView
...
@@ -32,6 +32,7 @@ import com.mints.goodnews.mvp.views.HomeView
import
com.mints.goodnews.ui.activitys.AwardActivity
import
com.mints.goodnews.ui.activitys.AwardActivity
import
com.mints.goodnews.ui.activitys.WebActivity
import
com.mints.goodnews.ui.activitys.WebActivity
import
com.mints.goodnews.ui.fragment.base.BaseFragment
import
com.mints.goodnews.ui.fragment.base.BaseFragment
import
com.mints.goodnews.ui.fragment.base.LazyLoadBaseFragment
import
com.mints.goodnews.ui.widgets.BindWxDialog
import
com.mints.goodnews.ui.widgets.BindWxDialog
import
com.mints.goodnews.ui.widgets.DialogListener
import
com.mints.goodnews.ui.widgets.DialogListener
import
com.mints.goodnews.ui.widgets.PowerDialog
import
com.mints.goodnews.ui.widgets.PowerDialog
...
@@ -40,7 +41,9 @@ import com.mints.goodnews.ui.widgets.countdowntimer.OnCountDownTimerListener
...
@@ -40,7 +41,9 @@ import com.mints.goodnews.ui.widgets.countdowntimer.OnCountDownTimerListener
import
com.mints.goodnews.ui.widgets.seekbar.BubbleUtils
import
com.mints.goodnews.ui.widgets.seekbar.BubbleUtils
import
com.mints.goodnews.utils.LogUtil
import
com.mints.goodnews.utils.LogUtil
import
com.mints.goodnews.utils.TimeRender
import
com.mints.goodnews.utils.TimeRender
import
com.mints.library.base.BaseLazyFragment
import
com.mints.library.utils.CommonUtils
import
com.mints.library.utils.CommonUtils
import
kotlinx.android.synthetic.main.fragment_liebao_game.*
import
kotlinx.android.synthetic.main.layout_red_bag.*
import
kotlinx.android.synthetic.main.layout_red_bag.*
import
kotlinx.android.synthetic.main.layout_red_box.*
import
kotlinx.android.synthetic.main.layout_red_box.*
import
net.grandcentrix.tray.AppPreferences
import
net.grandcentrix.tray.AppPreferences
...
@@ -52,7 +55,7 @@ private val TAG = MainFragment::class.java.simpleName
...
@@ -52,7 +55,7 @@ private val TAG = MainFragment::class.java.simpleName
* 作者:孟崔广
* 作者:孟崔广
* 时间:2020/10/10 17:30
* 时间:2020/10/10 17:30
*/
*/
class
MainFragment
:
BaseFragment
(),
HomeView
,
View
.
OnClickListener
{
class
MainFragment
:
LazyLoad
BaseFragment
(),
HomeView
,
View
.
OnClickListener
{
private
val
ps
by
lazy
{
AppPreferences
(
context
)
}
private
val
ps
by
lazy
{
AppPreferences
(
context
)
}
private
val
homePresenter
by
lazy
{
HomePresenter
()
}
private
val
homePresenter
by
lazy
{
HomePresenter
()
}
...
@@ -64,6 +67,10 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
...
@@ -64,6 +67,10 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
fragment_main_first
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
fragment_main_first
override
fun
initViewsAndEvents
()
{
override
fun
initViewsAndEvents
()
{
}
override
fun
onFragmentFirstVisible
()
{
homePresenter
.
attachView
(
this
)
homePresenter
.
attachView
(
this
)
videoAdingManager
=
VideoAdingManager
.
getInstance
(
activity
)
videoAdingManager
=
VideoAdingManager
.
getInstance
(
activity
)
...
@@ -80,32 +87,21 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
...
@@ -80,32 +87,21 @@ class MainFragment : BaseFragment(), HomeView, View.OnClickListener {
innerApp
()
innerApp
()
}
}
private
fun
innerApp
()
{
override
fun
onFragmentResume
()
{
if
(
userManager
.
userIsLogin
())
{
super
.
onFragmentResume
()
homePresenter
.
getNetWorkIp
()
TrackManager
.
getInstance
().
innerApp
()
}
}
override
fun
onHiddenChanged
(
hidden
:
Boolean
)
{
if
(
hidden
)
{
onPause
()
}
else
{
onResume
()
}
super
.
onHiddenChanged
(
hidden
)
}
override
fun
onResume
()
{
super
.
onResume
()
if
(
AppConfig
.
fragmentClickFlag
==
Constant
.
FRAGMENT_CLICK_ONE
)
{
if
(
AppConfig
.
fragmentClickFlag
==
Constant
.
FRAGMENT_CLICK_ONE
)
{
if
(!
TextUtils
.
isEmpty
(
userManager
?.
userID
))
{
if
(!
TextUtils
.
isEmpty
(
userManager
?.
userID
))
{
homePresenter
.
getHallBaseMsg
()
homePresenter
.
getHallBaseMsg
()
}
else
{
}
else
{
homePresenter
.
userLogin
()
homePresenter
.
userLogin
()
}
}
}
}
private
fun
innerApp
()
{
if
(
userManager
.
userIsLogin
())
{
homePresenter
.
getNetWorkIp
()
TrackManager
.
getInstance
().
innerApp
()
}
}
}
}
...
...
app/src/main/java/com/mints/goodnews/ui/fragment/MoneyFragment.kt
View file @
bca1dd75
...
@@ -17,16 +17,21 @@ import kotlinx.android.synthetic.main.fragment_main_money.*
...
@@ -17,16 +17,21 @@ import kotlinx.android.synthetic.main.fragment_main_money.*
class
MoneyFragment
:
BaseFragment
(),
XTabLayout
.
OnTabSelectedListener
{
class
MoneyFragment
:
BaseFragment
(),
XTabLayout
.
OnTabSelectedListener
{
companion
object
{
companion
object
{
const
val
FRAGMENT_TAG_
VIDEO
=
"FRAGMENT_TAG_VIDEO
"
const
val
FRAGMENT_TAG_
MAIN1
=
"FRAGMENT_TAG_MAIN1
"
const
val
FRAGMENT_TAG_
BOOKSTORE
=
"FRAGMENT_TAG_BOOKSTORE
"
const
val
FRAGMENT_TAG_
MAIN2
=
"FRAGMENT_TAG_MAIN2
"
const
val
FRAGMENT_TAG_
NEWS
=
"FRAGMENT_TAG_NEWS
"
const
val
FRAGMENT_TAG_
MAIN3
=
"FRAGMENT_TAG_MAIN3
"
const
val
FRAGMENT_TAG_
GAME
=
"FRAGMENT_TAG_GAME
"
const
val
FRAGMENT_TAG_
MAIN4
=
"FRAGMENT_TAG_MAIN4
"
const
val
FRAGMENT_TAG_
KYL
=
"FRAGMENT_TAG_KYL
"
const
val
FRAGMENT_TAG_
MAIN5
=
"FRAGMENT_TAG_MAIN5
"
const
val
FRAGMENT_TAG_XMLY
=
"FRAGMENT_TAG_XMLY"
const
val
FRAGMENT_TAG_XMLY
=
"FRAGMENT_TAG_XMLY"
const
val
FRAGMENT_TAG_GAME
=
"FRAGMENT_TAG_GAME"
}
}
private
var
currentFragment
:
Fragment
?
=
null
private
var
currentFragment
:
Fragment
?
=
null
private
var
mainFragment
:
Fragment
?
=
null
private
var
mainFragment1
:
Fragment
?
=
null
private
var
mainFragment2
:
Fragment
?
=
null
private
var
mainFragment3
:
Fragment
?
=
null
private
var
mainFragment4
:
Fragment
?
=
null
private
var
mainFragment5
:
Fragment
?
=
null
private
var
xmlyGameFragment
:
Fragment
?
=
null
private
var
xmlyGameFragment
:
Fragment
?
=
null
private
var
liebaoGameFragment
:
Fragment
?
=
null
private
var
liebaoGameFragment
:
Fragment
?
=
null
...
@@ -55,26 +60,39 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
...
@@ -55,26 +60,39 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
}
}
private
fun
initView
()
{
private
fun
initView
()
{
if
(
mainFragment
==
null
)
{
if
(
mainFragment
1
==
null
)
{
mainFragment
=
MainFragment
()
mainFragment
1
=
MainFragment
()
}
}
if
(!
mainFragment
!!
.
isAdded
)
{
if
(!
mainFragment
1
!!
.
isAdded
)
{
// 提交事务
// 提交事务
childFragmentManager
.
beginTransaction
().
add
(
R
.
id
.
fragment_container
,
mainFragment
!!
).
commitAllowingStateLoss
()
childFragmentManager
.
beginTransaction
().
add
(
R
.
id
.
fragment_container
,
mainFragment
1
!!
).
commitAllowingStateLoss
()
// 记录当前Fragment
// 记录当前Fragment
currentFragment
=
mainFragment
currentFragment
=
mainFragment
1
}
}
xtFragmentMoney
.
setxTabDisplayNum
(
3
)
xtFragmentMoney
.
setxTabDisplayNum
(
7
)
val
newTab1
=
xtFragmentMoney
.
newTab
()
val
newTab1
=
xtFragmentMoney
.
newTab
()
newTab1
.
text
=
"新闻"
val
newTab2
=
xtFragmentMoney
.
newTab
()
val
newTab3
=
xtFragmentMoney
.
newTab
()
val
newTab4
=
xtFragmentMoney
.
newTab
()
val
newTab4
=
xtFragmentMoney
.
newTab
()
newTab4
.
text
=
"听书"
val
newTab5
=
xtFragmentMoney
.
newTab
()
val
newTab5
=
xtFragmentMoney
.
newTab
()
newTab5
.
text
=
"游戏"
val
newTab6
=
xtFragmentMoney
.
newTab
()
val
newTab7
=
xtFragmentMoney
.
newTab
()
newTab1
.
text
=
"热点"
newTab2
.
text
=
"娱乐"
newTab3
.
text
=
"体育"
newTab4
.
text
=
"军事"
newTab5
.
text
=
"小说"
newTab6
.
text
=
"听书"
newTab7
.
text
=
"游戏"
xtFragmentMoney
.
addTab
(
newTab1
)
xtFragmentMoney
.
addTab
(
newTab1
)
xtFragmentMoney
.
addTab
(
newTab2
)
xtFragmentMoney
.
addTab
(
newTab3
)
xtFragmentMoney
.
addTab
(
newTab4
)
xtFragmentMoney
.
addTab
(
newTab4
)
xtFragmentMoney
.
addTab
(
newTab5
)
xtFragmentMoney
.
addTab
(
newTab5
)
xtFragmentMoney
.
addTab
(
newTab6
)
xtFragmentMoney
.
addTab
(
newTab7
)
xtFragmentMoney
.
addOnTabSelectedListener
(
this
)
xtFragmentMoney
.
addOnTabSelectedListener
(
this
)
}
}
...
@@ -96,28 +114,9 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
...
@@ -96,28 +114,9 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
currentFragment
=
fragment
currentFragment
=
fragment
}
}
fun
selectVedio
()
{
// vpFragmentMoney.currentItem = 0
xtFragmentMoney
.
getTabAt
(
0
)
?.
select
()
if
(
mainFragment
==
null
)
{
mainFragment
=
MainFragment
()
}
addOrShowFragment
(
childFragmentManager
,
mainFragment
!!
,
FRAGMENT_TAG_VIDEO
)
}
fun
selectBook
()
{
// vpFragmentMoney.currentItem = 1
// xtFragmentMoney.getTabAt(1)?.select()
// if (bookStoreFragment == null) {
// bookStoreFragment = ZhangyueFragment()
// }
//
// addOrShowFragment(childFragmentManager, bookStoreFragment!!, FRAGMENT_TAG_BOOKSTORE)
}
fun
selectXmly
()
{
fun
selectXmly
()
{
xtFragmentMoney
.
getTabAt
(
1
)
?.
select
()
xtFragmentMoney
.
getTabAt
(
5
)
?.
select
()
// xtFragmentMoney.getTabAt(2)?.select()
// xtFragmentMoney.getTabAt(2)?.select()
if
(
xmlyGameFragment
==
null
)
{
if
(
xmlyGameFragment
==
null
)
{
xmlyGameFragment
=
XmlyFragment
()
xmlyGameFragment
=
XmlyFragment
()
...
@@ -134,18 +133,42 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
...
@@ -134,18 +133,42 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
override
fun
onTabSelected
(
tab
:
XTabLayout
.
Tab
)
{
override
fun
onTabSelected
(
tab
:
XTabLayout
.
Tab
)
{
when
(
tab
.
position
)
{
when
(
tab
.
position
)
{
0
->
{
0
->
{
if
(
mainFragment
==
null
)
{
if
(
mainFragment
1
==
null
)
{
mainFragment
=
MainFragment
()
mainFragment
1
=
MainFragment
()
}
}
addOrShowFragment
(
childFragmentManager
,
mainFragment
!!
,
FRAGMENT_TAG_VIDEO
)
addOrShowFragment
(
childFragmentManager
,
mainFragment
1
!!
,
FRAGMENT_TAG_MAIN1
)
}
}
1
->
{
1
->
{
if
(
mainFragment2
==
null
)
{
mainFragment2
=
MainFragment
()
}
addOrShowFragment
(
childFragmentManager
,
mainFragment2
!!
,
FRAGMENT_TAG_MAIN2
)
}
2
->
{
if
(
mainFragment3
==
null
)
{
mainFragment3
=
MainFragment
()
}
addOrShowFragment
(
childFragmentManager
,
mainFragment3
!!
,
FRAGMENT_TAG_MAIN3
)
}
3
->
{
if
(
mainFragment4
==
null
)
{
mainFragment4
=
MainFragment
()
}
addOrShowFragment
(
childFragmentManager
,
mainFragment4
!!
,
FRAGMENT_TAG_MAIN4
)
}
4
->
{
if
(
mainFragment5
==
null
)
{
mainFragment4
=
MainFragment
()
}
addOrShowFragment
(
childFragmentManager
,
mainFragment5
!!
,
FRAGMENT_TAG_MAIN5
)
}
5
->
{
if
(
xmlyGameFragment
==
null
)
{
if
(
xmlyGameFragment
==
null
)
{
xmlyGameFragment
=
XmlyFragment
()
xmlyGameFragment
=
XmlyFragment
()
}
}
addOrShowFragment
(
childFragmentManager
,
xmlyGameFragment
!!
,
FRAGMENT_TAG_XMLY
)
addOrShowFragment
(
childFragmentManager
,
xmlyGameFragment
!!
,
FRAGMENT_TAG_XMLY
)
}
}
2
->
{
6
->
{
if
(
liebaoGameFragment
==
null
)
{
if
(
liebaoGameFragment
==
null
)
{
liebaoGameFragment
=
LiebaoGameFragment
()
liebaoGameFragment
=
LiebaoGameFragment
()
}
}
...
...
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