1
0
Fork 0
fenix/app/src/main/java/org/mozilla/fenix/loginexceptions/viewholders/LoginExceptionsListItemView...

51 lines
1.5 KiB
Kotlin
Raw Normal View History

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
2020-07-02 04:37:03 +02:00
package org.mozilla.fenix.loginexceptions.viewholders
import android.view.View
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.exception_item.view.*
2020-07-02 04:37:03 +02:00
import mozilla.components.feature.logins.exceptions.LoginException
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.components
2019-06-26 22:40:20 +02:00
import org.mozilla.fenix.ext.loadIntoView
2020-07-02 04:37:03 +02:00
import org.mozilla.fenix.loginexceptions.LoginExceptionsInteractor
/**
* View holder for a single website that is exempted from Tracking Protection.
*/
2020-07-02 04:37:03 +02:00
class LoginExceptionsListItemViewHolder(
view: View,
2020-07-02 04:37:03 +02:00
private val interactor: LoginExceptionsInteractor
2019-06-26 22:40:20 +02:00
) : RecyclerView.ViewHolder(view) {
private val favicon = view.favicon_image
private val url = view.webAddressView
private val deleteButton = view.delete_exception
2020-07-02 04:37:03 +02:00
private var item: LoginException? = null
init {
deleteButton.setOnClickListener {
item?.let {
interactor.onDeleteOne(it)
}
}
}
2020-07-02 04:37:03 +02:00
fun bind(item: LoginException) {
this.item = item
2020-07-02 04:37:03 +02:00
url.text = item.origin
}
private fun updateFavIcon(url: String) {
2019-06-26 22:40:20 +02:00
favicon.context.components.core.icons.loadIntoView(favicon, url)
}
companion object {
const val LAYOUT_ID = R.layout.exception_item
}
}