From 216446c55bf2e0ba055b8d1d4622fa04b80ceece Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Wed, 26 Mar 2014 15:11:56 -0700 Subject: [PATCH] scroll to the new message in conversation // FREEBIE --- .../thoughtcrime/securesms/ConversationActivity.java | 7 +++---- .../thoughtcrime/securesms/ConversationFragment.java | 11 +++++++++++ 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ConversationActivity.java b/src/org/thoughtcrime/securesms/ConversationActivity.java index cbe0a701b6..6b9477d684 100644 --- a/src/org/thoughtcrime/securesms/ConversationActivity.java +++ b/src/org/thoughtcrime/securesms/ConversationActivity.java @@ -1060,17 +1060,16 @@ public class ConversationActivity extends PassphraseRequiredSherlockFragmentActi this.recipients = recipients; this.threadId = threadId; + ConversationFragment fragment = (ConversationFragment) getSupportFragmentManager() + .findFragmentById(R.id.fragment_content); if (refreshFragment) { - ConversationFragment fragment - = (ConversationFragment)this.getSupportFragmentManager() - .findFragmentById(R.id.fragment_content); - fragment.reload(recipients, threadId); this.recipientsPanel.setVisibility(View.GONE); initializeTitleBar(); initializeSecurity(); } + fragment.scrollToBottom(); } private void sendMessage(boolean forcePlaintext) { diff --git a/src/org/thoughtcrime/securesms/ConversationFragment.java b/src/org/thoughtcrime/securesms/ConversationFragment.java index d5017a5dad..c377df05a3 100644 --- a/src/org/thoughtcrime/securesms/ConversationFragment.java +++ b/src/org/thoughtcrime/securesms/ConversationFragment.java @@ -17,6 +17,7 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.CursorAdapter; +import android.widget.ListView; import com.actionbarsherlock.app.SherlockListFragment; @@ -104,6 +105,16 @@ public class ConversationFragment extends SherlockListFragment initializeListAdapter(); } + public void scrollToBottom() { + final ListView list = getListView(); + list.post(new Runnable() { + @Override + public void run() { + list.setSelection(getListAdapter().getCount() - 1); + } + }); + } + private void handleCopyMessage(MessageRecord message) { String body = message.getDisplayBody().toString(); if (body == null) return;