From bbdaf5b0bd7c42729aeba12f3b4ea4cabc794c4f Mon Sep 17 00:00:00 2001 From: Daniel Gultsch Date: Sun, 2 Feb 2014 16:33:34 +0100 Subject: will update messages on conversation update as well --- src/de/gultsch/chat/ui/ConversationActivity.java | 4 ++++ src/de/gultsch/chat/ui/ConversationFragment.java | 14 +++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) (limited to 'src/de/gultsch/chat/ui') diff --git a/src/de/gultsch/chat/ui/ConversationActivity.java b/src/de/gultsch/chat/ui/ConversationActivity.java index b06fa21d1..8c3772416 100644 --- a/src/de/gultsch/chat/ui/ConversationActivity.java +++ b/src/de/gultsch/chat/ui/ConversationActivity.java @@ -73,6 +73,10 @@ public class ConversationActivity extends XmppActivity { finish(); } } + ConversationFragment selectedFragment = (ConversationFragment) getFragmentManager().findFragmentByTag("conversation"); + if (selectedFragment!=null) { + selectedFragment.updateMessages(); + } } }); } diff --git a/src/de/gultsch/chat/ui/ConversationFragment.java b/src/de/gultsch/chat/ui/ConversationFragment.java index b8edcbaf5..d6398c823 100644 --- a/src/de/gultsch/chat/ui/ConversationFragment.java +++ b/src/de/gultsch/chat/ui/ConversationFragment.java @@ -31,7 +31,8 @@ public class ConversationFragment extends Fragment { protected ListView messagesView; protected LayoutInflater inflater; protected List messageList = new ArrayList(); - + protected ArrayAdapter messageListAdapter; + @Override public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -76,7 +77,7 @@ public class ConversationFragment extends Fragment { mProfileCursor.moveToFirst(); final Uri profilePicture = Uri.parse(mProfileCursor.getString(1)); - messagesView.setAdapter(new ArrayAdapter(this.getActivity() + messageListAdapter = new ArrayAdapter(this.getActivity() .getApplicationContext(), R.layout.message_sent, this.messageList) { private static final int SENT = 0; @@ -134,7 +135,8 @@ public class ConversationFragment extends Fragment { } return view; } - }); + }; + messagesView.setAdapter(messageListAdapter); return view; } @@ -180,4 +182,10 @@ public class ConversationFragment extends Fragment { activity.invalidateOptionsMenu(); } } + + public void updateMessages() { + this.messageList.clear(); + this.messageList.addAll(this.conversation.getMessages()); + this.messageListAdapter.notifyDataSetChanged(); + } } -- cgit v1.2.3