fixed crashes when no network available

This commit is contained in:
Mariotaku Lee 2017-04-06 19:23:41 +08:00
parent 032cfda7ad
commit 3180a9c516
No known key found for this signature in database
GPG Key ID: 15C10F89D7C33535
3 changed files with 5 additions and 5 deletions

View File

@ -415,7 +415,7 @@ abstract class ParcelableStatusesAdapter(
var sum = 0
for (i in 0 until itemCounts.size) {
sum += when (i) {
ITEM_INDEX_STATUS -> data!!.size
ITEM_INDEX_STATUS -> data?.size ?: 0
else -> itemCounts[i]
}
if (position < sum) {

View File

@ -167,7 +167,7 @@ abstract class ParcelableStatusesFragment : AbsStatusesFragment() {
super.triggerRefresh()
val accountKeys = accountKeys
val statusStartIndex = adapter.statusStartIndex
if (statusStartIndex >= 0) {
if (statusStartIndex >= 0 && adapter.getStatusCount(true) > 0) {
val firstStatus = adapter.getStatus(statusStartIndex, true)
val sinceIds = Array(accountKeys.size) {
return@Array if (firstStatus.account_key == accountKeys[it]) firstStatus.id else null

View File

@ -2018,14 +2018,14 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
if (childCount > 0) {
if (isSmoothScrollbarEnabled) {
var extent = childCount * 100
var view = findViewByPosition(firstPosition)
var view = findViewByPosition(firstPosition) ?: return 0
val top = view.top
var height = view.height
if (height > 0) {
extent += top * 100 / height
}
view = findViewByPosition(lastPosition)
view = findViewByPosition(lastPosition) ?: return 0
val bottom = view.bottom
height = view.height
if (height > 0) {
@ -2047,7 +2047,7 @@ class StatusFragment : BaseFragment(), LoaderCallbacks<SingleResponse<Parcelable
val skippedCount = skippedScrollItemCount
if (firstPosition >= skippedCount && childCount > 0) {
if (isSmoothScrollbarEnabled) {
val view = findViewByPosition(firstPosition)
val view = findViewByPosition(firstPosition) ?: return 0
val top = view.top
val height = view.height
if (height > 0) {