优化代码

pull/32/head
Invinciblelee 6 years ago
parent 84832eee72
commit 5f97abadbd
  1. 11
      app/src/main/java/io/legado/app/base/BaseActivity.kt
  2. 17
      app/src/main/res/values/styles.xml

@ -7,6 +7,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.appcompat.view.menu.MenuBuilder
import androidx.appcompat.view.menu.MenuItemImpl
import androidx.core.content.ContextCompat
import androidx.core.view.forEach
import androidx.lifecycle.ViewModel
import io.legado.app.R
import io.legado.app.lib.theme.ColorUtils
@ -29,7 +30,7 @@ abstract class BaseActivity<VM : ViewModel> : AppCompatActivity() {
abstract fun onViewModelCreated(viewModel: VM, savedInstanceState: Bundle?)
override fun onCreateOptionsMenu(menu: Menu?): Boolean {
final override fun onCreateOptionsMenu(menu: Menu?): Boolean {
return menu?.let {
if (it is MenuBuilder) {
it.setOptionalIconsVisible(true)
@ -37,12 +38,12 @@ abstract class BaseActivity<VM : ViewModel> : AppCompatActivity() {
val bool = onCompatCreateOptionsMenu(it)
val primaryTextColor = getPrimaryTextColor(ColorUtils.isColorLight(ThemeStore.primaryColor(this)))
val defaultTextColor = ContextCompat.getColor(this, R.color.tv_text_default)
for (i in 0 until menu.size()) {
(menu.getItem(i) as MenuItemImpl).let { item ->
menu.forEach {item ->
(item as MenuItemImpl).let { impl ->
//overflow:展开的item
DrawableUtils.setTint(
item.icon,
if (item.requiresOverflow()) defaultTextColor else primaryTextColor
impl.icon,
if (impl.requiresOverflow()) defaultTextColor else primaryTextColor
)
}
}

@ -76,6 +76,15 @@
<item name="android:popupBackground">@color/background_menu</item>
</style>
<style name="Activity.Permission" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowDisablePreview">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowTranslucentStatus" tools:targetApi="kitkat">true</item>
<item name="android:windowAnimationStyle">@null</item>
</style>
//**************************************************************Widget Style******************************************************************************//
<style name="Style.Shadow.Top" parent="android:Widget">
@ -91,14 +100,6 @@
</style>
<style name="Activity.Permission" parent="Theme.AppCompat.Light.NoActionBar">
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowDisablePreview">true</item>
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowTranslucentStatus" tools:targetApi="kitkat">true</item>
<item name="android:windowAnimationStyle">@null</item>
</style>
<style name="Style.Line" parent="android:Widget">
<item name="android:layout_width">match_parent</item>
<item name="android:layout_height">0.5dp</item>

Loading…
Cancel
Save