Skip to content

Commit

Permalink
优化
Browse files Browse the repository at this point in the history
  • Loading branch information
821938089 committed Oct 30, 2023
1 parent c5d03e5 commit 75d4bc9
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
6 changes: 5 additions & 1 deletion app/src/main/java/io/legado/app/ui/book/toc/TocActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,11 @@ class TocActivity : VMBaseActivity<ActivityChapterListBinding, TocViewModel>(),
}
}
}
return super.dispatchTouchEvent(ev)
return try {
super.dispatchTouchEvent(ev)
} catch (e: IllegalArgumentException) {
false
}
}

override fun onCompatCreateOptionsMenu(menu: Menu): Boolean {
Expand Down
6 changes: 5 additions & 1 deletion app/src/main/java/io/legado/app/ui/main/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,11 @@ class MainActivity : VMBaseActivity<ActivityMainBinding, MainViewModel>(),
}
}
}
return super.dispatchTouchEvent(ev)
return try {
super.dispatchTouchEvent(ev)
} catch (e: IllegalArgumentException) {
false
}
}

override fun onPostCreate(savedInstanceState: Bundle?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,9 @@ class BooksFragment() : BaseFragment(R.layout.fragment_books),
AppLog.put("书架更新出错", it)
}.conflate().collect { list ->
binding.tvEmptyMsg.isGone = list.isNotEmpty()
binding.refreshLayout.isEnabled = list.isNotEmpty()
binding.refreshLayout.run {
isEnabled = isEnabled && list.isNotEmpty()
}
booksAdapter.setItems(list)
recoverPositionState()
delay(100)
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/io/legado/app/ui/rss/article/RssSortActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package io.legado.app.ui.rss.article
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import android.view.MotionEvent
import android.view.ViewGroup
import androidx.activity.viewModels
import androidx.fragment.app.Fragment
Expand Down Expand Up @@ -54,6 +55,14 @@ class RssSortActivity : VMBaseActivity<ActivityRssArtivlesBinding, RssSortViewMo
}
}

override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
return try {
super.dispatchTouchEvent(ev)
} catch (e: IllegalArgumentException) {
false
}
}

override fun onCompatCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.rss_articles, menu)
return super.onCompatCreateOptionsMenu(menu)
Expand All @@ -71,18 +80,21 @@ class RssSortActivity : VMBaseActivity<ActivityRssArtivlesBinding, RssSortViewMo
putExtra("type", "rssSource")
putExtra("key", viewModel.rssSource?.sourceUrl)
}

R.id.menu_refresh_sort -> viewModel.clearSortCache { upFragments() }
R.id.menu_set_source_variable -> setSourceVariable()
R.id.menu_edit_source -> viewModel.rssSource?.sourceUrl?.let {
editSourceResult.launch {
putExtra("sourceUrl", it)
}
}

R.id.menu_clear -> {
viewModel.url?.let {
viewModel.clearArticles()
}
}

R.id.menu_switch_layout -> {
viewModel.switchLayout()
upFragments()
Expand Down

0 comments on commit 75d4bc9

Please sign in to comment.