aboutsummaryrefslogtreecommitdiff
path: root/imagepicker/src/main/kotlin/ca/allanwang
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-07-23 13:13:36 -0700
committerGitHub <noreply@github.com>2017-07-23 13:13:36 -0700
commit4706b8f6a8d08a6961da6ab34d15881b63356d79 (patch)
tree3d1e611e43bd589a98a5f1840c5b6f52ff254468 /imagepicker/src/main/kotlin/ca/allanwang
parent61d87976e8b29ed25061ae98743a6cf4f4274542 (diff)
downloadkau-4706b8f6a8d08a6961da6ab34d15881b63356d79.tar.gz
kau-4706b8f6a8d08a6961da6ab34d15881b63356d79.tar.bz2
kau-4706b8f6a8d08a6961da6ab34d15881b63356d79.zip
Update kpref-activity's min-sdk and other minor changes (#11)3.1.0
* Move some resources to public * Lower kpref minsdk * Remove excess kauUtils annotations * Allow nullable throwable * Do not throw null throwable * Make image picker base abstract again * Migrate about strings to private * Update readme * Update readme * Update sample tagging * Update adapter readme
Diffstat (limited to 'imagepicker/src/main/kotlin/ca/allanwang')
-rw-r--r--imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImageItem.kt4
-rw-r--r--imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImagePickerActivityBase.kt (renamed from imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImagePickerActivity.kt)4
-rw-r--r--imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImagePickerBinder.kt6
3 files changed, 6 insertions, 8 deletions
diff --git a/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImageItem.kt b/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImageItem.kt
index d258822..2bfc57f 100644
--- a/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImageItem.kt
+++ b/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImageItem.kt
@@ -72,13 +72,13 @@ class ImageItem(val data: ImageModel)
.sizePx(sizePx)
.paddingPx(sizePx / 3)
.color(Color.WHITE))
- imageBase.setBackgroundColor(ImagePickerActivity.accentColor)
+ imageBase.setBackgroundColor(ImagePickerActivityBase.accentColor)
imageForeground.gone()
}
private fun computeViewSize(context: Context): Int {
val screenWidthPx = context.resources.displayMetrics.widthPixels
- return screenWidthPx / ImagePickerActivity.computeColumnCount(context)
+ return screenWidthPx / ImagePickerActivityBase.computeColumnCount(context)
}
override fun unbindView(holder: ViewHolder) {
diff --git a/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImagePickerActivity.kt b/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImagePickerActivityBase.kt
index 814cde4..9d988d1 100644
--- a/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImagePickerActivity.kt
+++ b/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImagePickerActivityBase.kt
@@ -32,7 +32,7 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial
*
* Base activity for selecting images from storage
*/
-open class ImagePickerActivity : AppCompatActivity(), LoaderManager.LoaderCallbacks<Cursor> {
+abstract class ImagePickerActivityBase : AppCompatActivity(), LoaderManager.LoaderCallbacks<Cursor> {
val imageAdapter = FastItemAdapter<ImageItem>()
@@ -75,7 +75,7 @@ open class ImagePickerActivity : AppCompatActivity(), LoaderManager.LoaderCallba
supportActionBar?.apply {
setDisplayHomeAsUpEnabled(true)
setDisplayShowHomeEnabled(true)
- setHomeAsUpIndicator(GoogleMaterial.Icon.gmd_close.toDrawable(this@ImagePickerActivity, 18))
+ setHomeAsUpIndicator(GoogleMaterial.Icon.gmd_close.toDrawable(this@ImagePickerActivityBase, 18))
}
toolbar.setNavigationOnClickListener { onBackPressed() }
diff --git a/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImagePickerBinder.kt b/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImagePickerBinder.kt
index 9e63464..8e8a69c 100644
--- a/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImagePickerBinder.kt
+++ b/imagepicker/src/main/kotlin/ca/allanwang/kau/imagepicker/ImagePickerBinder.kt
@@ -13,18 +13,16 @@ import android.content.Intent
/**
* Image picker launcher
*/
-fun Activity.kauLaunchImagePicker(clazz: Class<out ImagePickerActivity>, requestCode: Int) {
+fun Activity.kauLaunchImagePicker(clazz: Class<out ImagePickerActivityBase>, requestCode: Int) {
startActivityForResult(Intent(this, clazz), requestCode)
}
-fun Activity.kauLaunchImagePicker(requestCode: Int) = kauLaunchImagePicker(ImagePickerActivity::class.java, requestCode)
-
/**
* Image picker result
* call under [Activity.onActivityResult]
* and make sure that the requestCode matches first
*/
-fun Activity.kauOnImagePickerResult(resultCode: Int, data: Intent?) = ImagePickerActivity.onImagePickerResult(resultCode, data)
+fun Activity.kauOnImagePickerResult(resultCode: Int, data: Intent?) = ImagePickerActivityBase.onImagePickerResult(resultCode, data)
internal const val LOADER_ID = 42
internal const val IMAGE_PICKER_RESULT = "image_picker_result"