mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Code review cleanup and refactoring.
This commit is contained in:
		| @@ -82,14 +82,14 @@ abstract class SettingsController : PreferenceController() { | ||||
|     } | ||||
|  | ||||
|     private fun animatePreferenceHighlight(view: View) { | ||||
|         val duration = 500L | ||||
|         val repeat = 2 | ||||
|  | ||||
|         val colorAnimation = ValueAnimator.ofObject(ArgbEvaluator(), Color.TRANSPARENT, Color.WHITE) | ||||
|         colorAnimation.duration = duration | ||||
|         colorAnimation.repeatCount = repeat | ||||
|         colorAnimation.addUpdateListener { animator -> view.setBackgroundColor(animator.animatedValue as Int) } | ||||
|         colorAnimation.reverse() | ||||
|         ValueAnimator | ||||
|             .ofObject(ArgbEvaluator(), Color.TRANSPARENT, R.attr.rippleColor) | ||||
|             .apply { | ||||
|                 duration = 500L | ||||
|                 repeatCount = 2 | ||||
|                 addUpdateListener { animator -> view.setBackgroundColor(animator.animatedValue as Int) } | ||||
|                 reverse() | ||||
|             } | ||||
|     } | ||||
|  | ||||
|     open fun getTitle(): String? { | ||||
|   | ||||
| @@ -108,14 +108,10 @@ class SettingsMainController : SettingsController() { | ||||
|         searchView.queryTextEvents() | ||||
|             .filterIsInstance<QueryTextEvent.QueryChanged>() | ||||
|             .onEach { | ||||
|                 performSettingsSearch(it.queryText.toString()) | ||||
|                 router.pushController( | ||||
|                     SettingsSearchController().withFadeTransaction() | ||||
|                 ) | ||||
|             } | ||||
|             .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 | ||||
|      */ | ||||
|     fun getResultSet(query: String? = null): List<SettingsSearchItem> { | ||||
|         val list = mutableListOf<SettingsSearchItem>() | ||||
|  | ||||
|         if (!query.isNullOrBlank()) { | ||||
|             SettingsSearchHelper.getFilteredResults(query) | ||||
|                 .forEach { | ||||
|                     list.add(SettingsSearchItem(it, null)) | ||||
|                 } | ||||
|         if (!query.isNullOrBlank() && query.length >= 3) { | ||||
|             return SettingsSearchHelper.getFilteredResults(query) | ||||
|                 .map { SettingsSearchItem(it, null) } | ||||
|         } | ||||
|  | ||||
|         return list | ||||
|         return mutableListOf() | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|   | ||||
| @@ -1,9 +1,7 @@ | ||||
| package eu.kanade.tachiyomi.ui.setting.settingssearch | ||||
|  | ||||
| import android.os.Bundle | ||||
| import eu.kanade.tachiyomi.data.database.DatabaseHelper | ||||
| import eu.kanade.tachiyomi.data.preference.PreferencesHelper | ||||
| import eu.kanade.tachiyomi.source.SourceManager | ||||
| import eu.kanade.tachiyomi.ui.base.presenter.BasePresenter | ||||
| import uy.kohesive.injekt.Injekt | ||||
| import uy.kohesive.injekt.api.get | ||||
| @@ -20,8 +18,6 @@ open class SettingsSearchPresenter : BasePresenter<SettingsSearchController>() { | ||||
|     var query = "" | ||||
|         private set | ||||
|  | ||||
|     val sourceManager: SourceManager = Injekt.get() | ||||
|     val db: DatabaseHelper = Injekt.get() | ||||
|     val preferences: PreferencesHelper = Injekt.get() | ||||
|  | ||||
|     override fun onCreate(savedState: Bundle?) { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user