mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-19 03:59:19 +01:00
Code review cleanup and refactoring.
This commit is contained in:
parent
6f4b84c8fb
commit
a5098e5b5b
@ -82,14 +82,14 @@ abstract class SettingsController : PreferenceController() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun animatePreferenceHighlight(view: View) {
|
private fun animatePreferenceHighlight(view: View) {
|
||||||
val duration = 500L
|
ValueAnimator
|
||||||
val repeat = 2
|
.ofObject(ArgbEvaluator(), Color.TRANSPARENT, R.attr.rippleColor)
|
||||||
|
.apply {
|
||||||
val colorAnimation = ValueAnimator.ofObject(ArgbEvaluator(), Color.TRANSPARENT, Color.WHITE)
|
duration = 500L
|
||||||
colorAnimation.duration = duration
|
repeatCount = 2
|
||||||
colorAnimation.repeatCount = repeat
|
addUpdateListener { animator -> view.setBackgroundColor(animator.animatedValue as Int) }
|
||||||
colorAnimation.addUpdateListener { animator -> view.setBackgroundColor(animator.animatedValue as Int) }
|
reverse()
|
||||||
colorAnimation.reverse()
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
open fun getTitle(): String? {
|
open fun getTitle(): String? {
|
||||||
|
@ -108,14 +108,10 @@ class SettingsMainController : SettingsController() {
|
|||||||
searchView.queryTextEvents()
|
searchView.queryTextEvents()
|
||||||
.filterIsInstance<QueryTextEvent.QueryChanged>()
|
.filterIsInstance<QueryTextEvent.QueryChanged>()
|
||||||
.onEach {
|
.onEach {
|
||||||
performSettingsSearch(it.queryText.toString())
|
router.pushController(
|
||||||
|
SettingsSearchController().withFadeTransaction()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
.launchIn(scope)
|
.launchIn(scope)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun performSettingsSearch(query: String) {
|
|
||||||
router.pushController(
|
|
||||||
SettingsSearchController().withFadeTransaction()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -137,16 +137,12 @@ class SettingsSearchController :
|
|||||||
* returns a list of `SettingsSearchItem` to be shown as search results
|
* returns a list of `SettingsSearchItem` to be shown as search results
|
||||||
*/
|
*/
|
||||||
fun getResultSet(query: String? = null): List<SettingsSearchItem> {
|
fun getResultSet(query: String? = null): List<SettingsSearchItem> {
|
||||||
val list = mutableListOf<SettingsSearchItem>()
|
if (!query.isNullOrBlank() && query.length >= 3) {
|
||||||
|
return SettingsSearchHelper.getFilteredResults(query)
|
||||||
if (!query.isNullOrBlank()) {
|
.map { SettingsSearchItem(it, null) }
|
||||||
SettingsSearchHelper.getFilteredResults(query)
|
|
||||||
.forEach {
|
|
||||||
list.add(SettingsSearchItem(it, null))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return list
|
return mutableListOf()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package eu.kanade.tachiyomi.ui.setting.settingssearch
|
package eu.kanade.tachiyomi.ui.setting.settingssearch
|
||||||
|
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import eu.kanade.tachiyomi.data.database.DatabaseHelper
|
|
||||||
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
import eu.kanade.tachiyomi.data.preference.PreferencesHelper
|
||||||
import eu.kanade.tachiyomi.source.SourceManager
|
|
||||||
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter
|
||||||
import uy.kohesive.injekt.Injekt
|
import uy.kohesive.injekt.Injekt
|
||||||
import uy.kohesive.injekt.api.get
|
import uy.kohesive.injekt.api.get
|
||||||
@ -20,8 +18,6 @@ open class SettingsSearchPresenter : BasePresenter<SettingsSearchController>() {
|
|||||||
var query = ""
|
var query = ""
|
||||||
private set
|
private set
|
||||||
|
|
||||||
val sourceManager: SourceManager = Injekt.get()
|
|
||||||
val db: DatabaseHelper = Injekt.get()
|
|
||||||
val preferences: PreferencesHelper = Injekt.get()
|
val preferences: PreferencesHelper = Injekt.get()
|
||||||
|
|
||||||
override fun onCreate(savedState: Bundle?) {
|
override fun onCreate(savedState: Bundle?) {
|
||||||
|
@ -1,52 +1,45 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:id="@+id/title_wrapper"
|
||||||
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:layout_marginStart="48dp"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:background="?attr/selectableItemBackground">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<TextView
|
||||||
android:id="@+id/title_wrapper"
|
android:id="@+id/search_result_pref_title"
|
||||||
android:layout_width="match_parent"
|
style="@style/TextAppearance.Regular.SubHeading"
|
||||||
android:layout_height="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_marginStart="@dimen/search_result_wrapper_margin_start"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="@dimen/search_result_wrapper_margin_top"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:layout_marginBottom="@dimen/search_result_wrapper_margin_bottom"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
android:background="?attr/selectableItemBackground">
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
tools:text="Title" />
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/search_result_pref_title"
|
android:id="@+id/search_result_pref_summary"
|
||||||
style="@style/TextAppearance.Regular.SubHeading"
|
android:layout_width="0dp"
|
||||||
android:layout_width="0dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintTop_toBottomOf="@+id/search_result_pref_title"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
tools:text="Summary" />
|
||||||
tools:text="Title" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/search_result_pref_summary"
|
android:id="@+id/search_result_pref_breadcrumb"
|
||||||
android:layout_width="0dp"
|
style="@style/TextAppearance.Regular.Caption"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="0dp"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
android:ellipsize="end"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/search_result_pref_title"
|
android:maxLines="1"
|
||||||
tools:text="Summary" />
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/search_result_pref_summary"
|
||||||
|
tools:text="Location" />
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/search_result_pref_breadcrumb"
|
|
||||||
style="@style/TextAppearance.Regular.Caption"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:ellipsize="end"
|
|
||||||
android:maxLines="1"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintTop_toBottomOf="@+id/search_result_pref_summary"
|
|
||||||
tools:text="Location" />
|
|
||||||
|
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
|
@ -23,8 +23,4 @@
|
|||||||
<dimen name="text_small_body">14sp</dimen>
|
<dimen name="text_small_body">14sp</dimen>
|
||||||
|
|
||||||
<dimen name="bottom_sheet_width">0dp</dimen>
|
<dimen name="bottom_sheet_width">0dp</dimen>
|
||||||
|
|
||||||
<dimen name="search_result_wrapper_margin_start">50dp</dimen>
|
|
||||||
<dimen name="search_result_wrapper_margin_top">20dp</dimen>
|
|
||||||
<dimen name="search_result_wrapper_margin_bottom">20dp</dimen>
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user