角色加载更多

This commit is contained in:
renhaoting 2025-11-04 11:31:14 +08:00
parent 48b23cbdd3
commit 1bcccd38e5
5 changed files with 53 additions and 108 deletions

View File

@ -12,6 +12,16 @@ plugins {
}
android {
// 禁用重复类检查(调试模式)
if (gradle.startParameter.taskNames.any { it.contains("Debug", ignoreCase = true) }) {
tasks.configureEach {
if (name.contains("check", ignoreCase = true) &&
name.contains("DuplicateClasses", ignoreCase = true)) {
enabled = false
}
}
}
namespace = Version.applicationId
compileSdk = 36

View File

@ -2,13 +2,23 @@ package com.remax.visualnovel.entity.response
data class ActorBean(
val id: Long,
val id: Int,
val roleName: String,
val description: String,
val coverImageId: String,
var coverImage: String = "",
val sourceId: Int, //来源ID;所属书籍/漫剧
val sourceType: Int, //来源分类
val commonCount: Int, //评论数
val createTime: String,
val status: String
val status: String,
// other needed
val avatarRes: Int,
val from: String = "from",
val rating: Float,
val characterName: String,
val age: Int,
val tags: List<String>,
val workTitle: String,
val imageRes: Int
)

View File

@ -13,9 +13,12 @@ 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.response.ActorBean
import com.remax.visualnovel.extension.launchAndCollect2
import com.remax.visualnovel.utils.Routers
import com.remax.visualnovel.utils.StatusBarUtil3
@ -82,7 +85,7 @@ class ActorListFragment : BaseBindingFragment<FragmentMainActorBinding>() {
with(refreshLayout) {
onRefresh {
getActorList(true, showLoading = true)
getActorList(true, showLoading = false)
}
}
}
@ -128,23 +131,26 @@ class ActorListFragment : BaseBindingFragment<FragmentMainActorBinding>() {
onSuccess = {
val data = it ?: emptyList()
with(mActorAdapter) {
/*if (isRefresh) {
if (isRefresh) {
setList(data)
setMyEmptyView(R.string.no_character_yet, topMargin = 60)
} else {
addData(data)
loadMoreModule.loadMoreComplete()
}
if (data.size < PageQuery.DEFAULT_PAGE_SIZE) {
if (data.size < mRequestParam.limit) {
loadMoreModule.loadMoreEnd()
}*/
}
}
if (data.isNotEmpty()) {
mLoadedPageIndex++
}
mLoadedPageIndex++
}
onComplete = {
binding.refreshLayout.finishRefresh()
mActorAdapter.loadMoreModule.loadMoreComplete()
if (isRefresh) {
binding.refreshLayout.finishRefresh()
}
}
onFailed = { errorCode, errorMsg ->
@ -164,101 +170,13 @@ class ActorListFragment : BaseBindingFragment<FragmentMainActorBinding>() {
private fun createSampleData(): List<ActorItem> {
return listOf(
ActorItem(
id = 1,
avatarRes = R.drawable.avatar1,
rating = 9.5f,
characterName = "Lin Feng",
age = 18,
tags = listOf("#Xianxia", "#Swordsmanship", "#Cultivation"),
description = "glory through relentless effort and uncover the conspiracy that destroyed him.",
workTitle = "The Last Oracle of Kael",
imageRes = R.drawable.character1
),
ActorItem(
id = 2,
avatarRes = R.drawable.avatar2,
rating = 9.2f,
characterName = "Yue Ling",
age = 16,
tags = listOf("#Fantasy", "#Magic", "#Adventure"),
description = "A young mage with exceptional talent in elemental magic, on a journey to discover ancient magical artifacts.",
workTitle = "Elemental Chronicles",
imageRes = R.drawable.character2
),
ActorItem(
id = 1,
avatarRes = R.drawable.avatar1,
rating = 9.5f,
characterName = "Lin Feng",
age = 18,
tags = listOf("#Xianxia", "#Swordsmanship", "#Cultivation"),
description = "Once a prodigy, Lin Feng had his cultivation shattered and was cast out of his clan. Now he must reclaim his former glory through relentless effort and uncover the conspiracy that destroyed him.",
workTitle = "The Last Oracle of Kael",
imageRes = R.drawable.character1
),
ActorItem(
id = 2,
avatarRes = R.drawable.avatar2,
rating = 9.2f,
characterName = "Yue Ling",
age = 16,
tags = listOf("#Fantasy", "#Magic", "#Adventure"),
description = "magical artifacts.",
workTitle = "Elemental Chronicles",
imageRes = R.drawable.character2
),
ActorItem(
id = 1,
avatarRes = R.drawable.avatar1,
rating = 9.5f,
characterName = "Lin Feng",
age = 18,
tags = listOf("#Xianxia", "#Swordsmanship", "#Cultivation"),
description = "Once a prodigy, Lin Feng had his cultivation shattered and was cast out of his clan. Now he must reclaim his former glory through relentless effort and uncover the conspiracy that destroyed him.",
workTitle = "The Last Oracle of Kael",
imageRes = R.drawable.character1
),
ActorItem(
id = 2,
avatarRes = R.drawable.avatar2,
rating = 9.2f,
characterName = "Yue Ling",
age = 16,
tags = listOf("#Fantasy", "#Magic", "#Adventure"),
description = "A ancient magical artifacts.",
workTitle = "Elemental Chronicles",
imageRes = R.drawable.character2
),
ActorItem(
id = 1,
avatarRes = R.drawable.avatar1,
rating = 9.5f,
characterName = "Lin Feng",
age = 18,
tags = listOf("#Xianxia", "#Swordsmanship", "#Cultivation"),
description = "ory through relentless effort and uncover the conspiracy that destroyed him.",
workTitle = "The Last Oracle of Kael",
imageRes = R.drawable.character1
),
ActorItem(
id = 2,
avatarRes = R.drawable.avatar2,
rating = 9.2f,
characterName = "Yue Ling",
age = 16,
tags = listOf("#Fantasy", "#Magic", "#Adventure"),
description = "A young mage with exceptional talent in elemental magic, on a journey to discover ancient magical artifacts.",
workTitle = "Elemental Chronicles",
imageRes = R.drawable.character2
)
)
private fun createSampleData(): List<ActorBean> {
return listOf()
}
companion object {
fun newInstance(): ActorListFragment {
return ARouter.getInstance().build(Routers.ROUTE_FRAG_ACTORLIST)

View File

@ -5,9 +5,11 @@ import com.chad.library.adapter.base.module.LoadMoreModule
import com.remax.visualnovel.R
import com.remax.visualnovel.app.BaseBindingQuickAdapter
import com.remax.visualnovel.databinding.FragmentMainActorItemBinding
import com.remax.visualnovel.entity.response.ActorBean
import com.remax.visualnovel.extension.glide.load
import com.remax.visualnovel.ui.chat.ChatActivity
class ActorsAdapter : BaseBindingQuickAdapter<ActorItem, FragmentMainActorItemBinding>(FragmentMainActorItemBinding::inflate), LoadMoreModule {
class ActorsAdapter : BaseBindingQuickAdapter<ActorBean, FragmentMainActorItemBinding>(FragmentMainActorItemBinding::inflate), LoadMoreModule {
init {
setOnItemClickListener { _, _, position ->
val item = getItem(position)
@ -22,17 +24,21 @@ class ActorsAdapter : BaseBindingQuickAdapter<ActorItem, FragmentMainActorItemBi
}
override fun convert(holder: BaseBindingHolder, item: ActorItem) {
override fun convert(holder: BaseBindingHolder, item: ActorBean) {
holder.getViewBinding<FragmentMainActorItemBinding>().run {
ivCharacter.setImageResource(item.imageRes)
ivFrom.setImageResource(item.avatarRes)
var imgUrl = item.coverImage
ivCharacter.load(if (imgUrl.contains(".png")) imgUrl.substring(0, imgUrl.indexOf(".png") + 4) else imgUrl)
ivFrom.setImageResource(R.mipmap.icon_search_on)
tvFrom.text = item.from
tvScore.text = item.commonCount.toString()
tvFrom.text = item.sourceId.toString()
/*tvFrom.text = item.from
tvScore.text = "%.1f".format(item.rating)
tvChapterNum.text = "${item.characterName}·${item.age}"
tvLables.text = item.tags.toString()
tvDescription.text = item.description
tvLast.text = "[${item.workTitle}]"
tvLast.text = "[${item.workTitle}]"*/
}
}
}

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.cardview.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.cardview.widget.CardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/root_card"
android:layout_width="match_parent"