More refactoring

Cleanups, move classes to sane locations, etc.
This commit is contained in:
topjohnwu
2020-08-19 02:05:23 -07:00
parent 846bbb4da1
commit 34450cdddd
85 changed files with 365 additions and 522 deletions
@@ -0,0 +1,39 @@
package com.topjohnwu.magisk.view
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.databinding.ComparableRvItem
sealed class TappableHeadlineItem : ComparableRvItem<TappableHeadlineItem>() {
abstract val title: Int
abstract val icon: Int
override val layoutRes = R.layout.item_tappable_headline
override fun itemSameAs(other: TappableHeadlineItem) =
this === other
override fun contentSameAs(other: TappableHeadlineItem) =
title == other.title && icon == other.icon
// --- listener
interface Listener {
fun onItemPressed(item: TappableHeadlineItem)
}
// --- objects
object Hide : TappableHeadlineItem() {
override val title = R.string.magiskhide
override val icon = R.drawable.ic_hide_md2
}
object ThemeMode : TappableHeadlineItem() {
override val title = R.string.settings_dark_mode_title
override val icon = R.drawable.ic_day_night
}
}
@@ -0,0 +1,11 @@
package com.topjohnwu.magisk.view
import com.topjohnwu.magisk.R
import com.topjohnwu.magisk.databinding.ComparableRvItem
class TextItem(val text: Int) : ComparableRvItem<TextItem>() {
override val layoutRes = R.layout.item_text
override fun contentSameAs(other: TextItem) = text == other.text
override fun itemSameAs(other: TextItem) = contentSameAs(other)
}