Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -764,7 +764,7 @@ class MainActivity : AppCompatActivity(), ColorPickerDialogListener, BiometricCa
// when first loading up the app

// R.id.navigation_home -> R.id.home_preview_change_api
R.id.navigation_search -> R.id.main_search
R.id.navigation_search -> R.id.search_autofit_results
R.id.navigation_library -> R.id.main_search
R.id.navigation_downloads -> R.id.download_appbar
else -> null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class GrdLayoutManager(val context: Context, spanCount: Int) :
): View? {
return try {
val fromPos = getPosition(focused)
val nextPos = getNextViewPos(fromPos, focusDirection)
val nextPos = getNextViewPos(fromPos, focusDirection) ?: return null
findViewByPosition(nextPos)
} catch (e: Exception) {
null
Expand Down Expand Up @@ -50,18 +50,18 @@ class GrdLayoutManager(val context: Context, spanCount: Int) :
override fun onInterceptFocusSearch(focused: View, direction: Int): View? {
return try {
val fromPos = getPosition(focused)
val nextPos = getNextViewPos(fromPos, direction)
val nextPos = getNextViewPos(fromPos, direction) ?: return null
findViewByPosition(nextPos)
} catch (e: Exception) {
null
}
}

private fun getNextViewPos(fromPos: Int, direction: Int): Int {
private fun getNextViewPos(fromPos: Int, direction: Int): Int? {
val offset = calcOffsetToNextView(direction)

if (hitBorder(fromPos, offset)) {
return fromPos
return null
}

return fromPos + offset
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ class SearchFragment : BaseFragment<FragmentSearchBinding>(

override fun onResume() {
super.onResume()
searchViewModel.clearSuggestions()
afterPluginsLoadedEvent += ::reloadRepos
}

Expand All @@ -167,6 +168,7 @@ class SearchFragment : BaseFragment<FragmentSearchBinding>(
**/
fun search(query: String?) {
if (query == null) return
searchViewModel.clearSuggestions()
// don't resume state from prev search
(binding?.searchMasterRecycler?.adapter as? BaseAdapter<*, *>)?.clearState()
context?.let { ctx ->
Expand Down Expand Up @@ -202,18 +204,24 @@ class SearchFragment : BaseFragment<FragmentSearchBinding>(
private fun reloadRepos(success: Boolean = false) = main {
searchViewModel.reloadRepos()
context?.filterProviderByPreferredMedia()?.let { validAPIs ->
val isAdvanced = context?.let { PreferenceManager.getDefaultSharedPreferences(it) }
?.getBoolean("advanced_search", true) ?: true
val nextFocusDownId = if (isAdvanced) R.id.search_master_recycler else R.id.search_autofit_results
bindChips(
binding?.tvtypesChipsScroll?.tvtypesChips,
selectedSearchTypes,
validAPIs.flatMap { api -> api.supportedTypes }.distinct()
) { list ->
if (selectedSearchTypes.toSet() != list.toSet()) {
DataStoreHelper.searchPreferenceTags = list
selectedSearchTypes.clear()
selectedSearchTypes.addAll(list)
search(binding?.mainSearch?.query?.toString())
}
}
validAPIs.flatMap { api -> api.supportedTypes }.distinct(),
{ list ->
if (selectedSearchTypes.toSet() != list.toSet()) {
DataStoreHelper.searchPreferenceTags = list
selectedSearchTypes.clear()
selectedSearchTypes.addAll(list)
search(binding?.mainSearch?.query?.toString())
}
},
nextFocusDown = nextFocusDownId,
nextFocusUp = null
)
}
}

Expand Down