aboutsummaryrefslogtreecommitdiff
path: root/mediapicker/src/main/kotlin/ca/allanwang
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-12-26 04:01:23 -0500
committerGitHub <noreply@github.com>2017-12-26 04:01:23 -0500
commit7a3165ac7404381eb85ea40525db1a7a7d980761 (patch)
tree2341ea4ef0488b9abeea1fbe70697705d295aeb2 /mediapicker/src/main/kotlin/ca/allanwang
parentfb9ca21757068c0fb4123a5e30b1471ae4c32cf3 (diff)
downloadkau-7a3165ac7404381eb85ea40525db1a7a7d980761.tar.gz
kau-7a3165ac7404381eb85ea40525db1a7a7d980761.tar.bz2
kau-7a3165ac7404381eb85ea40525db1a7a7d980761.zip
Update/kpref activity (#113)
* Revamp kpref * Clean up data * Fix script * Test emulator * Test google api * Test again * Test gpg * Update dependencies
Diffstat (limited to 'mediapicker/src/main/kotlin/ca/allanwang')
-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 {