|
|
@ -17,7 +17,8 @@ import kotlinx.android.synthetic.main.item_bookshelf_list.view.* |
|
|
|
import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
|
import org.jetbrains.anko.sdk27.listeners.onClick |
|
|
|
import org.jetbrains.anko.sdk27.listeners.onLongClick |
|
|
|
import org.jetbrains.anko.sdk27.listeners.onLongClick |
|
|
|
|
|
|
|
|
|
|
|
class BookshelfAdapter : PagedListAdapter<Book, BookshelfAdapter.MyViewHolder>(DIFF_CALLBACK) { |
|
|
|
class BookshelfAdapter(private val callBack: CallBack) : |
|
|
|
|
|
|
|
PagedListAdapter<Book, BookshelfAdapter.MyViewHolder>(DIFF_CALLBACK) { |
|
|
|
|
|
|
|
|
|
|
|
companion object { |
|
|
|
companion object { |
|
|
|
@JvmField |
|
|
|
@JvmField |
|
|
@ -34,8 +35,6 @@ class BookshelfAdapter : PagedListAdapter<Book, BookshelfAdapter.MyViewHolder>(D |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
var callBack: CallBack? = null |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
fun notification(bookUrl: String) { |
|
|
|
fun notification(bookUrl: String) { |
|
|
|
for (i in 0..itemCount) { |
|
|
|
for (i in 0..itemCount) { |
|
|
|
getItem(i)?.let { |
|
|
|
getItem(i)?.let { |
|
|
@ -66,7 +65,7 @@ class BookshelfAdapter : PagedListAdapter<Book, BookshelfAdapter.MyViewHolder>(D |
|
|
|
itemView.setBackgroundColor(ThemeStore.backgroundColor(itemView.context)) |
|
|
|
itemView.setBackgroundColor(ThemeStore.backgroundColor(itemView.context)) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
fun bind(book: Book, callBack: CallBack?) = with(itemView) { |
|
|
|
fun bind(book: Book, callBack: CallBack) = with(itemView) { |
|
|
|
this.setBackgroundColor(context.getCompatColor(R.color.background)) |
|
|
|
this.setBackgroundColor(context.getCompatColor(R.color.background)) |
|
|
|
tv_name.text = book.name |
|
|
|
tv_name.text = book.name |
|
|
|
tv_author.text = book.author |
|
|
|
tv_author.text = book.author |
|
|
@ -79,21 +78,19 @@ class BookshelfAdapter : PagedListAdapter<Book, BookshelfAdapter.MyViewHolder>(D |
|
|
|
.centerCrop() |
|
|
|
.centerCrop() |
|
|
|
.setAsDrawable(iv_cover) |
|
|
|
.setAsDrawable(iv_cover) |
|
|
|
} |
|
|
|
} |
|
|
|
itemView.onClick { callBack?.open(book) } |
|
|
|
itemView.onClick { callBack.open(book) } |
|
|
|
itemView.onLongClick { |
|
|
|
itemView.onLongClick { |
|
|
|
callBack?.openBookInfo(book) |
|
|
|
callBack.openBookInfo(book) |
|
|
|
true |
|
|
|
true |
|
|
|
} |
|
|
|
} |
|
|
|
callBack?.let { |
|
|
|
if (book.origin != BookType.local && callBack.isUpdate(book.bookUrl)) { |
|
|
|
if (book.origin != BookType.local && it.isUpdate(book.bookUrl)) { |
|
|
|
bv_unread.invisible() |
|
|
|
bv_unread.invisible() |
|
|
|
rl_loading.show() |
|
|
|
rl_loading.show() |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
rl_loading.hide() |
|
|
|
rl_loading.hide() |
|
|
|
bv_unread.setBadgeCount(book.getUnreadChapterNum()) |
|
|
|
bv_unread.setBadgeCount(book.getUnreadChapterNum()) |
|
|
|
bv_unread.setHighlight(book.lastCheckCount > 0) |
|
|
|
bv_unread.setHighlight(book.lastCheckCount > 0) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} ?: rl_loading.hide() |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|