Improve scroll to last position behavior.
This commit is contained in:
parent
4325f714b9
commit
1e0e2fadfd
2 changed files with 16 additions and 2 deletions
|
@ -287,7 +287,7 @@ public class ConversationFragment extends LoggingFragment {
|
|||
int firstVisiblePosition = getListLayoutManager().findFirstCompletelyVisibleItemPosition();
|
||||
|
||||
final long lastVisibleMessageTimestamp;
|
||||
if (firstVisiblePosition != 0 && lastVisiblePosition != RecyclerView.NO_POSITION) {
|
||||
if (firstVisiblePosition > 0 && lastVisiblePosition != RecyclerView.NO_POSITION) {
|
||||
MessageRecord message = getListAdapter().getLastVisibleMessageRecord(lastVisiblePosition);
|
||||
|
||||
lastVisibleMessageTimestamp = message != null ? message.getDateReceived() : 0;
|
||||
|
|
|
@ -51,7 +51,6 @@ import org.thoughtcrime.securesms.util.CursorUtil;
|
|||
import org.thoughtcrime.securesms.util.JsonUtils;
|
||||
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
||||
import org.thoughtcrime.securesms.util.Util;
|
||||
import org.whispersystems.libsignal.util.Pair;
|
||||
import org.whispersystems.libsignal.util.guava.Optional;
|
||||
import org.whispersystems.signalservice.api.groupsv2.DecryptedGroupUtil;
|
||||
|
||||
|
@ -193,6 +192,10 @@ public class ThreadDatabase extends Database {
|
|||
contentValues.put(ARCHIVED, 0);
|
||||
}
|
||||
|
||||
if (count != getConversationMessageCount(threadId)) {
|
||||
contentValues.put(LAST_SCROLLED, 0);
|
||||
}
|
||||
|
||||
SQLiteDatabase db = databaseHelper.getWritableDatabase();
|
||||
db.update(TABLE_NAME, contentValues, ID + " = ?", new String[] {threadId + ""});
|
||||
notifyConversationListListeners();
|
||||
|
@ -666,6 +669,17 @@ public class ThreadDatabase extends Database {
|
|||
}
|
||||
}
|
||||
|
||||
public int getConversationMessageCount(long threadId) {
|
||||
SQLiteDatabase db = databaseHelper.getReadableDatabase();
|
||||
|
||||
try (Cursor cursor = db.query(TABLE_NAME, new String[]{MESSAGE_COUNT}, ID_WHERE, new String[]{String.valueOf(threadId)}, null, null, null)) {
|
||||
if (cursor != null && cursor.moveToFirst()) {
|
||||
return CursorUtil.requireInt(cursor, MESSAGE_COUNT);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void deleteConversation(long threadId) {
|
||||
DatabaseFactory.getSmsDatabase(context).deleteThread(threadId);
|
||||
DatabaseFactory.getMmsDatabase(context).deleteThread(threadId);
|
||||
|
|
Loading…
Add table
Reference in a new issue