2016-12-26 04:25:55 +01:00
|
|
|
package org.mariotaku.twidere.fragment.filter
|
|
|
|
|
2017-09-13 11:52:09 +02:00
|
|
|
import android.accounts.AccountManager
|
2017-01-07 12:16:17 +01:00
|
|
|
import android.app.Activity
|
2016-12-26 04:25:55 +01:00
|
|
|
import android.content.Context
|
|
|
|
import android.content.Intent
|
|
|
|
import android.database.Cursor
|
2017-01-13 07:51:35 +01:00
|
|
|
import android.graphics.PorterDuff
|
2016-12-26 04:25:55 +01:00
|
|
|
import android.net.Uri
|
|
|
|
import android.os.Bundle
|
2020-01-26 08:35:15 +01:00
|
|
|
import androidx.fragment.app.FragmentActivity
|
|
|
|
import androidx.core.content.ContextCompat
|
|
|
|
import androidx.loader.content.CursorLoader
|
|
|
|
import androidx.loader.content.Loader
|
|
|
|
import androidx.cursoradapter.widget.SimpleCursorAdapter
|
2017-01-13 07:51:35 +01:00
|
|
|
import android.text.SpannableStringBuilder
|
|
|
|
import android.text.Spanned
|
2017-09-13 11:52:09 +02:00
|
|
|
import android.view.*
|
2017-06-19 06:11:28 +02:00
|
|
|
import android.widget.ImageView
|
2016-12-26 04:25:55 +01:00
|
|
|
import android.widget.TextView
|
2017-10-05 05:50:35 +02:00
|
|
|
import com.bumptech.glide.RequestManager
|
2017-02-13 15:53:38 +01:00
|
|
|
import kotlinx.android.synthetic.main.fragment_content_listview.*
|
2017-09-13 11:52:09 +02:00
|
|
|
import nl.komponents.kovenant.then
|
|
|
|
import nl.komponents.kovenant.ui.alwaysUi
|
2016-12-26 04:25:55 +01:00
|
|
|
import org.mariotaku.kpreferences.KPreferences
|
2017-09-16 16:36:21 +02:00
|
|
|
import org.mariotaku.kpreferences.get
|
2017-09-13 11:52:09 +02:00
|
|
|
import org.mariotaku.ktextension.*
|
2017-03-05 09:08:09 +01:00
|
|
|
import org.mariotaku.library.objectcursor.ObjectCursor
|
2016-12-26 04:25:55 +01:00
|
|
|
import org.mariotaku.twidere.R
|
2016-12-26 15:11:20 +01:00
|
|
|
import org.mariotaku.twidere.TwidereConstants.*
|
2016-12-26 04:25:55 +01:00
|
|
|
import org.mariotaku.twidere.activity.AccountSelectorActivity
|
2016-12-26 15:11:20 +01:00
|
|
|
import org.mariotaku.twidere.activity.LinkHandlerActivity
|
2017-01-29 14:34:22 +01:00
|
|
|
import org.mariotaku.twidere.activity.UserSelectorActivity
|
2016-12-28 08:30:50 +01:00
|
|
|
import org.mariotaku.twidere.constant.IntentConstants.EXTRA_ACCOUNT_HOST
|
2016-12-26 04:25:55 +01:00
|
|
|
import org.mariotaku.twidere.constant.nameFirstKey
|
2017-09-13 11:52:09 +02:00
|
|
|
import org.mariotaku.twidere.exception.AccountNotFoundException
|
|
|
|
import org.mariotaku.twidere.extension.dismissProgressDialog
|
|
|
|
import org.mariotaku.twidere.extension.showProgressDialog
|
2017-02-13 15:53:38 +01:00
|
|
|
import org.mariotaku.twidere.fragment.AddUserFilterDialogFragment
|
2017-03-05 09:08:09 +01:00
|
|
|
import org.mariotaku.twidere.model.FiltersData
|
2016-12-26 04:25:55 +01:00
|
|
|
import org.mariotaku.twidere.model.ParcelableUser
|
|
|
|
import org.mariotaku.twidere.model.UserKey
|
2017-01-07 12:16:17 +01:00
|
|
|
import org.mariotaku.twidere.model.analyzer.PurchaseFinished
|
2017-09-13 11:52:09 +02:00
|
|
|
import org.mariotaku.twidere.model.util.AccountUtils
|
2017-01-13 07:51:35 +01:00
|
|
|
import org.mariotaku.twidere.provider.TwidereDataStore.Filters
|
2017-09-13 11:52:09 +02:00
|
|
|
import org.mariotaku.twidere.task.CreateUserMuteTask
|
2017-01-13 07:51:35 +01:00
|
|
|
import org.mariotaku.twidere.text.style.EmojiSpan
|
2017-01-31 15:28:26 +01:00
|
|
|
import org.mariotaku.twidere.util.Analyzer
|
2017-09-13 11:52:09 +02:00
|
|
|
import org.mariotaku.twidere.util.IntentUtils
|
2017-01-31 15:28:26 +01:00
|
|
|
import org.mariotaku.twidere.util.ThemeUtils
|
|
|
|
import org.mariotaku.twidere.util.UserColorNameManager
|
2017-02-13 15:53:38 +01:00
|
|
|
import org.mariotaku.twidere.util.content.ContentResolverUtils
|
2017-04-16 15:09:56 +02:00
|
|
|
import org.mariotaku.twidere.util.dagger.GeneralComponent
|
2016-12-26 04:25:55 +01:00
|
|
|
import javax.inject.Inject
|
|
|
|
|
|
|
|
class FilteredUsersFragment : BaseFiltersFragment() {
|
|
|
|
|
2017-01-13 07:51:35 +01:00
|
|
|
override val contentUri: Uri = Filters.Users.CONTENT_URI
|
|
|
|
override val contentColumns: Array<String> = Filters.Users.COLUMNS
|
|
|
|
override val sortOrder: String? = "${Filters.Users.SOURCE} >= 0"
|
2017-01-31 15:28:26 +01:00
|
|
|
override val supportsEdit: Boolean = false
|
2016-12-26 04:25:55 +01:00
|
|
|
|
|
|
|
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
|
|
when (requestCode) {
|
|
|
|
REQUEST_SELECT_USER -> {
|
2017-01-31 09:02:44 +01:00
|
|
|
if (resultCode != FragmentActivity.RESULT_OK || data == null) return
|
|
|
|
val user = data.getParcelableExtra<ParcelableUser>(EXTRA_USER)
|
2017-02-13 15:53:38 +01:00
|
|
|
executeAfterFragmentResumed { fragment ->
|
|
|
|
AddUserFilterDialogFragment.show(fragment.childFragmentManager, user)
|
|
|
|
}
|
2016-12-26 04:25:55 +01:00
|
|
|
}
|
|
|
|
REQUEST_IMPORT_BLOCKS_SELECT_ACCOUNT -> {
|
2017-01-31 09:02:44 +01:00
|
|
|
if (resultCode != FragmentActivity.RESULT_OK || data == null) return
|
2016-12-26 15:11:20 +01:00
|
|
|
val intent = Intent(context, LinkHandlerActivity::class.java)
|
2017-09-13 11:52:09 +02:00
|
|
|
intent.data = IntentUtils.UriBuilder(AUTHORITY_FILTERS).path(PATH_FILTERS_IMPORT_BLOCKS).build()
|
2017-01-31 09:02:44 +01:00
|
|
|
intent.putExtra(EXTRA_ACCOUNT_KEY, data.getParcelableExtra<UserKey>(EXTRA_ACCOUNT_KEY))
|
2016-12-26 15:11:20 +01:00
|
|
|
startActivity(intent)
|
2016-12-26 04:25:55 +01:00
|
|
|
}
|
|
|
|
REQUEST_IMPORT_MUTES_SELECT_ACCOUNT -> {
|
2017-01-31 09:02:44 +01:00
|
|
|
if (resultCode != FragmentActivity.RESULT_OK || data == null) return
|
2016-12-26 15:11:20 +01:00
|
|
|
val intent = Intent(context, LinkHandlerActivity::class.java)
|
2017-09-13 11:52:09 +02:00
|
|
|
intent.data = IntentUtils.UriBuilder(AUTHORITY_FILTERS).path(PATH_FILTERS_IMPORT_MUTES).build()
|
2017-01-31 09:02:44 +01:00
|
|
|
intent.putExtra(EXTRA_ACCOUNT_KEY, data.getParcelableExtra<UserKey>(EXTRA_ACCOUNT_KEY))
|
2016-12-26 15:11:20 +01:00
|
|
|
startActivity(intent)
|
2016-12-26 04:25:55 +01:00
|
|
|
}
|
|
|
|
REQUEST_ADD_USER_SELECT_ACCOUNT -> {
|
2017-01-31 09:02:44 +01:00
|
|
|
if (resultCode != FragmentActivity.RESULT_OK || data == null) return
|
2016-12-26 04:25:55 +01:00
|
|
|
val intent = Intent(INTENT_ACTION_SELECT_USER)
|
2020-01-26 08:35:15 +01:00
|
|
|
context?.let { intent.setClass(it, UserSelectorActivity::class.java) }
|
2017-01-31 09:02:44 +01:00
|
|
|
intent.putExtra(EXTRA_ACCOUNT_KEY, data.getParcelableExtra<UserKey>(EXTRA_ACCOUNT_KEY))
|
|
|
|
startActivityForResult(intent, REQUEST_SELECT_USER)
|
2016-12-26 04:25:55 +01:00
|
|
|
}
|
2017-09-13 11:52:09 +02:00
|
|
|
REQUEST_EXPORT_MUTES_SELECT_ACCOUNT -> {
|
|
|
|
if (resultCode != FragmentActivity.RESULT_OK || data == null) return
|
|
|
|
val accountKey = data.getParcelableExtra<UserKey>(EXTRA_ACCOUNT_KEY)
|
|
|
|
val userKeys = data.getBundleExtra(EXTRA_EXTRAS)?.getNullableTypedArray<UserKey>(EXTRA_ITEMS) ?: return
|
|
|
|
exportToMutedUsers(accountKey, userKeys)
|
|
|
|
}
|
2017-01-07 11:02:32 +01:00
|
|
|
REQUEST_PURCHASE_EXTRA_FEATURES -> {
|
2017-01-07 12:16:17 +01:00
|
|
|
if (resultCode == Activity.RESULT_OK) {
|
2017-01-09 06:16:23 +01:00
|
|
|
Analyzer.log(PurchaseFinished.create(data!!))
|
2017-01-07 12:16:17 +01:00
|
|
|
}
|
2017-01-07 11:02:32 +01:00
|
|
|
}
|
2016-12-26 04:25:55 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-09-13 11:52:09 +02:00
|
|
|
override fun onCreateLoader(id: Int, args: Bundle?): Loader<Cursor?> {
|
2020-05-31 07:54:57 +02:00
|
|
|
return CursorLoader(requireActivity(), contentUri, contentColumns, null, null, sortOrder)
|
2017-09-13 11:52:09 +02:00
|
|
|
}
|
|
|
|
|
2016-12-26 04:25:55 +01:00
|
|
|
override fun onCreateOptionsMenu(menu: Menu, inflater: MenuInflater) {
|
|
|
|
inflater.inflate(R.menu.menu_filters_users, menu)
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onPrepareOptionsMenu(menu: Menu) {
|
|
|
|
super.onPrepareOptionsMenu(menu)
|
2017-01-01 16:28:00 +01:00
|
|
|
val isFeaturesSupported = extraFeaturesService.isSupported()
|
2017-09-11 14:57:20 +02:00
|
|
|
menu.setGroupAvailability(R.id.import_export, isFeaturesSupported)
|
2016-12-26 04:25:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
|
|
|
val intent = Intent(context, AccountSelectorActivity::class.java)
|
|
|
|
intent.putExtra(EXTRA_SINGLE_SELECTION, true)
|
|
|
|
intent.putExtra(EXTRA_SELECT_ONLY_ITEM_AUTOMATICALLY, true)
|
|
|
|
val requestCode = when (item.itemId) {
|
2017-09-11 14:57:20 +02:00
|
|
|
R.id.add_user -> REQUEST_ADD_USER_SELECT_ACCOUNT
|
2016-12-26 04:25:55 +01:00
|
|
|
R.id.import_from_blocked_users -> {
|
|
|
|
REQUEST_IMPORT_BLOCKS_SELECT_ACCOUNT
|
|
|
|
}
|
|
|
|
R.id.import_from_muted_users -> {
|
2016-12-28 08:30:50 +01:00
|
|
|
intent.putExtra(EXTRA_ACCOUNT_HOST, USER_TYPE_TWITTER_COM)
|
2016-12-26 04:25:55 +01:00
|
|
|
REQUEST_IMPORT_MUTES_SELECT_ACCOUNT
|
|
|
|
}
|
|
|
|
else -> return false
|
|
|
|
}
|
|
|
|
|
2017-03-28 05:15:58 +02:00
|
|
|
startActivityForResult(intent, requestCode)
|
2016-12-26 04:25:55 +01:00
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2017-09-16 16:36:21 +02:00
|
|
|
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
|
|
|
|
super.onCreateActionMode(mode, menu)
|
|
|
|
mode.menuInflater.inflate(R.menu.action_multi_select_filtered_users, menu)
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2017-09-13 11:52:09 +02:00
|
|
|
override fun onPrepareActionMode(mode: ActionMode, menu: Menu): Boolean {
|
|
|
|
val result = super.onPrepareActionMode(mode, menu)
|
|
|
|
val isFeaturesSupported = extraFeaturesService.isSupported()
|
|
|
|
menu.setGroupAvailability(R.id.import_export, isFeaturesSupported)
|
|
|
|
return result && menu.hasVisibleItems()
|
|
|
|
}
|
|
|
|
|
|
|
|
override fun onActionItemClicked(mode: ActionMode, item: MenuItem): Boolean {
|
|
|
|
when (item.itemId) {
|
|
|
|
R.id.export_to_muted_users -> {
|
|
|
|
requestExportToMutes()
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return super.onActionItemClicked(mode, item)
|
|
|
|
}
|
|
|
|
|
2017-10-05 05:50:35 +02:00
|
|
|
override fun onCreateAdapter(context: Context, requestManager: RequestManager): SimpleCursorAdapter {
|
2016-12-26 04:25:55 +01:00
|
|
|
return FilterUsersListAdapter(context)
|
|
|
|
}
|
|
|
|
|
2017-09-16 16:36:21 +02:00
|
|
|
override fun onItemClick(position: Int) {
|
|
|
|
val adapter = this.adapter as FilterUsersListAdapter
|
|
|
|
val item = adapter.getFilterItem(position) ?: return
|
|
|
|
if (item.source >= 0) return
|
|
|
|
addOrEditItem(item.id, userColorNameManager.getDisplayName(item,
|
|
|
|
preferences[nameFirstKey]), item.scope)
|
|
|
|
}
|
|
|
|
|
2017-09-14 10:21:59 +02:00
|
|
|
override fun addOrEditItem(id: Long, value: String?, scope: Int) {
|
2017-01-31 15:28:26 +01:00
|
|
|
// No-op
|
2017-09-16 16:36:21 +02:00
|
|
|
if (id < 0) return
|
|
|
|
super.addOrEditItem(id, value, scope)
|
2017-01-31 15:28:26 +01:00
|
|
|
}
|
|
|
|
|
2017-02-13 15:53:38 +01:00
|
|
|
override fun performDeletion() {
|
2020-01-26 08:35:15 +01:00
|
|
|
val context = context ?: return
|
2017-02-13 15:53:38 +01:00
|
|
|
val positions = listView.checkedItemPositions
|
|
|
|
val keys = (0 until positions.size()).mapNotNull {
|
|
|
|
if (!positions.valueAt(it)) return@mapNotNull null
|
|
|
|
return@mapNotNull (adapter as FilterUsersListAdapter).getUserKeyString(positions.keyAt(it))
|
|
|
|
}
|
|
|
|
super.performDeletion()
|
|
|
|
ContentResolverUtils.bulkDelete(context.contentResolver, Filters.Keywords.CONTENT_URI,
|
|
|
|
Filters.USER_KEY, false, keys, null, null)
|
|
|
|
ContentResolverUtils.bulkDelete(context.contentResolver, Filters.Links.CONTENT_URI,
|
|
|
|
Filters.USER_KEY, false, keys, null, null)
|
|
|
|
}
|
|
|
|
|
2017-09-13 11:52:09 +02:00
|
|
|
private fun requestExportToMutes() {
|
|
|
|
val adapter = this.adapter as? FilterUsersListAdapter ?: return
|
|
|
|
val checkedPos = listView.checkedItemPositions
|
|
|
|
val userKeys = (0 until checkedPos.size()).mapNotNull { i ->
|
|
|
|
if (checkedPos.valueAt(i)) {
|
|
|
|
return@mapNotNull adapter.getUserKey(checkedPos.keyAt(i))
|
|
|
|
}
|
|
|
|
return@mapNotNull null
|
|
|
|
}.toTypedArray()
|
|
|
|
val intent = Intent(context, AccountSelectorActivity::class.java)
|
|
|
|
intent.putExtra(EXTRA_SINGLE_SELECTION, true)
|
|
|
|
intent.putExtra(EXTRA_SELECT_ONLY_ITEM_AUTOMATICALLY, true)
|
|
|
|
intent.putExtra(EXTRA_EXTRAS, Bundle {
|
|
|
|
this[EXTRA_ITEMS] = userKeys
|
|
|
|
})
|
|
|
|
startActivityForResult(intent, REQUEST_EXPORT_MUTES_SELECT_ACCOUNT)
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun exportToMutedUsers(accountKey: UserKey, items: Array<UserKey>) {
|
|
|
|
val weakThis = this.weak()
|
|
|
|
showProgressDialog("export_to_muted").then {
|
|
|
|
val fragment = weakThis.get() ?: throw InterruptedException()
|
|
|
|
val am = AccountManager.get(fragment.context)
|
|
|
|
val account = AccountUtils.getAccountDetails(am, accountKey, true) ?:
|
|
|
|
throw AccountNotFoundException()
|
2020-05-31 07:54:57 +02:00
|
|
|
CreateUserMuteTask.muteUsers(fragment.requireContext(), account, items)
|
2017-09-13 11:52:09 +02:00
|
|
|
}.alwaysUi {
|
|
|
|
weakThis.get()?.dismissProgressDialog("export_to_muted")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-12-26 04:25:55 +01:00
|
|
|
class FilterUsersListAdapter(
|
|
|
|
context: Context
|
2017-01-12 18:08:10 +01:00
|
|
|
) : SimpleCursorAdapter(context, R.layout.list_item_two_line, null,
|
2017-09-13 11:52:09 +02:00
|
|
|
emptyArray(), IntArray(0), 0), IFilterAdapter {
|
2016-12-26 04:25:55 +01:00
|
|
|
|
|
|
|
@Inject
|
|
|
|
lateinit var userColorNameManager: UserColorNameManager
|
|
|
|
@Inject
|
|
|
|
lateinit var preferences: KPreferences
|
|
|
|
|
|
|
|
private val nameFirst: Boolean
|
|
|
|
|
2017-03-05 09:08:09 +01:00
|
|
|
private var indices: ObjectCursor.CursorIndices<FiltersData.UserItem>? = null
|
2017-01-13 07:51:35 +01:00
|
|
|
private val secondaryTextColor = ThemeUtils.getTextColorSecondary(context)
|
2016-12-26 04:25:55 +01:00
|
|
|
|
|
|
|
init {
|
2017-04-16 15:09:56 +02:00
|
|
|
GeneralComponent.get(context).inject(this)
|
2016-12-26 04:25:55 +01:00
|
|
|
nameFirst = preferences[nameFirstKey]
|
|
|
|
}
|
|
|
|
|
2017-03-02 10:23:34 +01:00
|
|
|
override fun bindView(view: View, context: Context, cursor: Cursor) {
|
2016-12-26 04:25:55 +01:00
|
|
|
super.bindView(view, context, cursor)
|
|
|
|
val indices = this.indices!!
|
2017-06-19 06:11:28 +02:00
|
|
|
val icon = view.findViewById<ImageView>(android.R.id.icon)
|
|
|
|
val text1 = view.findViewById<TextView>(android.R.id.text1)
|
|
|
|
val text2 = view.findViewById<TextView>(android.R.id.text2)
|
2017-01-12 18:08:10 +01:00
|
|
|
|
|
|
|
icon.visibility = View.GONE
|
|
|
|
|
2017-04-12 14:58:08 +02:00
|
|
|
val userKey = UserKey.valueOf(cursor.getString(indices[Filters.Users.USER_KEY]))
|
2017-03-05 09:08:09 +01:00
|
|
|
val name = cursor.getString(indices[Filters.Users.NAME])
|
|
|
|
val screenName = cursor.getString(indices[Filters.Users.SCREEN_NAME])
|
2017-04-12 14:58:08 +02:00
|
|
|
val displayName = userColorNameManager.getDisplayName(userKey, name, screenName,
|
2016-12-26 04:25:55 +01:00
|
|
|
nameFirst)
|
2017-05-13 08:19:23 +02:00
|
|
|
text1.spannable = displayName
|
2017-01-13 07:51:35 +01:00
|
|
|
|
|
|
|
val ssb = SpannableStringBuilder(displayName)
|
2017-03-05 09:08:09 +01:00
|
|
|
if (cursor.getLong(indices[Filters.Users.SOURCE]) >= 0) {
|
2017-01-13 07:51:35 +01:00
|
|
|
val start = ssb.length
|
|
|
|
ssb.append("*")
|
|
|
|
val end = start + 1
|
2020-01-26 08:35:15 +01:00
|
|
|
ContextCompat.getDrawable(context, R.drawable.ic_action_sync) ?.let { drawable ->
|
|
|
|
drawable.setColorFilter(secondaryTextColor, PorterDuff.Mode.SRC_ATOP)
|
|
|
|
ssb.setSpan(EmojiSpan(drawable), start, end, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE)
|
|
|
|
}
|
2017-01-13 07:51:35 +01:00
|
|
|
}
|
2017-05-13 08:19:23 +02:00
|
|
|
text1.spannable = ssb
|
|
|
|
text2.spannable = userKey.host
|
2016-12-26 04:25:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
override fun swapCursor(c: Cursor?): Cursor? {
|
2017-03-05 09:08:09 +01:00
|
|
|
indices = c?.let { ObjectCursor.indicesFrom(it, FiltersData.UserItem::class.java) }
|
|
|
|
return super.swapCursor(c)
|
2016-12-26 04:25:55 +01:00
|
|
|
}
|
|
|
|
|
2017-09-13 11:52:09 +02:00
|
|
|
override fun isReadOnly(position: Int): Boolean {
|
2017-01-13 07:51:35 +01:00
|
|
|
val cursor = this.cursor ?: return false
|
2017-09-13 11:52:09 +02:00
|
|
|
val indices = this.indices ?: return false
|
2017-01-13 07:51:35 +01:00
|
|
|
if (cursor.moveToPosition(position)) {
|
2017-09-13 11:52:09 +02:00
|
|
|
return cursor.getLong(indices[Filters.Users.SOURCE]) >= 0
|
2017-01-13 07:51:35 +01:00
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
2017-02-13 15:53:38 +01:00
|
|
|
|
|
|
|
fun getUserKeyString(position: Int): String? {
|
|
|
|
val cursor = this.cursor ?: return null
|
2017-09-13 11:52:09 +02:00
|
|
|
val indices = this.indices ?: return null
|
|
|
|
if (cursor.moveToPosition(position)) {
|
|
|
|
return cursor.getString(indices[Filters.Users.USER_KEY])
|
|
|
|
}
|
|
|
|
return null
|
|
|
|
}
|
|
|
|
|
|
|
|
fun getUserKey(position: Int): UserKey? {
|
|
|
|
val cursor = this.cursor ?: return null
|
|
|
|
val indices = this.indices ?: return null
|
2017-02-13 15:53:38 +01:00
|
|
|
if (cursor.moveToPosition(position)) {
|
2017-09-13 11:52:09 +02:00
|
|
|
return cursor.getString(indices[Filters.Users.USER_KEY])?.let(UserKey::valueOf)
|
2017-02-13 15:53:38 +01:00
|
|
|
}
|
|
|
|
return null
|
|
|
|
}
|
2017-09-16 16:36:21 +02:00
|
|
|
|
|
|
|
fun getFilterItem(position: Int): FiltersData.UserItem? {
|
|
|
|
val cursor = this.cursor ?: return null
|
|
|
|
val indices = this.indices ?: return null
|
|
|
|
if (cursor.moveToPosition(position)) {
|
|
|
|
return indices.newObject(cursor)
|
|
|
|
}
|
|
|
|
return null
|
|
|
|
}
|
2016-12-26 04:25:55 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|