fixed some NPE

This commit is contained in:
Mariotaku Lee 2017-02-14 11:34:31 +08:00
parent 645e57cd2c
commit da54c028bd
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
2 changed files with 7 additions and 6 deletions

View File

@ -80,9 +80,8 @@ class UserTimelineFragment : ParcelableStatusesFragment() {
return sb.toString()
}
override fun onCreateStatusesLoader(context: Context,
args: Bundle,
fromUser: Boolean): Loader<List<ParcelableStatus>?> {
override fun onCreateStatusesLoader(context: Context, args: Bundle, fromUser: Boolean):
Loader<List<ParcelableStatus>?> {
refreshing = true
val data = adapterData
val accountKey = Utils.getAccountKey(context, args)
@ -98,9 +97,9 @@ class UserTimelineFragment : ParcelableStatusesFragment() {
}
override fun onStatusesLoaded(loader: Loader<List<ParcelableStatus>?>, data: List<ParcelableStatus>?) {
val timelineLoader = loader as UserTimelineLoader
val timelineLoader = loader as? UserTimelineLoader
if (!adapter.hasPinnedStatuses) {
adapter.pinnedStatuses = timelineLoader.pinnedStatuses
adapter.pinnedStatuses = timelineLoader?.pinnedStatuses
}
super.onStatusesLoaded(loader, data)
}

View File

@ -25,6 +25,7 @@ import android.text.SpannableString
import android.text.style.URLSpan
import android.view.ActionMode
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
import android.webkit.URLUtil
import android.widget.TextView
@ -37,7 +38,8 @@ import org.mariotaku.twidere.R
class StatusActionModeCallback(private val textView: TextView, private val context: Context) : ActionMode.Callback {
override fun onCreateActionMode(mode: ActionMode, menu: Menu): Boolean {
mode.menuInflater.inflate(R.menu.action_status_text_selection, menu)
val inflater = mode.menuInflater ?: MenuInflater(context)
inflater.inflate(R.menu.action_status_text_selection, menu)
mode.setTitle(android.R.string.selectTextMode)
return true
}