aboutsummaryrefslogtreecommitdiff
path: root/mediapicker/src/main/kotlin/ca/allanwang
diff options
context:
space:
mode:
authorAllan Wang <allanwang@google.com>2019-07-27 17:56:41 -0700
committerAllan Wang <allanwang@google.com>2019-07-27 17:56:41 -0700
commit99f1e76a4d8d35d4d3ca1aadf68bbc227a70ba01 (patch)
tree2910c610362ca7e94c69ea7ae949aa1f1616ca42 /mediapicker/src/main/kotlin/ca/allanwang
parent50c8012e2fe88d6b275d1a3269033590962caa7f (diff)
downloadkau-99f1e76a4d8d35d4d3ca1aadf68bbc227a70ba01.tar.gz
kau-99f1e76a4d8d35d4d3ca1aadf68bbc227a70ba01.tar.bz2
kau-99f1e76a4d8d35d4d3ca1aadf68bbc227a70ba01.zip
Migrate some items
Diffstat (limited to 'mediapicker/src/main/kotlin/ca/allanwang')
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt13
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt34
2 files changed, 29 insertions, 18 deletions
diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt
index a365e13..55b448e 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt
@@ -26,7 +26,6 @@ import ca.allanwang.kau.permissions.PERMISSION_WRITE_EXTERNAL_STORAGE
import ca.allanwang.kau.permissions.kauRequestPermissions
import ca.allanwang.kau.utils.materialDialog
import ca.allanwang.kau.utils.string
-import com.mikepenz.google_material_typeface_library.GoogleMaterial
import com.mikepenz.iconics.typeface.IIcon
import com.mikepenz.iconics.typeface.library.googlematerial.GoogleMaterial
import java.io.File
@@ -37,18 +36,22 @@ import java.io.File
class MediaActionItem(
val action: MediaAction,
val mediaType: MediaType
-) : KauIItem<MediaActionItem, MediaItemBasic.ViewHolder>(
+) : KauIItem<MediaItemBasic.ViewHolder>(
R.layout.kau_iitem_image_basic,
{ MediaItemBasic.ViewHolder(it) },
R.id.kau_item_media_action
) {
- override fun isSelectable(): Boolean = false
-
override fun bindView(holder: MediaItemBasic.ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)
holder.image.apply {
- setImageDrawable(MediaPickerCore.getIconDrawable(context, action.iicon(this@MediaActionItem), action.color))
+ setImageDrawable(
+ MediaPickerCore.getIconDrawable(
+ context,
+ action.iicon(this@MediaActionItem),
+ action.color
+ )
+ )
setOnClickListener { action(context, this@MediaActionItem) }
}
}
diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt
index 5d3e7b9..5d47590 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt
@@ -24,33 +24,37 @@ import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener
import com.bumptech.glide.request.target.Target
import com.mikepenz.fastadapter.FastAdapter
+import com.mikepenz.fastadapter.select.getSelectExtension
/**
* Created by Allan Wang on 2017-07-04.
*/
class MediaItem(val data: MediaModel) :
- KauIItem<MediaItem, MediaItem.ViewHolder>(R.layout.kau_iitem_image, { ViewHolder(it) }),
+ KauIItem<MediaItem.ViewHolder>(R.layout.kau_iitem_image, { ViewHolder(it) }),
GlideContract by GlideDelegate() {
private var failedToLoad = false
companion object {
fun bindEvents(fastAdapter: FastAdapter<MediaItem>) {
- fastAdapter.withMultiSelect(true)
- .withSelectable(true)
- //adapter selector occurs before the on click event
- .withOnClickListener { v, _, item, _ ->
- val image = v as BlurredImageView
- if (item.isSelected) image.blur()
- else image.removeBlur()
- true
- }
+ fastAdapter.getSelectExtension().apply {
+ isSelectable = true
+ multiSelect = true
+ }
+ fastAdapter.onClickListener = { v, _, item, _ ->
+ val image = v as BlurredImageView
+ if (item.isSelected) image.blur()
+ else image.removeBlur()
+ true
+ }
}
}
- override fun isSelectable(): Boolean = !failedToLoad
+ override var isSelectable: Boolean
+ get() = !failedToLoad
+ set(value) {}
- override fun bindView(holder: ViewHolder, payloads: List<Any>) {
+ override fun bindView(holder: ViewHolder, payloads: MutableList<Any>) {
super.bindView(holder, payloads)
glide(holder.itemView)
.load(data.data)
@@ -63,7 +67,11 @@ class MediaItem(val data: MediaModel) :
isFirstResource: Boolean
): Boolean {
failedToLoad = true
- holder.container.imageBase.setImageDrawable(MediaPickerCore.getErrorDrawable(holder.itemView.context))
+ holder.container.imageBase.setImageDrawable(
+ MediaPickerCore.getErrorDrawable(
+ holder.itemView.context
+ )
+ )
return true
}