Open filter from list header
parent
238bc89be9
commit
5c05aaeacf
@ -1,41 +0,0 @@
|
|||||||
package org.koitharu.kotatsu.base.ui.widgets
|
|
||||||
|
|
||||||
import android.content.Context
|
|
||||||
import android.graphics.drawable.Drawable
|
|
||||||
import android.util.AttributeSet
|
|
||||||
import android.view.View
|
|
||||||
import androidx.appcompat.widget.Toolbar
|
|
||||||
import androidx.core.view.isGone
|
|
||||||
import com.google.android.material.R
|
|
||||||
import com.google.android.material.appbar.MaterialToolbar
|
|
||||||
import java.lang.reflect.Field
|
|
||||||
|
|
||||||
class AnimatedToolbar @JvmOverloads constructor(
|
|
||||||
context: Context,
|
|
||||||
attrs: AttributeSet? = null,
|
|
||||||
defStyleAttr: Int = R.attr.toolbarStyle,
|
|
||||||
) : MaterialToolbar(context, attrs, defStyleAttr) {
|
|
||||||
|
|
||||||
private var navButtonView: View? = null
|
|
||||||
get() {
|
|
||||||
if (field == null) {
|
|
||||||
runCatching {
|
|
||||||
field = navButtonViewField?.get(this) as? View
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return field
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun setNavigationIcon(icon: Drawable?) {
|
|
||||||
super.setNavigationIcon(icon)
|
|
||||||
navButtonView?.isGone = (icon == null)
|
|
||||||
}
|
|
||||||
|
|
||||||
private companion object {
|
|
||||||
|
|
||||||
val navButtonViewField: Field? = runCatching {
|
|
||||||
Toolbar::class.java.getDeclaredField("mNavButtonView")
|
|
||||||
.also { it.isAccessible = true }
|
|
||||||
}.getOrNull()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,8 +1,10 @@
|
|||||||
package org.koitharu.kotatsu.list.ui.model
|
package org.koitharu.kotatsu.list.ui.model
|
||||||
|
|
||||||
import androidx.annotation.StringRes
|
import androidx.annotation.StringRes
|
||||||
|
import org.koitharu.kotatsu.core.model.SortOrder
|
||||||
|
|
||||||
data class ListHeader(
|
data class ListHeader(
|
||||||
val text: CharSequence?,
|
val text: CharSequence?,
|
||||||
@StringRes val textRes: Int,
|
@StringRes val textRes: Int,
|
||||||
|
val sortOrder: SortOrder?,
|
||||||
) : ListModel
|
) : ListModel
|
||||||
@ -0,0 +1,36 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<RelativeLayout
|
||||||
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView_title"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentStart="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_toStartOf="@id/textView_filter"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAppearance="@style/TextAppearance.Kotatsu.SectionHeader"
|
||||||
|
tools:text="@tools:sample/lorem[21]" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/textView_filter"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:background="@drawable/list_selector"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:paddingStart="6dp"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textAppearance="@style/TextAppearance.Kotatsu.SectionHeader"
|
||||||
|
app:drawableEndCompat="@drawable/ic_drop_down"
|
||||||
|
app:drawableTint="?android:attr/textColorSecondary"
|
||||||
|
tools:ignore="RtlSymmetry"
|
||||||
|
tools:text="@string/popular" />
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
Loading…
Reference in New Issue