mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-11-09 19:25:10 +01:00
More updates to MenuSheetItemView
support for maxlines, remove isclickable (since it messes up xml inflatation)
This commit is contained in:
parent
da2cca16a6
commit
a0f00df1ab
@ -9,7 +9,7 @@ import android.widget.LinearLayout
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isGone
|
||||
import androidx.core.widget.TextViewCompat
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.databinding.MenuSheetItemBinding
|
||||
@ -19,6 +19,7 @@ class MenuSheetItemView @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
private val mText: String
|
||||
private val mIconRes: Int
|
||||
private val mEndIconRes: Int
|
||||
private val mMaxLines: Int
|
||||
|
||||
private var binding: MenuSheetItemBinding? = null
|
||||
|
||||
@ -34,6 +35,9 @@ class MenuSheetItemView @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
val e = a.getResourceId(R.styleable.MenuSheetItemView_endIcon, 0)
|
||||
mEndIconRes = e
|
||||
|
||||
val m = a.getInt(R.styleable.MenuSheetItemView_android_maxLines, Int.MAX_VALUE)
|
||||
mMaxLines = m
|
||||
|
||||
a.recycle()
|
||||
}
|
||||
|
||||
@ -47,6 +51,7 @@ class MenuSheetItemView @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
text = mText
|
||||
setIcon(mIconRes)
|
||||
setEndIcon(mEndIconRes)
|
||||
binding?.itemTextView?.maxLines = mMaxLines
|
||||
}
|
||||
|
||||
var text: CharSequence?
|
||||
@ -85,13 +90,26 @@ class MenuSheetItemView @JvmOverloads constructor(context: Context, attrs: Attri
|
||||
)
|
||||
}
|
||||
|
||||
fun setIcon(drawable: Drawable?) {
|
||||
binding?.itemTextView?.setCompoundDrawablesRelativeWithIntrinsicBounds(
|
||||
drawable,
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
)
|
||||
}
|
||||
|
||||
fun getIcon(): Drawable? {
|
||||
return binding?.itemTextView?.compoundDrawablesRelative?.getOrNull(0)
|
||||
}
|
||||
|
||||
fun setEndIcon(@DrawableRes res: Int) {
|
||||
binding?.menuEndItem?.isInvisible = res == 0
|
||||
binding?.menuEndItem?.isGone = res == 0
|
||||
binding?.menuEndItem?.setImageResource(res)
|
||||
}
|
||||
|
||||
fun setEndIcon(drawable: Drawable?) {
|
||||
binding?.menuEndItem?.isInvisible = drawable == null
|
||||
binding?.menuEndItem?.isGone = drawable == null
|
||||
binding?.menuEndItem?.setImageDrawable(drawable)
|
||||
}
|
||||
}
|
||||
|
@ -5,8 +5,6 @@
|
||||
android:layout_height="48sp"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="?attr/selectableItemBackground"
|
||||
android:clickable="true"
|
||||
android:focusable="true"
|
||||
android:orientation="horizontal"
|
||||
tools:icon="@drawable/ic_share_24dp"
|
||||
tools:endIcon="@drawable/ic_arrow_downward_24dp"
|
||||
@ -22,6 +20,7 @@
|
||||
android:gravity="center|start"
|
||||
android:paddingStart="16dp"
|
||||
android:paddingEnd="16dp"
|
||||
android:ellipsize="end"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="13sp"
|
||||
android:tint="@color/md_white_1000_54" />
|
||||
|
@ -28,6 +28,7 @@
|
||||
|
||||
<declare-styleable name="MenuSheetItemView">
|
||||
<attr name="android:text"/>
|
||||
<attr name="android:maxLines"/>
|
||||
<attr name="icon" format="reference"/>
|
||||
<attr name="endIcon" format="reference"/>
|
||||
</declare-styleable>
|
||||
|
Loading…
Reference in New Issue
Block a user