2019-08-23 12:54:03 +02:00
|
|
|
/* 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/. */
|
|
|
|
|
|
|
|
package org.mozilla.fenix.share.viewholders
|
|
|
|
|
|
|
|
import android.view.View
|
2019-08-29 17:47:49 +02:00
|
|
|
import androidx.annotation.VisibleForTesting
|
2019-08-23 12:54:03 +02:00
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
|
import kotlinx.android.synthetic.main.app_share_list_item.view.*
|
|
|
|
import org.mozilla.fenix.R
|
|
|
|
import org.mozilla.fenix.share.ShareToAppsInteractor
|
2019-11-06 02:30:04 +01:00
|
|
|
import org.mozilla.fenix.share.listadapters.AppShareOption
|
2019-08-23 12:54:03 +02:00
|
|
|
|
|
|
|
class AppViewHolder(
|
|
|
|
itemView: View,
|
2019-11-05 03:33:02 +01:00
|
|
|
@VisibleForTesting val interactor: ShareToAppsInteractor
|
2019-08-23 12:54:03 +02:00
|
|
|
) : RecyclerView.ViewHolder(itemView) {
|
|
|
|
|
2019-11-06 02:30:04 +01:00
|
|
|
private var application: AppShareOption? = null
|
2019-08-23 12:54:03 +02:00
|
|
|
|
|
|
|
init {
|
|
|
|
itemView.setOnClickListener {
|
2019-11-06 02:30:04 +01:00
|
|
|
application?.let { app ->
|
|
|
|
interactor.onShareToApp(app)
|
2019-08-23 12:54:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-06 02:30:04 +01:00
|
|
|
fun bind(item: AppShareOption) {
|
2019-08-23 12:54:03 +02:00
|
|
|
application = item
|
2019-11-05 03:33:02 +01:00
|
|
|
|
2019-11-06 02:30:04 +01:00
|
|
|
itemView.appName.text = item.name
|
|
|
|
itemView.appIcon.setImageDrawable(item.icon)
|
2019-08-23 12:54:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
companion object {
|
|
|
|
const val LAYOUT_ID = R.layout.app_share_list_item
|
|
|
|
}
|
|
|
|
}
|