|
|
@@ -4,10 +4,13 @@ import android.support.v7.widget.RecyclerView
|
|
|
import android.view.ViewGroup
|
|
|
import me.vadik.knigopis.R
|
|
|
import me.vadik.knigopis.createNewBookIntent
|
|
|
+import me.vadik.knigopis.dialog.DialogFactory
|
|
|
+import me.vadik.knigopis.dialog.DialogItem
|
|
|
import me.vadik.knigopis.inflate
|
|
|
|
|
|
class BooksAdapter(
|
|
|
- private val books: List<UserBook>
|
|
|
+ private val books: List<UserBook>,
|
|
|
+ private val dialogs: DialogFactory
|
|
|
) : RecyclerView.Adapter<BookViewHolder>() {
|
|
|
|
|
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int) =
|
|
|
@@ -23,7 +26,15 @@ class BooksAdapter(
|
|
|
holder.notes = book.notes
|
|
|
val context = holder.view.context
|
|
|
holder.view.setOnLongClickListener {
|
|
|
- context.startActivity(context.createNewBookIntent(book.title, book.author))
|
|
|
+ dialogs.showDialog(
|
|
|
+ book.title + " — " + book.author,
|
|
|
+ DialogItem(R.string.add_book_todo, R.drawable.ic_playlist_add) {
|
|
|
+ context.startActivity(context.createNewBookIntent(book.title, book.author))
|
|
|
+ },
|
|
|
+ DialogItem(R.string.add_book_done, R.drawable.ic_playlist_add_check) {
|
|
|
+ context.startActivity(context.createNewBookIntent(book.title, book.author, 100))
|
|
|
+ }
|
|
|
+ )
|
|
|
true
|
|
|
}
|
|
|
}
|