Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
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
bp
ShenghuoquanBusiness
Commits
e964b611
Commit
e964b611
authored
Jul 09, 2021
by
shiyl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
选择类目增加二次进入被选中的效果
parent
56b971c2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
7 deletions
+16
-7
CategoryListDto.kt
.../com/yidian/shenghuoquan/commodity/dto/CategoryListDto.kt
+6
-5
ChooseCategoryViewModel.kt
...enghuoquan/commodity/ui/coupon/ChooseCategoryViewModel.kt
+1
-0
CategorySubListAdapter.kt
...uan/commodity/ui/coupon/adapter/CategorySubListAdapter.kt
+9
-2
No files found.
Components/commodity/src/main/java/com/yidian/shenghuoquan/commodity/dto/CategoryListDto.kt
View file @
e964b611
...
...
@@ -5,14 +5,15 @@ package com.yidian.shenghuoquan.commodity.dto
* 类目列表
*/
data class
CategoryListDto
(
val
category_id
:
Int
,
// 分类id
val
name
:
String
,
// 分类名称
val
sub_list
:
List
<
SubCategory
>
// 二级分类
val
category_id
:
Int
,
// 分类id
val
name
:
String
,
// 分类名称
val
sub_list
:
List
<
SubCategory
>
// 二级分类
)
data class
SubCategory
(
val
category_id
:
Int
,
val
name
:
String
val
category_id
:
Int
,
val
name
:
String
,
var
isSelect
:
Boolean
=
false
)
/**
...
...
Components/commodity/src/main/java/com/yidian/shenghuoquan/commodity/ui/coupon/ChooseCategoryViewModel.kt
View file @
e964b611
...
...
@@ -68,6 +68,7 @@ class ChooseCategoryViewModel : BaseViewModel() {
if
(
categoryListDto
.
category_id
==
selectedCategory
.
value
?.
firstCategoryId
)
{
categoryListDto
.
sub_list
.
forEach
{
sub
->
if
(
sub
.
category_id
==
selectSecondCategoryId
.
value
)
{
sub
.
isSelect
=
true
// 匹配成功的一级类目
matchSuccessFirstCategory
=
categoryListDto
matchSuccess
=
true
...
...
Components/commodity/src/main/java/com/yidian/shenghuoquan/commodity/ui/coupon/adapter/CategorySubListAdapter.kt
View file @
e964b611
package
com.yidian.shenghuoquan.commodity.ui.coupon.adapter
import
android.widget.TextView
import
androidx.core.content.ContextCompat
import
com.chad.library.adapter.base.BaseQuickAdapter
import
com.chad.library.adapter.base.viewholder.BaseViewHolder
import
com.yidian.shenghuoquan.commodity.R
import
com.yidian.shenghuoquan.commodity.dto.SubCategory
class
CategorySubListAdapter
:
BaseQuickAdapter
<
SubCategory
,
BaseViewHolder
>(
R
.
layout
.
commodity_layout_category_list_item
)
{
class
CategorySubListAdapter
:
BaseQuickAdapter
<
SubCategory
,
BaseViewHolder
>(
R
.
layout
.
commodity_layout_category_list_item
)
{
override
fun
convert
(
holder
:
BaseViewHolder
,
item
:
SubCategory
)
{
holder
.
getView
<
TextView
>(
R
.
id
.
tv_category_name
).
text
=
item
.
name
val
categoryName
=
holder
.
getView
<
TextView
>(
R
.
id
.
tv_category_name
)
categoryName
.
text
=
item
.
name
if
(
item
.
isSelect
)
{
categoryName
.
setTextColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
color_1852F1
))
}
else
{
categoryName
.
setTextColor
(
ContextCompat
.
getColor
(
context
,
R
.
color
.
color_333333
))
}
}
}
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