Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
android_goodmoney
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_goodmoney
Commits
4e78560b
Commit
4e78560b
authored
Dec 21, 2020
by
mengcuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
代码优化
parent
68b4b32d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
94 additions
and
16 deletions
+94
-16
XmlyPageAdapter.kt
...in/java/com/mints/goodmoney/ui/adapter/XmlyPageAdapter.kt
+43
-0
MoneyFragment.kt
...ain/java/com/mints/goodmoney/ui/fragment/MoneyFragment.kt
+12
-12
XmlyPageFragment.kt
.../java/com/mints/goodmoney/ui/fragment/XmlyPageFragment.kt
+13
-0
fragment_main_xmly_page.xml
...Money/app/src/main/res/layout/fragment_main_xmly_page.xml
+6
-4
item_rv_xmly_page.xml
GoodMoney/app/src/main/res/layout/item_rv_xmly_page.xml
+20
-0
No files found.
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/adapter/XmlyPageAdapter.kt
0 → 100644
View file @
4e78560b
package
com.mints.goodmoney.ui.adapter
import
android.content.Context
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
androidx.recyclerview.widget.RecyclerView
import
com.mints.goodmoney.R
class
XmlyPageAdapter
(
val
xmlyPageList
:
Any
?)
:
RecyclerView
.
Adapter
<
XmlyPageAdapter
.
ViewHolder
>()
{
lateinit
var
context
:
Context
lateinit
var
mOnItemClickListener
:
OnItemClickListener
inner
class
ViewHolder
(
view
:
View
)
:
RecyclerView
.
ViewHolder
(
view
)
{
}
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
ViewHolder
{
context
=
parent
.
context
val
view
=
LayoutInflater
.
from
(
context
).
inflate
(
R
.
layout
.
item_rv_xmly_page
,
parent
,
false
)
val
viewHolder
=
ViewHolder
(
view
)
return
viewHolder
}
override
fun
onBindViewHolder
(
holder
:
ViewHolder
,
position
:
Int
)
{
holder
.
itemView
.
setTag
(
position
)
}
// override fun getItemCount() = xmlyPageList?.size
override
fun
getItemCount
()
=
10
interface
OnItemClickListener
{
fun
onItemClick
(
position
:
Int
)
}
fun
setOnItemClickListener
(
listener
:
OnItemClickListener
)
{
mOnItemClickListener
=
listener
}
}
\ No newline at end of file
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/MoneyFragment.kt
View file @
4e78560b
...
...
@@ -44,7 +44,7 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
override
fun
onHiddenChanged
(
hidden
:
Boolean
)
{
if
(
curPosition
==
0
)
{
mainFragment
?.
onHiddenChanged
(
hidden
)
}
else
if
(
curPosition
==
4
)
{
}
else
if
(
curPosition
==
3
)
{
liebaoGameFragment
?.
onHiddenChanged
(
hidden
)
}
super
.
onHiddenChanged
(
hidden
)
...
...
@@ -90,20 +90,20 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
currentFragment
=
mainFragment
}
xtFragmentMoney
.
setxTabDisplayNum
(
5
)
xtFragmentMoney
.
setxTabDisplayNum
(
4
)
val
newTab1
=
xtFragmentMoney
.
newTab
()
newTab1
.
text
=
"视频"
val
newTab2
=
xtFragmentMoney
.
newTab
()
newTab2
.
text
=
"书城"
val
newTab3
=
xtFragmentMoney
.
newTab
()
newTab3
.
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(newTab3)
xtFragmentMoney
.
addTab
(
newTab4
)
xtFragmentMoney
.
addTab
(
newTab5
)
xtFragmentMoney
.
addOnTabSelectedListener
(
this
)
...
...
@@ -172,19 +172,19 @@ class MoneyFragment : BaseFragment(), XTabLayout.OnTabSelectedListener {
}
addOrShowFragment
(
childFragmentManager
,
bookStoreFragment
!!
,
FRAGMENT_TAG_BOOKSTORE
)
}
// 2 -> {
// if (newsFragment == null) {
// newsFragment = RsNewsFragment()
// }
// addOrShowFragment(childFragmentManager, newsFragment!!, FRAGMENT_TAG_NEWS)
// }
2
->
{
if
(
newsFragment
==
null
)
{
newsFragment
=
RsNewsFragment
()
}
addOrShowFragment
(
childFragmentManager
,
newsFragment
!!
,
FRAGMENT_TAG_NEWS
)
}
3
->
{
if
(
xmlyGameFragment
==
null
)
{
xmlyGameFragment
=
XmlyFragment
()
}
addOrShowFragment
(
childFragmentManager
,
xmlyGameFragment
!!
,
FRAGMENT_TAG_XMLY
)
}
4
->
{
3
->
{
if
(
liebaoGameFragment
==
null
)
{
liebaoGameFragment
=
LiebaoGameFragment
()
}
...
...
GoodMoney/app/src/main/java/com/mints/goodmoney/ui/fragment/XmlyPageFragment.kt
View file @
4e78560b
package
com.mints.goodmoney.ui.fragment
import
androidx.recyclerview.widget.GridLayoutManager
import
com.mints.goodmoney.R
import
com.mints.goodmoney.ui.adapter.XmlyPageAdapter
import
com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment
import
kotlinx.android.synthetic.main.fragment_main_xmly_page.*
/**
* 描述:喜马拉雅封面
...
...
@@ -9,9 +12,12 @@ import com.mints.goodmoney.ui.fragment.base.LazyLoadBaseFragment
*/
class
XmlyPageFragment
(
val
data
:
Int
)
:
LazyLoadBaseFragment
()
{
private
lateinit
var
xmlyPageAdapter
:
XmlyPageAdapter
override
fun
getContentViewLayoutID
()
=
R
.
layout
.
fragment_main_xmly_page
override
fun
initViewsAndEvents
()
{
}
override
fun
onFragmentFirstVisible
()
{
...
...
@@ -19,8 +25,15 @@ class XmlyPageFragment(val data: Int) : LazyLoadBaseFragment() {
showToast
(
""
+
data
)
//recyclerview 加载封面
initRvView
()
//recyclerview 事件监听
}
private
fun
initRvView
()
{
val
gridLayoutManager
=
GridLayoutManager
(
context
,
2
)
xmlyPageVip
.
layoutManager
=
gridLayoutManager
xmlyPageAdapter
=
XmlyPageAdapter
(
null
)
xmlyPageVip
.
adapter
=
xmlyPageAdapter
}
}
\ No newline at end of file
GoodMoney/app/src/main/res/layout/fragment_main_xmly_page.xml
View file @
4e78560b
<?xml version="1.0" encoding="utf-8"?>
<
com.mints.goodmoney.ui.widgets.MyViewPager
xmlns:android=
"http://schemas.android.com/apk/res/android"
<
androidx.recyclerview.widget.RecyclerView
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:id=
"@+id/vpFragmentXmly"
android:background=
"#0f0"
android:id=
"@+id/xmlyPageVip"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
\ No newline at end of file
android:layout_height=
"match_parent"
android:layout_gravity=
"center_horizontal"
android:background=
"@null"
android:overScrollMode=
"never"
/>
\ No newline at end of file
GoodMoney/app/src/main/res/layout/item_rv_xmly_page.xml
0 → 100644
View file @
4e78560b
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
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=
"wrap_content"
android:gravity=
"center_horizontal"
android:background=
"#0f0"
android:layout_margin=
"10dp"
android:orientation=
"vertical"
>
<TextView
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"6dp"
android:layout_marginBottom=
"16dp"
android:textSize=
"14sp"
android:textColor=
"@color/black"
android:text=
"原价:123"
/>
</LinearLayout>
\ No newline at end of file
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