|
|
@ -68,41 +68,47 @@ class BookSourceAdapter(context: Context, val callBack: CallBack) : |
|
|
|
|
|
|
|
|
|
|
|
override fun convert(holder: ItemViewHolder, item: BookSource, payloads: MutableList<Any>) { |
|
|
|
override fun convert(holder: ItemViewHolder, item: BookSource, payloads: MutableList<Any>) { |
|
|
|
with(holder.itemView) { |
|
|
|
with(holder.itemView) { |
|
|
|
this.setBackgroundColor(context.backgroundColor) |
|
|
|
if (payloads.isEmpty()) { |
|
|
|
if (item.bookSourceGroup.isNullOrEmpty()) { |
|
|
|
this.setBackgroundColor(context.backgroundColor) |
|
|
|
cb_book_source.text = item.bookSourceName |
|
|
|
if (item.bookSourceGroup.isNullOrEmpty()) { |
|
|
|
} else { |
|
|
|
cb_book_source.text = item.bookSourceName |
|
|
|
cb_book_source.text = |
|
|
|
|
|
|
|
String.format("%s (%s)", item.bookSourceName, item.bookSourceGroup) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
swt_enabled.isChecked = item.enabled |
|
|
|
|
|
|
|
swt_enabled.onClick { |
|
|
|
|
|
|
|
item.enabled = swt_enabled.isChecked |
|
|
|
|
|
|
|
callBack.update(item) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
cb_book_source.isChecked = selectedIds.contains(item.bookSourceUrl) |
|
|
|
|
|
|
|
cb_book_source.setOnClickListener { |
|
|
|
|
|
|
|
if (cb_book_source.isChecked) { |
|
|
|
|
|
|
|
selectedIds.add(item.bookSourceUrl) |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
selectedIds.remove(item.bookSourceUrl) |
|
|
|
cb_book_source.text = |
|
|
|
|
|
|
|
String.format("%s (%s)", item.bookSourceName, item.bookSourceGroup) |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
swt_enabled.isChecked = item.enabled |
|
|
|
iv_edit.onClick { callBack.edit(item) } |
|
|
|
swt_enabled.onClick { |
|
|
|
iv_menu_more.onClick { |
|
|
|
item.enabled = swt_enabled.isChecked |
|
|
|
val popupMenu = PopupMenu(context, it) |
|
|
|
callBack.update(item) |
|
|
|
popupMenu.menu.add(Menu.NONE, R.id.menu_top, Menu.NONE, R.string.to_top) |
|
|
|
} |
|
|
|
popupMenu.menu.add(Menu.NONE, R.id.menu_del, Menu.NONE, R.string.delete) |
|
|
|
cb_book_source.isChecked = selectedIds.contains(item.bookSourceUrl) |
|
|
|
popupMenu.setOnMenuItemClickListener { menuItem -> |
|
|
|
cb_book_source.setOnClickListener { |
|
|
|
when (menuItem.itemId) { |
|
|
|
if (cb_book_source.isChecked) { |
|
|
|
R.id.menu_top -> callBack.toTop(item) |
|
|
|
selectedIds.add(item.bookSourceUrl) |
|
|
|
R.id.menu_del -> callBack.del(item) |
|
|
|
} else { |
|
|
|
|
|
|
|
selectedIds.remove(item.bookSourceUrl) |
|
|
|
} |
|
|
|
} |
|
|
|
true |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
popupMenu.show() |
|
|
|
iv_edit.onClick { callBack.edit(item) } |
|
|
|
|
|
|
|
iv_menu_more.onClick { |
|
|
|
|
|
|
|
val popupMenu = PopupMenu(context, it) |
|
|
|
|
|
|
|
popupMenu.menu.add(Menu.NONE, R.id.menu_top, Menu.NONE, R.string.to_top) |
|
|
|
|
|
|
|
popupMenu.menu.add(Menu.NONE, R.id.menu_del, Menu.NONE, R.string.delete) |
|
|
|
|
|
|
|
popupMenu.setOnMenuItemClickListener { menuItem -> |
|
|
|
|
|
|
|
when (menuItem.itemId) { |
|
|
|
|
|
|
|
R.id.menu_top -> callBack.toTop(item) |
|
|
|
|
|
|
|
R.id.menu_del -> callBack.del(item) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
true |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
popupMenu.show() |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
when (payloads[0]) { |
|
|
|
|
|
|
|
1 -> cb_book_source.isChecked = selectedIds.contains(item.bookSourceUrl) |
|
|
|
|
|
|
|
2 -> swt_enabled.isChecked = item.enabled |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|