fixed a serious crash in link handler
This commit is contained in:
parent
150e07d373
commit
da5b276e16
|
@ -27,6 +27,7 @@ import android.graphics.Rect
|
|||
import android.net.Uri
|
||||
import android.os.BadParcelableException
|
||||
import android.os.Bundle
|
||||
import android.support.design.widget.FloatingActionButton
|
||||
import android.support.v4.app.Fragment
|
||||
import android.support.v4.app.FragmentManager
|
||||
import android.support.v4.app.FragmentManager.FragmentLifecycleCallbacks
|
||||
|
@ -104,10 +105,11 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IContro
|
|||
return
|
||||
}
|
||||
val linkId = TwidereLinkMatcher.match(uri)
|
||||
var transactionRequired = false
|
||||
intent.setExtrasClassLoader(classLoader)
|
||||
val fragment: Fragment
|
||||
try {
|
||||
fragment = createFragmentForIntent(this, linkId, intent) ?: run {
|
||||
val fragment: Fragment = currentVisibleFragment ?: try {
|
||||
transactionRequired = true
|
||||
createFragmentForIntent(this, linkId, intent) ?: run {
|
||||
finish()
|
||||
return
|
||||
}
|
||||
|
@ -153,9 +155,11 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IContro
|
|||
|
||||
setupActionBarOption()
|
||||
Utils.logOpenNotificationFromUri(this, uri)
|
||||
if (transactionRequired) {
|
||||
val ft = supportFragmentManager.beginTransaction()
|
||||
ft.replace(contentFragmentId, fragment, "content_fragment")
|
||||
ft.commit()
|
||||
}
|
||||
setTitle(linkId, uri)
|
||||
finishOnly = uri.getQueryParameter(QUERY_PARAM_FINISH_ONLY)?.toBoolean() ?: false
|
||||
|
||||
|
@ -507,7 +511,7 @@ class LinkHandlerActivity : BaseActivity(), SystemWindowsInsetsCallback, IContro
|
|||
}
|
||||
|
||||
private fun updateActionsButton() {
|
||||
val fab = this.actionsButton ?: return
|
||||
val fab = window.findViewById(R.id.actionButtons) as? FloatingActionButton ?: return
|
||||
val fragment = currentVisibleFragment as? IFloatingActionButtonFragment
|
||||
val info = fragment?.getActionInfo("link_handler") ?: run {
|
||||
fab.visibility = View.GONE
|
||||
|
|
Loading…
Reference in New Issue