fetch launcher names in an incasesensitive way

This commit is contained in:
tibbi 2017-11-12 17:23:39 +01:00
parent f5de06dd43
commit 3896bd8943
3 changed files with 5 additions and 13 deletions

View File

@ -1,7 +1,5 @@
package com.simplemobiletools.applauncher.adapters
import android.content.pm.PackageManager
import android.content.res.Resources
import android.support.v7.view.ActionMode
import android.support.v7.widget.RecyclerView
import android.util.SparseArray
@ -34,8 +32,6 @@ class RecyclerAdapter(val activity: SimpleActivity, val launchers: MutableList<A
private var itemViews = SparseArray<View>()
private val selectedPositions = HashSet<Int>()
private var textColor = config.textColor
private var resources = activity.resources
private var packageManager = activity.packageManager
fun toggleItemSelection(select: Boolean, pos: Int) {
if (select) {
@ -103,7 +99,7 @@ class RecyclerAdapter(val activity: SimpleActivity, val launchers: MutableList<A
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
itemViews.put(position, holder.bindView(launchers[position], textColor, resources, packageManager))
itemViews.put(position, holder.bindView(launchers[position], textColor))
toggleItemSelection(selectedPositions.contains(position), position)
holder.itemView.tag = holder
}
@ -153,7 +149,7 @@ class RecyclerAdapter(val activity: SimpleActivity, val launchers: MutableList<A
class ViewHolder(view: View, val adapterListener: MyAdapterListener, val activity: SimpleActivity, val multiSelectorCallback: ModalMultiSelectorCallback,
val multiSelector: MultiSelector, val listener: AppLaunchersListener?, val itemClick: (AppLauncher) -> (Unit)) : SwappingHolder(view, MultiSelector()) {
fun bindView(launcher: AppLauncher, textColor: Int, resources: Resources, packageManager: PackageManager): View {
fun bindView(launcher: AppLauncher, textColor: Int): View {
itemView.apply {
launcher_label.text = launcher.name
launcher_label.setTextColor(textColor)

View File

@ -1,8 +1,6 @@
package com.simplemobiletools.applauncher.adapters
import android.app.Activity
import android.content.pm.PackageManager
import android.content.res.Resources
import android.support.v7.widget.RecyclerView
import android.util.SparseArray
import android.view.LayoutInflater
@ -23,8 +21,6 @@ class RecyclerDialogAdapter(activity: Activity, val launchers: List<AppLauncher>
private var itemViews = SparseArray<View>()
private val selectedPositions = HashSet<Int>()
private var textColor = config.textColor
private var resources = activity.resources
private var packageManager = activity.packageManager
fun toggleItemSelection(select: Boolean, pos: Int) {
if (select) {
@ -56,7 +52,7 @@ class RecyclerDialogAdapter(activity: Activity, val launchers: List<AppLauncher>
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
itemViews.put(position, holder.bindView(launchers[position], textColor, resources, packageManager))
itemViews.put(position, holder.bindView(launchers[position], textColor))
toggleItemSelection(selectedPositions.contains(position), position)
}
@ -68,7 +64,7 @@ class RecyclerDialogAdapter(activity: Activity, val launchers: List<AppLauncher>
override fun getItemCount() = launchers.count()
class ViewHolder(view: View, val adapterListener: MyAdapterListener) : RecyclerView.ViewHolder(view) {
fun bindView(launcher: AppLauncher, textColor: Int, resources: Resources, packageManager: PackageManager): View {
fun bindView(launcher: AppLauncher, textColor: Int): View {
itemView.apply {
launcher_label.text = launcher.name
launcher_label.setTextColor(textColor)

View File

@ -101,7 +101,7 @@ class DBHelper private constructor(val context: Context) : SQLiteOpenHelper(cont
val packageManager = context.packageManager
val launchers = ArrayList<AppLauncher>()
val cols = arrayOf(COL_ID, COL_NAME, COL_PKG_NAME)
val cursor = mDb.query(MAIN_TABLE_NAME, cols, null, null, null, null, COL_NAME)
val cursor = mDb.query(MAIN_TABLE_NAME, cols, null, null, null, null, "$COL_NAME COLLATE NOCASE")
cursor.use {
while (cursor.moveToNext()) {
val id = cursor.getIntValue(COL_ID)