|
|
@ -42,9 +42,12 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) : |
|
|
|
|
|
|
|
|
|
|
|
override fun convert(holder: ItemViewHolder, item: Book, payloads: MutableList<Any>) { |
|
|
|
override fun convert(holder: ItemViewHolder, item: Book, payloads: MutableList<Any>) { |
|
|
|
with(holder.itemView) { |
|
|
|
with(holder.itemView) { |
|
|
|
tv_name.text = item.name |
|
|
|
tv_name.text = if (item.author.isEmpty()) { |
|
|
|
tv_author.text = context.getString(R.string.author_show, item.author) |
|
|
|
item.name |
|
|
|
tv_group.text = getGroupName(item.group) |
|
|
|
} else { |
|
|
|
|
|
|
|
"${item.name}(${item.author})" |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
tv_author.text = getGroupName(item.group) |
|
|
|
checkbox.isChecked = selectedBooks.contains(item) |
|
|
|
checkbox.isChecked = selectedBooks.contains(item) |
|
|
|
checkbox.onClick { |
|
|
|
checkbox.onClick { |
|
|
|
if (checkbox.isChecked) { |
|
|
|
if (checkbox.isChecked) { |
|
|
@ -74,12 +77,16 @@ class ArrangeBookAdapter(context: Context, val callBack: CallBack) : |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private fun getGroupName(groupId: Int): String { |
|
|
|
private fun getGroupName(groupId: Int): String { |
|
|
|
|
|
|
|
val groupNames = arrayListOf<String>() |
|
|
|
callBack.groupList.forEach { |
|
|
|
callBack.groupList.forEach { |
|
|
|
if (it.groupId == groupId) { |
|
|
|
if (it.groupId and groupId > 0) { |
|
|
|
return it.groupName |
|
|
|
groupNames.add(it.groupName) |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if (groupNames.isEmpty()) { |
|
|
|
|
|
|
|
return context.getString(R.string.no_group) |
|
|
|
} |
|
|
|
} |
|
|
|
return context.getString(R.string.group) |
|
|
|
return groupNames.joinToString(",") |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
interface CallBack { |
|
|
|
interface CallBack { |
|
|
|