Skip to content

Commit

Permalink
tint sub popup menu
Browse files Browse the repository at this point in the history
  • Loading branch information
ekibun committed Apr 19, 2020
1 parent 4bb1b1d commit 3d3bd05
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 7 additions & 2 deletions app/src/main/java/soko/ekibun/bangumi/util/ResourceUtil.kt
Original file line number Diff line number Diff line change
Expand Up @@ -86,14 +86,19 @@ object ResourceUtil{
return typedValue
}

fun checkMenu(context: Context, menu: Menu, isChecked: (MenuItem) -> Boolean) {
fun checkMenu(context: Context, menu: Menu?, isChecked: (MenuItem) -> Boolean): Boolean {
if (menu == null) return false
var hasCheckedItem = false
menu.forEach {
val checked = isChecked(it) || checkMenu(context, it.subMenu, isChecked)
hasCheckedItem = hasCheckedItem || checked
it.title = SpannableString(it.title.toString()).also { span ->
if (isChecked(it)) span.setSpan(
if (checked) span.setSpan(
ForegroundColorSpan(resolveColorAttr(context, R.attr.colorAccent)),
0, span.length, Spannable.SPAN_INCLUSIVE_EXCLUSIVE
)
}
}
return hasCheckedItem
}
}
2 changes: 2 additions & 0 deletions app/src/main/res/layout/item_calendar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
app:layout_constraintTop_toTopOf="parent"/>

<TextView
android:visibility="gone"
tools:visibility="visible"
android:transitionName="title"
android:id="@+id/item_chase"
android:layout_width="wrap_content"
Expand Down

0 comments on commit 3d3bd05

Please sign in to comment.