Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
821938089 committed Sep 22, 2023
1 parent 4b2a3b4 commit 49e5063
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,13 @@ class PermissionActivity : AppCompatActivity() {

override fun startActivity(intent: Intent) {
super.startActivity(intent)
@Suppress("DEPRECATION")
overridePendingTransition(0, 0)
}

override fun finish() {
super.finish()
@Suppress("DEPRECATION")
overridePendingTransition(0, 0)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import android.view.Menu
import android.view.MenuItem
import android.view.View
import android.view.ViewGroup
import android.widget.ImageButton
import androidx.appcompat.widget.SearchView
import androidx.appcompat.widget.Toolbar
import androidx.core.os.bundleOf
Expand All @@ -26,16 +27,19 @@ import io.legado.app.data.entities.SearchBook
import io.legado.app.databinding.DialogBookChangeSourceBinding
import io.legado.app.help.config.AppConfig
import io.legado.app.lib.dialogs.alert
import io.legado.app.lib.theme.getPrimaryTextColor
import io.legado.app.lib.theme.primaryColor
import io.legado.app.ui.book.read.ReadBookActivity
import io.legado.app.ui.book.source.edit.BookSourceEditActivity
import io.legado.app.ui.book.source.manage.BookSourceActivity
import io.legado.app.ui.widget.dialog.WaitDialog
import io.legado.app.ui.widget.recycler.VerticalDivider
import io.legado.app.utils.ColorUtils
import io.legado.app.utils.StartActivityContract
import io.legado.app.utils.applyTint
import io.legado.app.utils.cnCompare
import io.legado.app.utils.dpToPx
import io.legado.app.utils.getCompatDrawable
import io.legado.app.utils.observeEvent
import io.legado.app.utils.setLayout
import io.legado.app.utils.startActivity
Expand Down Expand Up @@ -95,18 +99,12 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
}

override fun onFragmentCreated(view: View, savedInstanceState: Bundle?) {
context?.obtainStyledAttributes(intArrayOf(android.R.attr.homeAsUpIndicator))?.use {
binding.toolBar.navigationIcon = it.getDrawable(0)
binding.toolBar.setNavigationContentDescription(androidx.appcompat.R.string.abc_action_bar_up_description)
binding.toolBar.setNavigationOnClickListener {
dismissAllowingStateLoss()
}
}
binding.toolBar.setBackgroundColor(primaryColor)
viewModel.initData(arguments, callBack?.oldBook, activity is ReadBookActivity)
showTitle()
initMenu()
initRecyclerView()
initNavigationView()
initSearchView()
initBottomBar()
initLiveData()
Expand All @@ -116,9 +114,8 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
private fun showTitle() {
binding.toolBar.title = viewModel.name
binding.toolBar.subtitle = viewModel.author
context?.obtainStyledAttributes(intArrayOf(android.R.attr.homeAsUpIndicator))?.use {
binding.toolBar.navigationIcon = it.getDrawable(0)
}
binding.toolBar.navigationIcon =
getCompatDrawable(androidx.appcompat.R.drawable.abc_ic_ab_back_material)
}

private fun initMenu() {
Expand Down Expand Up @@ -177,6 +174,23 @@ class ChangeBookSourceDialog() : BaseDialogFragment(R.layout.dialog_book_change_
})
}

private fun initNavigationView() {
binding.toolBar.navigationIcon =
getCompatDrawable(androidx.appcompat.R.drawable.abc_ic_ab_back_material)
binding.toolBar.setNavigationContentDescription(androidx.appcompat.R.string.abc_action_bar_up_description)
binding.toolBar.setNavigationOnClickListener {
dismissAllowingStateLoss()
}
kotlin.runCatching {
val mNavButtonViewField = Toolbar::class.java.getDeclaredField("mNavButtonView")
mNavButtonViewField.isAccessible = true
val navigationView = mNavButtonViewField.get(binding.toolBar) as ImageButton
val isLight = ColorUtils.isColorLight(primaryColor)
val textColor = requireContext().getPrimaryTextColor(isLight)
navigationView.setColorFilter(textColor)
}
}

private fun initBottomBar() {
binding.tvDur.text = callBack?.oldBook?.originName
binding.tvDur.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ConfigActivity : VMBaseActivity<ActivityConfigBinding, ConfigViewModel>()

inline fun <reified T : Fragment> replaceFragment(configTag: String) {
intent.putExtra("configTag", configTag)
@Suppress("DEPRECATION")
val configFragment = supportFragmentManager.findFragmentByTag(configTag)
?: T::class.java.newInstance()
supportFragmentManager.beginTransaction()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import io.legado.app.R
inline fun <reified T : DialogFragment> AppCompatActivity.showDialogFragment(
arguments: Bundle.() -> Unit = {}
) {
@Suppress("DEPRECATION")
val dialog = T::class.java.newInstance()
val bundle = Bundle()
bundle.apply(arguments)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import androidx.fragment.app.Fragment
inline fun <reified T : DialogFragment> Fragment.showDialogFragment(
arguments: Bundle.() -> Unit = {}
) {
@Suppress("DEPRECATION")
val dialog = T::class.java.newInstance()
val bundle = Bundle()
bundle.apply(arguments)
Expand Down

0 comments on commit 49e5063

Please sign in to comment.