角色tag 初步
This commit is contained in:
parent
9aac716672
commit
2fe723aead
|
|
@ -3,22 +3,21 @@ package com.remax.visualnovel.api.service
|
|||
import com.remax.visualnovel.BuildConfig
|
||||
import com.remax.visualnovel.entity.response.basenew.ResponseNew
|
||||
import com.remax.visualnovel.entity.request.ParamActorList
|
||||
import com.remax.visualnovel.entity.request.ParamActorTag
|
||||
import com.remax.visualnovel.entity.response.ActorBean
|
||||
import com.remax.visualnovel.entity.response.ActorTag
|
||||
import com.remax.visualnovel.widget.custom.ActorTag
|
||||
import retrofit2.http.Body
|
||||
import retrofit2.http.GET
|
||||
import retrofit2.http.POST
|
||||
|
||||
|
||||
interface ActorsService {
|
||||
@GET(BuildConfig.API_BASE + "/tag/getTags")
|
||||
suspend fun requestActorTags(): ResponseNew<List<ActorTag>>
|
||||
@POST(BuildConfig.API_BASE + "/tag/selectByCondition")
|
||||
suspend fun requestActorTags(@Body param: ParamActorTag): ResponseNew<List<ActorTag>>
|
||||
|
||||
@POST(BuildConfig.API_BASE + "/character/select/list")
|
||||
suspend fun requestActorList(@Body param: ParamActorList): ResponseNew<List<ActorBean>>
|
||||
|
||||
/*@GET(BuildConfig.API_BASE + "/character/select/roleInfo/{roleId}")
|
||||
suspend fun requestActorInfo(): ResponseNew<ActorTag>*/
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
package com.remax.visualnovel.entity.request
|
||||
|
||||
|
||||
data class ParamActorTag(
|
||||
var name: String = "",
|
||||
var limit: Int = 5
|
||||
)
|
||||
|
|
@ -1,7 +0,0 @@
|
|||
package com.remax.visualnovel.entity.response
|
||||
|
||||
|
||||
data class ActorTag(
|
||||
val tagName: String,
|
||||
val tagId: Long
|
||||
)
|
||||
|
|
@ -2,13 +2,14 @@ package com.remax.visualnovel.repository.api
|
|||
|
||||
import com.remax.visualnovel.api.service.ActorsService
|
||||
import com.remax.visualnovel.entity.request.ParamActorList
|
||||
import com.remax.visualnovel.entity.request.ParamActorTag
|
||||
import com.remax.visualnovel.repository.api.base.BaseRepositoryNew
|
||||
import javax.inject.Inject
|
||||
|
||||
|
||||
class ActorsRepository @Inject constructor(private val mActorsService: ActorsService) : BaseRepositoryNew() {
|
||||
suspend fun getActorTags() = executeHttp {
|
||||
mActorsService.requestActorTags()
|
||||
suspend fun getActorTags(param: ParamActorTag) = executeHttp {
|
||||
mActorsService.requestActorTags(param)
|
||||
}
|
||||
|
||||
suspend fun getActorList(param: ParamActorList) = executeHttp {
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import androidx.appcompat.widget.AppCompatImageView
|
|||
import androidx.fragment.app.Fragment
|
||||
import androidx.viewpager2.adapter.FragmentStateAdapter
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.gyf.immersionbar.ImmersionBar
|
||||
import com.remax.visualnovel.R
|
||||
import com.remax.visualnovel.app.base.BaseBindingActivity
|
||||
import com.remax.visualnovel.databinding.ActivityMainBinding
|
||||
|
|
@ -30,7 +31,6 @@ import com.remax.visualnovel.ui.main.actor.ActorListFragment
|
|||
import com.remax.visualnovel.ui.main.book.BookListFragment
|
||||
import com.remax.visualnovel.ui.main.history.HistoryFragment
|
||||
import com.remax.visualnovel.ui.main.managa.MangaListFragment
|
||||
import com.remax.visualnovel.utils.StatusBarUtil3
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
|
||||
|
||||
|
|
@ -42,9 +42,12 @@ class MainActivity : BaseBindingActivity<ActivityMainBinding>() {
|
|||
private val mainViewModel by viewModels<MainViewModel>()
|
||||
|
||||
override fun initView() {
|
||||
/*StatusBarUtils.setStatusBarAndNavBarIsLight(this, false)
|
||||
StatusBarUtils.setTransparent(this)*/
|
||||
StatusBarUtil3.setImmersiveStatusBar(this, true)
|
||||
ImmersionBar.with(this)
|
||||
.transparentStatusBar()
|
||||
.statusBarColor(R.color.transparent)
|
||||
.statusBarDarkFont(true)
|
||||
.fitsSystemWindows(true)
|
||||
.init();
|
||||
|
||||
onBackPressedDispatcher.addCallback(this) {
|
||||
if (mainViewModel.canBack) {
|
||||
|
|
|
|||
|
|
@ -9,19 +9,19 @@ import androidx.recyclerview.widget.DefaultItemAnimator
|
|||
import androidx.recyclerview.widget.StaggeredGridLayoutManager
|
||||
import com.alibaba.android.arouter.facade.annotation.Route
|
||||
import com.alibaba.android.arouter.launcher.ARouter
|
||||
import com.chad.library.adapter.base.loadmore.LoadMoreStatus
|
||||
import com.dylanc.loadingstateview.BgColorType
|
||||
import com.remax.visualnovel.R
|
||||
import com.remax.visualnovel.app.base.BaseBindingFragment
|
||||
import com.remax.visualnovel.app.widget.setMyEmptyView
|
||||
import com.remax.visualnovel.configs.NovelApplication
|
||||
import com.remax.visualnovel.databinding.FragmentMainActorBinding
|
||||
import com.remax.visualnovel.entity.request.PageQuery
|
||||
import com.remax.visualnovel.entity.request.ParamActorList
|
||||
import com.remax.visualnovel.entity.request.ParamActorTag
|
||||
import com.remax.visualnovel.entity.response.ActorBean
|
||||
import com.remax.visualnovel.extension.launchAndCollect2
|
||||
import com.remax.visualnovel.utils.Routers
|
||||
import com.remax.visualnovel.utils.StatusBarUtil3
|
||||
import com.remax.visualnovel.widget.custom.ActorTag
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import kotlin.getValue
|
||||
import kotlin.math.max
|
||||
|
|
@ -35,6 +35,7 @@ class ActorListFragment : BaseBindingFragment<FragmentMainActorBinding>() {
|
|||
private val mActorsModel by viewModels<ActorsViewModel>()
|
||||
private var mLoadedPageIndex = 0
|
||||
private val mRequestParam by lazy { ParamActorList() }
|
||||
private val mRequestTagsParam by lazy { ParamActorTag() }
|
||||
|
||||
|
||||
override fun onCreated(bundle: Bundle?) {
|
||||
|
|
@ -46,6 +47,7 @@ class ActorListFragment : BaseBindingFragment<FragmentMainActorBinding>() {
|
|||
}
|
||||
|
||||
override fun lazyInit() {
|
||||
getActorTags()
|
||||
getActorList(true, showLoading = false)
|
||||
}
|
||||
|
||||
|
|
@ -93,23 +95,18 @@ class ActorListFragment : BaseBindingFragment<FragmentMainActorBinding>() {
|
|||
|
||||
private fun initTagLayout() {
|
||||
with(binding) {
|
||||
val tags = listOf(
|
||||
ActorTagBean("1", "Youth"),
|
||||
ActorTagBean("2", "Lolita"),
|
||||
ActorTagBean("2", "Lolita2"),
|
||||
ActorTagBean("3", "Overbearing CEO ABCDEFG Overbearing CEO ABCDEFG Overbearing CEO ABCDEFG"),
|
||||
ActorTagBean("3", "ggggggggggg CEO ABCDEFG Overbearing CEO ABCDEFG Overbearing CEO ABCDEFG"),
|
||||
ActorTagBean("4", "Uncle"),
|
||||
ActorTagBean("5", "Character Status"),
|
||||
ActorTagBean("6", "Imouto"),
|
||||
ActorTagBean("7", "Fanwork"),
|
||||
ActorTagBean("8", "LastLine"),
|
||||
/*val tags = listOf(
|
||||
ActorTag(1, "Youth"),
|
||||
ActorTag(2, "Lolita"),
|
||||
ActorTag(3, "Lolita2"),
|
||||
ActorTag(4, "Overbearing CEO ABCDEFG Overbearing CEO ABCDEFG Overbearing CEO ABCDEFG"),
|
||||
ActorTag(5, "ggggggggggg CEO ABCDEFG Overbearing CEO ABCDEFG Overbearing CEO ABCDEFG"),
|
||||
)
|
||||
|
||||
tagFlowLayout.setTagDataList(tags)
|
||||
|
||||
*/
|
||||
tagFlowLayout.setOnTagClickListener { tag ->
|
||||
Toast.makeText(context, "Clicked: ${tag.showStr}", Toast.LENGTH_SHORT).show()
|
||||
Toast.makeText(context, "Clicked: ${tag.name}", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
||||
tagFlowLayout.setOnExpandStateChangeListener { isExpanded ->
|
||||
|
|
@ -152,22 +149,24 @@ class ActorListFragment : BaseBindingFragment<FragmentMainActorBinding>() {
|
|||
binding.refreshLayout.finishRefresh()
|
||||
}
|
||||
}
|
||||
|
||||
onFailed = { errorCode, errorMsg ->
|
||||
var temp = 100
|
||||
}
|
||||
|
||||
onFailedWithData = {
|
||||
var temp = 100
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun getActorTags() {
|
||||
mRequestTagsParam.limit = Int.MAX_VALUE
|
||||
|
||||
launchAndCollect2({
|
||||
mActorsModel.getActorTags(mRequestTagsParam)
|
||||
}, showLoading = false) {
|
||||
onSuccess = {
|
||||
val data = it ?: emptyList()
|
||||
binding.tagFlowLayout.setTagDataList(data)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
private fun createSampleData(): List<ActorBean> {
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
package com.remax.visualnovel.ui.main.actor
|
||||
|
||||
import com.remax.visualnovel.widget.custom.AbsTagBean
|
||||
|
||||
data class ActorTagBean(val tagId: String, override val showStr: String) : AbsTagBean(showStr) {
|
||||
|
||||
}
|
||||
|
|
@ -3,6 +3,7 @@ package com.remax.visualnovel.ui.main.actor
|
|||
|
||||
import com.remax.visualnovel.app.viewmodel.base.BaseViewModel
|
||||
import com.remax.visualnovel.entity.request.ParamActorList
|
||||
import com.remax.visualnovel.entity.request.ParamActorTag
|
||||
import com.remax.visualnovel.entity.response.basenew.ResponseNew
|
||||
import com.remax.visualnovel.entity.response.ActorBean
|
||||
import com.remax.visualnovel.repository.api.ActorsRepository
|
||||
|
|
@ -21,4 +22,6 @@ class ActorsViewModel @Inject constructor(private val mActorsRepository: ActorsR
|
|||
|
||||
suspend fun getActorList(param: ParamActorList) = mActorsRepository.getActorList(param)
|
||||
|
||||
suspend fun getActorTags(param: ParamActorTag) = mActorsRepository.getActorTags(param)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package com.remax.visualnovel.widget.custom
|
||||
|
||||
abstract class AbsTagBean(
|
||||
open val showStr: String,
|
||||
data class ActorTag(
|
||||
val id: Int,
|
||||
val name: String,
|
||||
var isSelected: Boolean = false
|
||||
)
|
||||
|
|
@ -45,12 +45,12 @@ class TagFlowLayout2 @JvmOverloads constructor(
|
|||
private var eachLineAvailableWidth = 0
|
||||
|
||||
// 数据
|
||||
private val tagItems = mutableListOf<AbsTagBean>()
|
||||
private val tagItems = mutableListOf<ActorTag>()
|
||||
private val tagViews = mutableListOf<TextView>()
|
||||
private lateinit var expandIcon: ImageView
|
||||
|
||||
// 监听器
|
||||
private var onTagClickListener: ((AbsTagBean) -> Unit)? = null
|
||||
private var onTagClickListener: ((ActorTag) -> Unit)? = null
|
||||
private var onExpandStateChangeListener: ((Boolean) -> Unit)? = null
|
||||
|
||||
init {
|
||||
|
|
@ -115,7 +115,7 @@ class TagFlowLayout2 @JvmOverloads constructor(
|
|||
}
|
||||
|
||||
|
||||
fun setTagDataList(tags: List<AbsTagBean>) {
|
||||
fun setTagDataList(tags: List<ActorTag>) {
|
||||
tagItems.clear()
|
||||
tagViews.forEach { removeView(it) }
|
||||
tagViews.clear()
|
||||
|
|
@ -130,9 +130,9 @@ class TagFlowLayout2 @JvmOverloads constructor(
|
|||
requestLayout()
|
||||
}
|
||||
|
||||
private fun createTagView(tag: AbsTagBean): TextView {
|
||||
private fun createTagView(tag: ActorTag): TextView {
|
||||
return TextView(context).apply {
|
||||
text = tag.showStr
|
||||
text = tag.name
|
||||
setTextColor(textColor)
|
||||
textSize = textSize / resources.displayMetrics.scaledDensity
|
||||
setPadding(10.dpToPx(), 7.dpToPx(), 10.dpToPx(), 7.dpToPx())
|
||||
|
|
@ -298,7 +298,7 @@ class TagFlowLayout2 @JvmOverloads constructor(
|
|||
expandIcon.setImageDrawable(indicator)
|
||||
}
|
||||
|
||||
fun setOnTagClickListener(listener: (AbsTagBean) -> Unit) {
|
||||
fun setOnTagClickListener(listener: (ActorTag) -> Unit) {
|
||||
onTagClickListener = listener
|
||||
}
|
||||
|
||||
|
|
@ -326,7 +326,7 @@ class TagFlowLayout2 @JvmOverloads constructor(
|
|||
requestLayout()
|
||||
}
|
||||
|
||||
fun getSelectedTagList() : List<AbsTagBean> {
|
||||
fun getSelectedTagList() : List<ActorTag> {
|
||||
return tagItems.filter { it.isSelected }
|
||||
}
|
||||
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,2 +0,0 @@
|
|||
1
|
||||
0
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -1,2 +0,0 @@
|
|||
Manifest-Version: 1.0
|
||||
|
||||
Loading…
Reference in New Issue