|
|
|
@ -9,17 +9,28 @@ import android.widget.CompoundButton
|
|
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
|
|
import io.reactivex.Observer
|
|
|
|
|
import kotlinx.android.synthetic.main.history_list_item.view.*
|
|
|
|
|
import kotlinx.coroutines.CoroutineScope
|
|
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
|
|
import kotlinx.coroutines.Job
|
|
|
|
|
import kotlinx.coroutines.launch
|
|
|
|
|
import mozilla.components.browser.icons.IconRequest
|
|
|
|
|
import mozilla.components.browser.menu.BrowserMenu
|
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
|
import org.mozilla.fenix.ext.components
|
|
|
|
|
import org.mozilla.fenix.library.history.HistoryAction
|
|
|
|
|
import org.mozilla.fenix.library.history.HistoryItem
|
|
|
|
|
import org.mozilla.fenix.library.history.HistoryItemMenu
|
|
|
|
|
import org.mozilla.fenix.library.history.HistoryState
|
|
|
|
|
import kotlin.coroutines.CoroutineContext
|
|
|
|
|
|
|
|
|
|
class HistoryListItemViewHolder(
|
|
|
|
|
view: View,
|
|
|
|
|
private val actionEmitter: Observer<HistoryAction>
|
|
|
|
|
) : RecyclerView.ViewHolder(view) {
|
|
|
|
|
private val actionEmitter: Observer<HistoryAction>,
|
|
|
|
|
val job: Job
|
|
|
|
|
) : RecyclerView.ViewHolder(view), CoroutineScope {
|
|
|
|
|
|
|
|
|
|
override val coroutineContext: CoroutineContext
|
|
|
|
|
get() = Dispatchers.IO + job
|
|
|
|
|
|
|
|
|
|
private val checkbox = view.should_remove_checkbox
|
|
|
|
|
private val favicon = view.history_favicon
|
|
|
|
@ -99,6 +110,8 @@ class HistoryListItemViewHolder(
|
|
|
|
|
}
|
|
|
|
|
checkbox.setOnCheckedChangeListener(checkListener)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateFavIcon(item.url)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun setupMenu() {
|
|
|
|
@ -111,6 +124,16 @@ class HistoryListItemViewHolder(
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun updateFavIcon(url: String) {
|
|
|
|
|
launch(Dispatchers.IO) {
|
|
|
|
|
val bitmap = favicon.context.components.utils.icons
|
|
|
|
|
.loadIcon(IconRequest(url)).await().bitmap
|
|
|
|
|
launch(Dispatchers.Main) {
|
|
|
|
|
favicon.setImageBitmap(bitmap)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
|
const val LAYOUT_ID = R.layout.history_list_item
|
|
|
|
|
}
|
|
|
|
|