aboutsummaryrefslogtreecommitdiff
path: root/library/src
diff options
context:
space:
mode:
Diffstat (limited to 'library/src')
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBinder.kt16
-rw-r--r--library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt19
2 files changed, 18 insertions, 17 deletions
diff --git a/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBinder.kt b/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBinder.kt
index 9503c3a..5fdb6bc 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBinder.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/kpref/KPrefBinder.kt
@@ -6,6 +6,8 @@ import android.support.v7.widget.RecyclerView
import ca.allanwang.kau.R
import ca.allanwang.kau.kpref.items.*
import com.mikepenz.fastadapter.commons.adapters.FastItemAdapter
+import org.jetbrains.anko.doAsync
+import org.jetbrains.anko.uiThread
/**
* Created by Allan Wang on 2017-06-08.
@@ -22,13 +24,13 @@ fun RecyclerView.setKPrefAdapter(globalOptions: GlobalOptions, builder: KPrefAda
val adapter = FastItemAdapter<KPrefItemCore>()
adapter.withOnClickListener { v, _, item, _ -> item.onClick(v, v.findViewById(R.id.kau_pref_inner_content)) }
this.adapter = adapter
-// doAsync {
-// val items = KPrefAdapterBuilder(globalOptions)
-// builder.invoke(items)
-// uiThread {
-// adapter.add(items.list)
-// }
-// }
+ doAsync {
+ val items = KPrefAdapterBuilder(globalOptions)
+ builder.invoke(items)
+ uiThread {
+ adapter.add(items.list)
+ }
+ }
return adapter
}
diff --git a/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt b/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
index 08097de..e3931b9 100644
--- a/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
+++ b/library/src/main/kotlin/ca/allanwang/kau/searchview/SearchView.kt
@@ -21,6 +21,7 @@ import com.mikepenz.google_material_typeface_library.GoogleMaterial
import com.mikepenz.iconics.typeface.IIcon
import io.reactivex.Observable
import io.reactivex.schedulers.Schedulers
+import org.jetbrains.anko.runOnUiThread
/**
@@ -121,22 +122,20 @@ class SearchView @JvmOverloads constructor(
*/
var results: List<SearchItem>
get() = adapter.adapterItems
- set(value) {}
-// set(value) = context.runOnUiThread {
-// cardTransition()
-// adapter.setNewList(
-// if (configs.noResultsFound > 0 && value.isEmpty())
-// listOf(SearchItem("", context.string(configs.noResultsFound), null))
-// else value)
-// }
+ set(value) = context.runOnUiThread {
+ cardTransition()
+ adapter.setNewList(
+ if (configs.noResultsFound > 0 && value.isEmpty())
+ listOf(SearchItem("", context.string(configs.noResultsFound), null))
+ else value)
+ }
/**
* Empties the list on the UI thread
* Note that this does not include any animations
* Use results = listOf() for the animated version
*/
- internal fun clearResults() {}
-// = context.runOnUiThread { adapter.clear() }
+ internal fun clearResults() = context.runOnUiThread { adapter.clear() }
val configs = Configs()
//views