fix: 修复 Bug

This commit is contained in:
HuanCheng65 2022-08-07 18:38:27 +08:00
parent 7539406b38
commit c5c9cd9751
No known key found for this signature in database
GPG Key ID: E9031EF91A805148
2 changed files with 10 additions and 8 deletions

View File

@ -79,11 +79,11 @@ inline fun <reified T : Activity> Fragment.goToActivity(pre: Intent.() -> Unit)
}
fun Context.toastShort(text: String) {
Toast.makeText(this, text, Toast.LENGTH_SHORT).show()
runCatching { Toast.makeText(this, text, Toast.LENGTH_SHORT).show() }
}
fun Context.toastShort(resId: Int, vararg args: Any) {
Toast.makeText(this, getString(resId, *args), Toast.LENGTH_SHORT).show()
toastShort(getString(resId, *args))
}
fun ViewGroup.enableChangingLayoutTransition() {

View File

@ -91,6 +91,8 @@ class ForumInfoFragment : BaseFragment(), Refreshable, ScrollTopable {
val bundle = arguments
if (savedInstanceState == null && bundle != null) {
forumName = bundle.getString(ForumFragment.PARAM_FORUM_NAME)
} else if (savedInstanceState != null) {
forumName = savedInstanceState.getString(ForumFragment.PARAM_FORUM_NAME)
}
}
@ -99,14 +101,13 @@ class ForumInfoFragment : BaseFragment(), Refreshable, ScrollTopable {
super.onSaveInstanceState(outState)
}
@Deprecated("Deprecated in Java")
override fun onActivityCreated(savedInstanceState: Bundle?) {
if (savedInstanceState != null) {
forumName = savedInstanceState.getString(ForumFragment.PARAM_FORUM_NAME)
}
super.onActivityCreated(savedInstanceState)
override fun onViewStateRestored(savedInstanceState: Bundle?) {
super.onViewStateRestored(savedInstanceState)
if (savedInstanceState != null) forumName =
savedInstanceState.getString(ForumFragment.PARAM_FORUM_NAME)
}
override fun getLayoutId(): Int {
return R.layout.fragment_forum_info
}
@ -145,6 +146,7 @@ class ForumInfoFragment : BaseFragment(), Refreshable, ScrollTopable {
}
private fun refresh() {
forumName ?: return
mRefreshLayout.isRefreshing = true
launch(IO + job) {
TiebaApi.getInstance()