|
|
@ -68,17 +68,38 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : |
|
|
|
String.format("%s (%s)", item.bookSourceName, item.bookSourceGroup) |
|
|
|
String.format("%s (%s)", item.bookSourceName, item.bookSourceGroup) |
|
|
|
} |
|
|
|
} |
|
|
|
swt_enabled.isChecked = item.enabled |
|
|
|
swt_enabled.isChecked = item.enabled |
|
|
|
|
|
|
|
cb_book_source.isChecked = selected.contains(item) |
|
|
|
|
|
|
|
upShowExplore(iv_explore, item) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
payload.keySet().map { |
|
|
|
|
|
|
|
when (it) { |
|
|
|
|
|
|
|
"selected" -> cb_book_source.isChecked = selected.contains(item) |
|
|
|
|
|
|
|
"name", "group" -> if (item.bookSourceGroup.isNullOrEmpty()) { |
|
|
|
|
|
|
|
cb_book_source.text = item.bookSourceName |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
cb_book_source.text = |
|
|
|
|
|
|
|
String.format("%s (%s)", item.bookSourceName, item.bookSourceGroup) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
"enabled" -> swt_enabled.isChecked = payload.getBoolean(it) |
|
|
|
|
|
|
|
"showExplore" -> upShowExplore(iv_explore, item) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun registerListener(holder: ItemViewHolder, position: Int) { |
|
|
|
|
|
|
|
holder.itemView.apply { |
|
|
|
swt_enabled.setOnCheckedChangeListener { view, checked -> |
|
|
|
swt_enabled.setOnCheckedChangeListener { view, checked -> |
|
|
|
getItem(holder.layoutPosition)?.let { |
|
|
|
getItem(position)?.let { |
|
|
|
if (view.isPressed) { |
|
|
|
if (view.isPressed) { |
|
|
|
it.enabled = checked |
|
|
|
it.enabled = checked |
|
|
|
callBack.update(it) |
|
|
|
callBack.update(it) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
cb_book_source.isChecked = selected.contains(item) |
|
|
|
|
|
|
|
cb_book_source.setOnCheckedChangeListener { view, checked -> |
|
|
|
cb_book_source.setOnCheckedChangeListener { view, checked -> |
|
|
|
getItem(holder.layoutPosition)?.let { |
|
|
|
getItem(position)?.let { |
|
|
|
if (view.isPressed) { |
|
|
|
if (view.isPressed) { |
|
|
|
if (checked) { |
|
|
|
if (checked) { |
|
|
|
selected.add(it) |
|
|
|
selected.add(it) |
|
|
@ -90,28 +111,12 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
iv_edit.onClick { |
|
|
|
iv_edit.onClick { |
|
|
|
getItem(holder.layoutPosition)?.let { |
|
|
|
getItem(position)?.let { |
|
|
|
callBack.edit(it) |
|
|
|
callBack.edit(it) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
iv_menu_more.onClick { |
|
|
|
iv_menu_more.onClick { |
|
|
|
showMenu(iv_menu_more, holder.layoutPosition) |
|
|
|
showMenu(iv_menu_more, position) |
|
|
|
} |
|
|
|
|
|
|
|
upShowExplore(iv_explore, item) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
payload.keySet().map { |
|
|
|
|
|
|
|
when (it) { |
|
|
|
|
|
|
|
"selected" -> cb_book_source.isChecked = selected.contains(item) |
|
|
|
|
|
|
|
"name", "group" -> if (item.bookSourceGroup.isNullOrEmpty()) { |
|
|
|
|
|
|
|
cb_book_source.text = item.bookSourceName |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
cb_book_source.text = |
|
|
|
|
|
|
|
String.format("%s (%s)", item.bookSourceName, item.bookSourceGroup) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
"enabled" -> swt_enabled.isChecked = payload.getBoolean(it) |
|
|
|
|
|
|
|
"showExplore" -> upShowExplore(iv_explore, item) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|