aboutsummaryrefslogtreecommitdiff
path: root/mediapicker/src/main/kotlin/ca
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-11-09 01:54:02 -0500
committerGitHub <noreply@github.com>2017-11-09 01:54:02 -0500
commit637851b6ddc4a22583797a45bdbb72eb9c6dac23 (patch)
tree68b5a496ea3c8783fa61748c74a88fb692df553b /mediapicker/src/main/kotlin/ca
parent98e8a962c419d49de6e6050bf834f4d490932aa9 (diff)
downloadkau-637851b6ddc4a22583797a45bdbb72eb9c6dac23.tar.gz
kau-637851b6ddc4a22583797a45bdbb72eb9c6dac23.tar.bz2
kau-637851b6ddc4a22583797a45bdbb72eb9c6dac23.zip
misc (#97)
* Update translators * Increase debounce test interval * Clean unnecessary adapter files * Update fastadapter * Add fastadapter helper method * Remove external method * Add better wrap * Add more helpers
Diffstat (limited to 'mediapicker/src/main/kotlin/ca')
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt13
1 files changed, 7 insertions, 6 deletions
diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt
index ec5d2f0..9bab4c4 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt
@@ -18,6 +18,7 @@ import android.support.v4.content.CursorLoader
import android.support.v4.content.Loader
import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.RecyclerView
+import ca.allanwang.kau.adapters.fastAdapter
import ca.allanwang.kau.animators.FadeScaleAnimatorAdd
import ca.allanwang.kau.animators.KauAnimator
import ca.allanwang.kau.internal.KauBaseActivity
@@ -29,7 +30,7 @@ import ca.allanwang.kau.utils.toast
import com.bumptech.glide.Glide
import com.bumptech.glide.RequestManager
import com.mikepenz.fastadapter.IItem
-import com.mikepenz.fastadapter.adapters.HeaderAdapter
+import com.mikepenz.fastadapter.adapters.ItemAdapter
import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter
import com.mikepenz.google_material_typeface_library.GoogleMaterial
import com.mikepenz.iconics.IconicsDrawable
@@ -108,7 +109,7 @@ abstract class MediaPickerCore<T : IItem<*, *>>(
private var hasPreloaded = false
private var prefetcher: Future<*>? = null
- val adapter: FastItemAdapter<T> = FastItemAdapter()
+ val adapter = FastItemAdapter<T>()
/**
* Further improve preloading by extending the layout space
@@ -121,9 +122,9 @@ abstract class MediaPickerCore<T : IItem<*, *>>(
}
fun initializeRecycler(recycler: RecyclerView) {
- val adapterWrapper = HeaderAdapter<MediaActionItem>()
- adapterWrapper.wrap(adapter)
- adapterWrapper.add(mediaActions.map { MediaActionItem(it, mediaType) })
+ val adapterHeader = ItemAdapter<MediaActionItem>()
+ val fulladapter = fastAdapter(adapterHeader, adapter)
+ adapterHeader.add(mediaActions.map { MediaActionItem(it, mediaType) })
recycler.apply {
val manager = object : GridLayoutManager(context, computeColumnCount(context)) {
override fun getExtraLayoutSpace(state: RecyclerView.State?): Int {
@@ -133,7 +134,7 @@ abstract class MediaPickerCore<T : IItem<*, *>>(
setItemViewCacheSize(CACHE_SIZE)
isDrawingCacheEnabled = true
layoutManager = manager
- adapter = adapterWrapper
+ adapter = fulladapter
setHasFixedSize(true)
itemAnimator = KauAnimator(FadeScaleAnimatorAdd(0.8f))
}