Fix search crash
This commit is contained in:
1 parent
8e1bacbfac
commit
72da7ebfe4
1 file changed
+10
-3
@@ -128,16 +128,17 @@ class SearchLayout : EasyRecyclerView, CompoundButton.OnCheckedChangeListener, V
|
||||
|
||||
val mCategoryGroup = normalView.findViewById(R.id.search_category_chipgroup) as ChipGroup
|
||||
for (mPair in mCategoryTable) {
|
||||
val mChip = Chip(context)
|
||||
val mChip = IdentifiedChip(context)
|
||||
mChip.isCheckable = true
|
||||
mChip.setText(mPair.second)
|
||||
mChip.idt = mPair.first
|
||||
mChip.isChecked = NumberUtils.int2boolean(mPair.first and mCategoryStored)
|
||||
mCategoryGroup.addView(mChip)
|
||||
}
|
||||
mCategoryGroup.setOnCheckedStateChangeListener { group, checkedIds ->
|
||||
mCategoryGroup.setOnCheckedStateChangeListener { _, checkedIds ->
|
||||
var mCategory = 0
|
||||
for (index in checkedIds) {
|
||||
mCategory = mCategory or mCategoryTable[index - 1].first
|
||||
mCategory = mCategory or findViewById<IdentifiedChip>(index).idt
|
||||
}
|
||||
mSharePref.edit { putInt(SEARCH_CATEGORY_PREF, mCategory) }
|
||||
}
|
||||
@@ -382,6 +383,12 @@ class SearchLayout : EasyRecyclerView, CompoundButton.OnCheckedChangeListener, V
|
||||
}
|
||||
}
|
||||
|
||||
inner class IdentifiedChip @JvmOverloads constructor(
|
||||
context: Context, attrs: AttributeSet? = null
|
||||
) : Chip(context, attrs) {
|
||||
var idt = 0
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val SEARCH_MODE_NORMAL = 0
|
||||
const val SEARCH_MODE_IMAGE = 1
|
||||
|
||||
Reference in new issue
Block a user