aboutsummaryrefslogtreecommitdiff
path: root/mediapicker/src/main/kotlin/ca
diff options
context:
space:
mode:
authorAllan Wang <me@allanwang.ca>2017-12-27 00:16:09 -0500
committerGitHub <noreply@github.com>2017-12-27 00:16:09 -0500
commitbbaddee2ed4c5f2e534683d9687392d254c37d67 (patch)
treecb7bd886194f207cddb2f654e659acbaa65ee078 /mediapicker/src/main/kotlin/ca
parent23b9f24503130f1f3d29f0ab7a33ea3a08e0c064 (diff)
downloadkau-bbaddee2ed4c5f2e534683d9687392d254c37d67.tar.gz
kau-bbaddee2ed4c5f2e534683d9687392d254c37d67.tar.bz2
kau-bbaddee2ed4c5f2e534683d9687392d254c37d67.zip
Feature/fast adapter (#119)
* Update fast adapter implementation * Add repeated click listener
Diffstat (limited to 'mediapicker/src/main/kotlin/ca')
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt11
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt2
-rw-r--r--mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt2
3 files changed, 9 insertions, 6 deletions
diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt
index c3b6396..464c85e 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityBase.kt
@@ -48,14 +48,16 @@ abstract class MediaPickerActivityBase(
initializeRecycler(recycler)
- MediaItem.bindEvents(adapter)
- adapter.withSelectionListener({ _, _ -> selectionCount.text = adapter.selections.size.toString() })
+ MediaItem.bindEvents(adapter.fastAdapter)
+ adapter.fastAdapter.withSelectionListener { _, _ ->
+ selectionCount.text = adapter.fastAdapter.selections.size.toString()
+ }
fab.apply {
show()
setIcon(GoogleMaterial.Icon.gmd_send)
setOnClickListener {
- val selection = adapter.selectedItems
+ val selection = adapter.fastAdapter.selectedItems
if (selection.isEmpty()) {
toast(R.string.kau_no_items_selected)
} else {
@@ -88,7 +90,8 @@ abstract class MediaPickerActivityBase(
override fun onLoadFinished(loader: Loader<Cursor>?, data: Cursor?) {
super.onLoadFinished(loader, data)
- setToolbarScrollable((recycler.layoutManager as LinearLayoutManager).findLastCompletelyVisibleItemPosition() < adapter.getItemCount() - 1)
+ setToolbarScrollable((recycler.layoutManager as LinearLayoutManager)
+ .findLastCompletelyVisibleItemPosition() < adapter.adapterItemCount - 1)
}
override fun onStatusChange(loaded: Boolean) {
diff --git a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt
index 67f9577..9516eab 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerActivityOverlayBase.kt
@@ -29,7 +29,7 @@ abstract class MediaPickerActivityOverlayBase(
super.onCreate(savedInstanceState)
setContentView(R.layout.kau_activity_image_picker_overlay)
initializeRecycler(recycler)
- MediaItemBasic.bindEvents(this, adapter)
+ MediaItemBasic.bindEvents(this, adapter.fastAdapter)
draggable.addExitListener(this, R.transition.kau_image_exit_bottom, R.transition.kau_image_exit_top)
draggable.setOnClickListener { finishAfterTransition() }
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 9bab4c4..af90fdc 100644
--- a/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt
+++ b/mediapicker/src/main/kotlin/ca/allanwang/kau/mediapicker/MediaPickerCore.kt
@@ -109,7 +109,7 @@ abstract class MediaPickerCore<T : IItem<*, *>>(
private var hasPreloaded = false
private var prefetcher: Future<*>? = null
- val adapter = FastItemAdapter<T>()
+ val adapter = ItemAdapter<T>()
/**
* Further improve preloading by extending the layout space