Correctly initialize conversation after message sent.

This commit is contained in:
Moxie Marlinspike 2012-07-31 16:27:58 -07:00
parent 853e12693d
commit bc8f26c591
3 changed files with 17 additions and 45 deletions

View File

@ -1,22 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
* Copyright (C) 2008 Esmertec AG.
* Copyright (C) 2008 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
@ -45,23 +28,6 @@
android:layout_height="match_parent"
android:layout_above="@+id/bottom_container" />
<!-- <ListView -->
<!-- android:id="@+id/conversation" -->
<!-- android:layout_width="fill_parent" -->
<!-- android:layout_height="fill_parent" -->
<!-- android:layout_weight="1.0" -->
<!-- android:listSelector="@drawable/chat_history_selector" -->
<!-- android:drawSelectorOnTop="true" -->
<!-- android:transcriptMode="alwaysScroll" -->
<!-- android:scrollbarAlwaysDrawVerticalTrack="true" -->
<!-- android:scrollbarStyle="insideInset" -->
<!-- android:stackFromBottom="true" -->
<!-- android:visibility="gone" -->
<!-- android:fadingEdge="none" -->
<!-- android:layout_marginBottom="1dip" -->
<!-- android:cacheColorHint="@android:color/white" -->
<!-- android:dividerHeight="0px" android:divider="#ffffffff"/> -->
<ScrollView android:id="@id/bottom_container"
android:layout_width="fill_parent"
android:layout_height="wrap_content"

View File

@ -551,9 +551,12 @@ public class ConversationActivity extends SherlockFragmentActivity {
this.threadId = threadId;
if (this.recipientsPanel.getVisibility() == View.VISIBLE) {
///XXX call down to fragment! ??
ConversationFragment fragment
= (ConversationFragment)this.getSupportFragmentManager()
.findFragmentById(R.id.fragment_content);
fragment.reload(recipients, threadId);
// initializeConversationAdapter();
this.recipientsPanel.setVisibility(View.GONE);
initializeTitleBar();
}

View File

@ -47,8 +47,6 @@ public class ConversationFragment extends SherlockListFragment
initializeResources();
initializeListAdapter();
registerForContextMenu(getListView());
getLoaderManager().initLoader(0, null, this);
}
@Override
@ -75,6 +73,13 @@ public class ConversationFragment extends SherlockListFragment
return false;
}
public void reload(Recipients recipients, long threadId) {
this.recipients = recipients;
this.threadId = threadId;
initializeListAdapter();
}
private void handleCopyMessage(MessageRecord message) {
String body = message.getBody();
if (body == null) return;
@ -141,17 +146,15 @@ public class ConversationFragment extends SherlockListFragment
private void initializeListAdapter() {
if (this.recipients != null && this.threadId != -1) {
this.setListAdapter(new ConversationAdapter(recipients, threadId, getActivity(), masterSecret, new FailedIconClickHandler()));
this.setListAdapter(new ConversationAdapter(recipients, threadId, getActivity(),
masterSecret, new FailedIconClickHandler()));
getLoaderManager().initLoader(0, null, this);
}
}
@Override
public Loader<Cursor> onCreateLoader(int arg0, Bundle arg1) {
if (this.threadId != -1) {
return new ConversationLoader(getActivity(), threadId);
} else {
return null;
}
return new ConversationLoader(getActivity(), threadId);
}
@Override