优化"新分类"模块
This commit is contained in:
@ -899,7 +899,7 @@ object DirectUtils {
|
||||
fun directCatalog(context: Context, catalogId: String, catalogTitle: String, entrance: String? = null, path: String? = "") {
|
||||
if (catalogId.isEmpty()) return
|
||||
val bundle = Bundle()
|
||||
bundle.putString(KEY_TO, CategoryDirectoryActivity::class.java.name)
|
||||
bundle.putString(KEY_TO, CatalogActivity::class.java.name)
|
||||
bundle.putString(KEY_CATALOG_ID, catalogId)
|
||||
bundle.putString(KEY_CATALOG_TITLE, catalogTitle)
|
||||
bundle.putString(KEY_ENTRANCE, entrance ?: ENTRANCE_BROWSER)
|
||||
|
||||
@ -298,11 +298,11 @@ class CatalogFilterView @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
private fun getDefaultSizeFilterArray(): ArrayList<SubjectSettingEntity.Size> {
|
||||
return arrayListOf<SubjectSettingEntity.Size>().apply {
|
||||
add(SubjectSettingEntity.Size(min = -1, max = -1, text = "全部大小"))
|
||||
add(SubjectSettingEntity.Size(min = -1, max = 20, text = "20M以下"))
|
||||
add(SubjectSettingEntity.Size(min = 20, max = 50, text = "20-50M"))
|
||||
add(SubjectSettingEntity.Size(min = 50, max = 100, text = "50-100M"))
|
||||
add(SubjectSettingEntity.Size(min = 100, max = 500, text = "100-500M"))
|
||||
add(SubjectSettingEntity.Size(min = 500, max = -1, text = "500M以上"))
|
||||
add(SubjectSettingEntity.Size(min = -1, max = 100, text = "100M以下"))
|
||||
add(SubjectSettingEntity.Size(min = 100, max = 300, text = "100-300M"))
|
||||
add(SubjectSettingEntity.Size(min = 300, max = 500, text = "300-500M"))
|
||||
add(SubjectSettingEntity.Size(min = 500, max = 1000, text = "100M-1G"))
|
||||
add(SubjectSettingEntity.Size(min = 1000, max = -1, text = "1G以上"))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -22,6 +22,52 @@ import com.gh.gamecenter.subject.SubjectActivity.Companion.startSubjectActivity
|
||||
|
||||
class SpecialCatalogAdapter(context: Context) : ListAdapter<SpecialCatalogItemData>(context) {
|
||||
|
||||
override fun getItemCount() = if (mEntityList.isNullOrEmpty()) 0 else mEntityList.size + FOOTER_ITEM_COUNT
|
||||
|
||||
override fun areItemsTheSame(oldItem: SpecialCatalogItemData?, newItem: SpecialCatalogItemData?): Boolean {
|
||||
return when {
|
||||
oldItem?.header != null && newItem?.header != null -> {
|
||||
oldItem.header.id == newItem.header.id
|
||||
}
|
||||
|
||||
oldItem?.bigImage != null && newItem?.bigImage != null -> {
|
||||
oldItem.bigImage.id == newItem.bigImage.id
|
||||
}
|
||||
|
||||
oldItem?.subject != null && newItem?.subject != null -> {
|
||||
oldItem.subject.id == newItem.subject.id
|
||||
}
|
||||
|
||||
oldItem?.subjectCollection != null && newItem?.subjectCollection != null -> {
|
||||
oldItem.subjectCollection.id == newItem.subjectCollection.id
|
||||
}
|
||||
|
||||
else -> super.areItemsTheSame(oldItem, newItem)
|
||||
}
|
||||
}
|
||||
|
||||
override fun areContentsTheSame(oldItem: SpecialCatalogItemData?, newItem: SpecialCatalogItemData?): Boolean {
|
||||
return when {
|
||||
oldItem?.header != null && newItem?.header != null -> {
|
||||
oldItem.header.id == newItem.header.id
|
||||
}
|
||||
|
||||
oldItem?.bigImage != null && newItem?.bigImage != null -> {
|
||||
oldItem.bigImage.id == newItem.bigImage.id
|
||||
}
|
||||
|
||||
oldItem?.subject != null && newItem?.subject != null -> {
|
||||
oldItem.subject.id == newItem.subject.id
|
||||
}
|
||||
|
||||
oldItem?.subjectCollection != null && newItem?.subjectCollection != null -> {
|
||||
oldItem.subjectCollection.id == newItem.subjectCollection.id
|
||||
}
|
||||
|
||||
else -> super.areItemsTheSame(oldItem, newItem)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
val view: View
|
||||
return when (viewType) {
|
||||
@ -98,8 +144,6 @@ class SpecialCatalogAdapter(context: Context) : ListAdapter<SpecialCatalogItemDa
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount() = if (mEntityList.isNullOrEmpty()) 0 else mEntityList.size + FOOTER_ITEM_COUNT
|
||||
|
||||
class CatalogImageItemHolder(val binding: CatalogImageItemBinding) : BaseRecyclerViewHolder<Any>(binding.root)
|
||||
|
||||
class CatalogHeaderItemHolder(val binding: CatalogHeaderItemBinding) : BaseRecyclerViewHolder<Any>(binding.root)
|
||||
|
||||
@ -24,6 +24,7 @@ class SubCatalogAdapter(context: Context, private val mPrimaryCatalog: CatalogEn
|
||||
holder.binding.run {
|
||||
val catalogEntity = mList[position]
|
||||
entity = catalogEntity
|
||||
executePendingBindings()
|
||||
root.setOnClickListener {
|
||||
root.context.startActivity(NewCatalogListActivity.getIntent(mContext, catalogEntity.name, mPrimaryCatalog, catalogEntity.name))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user