mirror of
https://github.com/mihonapp/mihon.git
synced 2025-06-25 18:47:51 +02:00
UI tweaks
This commit is contained in:
@ -14,8 +14,6 @@ import eu.kanade.tachiyomi.ui.download.DownloadFragment
|
||||
import eu.kanade.tachiyomi.ui.library.LibraryFragment
|
||||
import eu.kanade.tachiyomi.ui.recent.RecentChaptersFragment
|
||||
import eu.kanade.tachiyomi.ui.setting.SettingsActivity
|
||||
import eu.kanade.tachiyomi.util.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.setVectorCompat
|
||||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
import kotlinx.android.synthetic.main.toolbar.*
|
||||
|
||||
@ -45,8 +43,7 @@ class MainActivity : BaseActivity() {
|
||||
// Set behavior of Navigation drawer
|
||||
nav_view.setNavigationItemSelectedListener { item ->
|
||||
// Make information view invisible
|
||||
image_view.setImageResource(android.R.color.transparent)
|
||||
text_label.text = ""
|
||||
empty_view.hide()
|
||||
|
||||
when (item.itemId) {
|
||||
R.id.nav_drawer_library -> setFragment(LibraryFragment.newInstance())
|
||||
@ -91,12 +88,6 @@ class MainActivity : BaseActivity() {
|
||||
}
|
||||
|
||||
fun updateEmptyView(show: Boolean, textResource: Int, drawable: Int) {
|
||||
if (show) {
|
||||
image_view.setVectorCompat(drawable, theme.getResourceColor(android.R.attr.textColorHint))
|
||||
text_label.text = getString(textResource)
|
||||
} else {
|
||||
image_view.setImageResource(android.R.color.transparent)
|
||||
text_label.text = ""
|
||||
}
|
||||
if (show) empty_view.show(drawable, textResource) else empty_view.hide()
|
||||
}
|
||||
}
|
36
app/src/main/java/eu/kanade/tachiyomi/widget/EmptyView.kt
Normal file
36
app/src/main/java/eu/kanade/tachiyomi/widget/EmptyView.kt
Normal file
@ -0,0 +1,36 @@
|
||||
package eu.kanade.tachiyomi.widget
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.View
|
||||
import android.widget.RelativeLayout
|
||||
import eu.kanade.tachiyomi.R
|
||||
import eu.kanade.tachiyomi.util.getResourceColor
|
||||
import eu.kanade.tachiyomi.util.setVectorCompat
|
||||
import kotlinx.android.synthetic.main.view_empty.view.*
|
||||
|
||||
class EmptyView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null) :
|
||||
RelativeLayout (context, attrs) {
|
||||
|
||||
init {
|
||||
inflate(context, R.layout.view_empty, this)
|
||||
}
|
||||
|
||||
/**
|
||||
* Hide the information view
|
||||
*/
|
||||
fun hide() {
|
||||
this.visibility = View.GONE
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the information view
|
||||
* @param drawable icon of information view
|
||||
* @param textResource text of information view
|
||||
*/
|
||||
fun show(drawable: Int, textResource: Int) {
|
||||
image_view.setVectorCompat(drawable, context.theme.getResourceColor(android.R.attr.textColorHint))
|
||||
text_label.text = context.getString(textResource)
|
||||
this.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user