aboutsummaryrefslogtreecommitdiff
path: root/mediapicker
diff options
context:
space:
mode:
Diffstat (limited to 'mediapicker')
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt16
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt6
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt4
3 files changed, 12 insertions, 14 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 6171470..0cf6340 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaActionItem.kt
@@ -30,7 +30,7 @@ class MediaActionItem(
super.bindView(holder, payloads)
holder.image.apply {
setImageDrawable(MediaPickerCore.getIconDrawable(context, action.iicon(this@MediaActionItem), action.color))
- setOnClickListener { action.invoke(context, this@MediaActionItem) }
+ setOnClickListener { action(context, this@MediaActionItem) }
}
}
@@ -46,7 +46,7 @@ class MediaActionItem(
interface MediaAction {
var color: Int
fun iicon(item: MediaActionItem): IIcon
- fun invoke(c: Context, item: MediaActionItem)
+ operator fun invoke(c: Context, item: MediaActionItem)
}
internal const val MEDIA_ACTION_REQUEST_CAMERA = 100
@@ -71,9 +71,8 @@ abstract class MediaActionCamera(
MediaType.VIDEO -> GoogleMaterial.Icon.gmd_videocam
}
- override fun invoke(c: Context, item: MediaActionItem) {
- c.kauRequestPermissions(PERMISSION_WRITE_EXTERNAL_STORAGE) {
- granted, _ ->
+ override operator fun invoke(c: Context, item: MediaActionItem) {
+ c.kauRequestPermissions(PERMISSION_WRITE_EXTERNAL_STORAGE) { granted, _ ->
if (granted) {
val intent = Intent(item.mediaType.captureType)
if (intent.resolveActivity(c.packageManager) == null) {
@@ -109,7 +108,7 @@ class MediaActionCameraVideo(
override var color: Int = MediaPickerCore.accentColor
) : MediaAction {
override fun iicon(item: MediaActionItem) = GoogleMaterial.Icon.gmd_videocam
- override fun invoke(c: Context, item: MediaActionItem) {
+ override operator fun invoke(c: Context, item: MediaActionItem) {
val intent = Intent(MediaStore.ACTION_VIDEO_CAPTURE)
if (intent.resolveActivity(c.packageManager) == null) {
c.materialDialog {
@@ -136,9 +135,8 @@ class MediaActionGallery(
MediaType.VIDEO -> GoogleMaterial.Icon.gmd_video_library
}
- override fun invoke(c: Context, item: MediaActionItem) {
- c.kauRequestPermissions(PERMISSION_READ_EXTERNAL_STORAGE) {
- granted, _ ->
+ override operator fun invoke(c: Context, item: MediaActionItem) {
+ c.kauRequestPermissions(PERMISSION_READ_EXTERNAL_STORAGE) { granted, _ ->
if (granted) {
val intent = Intent().apply {
type = item.mediaType.mimeType
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 486ee31..b2cfa46 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItem.kt
@@ -35,7 +35,7 @@ class MediaItem(val data: MediaModel)
override fun isSelectable(): Boolean = !failedToLoad
- override fun bindView(holder: ViewHolder, payloads: List<Any>?) {
+ override fun bindView(holder: ViewHolder, payloads: List<Any>) {
super.bindView(holder, payloads)
glide(holder.itemView)
.load(data.data)
@@ -44,13 +44,13 @@ class MediaItem(val data: MediaModel)
override fun onLoadFailed(e: GlideException?, model: Any, target: Target<Drawable>, isFirstResource: Boolean): Boolean {
failedToLoad = true
holder.container.imageBase.setImageDrawable(MediaPickerCore.getErrorDrawable(holder.itemView.context))
- return true;
+ return true
}
override fun onResourceReady(resource: Drawable, model: Any, target: Target<Drawable>, dataSource: DataSource, isFirstResource: Boolean): Boolean {
holder.container.imageBase.setImageDrawable(resource)
if (isSelected) holder.container.blurInstantly()
- return true;
+ return true
}
})
.into(holder.container.imageBase)
diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt
index fb2d383..1fa18aa 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaItemBasic.kt
@@ -34,7 +34,7 @@ class MediaItemBasic(val data: MediaModel)
override fun isSelectable(): Boolean = false
- override fun bindView(holder: ViewHolder, payloads: List<Any>?) {
+ override fun bindView(holder: ViewHolder, payloads: List<Any>) {
super.bindView(holder, payloads)
glide(holder.itemView)
.load(data.data)
@@ -42,7 +42,7 @@ class MediaItemBasic(val data: MediaModel)
.listener(object : RequestListener<Drawable> {
override fun onLoadFailed(e: GlideException?, model: Any, target: Target<Drawable>, isFirstResource: Boolean): Boolean {
holder.image.setImageDrawable(MediaPickerCore.getErrorDrawable(holder.itemView.context))
- return true;
+ return true
}
override fun onResourceReady(resource: Drawable, model: Any, target: Target<Drawable>, dataSource: DataSource, isFirstResource: Boolean): Boolean {