mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-14 16:45:06 +01:00
More binding
This commit is contained in:
parent
e2362a2f72
commit
632d2759cb
@ -2,21 +2,28 @@ package eu.kanade.tachiyomi.ui.base
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
|
import android.widget.TextView
|
||||||
import androidx.appcompat.graphics.drawable.DrawerArrowDrawable
|
import androidx.appcompat.graphics.drawable.DrawerArrowDrawable
|
||||||
import com.google.android.material.appbar.MaterialToolbar
|
import com.google.android.material.appbar.MaterialToolbar
|
||||||
|
import com.google.android.material.textview.MaterialTextView
|
||||||
import eu.kanade.tachiyomi.R
|
import eu.kanade.tachiyomi.R
|
||||||
import kotlinx.android.synthetic.main.main_activity.view.*
|
|
||||||
|
|
||||||
class CenteredToolbar@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
class CenteredToolbar@JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||||
MaterialToolbar(context, attrs) {
|
MaterialToolbar(context, attrs) {
|
||||||
|
|
||||||
|
private lateinit var toolbarTitle:TextView
|
||||||
|
override fun onFinishInflate() {
|
||||||
|
super.onFinishInflate()
|
||||||
|
toolbarTitle = findViewById<MaterialTextView>(R.id.toolbar_title)
|
||||||
|
}
|
||||||
|
|
||||||
override fun setTitle(resId: Int) {
|
override fun setTitle(resId: Int) {
|
||||||
if (navigationIcon is DrawerArrowDrawable) {
|
if (navigationIcon is DrawerArrowDrawable) {
|
||||||
super.setTitle(resId)
|
super.setTitle(resId)
|
||||||
toolbar_title.text = null
|
toolbarTitle.text = null
|
||||||
hideDropdown()
|
hideDropdown()
|
||||||
} else {
|
} else {
|
||||||
toolbar_title.text = context.getString(resId)
|
toolbarTitle.text = context.getString(resId)
|
||||||
super.setTitle(null)
|
super.setTitle(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -24,16 +31,16 @@ class CenteredToolbar@JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
override fun setTitle(title: CharSequence?) {
|
override fun setTitle(title: CharSequence?) {
|
||||||
if (navigationIcon is DrawerArrowDrawable) {
|
if (navigationIcon is DrawerArrowDrawable) {
|
||||||
super.setTitle(title)
|
super.setTitle(title)
|
||||||
toolbar_title.text = ""
|
toolbarTitle.text = ""
|
||||||
hideDropdown()
|
hideDropdown()
|
||||||
} else {
|
} else {
|
||||||
toolbar_title.text = title
|
toolbarTitle.text = title
|
||||||
super.setTitle(null)
|
super.setTitle(null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showDropdown(down: Boolean = true) {
|
fun showDropdown(down: Boolean = true) {
|
||||||
toolbar_title.setCompoundDrawablesRelativeWithIntrinsicBounds(
|
toolbarTitle.setCompoundDrawablesRelativeWithIntrinsicBounds(
|
||||||
R.drawable.ic_blank_24dp,
|
R.drawable.ic_blank_24dp,
|
||||||
0,
|
0,
|
||||||
if (down) {
|
if (down) {
|
||||||
@ -46,6 +53,6 @@ class CenteredToolbar@JvmOverloads constructor(context: Context, attrs: Attribut
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun hideDropdown() {
|
fun hideDropdown() {
|
||||||
toolbar_title.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0)
|
toolbarTitle.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,6 @@ import com.bluelinelabs.conductor.ControllerChangeHandler
|
|||||||
import com.bluelinelabs.conductor.ControllerChangeType
|
import com.bluelinelabs.conductor.ControllerChangeType
|
||||||
import com.bluelinelabs.conductor.RestoreViewOnCreateController
|
import com.bluelinelabs.conductor.RestoreViewOnCreateController
|
||||||
import kotlinx.android.extensions.LayoutContainer
|
import kotlinx.android.extensions.LayoutContainer
|
||||||
import kotlinx.android.synthetic.*
|
|
||||||
import timber.log.Timber
|
import timber.log.Timber
|
||||||
|
|
||||||
abstract class BaseController<VB : ViewBinding>(bundle: Bundle? = null) :
|
abstract class BaseController<VB : ViewBinding>(bundle: Bundle? = null) :
|
||||||
@ -54,11 +53,6 @@ abstract class BaseController<VB : ViewBinding>(bundle: Bundle? = null) :
|
|||||||
return inflateView(inflater, container)
|
return inflateView(inflater, container)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onDestroyView(view: View) {
|
|
||||||
super.onDestroyView(view)
|
|
||||||
clearFindViewByIdCache()
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract fun inflateView(inflater: LayoutInflater, container: ViewGroup): View
|
abstract fun inflateView(inflater: LayoutInflater, container: ViewGroup): View
|
||||||
|
|
||||||
open fun onViewCreated(view: View) { }
|
open fun onViewCreated(view: View) { }
|
||||||
|
Loading…
Reference in New Issue
Block a user