diff --git a/twidere/src/.google.commit-id b/twidere/src/.google.commit-id index a34a36a45..f6d0d42fe 100644 --- a/twidere/src/.google.commit-id +++ b/twidere/src/.google.commit-id @@ -1 +1 @@ -4204ab37b28019cfa0f51195034d1d0b5f2d31df +9ae153916806db7a16fffd9b76ef03d7ff4077a8 diff --git a/twidere/src/main/java/org/mariotaku/twidere/model/timeline/UserTimelineFilter.java b/twidere/src/main/java/org/mariotaku/twidere/model/timeline/UserTimelineFilter.java index 98f9eaa8b..38db346ba 100644 --- a/twidere/src/main/java/org/mariotaku/twidere/model/timeline/UserTimelineFilter.java +++ b/twidere/src/main/java/org/mariotaku/twidere/model/timeline/UserTimelineFilter.java @@ -60,6 +60,8 @@ public class UserTimelineFilter implements TimelineFilter, Parcelable { return context.getString(R.string.label_statuses_retweets_replies); } else if (includeReplies) { return context.getString(R.string.label_statuses_replies); + } else if (includeRetweets) { + return context.getString(R.string.label_statuses_retweets); } return context.getString(R.string.label_statuses); } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ParcelableActivitiesAdapter.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ParcelableActivitiesAdapter.kt index 477003e33..9505826ac 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ParcelableActivitiesAdapter.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ParcelableActivitiesAdapter.kt @@ -123,19 +123,27 @@ class ParcelableActivitiesAdapter( } override fun getItemId(position: Int): Long { - val dataPosition = position - activityStartIndex - if (data is ObjectCursor) { - val cursor = (data as ObjectCursor).cursor - if (!cursor.moveToPosition(dataPosition)) return -1 - val indices = (data as ObjectCursor).indices - val accountKey = UserKey.valueOf(cursor.getString(indices[Activities.ACCOUNT_KEY])) - val timestamp = cursor.getLong(indices[Activities.TIMESTAMP]) - val maxPosition = cursor.getLong(indices[Activities.MAX_SORT_POSITION]) - val minPosition = cursor.getLong(indices[Activities.MIN_SORT_POSITION]) - return ParcelableActivity.calculateHashCode(accountKey, timestamp, maxPosition, - minPosition).toLong() + val countIndex = itemCounts.getItemCountIndex(position) + when (countIndex) { + ITEM_INDEX_ACTIVITY -> { + val dataPosition = position - activityStartIndex + if (data is ObjectCursor) { + val cursor = (data as ObjectCursor).cursor + if (!cursor.moveToPosition(dataPosition)) return -1 + val indices = (data as ObjectCursor).indices + val accountKey = UserKey.valueOf(cursor.getString(indices[Activities.ACCOUNT_KEY])) + val timestamp = cursor.getLong(indices[Activities.TIMESTAMP]) + val maxPosition = cursor.getLong(indices[Activities.MAX_SORT_POSITION]) + val minPosition = cursor.getLong(indices[Activities.MIN_SORT_POSITION]) + return ParcelableActivity.calculateHashCode(accountKey, timestamp, maxPosition, + minPosition).toLong() + } + return (countIndex.toLong() shl 32) or getActivity(position, false).hashCode().toLong() + } + else -> { + return (countIndex.toLong() shl 32) or getItemViewType(position).toLong() + } } - return getActivity(position, false).hashCode().toLong() } fun getTimestamp(adapterPosition: Int, raw: Boolean = false): Long { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ParcelableStatusesAdapter.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ParcelableStatusesAdapter.kt index 4e246dfe1..e1e43b7e4 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ParcelableStatusesAdapter.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/ParcelableStatusesAdapter.kt @@ -213,17 +213,16 @@ abstract class ParcelableStatusesAdapter( when (countIndex) { ITEM_INDEX_PINNED_STATUS -> { val status = pinnedStatuses!![position - getItemStartPosition(ITEM_INDEX_PINNED_STATUS)] - val mask = ITEM_INDEX_PINNED_STATUS.toLong() shl 32 - return mask + status.hashCode() + return (countIndex.toLong() shl 32) or status.hashCode().toLong() } - ITEM_INDEX_STATUS -> return getFieldValue(position, { cursor, indices -> + ITEM_INDEX_STATUS -> return (countIndex.toLong() shl 32) or getFieldValue(position, { cursor, indices -> val accountKey = UserKey.valueOf(cursor.getString(indices[Statuses.ACCOUNT_KEY])) val id = cursor.getString(indices[Statuses.STATUS_ID]) - return@getFieldValue ParcelableStatus.calculateHashCode(accountKey, id).toLong() + return@getFieldValue ParcelableStatus.calculateHashCode(accountKey, id) }, { status -> - return@getFieldValue status.hashCode().toLong() - }, -1L) - else -> return (countIndex.toLong() shl 32) + position + return@getFieldValue status.hashCode() + }, -1).toLong() + else -> return (countIndex.toLong() shl 32) or position.toLong() } } diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/SelectableUsersAdapter.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/SelectableUsersAdapter.kt index dd36b8938..07ad5f72e 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/SelectableUsersAdapter.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/adapter/SelectableUsersAdapter.kt @@ -90,8 +90,8 @@ class SelectableUsersAdapter( override fun getItemViewType(position: Int): Int { val countIndex = itemCounts.getItemCountIndex(position) when (countIndex) { - 0, 2 -> ILoadMoreSupportAdapter.ITEM_VIEW_TYPE_LOAD_INDICATOR - 1 -> return ITEM_VIEW_TYPE_USER + ITEM_TYPE_START_INDICATOR, ITEM_TYPE_END_INDICATOR -> ILoadMoreSupportAdapter.ITEM_VIEW_TYPE_LOAD_INDICATOR + ITEM_TYPE_USER -> return ITEM_VIEW_TYPE_USER } throw UnsupportedOperationException("Unsupported countIndex $countIndex, position $position") } @@ -99,8 +99,8 @@ class SelectableUsersAdapter( override fun getItemId(position: Int): Long { val countIndex = itemCounts.getItemCountIndex(position) when (countIndex) { - 0, 2 -> return Integer.MAX_VALUE.toLong() + countIndex - 1 -> return getUser(position)!!.hashCode().toLong() + ITEM_TYPE_START_INDICATOR, ITEM_TYPE_END_INDICATOR -> return (countIndex.toLong() shl 32) + ITEM_TYPE_USER -> return (countIndex.toLong() shl 32) or getUser(position)!!.hashCode().toLong() } throw UnsupportedOperationException("Unsupported countIndex $countIndex, position $position") } @@ -111,9 +111,9 @@ class SelectableUsersAdapter( private fun updateItemCounts() { val position = loadMoreIndicatorPosition - itemCounts[0] = if (position and ILoadMoreSupportAdapter.START != 0L) 1 else 0 - itemCounts[1] = userCount - itemCounts[2] = if (position and ILoadMoreSupportAdapter.END != 0L) 1 else 0 + itemCounts[ITEM_TYPE_START_INDICATOR] = if (position and ILoadMoreSupportAdapter.START != 0L) 1 else 0 + itemCounts[ITEM_TYPE_USER] = userCount + itemCounts[ITEM_TYPE_END_INDICATOR] = if (position and ILoadMoreSupportAdapter.END != 0L) 1 else 0 } fun getUser(position: Int): ParcelableUser? { @@ -227,4 +227,10 @@ class SelectableUsersAdapter( fun clearSelection() { checkedState.clear() } + + companion object { + const val ITEM_TYPE_START_INDICATOR = 0 + const val ITEM_TYPE_USER = 1 + const val ITEM_TYPE_END_INDICATOR = 2 + } } \ No newline at end of file diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/StatusFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/StatusFragment.kt index b860169c1..7cead682d 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/StatusFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/StatusFragment.kt @@ -1822,12 +1822,13 @@ class StatusFragment : BaseFragment(), LoaderCallbacks { - return getStatus(position).hashCode().toLong() + return (countIndex.toLong() shl 32) or getStatus(position).hashCode().toLong() } } - return getItemType(position).toLong() + return (countIndex.toLong() shl 32) or getItemType(position).toLong() } override fun getItemCount(): Int { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessageConversationInfoFragment.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessageConversationInfoFragment.kt index 1d569baa9..7fc9f8ee6 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessageConversationInfoFragment.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/fragment/message/MessageConversationInfoFragment.kt @@ -31,7 +31,6 @@ import android.os.Bundle import android.support.v4.app.DialogFragment import android.support.v4.app.FragmentActivity import android.support.v4.app.LoaderManager -import android.support.v4.content.AsyncTaskLoader import android.support.v4.content.FixedAsyncTaskLoader import android.support.v4.content.Loader import android.support.v7.app.AlertDialog @@ -582,13 +581,14 @@ class MessageConversationInfoFragment : BaseFragment(), IToolBarSupportFragment, } override fun getItemId(position: Int): Long { - when (itemCounts.getItemCountIndex(position)) { + val countIndex = itemCounts.getItemCountIndex(position) + when (countIndex) { ITEM_INDEX_ITEM -> { val user = getUser(position)!! - return user.hashCode().toLong() + return (countIndex.toLong() shl 32) or user.hashCode().toLong() } else -> { - return Integer.MAX_VALUE.toLong() + getItemViewType(position) + return (countIndex.toLong() shl 32) or getItemViewType(position).toLong() } } }