2019-04-11 19:17:54 +00:00
|
|
|
package com.topjohnwu.magisk.utils
|
|
|
|
|
|
|
|
import android.view.View
|
2019-04-14 09:00:16 +00:00
|
|
|
import androidx.annotation.ColorInt
|
2019-04-12 22:14:37 +00:00
|
|
|
import androidx.annotation.DrawableRes
|
|
|
|
import androidx.appcompat.widget.AppCompatImageView
|
2019-04-11 19:17:54 +00:00
|
|
|
import androidx.appcompat.widget.Toolbar
|
|
|
|
import androidx.databinding.BindingAdapter
|
2019-04-16 17:00:32 +00:00
|
|
|
import androidx.drawerlayout.widget.DrawerLayout
|
|
|
|
import com.google.android.material.navigation.NavigationView
|
2019-04-11 19:17:54 +00:00
|
|
|
|
|
|
|
|
|
|
|
@BindingAdapter("onNavigationClick")
|
|
|
|
fun setOnNavigationClickedListener(view: Toolbar, listener: View.OnClickListener) {
|
|
|
|
view.setNavigationOnClickListener(listener)
|
|
|
|
}
|
2019-04-12 22:14:37 +00:00
|
|
|
|
2019-04-16 17:00:32 +00:00
|
|
|
@BindingAdapter("onNavigationClick")
|
|
|
|
fun setOnNavigationClickedListener(
|
|
|
|
view: NavigationView,
|
|
|
|
listener: NavigationView.OnNavigationItemSelectedListener
|
|
|
|
) {
|
|
|
|
view.setNavigationItemSelectedListener {
|
|
|
|
(view.parent as? DrawerLayout)?.closeDrawers()
|
|
|
|
listener.onNavigationItemSelected(it)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-12 22:14:37 +00:00
|
|
|
@BindingAdapter("srcCompat")
|
|
|
|
fun setImageResource(view: AppCompatImageView, @DrawableRes resId: Int) {
|
|
|
|
view.setImageResource(resId)
|
|
|
|
}
|
2019-04-14 09:00:16 +00:00
|
|
|
|
|
|
|
@BindingAdapter("app:tint")
|
|
|
|
fun setTint(view: AppCompatImageView, @ColorInt tint: Int) {
|
|
|
|
view.setColorFilter(tint)
|
|
|
|
}
|