fixed some NPEs

This commit is contained in:
Mariotaku Lee 2017-04-24 19:09:02 +08:00
parent 92ab85adf9
commit b67cc84718
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
2 changed files with 12 additions and 2 deletions

View File

@ -30,7 +30,7 @@ import org.mariotaku.twidere.model.UserKey
abstract class AbsStatusDialogActivity : BaseActivity() {
private val statusId: String
private val statusId: String?
get() = intent.getStringExtra(EXTRA_STATUS_ID)
private val accountKey: UserKey?
@ -45,6 +45,11 @@ abstract class AbsStatusDialogActivity : BaseActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
if (savedInstanceState == null) {
val statusId = this.statusId ?: run {
setResult(RESULT_CANCELED)
finish()
return
}
val accountKey = this.accountKey
if (accountKey != null) {
showDialogFragment(accountKey, statusId, status)
@ -62,6 +67,11 @@ abstract class AbsStatusDialogActivity : BaseActivity() {
when (requestCode) {
REQUEST_SELECT_ACCOUNT -> {
if (resultCode == RESULT_OK && data != null) {
val statusId = this.statusId ?: run {
setResult(RESULT_CANCELED)
finish()
return
}
val accountKey = data.getParcelableExtra<UserKey>(EXTRA_ACCOUNT_KEY)
showDialogFragment(accountKey, statusId, status)
return

View File

@ -369,7 +369,7 @@ abstract class AbsActivitiesFragment protected constructor() :
}
override fun onQuotedStatusClick(holder: IStatusViewHolder, position: Int) {
val status = getActivityStatus(position) ?: return
val status = getActivityStatus(position)?.takeIf { it.quoted_id != null } ?: return
IntentUtils.openStatus(context, status.account_key, status.quoted_id)
}