aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationActivity.java17
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationFragment.java6
-rw-r--r--src/main/java/de/pixart/messenger/ui/ConversationsOverviewFragment.java31
3 files changed, 36 insertions, 18 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
index c3fdfefa2..2103b63e5 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationActivity.java
@@ -173,17 +173,24 @@ public class ConversationActivity extends XmppActivity implements OnConversation
final boolean mainNeedsRefresh;
if (conversationFragment == null) {
mainNeedsRefresh = false;
- conversationFragment = new ConversationFragment();
- FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
- fragmentTransaction.replace(R.id.main_fragment, conversationFragment);
- fragmentTransaction.addToBackStack(null);
- fragmentTransaction.commit();
+ Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
+ if (mainFragment != null && mainFragment instanceof ConversationFragment) {
+ conversationFragment = (ConversationFragment) mainFragment;
+ } else {
+ conversationFragment = new ConversationFragment();
+ FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
+ fragmentTransaction.replace(R.id.main_fragment, conversationFragment);
+ fragmentTransaction.addToBackStack(null);
+ fragmentTransaction.commit();
+ }
} else {
mainNeedsRefresh = true;
}
conversationFragment.reInit(conversation);
if (mainNeedsRefresh) {
refreshFragment(R.id.main_fragment);
+ } else {
+ invalidateActionBarTitle();
}
}
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
index f5fc419a1..4e898b66d 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationFragment.java
@@ -977,6 +977,12 @@ public class ConversationFragment extends XmppFragment implements EditMessage.Ke
}
@Override
+ public void onDetach() {
+ super.onDetach();
+ this.activity = null;
+ }
+
+ @Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setHasOptionsMenu(true);
diff --git a/src/main/java/de/pixart/messenger/ui/ConversationsOverviewFragment.java b/src/main/java/de/pixart/messenger/ui/ConversationsOverviewFragment.java
index 173d09cc7..8c77b7c51 100644
--- a/src/main/java/de/pixart/messenger/ui/ConversationsOverviewFragment.java
+++ b/src/main/java/de/pixart/messenger/ui/ConversationsOverviewFragment.java
@@ -52,11 +52,22 @@ import de.pixart.messenger.ui.util.PendingItem;
public class ConversationsOverviewFragment extends XmppFragment {
private final List<Conversation> conversations = new ArrayList<>();
+ private final PendingItem<Conversation> swipedConversation = new PendingItem<>();
private FragmentConversationsOverviewBinding binding;
private ConversationAdapter conversationsAdapter;
private XmppActivity activity;
- private final PendingItem<Conversation> swipedConversation = new PendingItem<>();
+ public static Conversation getSuggestion(Activity activity) {
+ Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment);
+ if (fragment != null && fragment instanceof ConversationsOverviewFragment) {
+ List<Conversation> conversations = ((ConversationsOverviewFragment) fragment).conversations;
+ if (conversations.size() > 0) {
+ return conversations.get(0);
+ }
+ }
+ return null;
+
+ }
@Override
public void onAttach(Activity activity) {
@@ -70,6 +81,12 @@ public class ConversationsOverviewFragment extends XmppFragment {
}
@Override
+ public void onDetach() {
+ super.onDetach();
+ this.activity = null;
+ }
+
+ @Override
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Log.d(Config.LOGTAG, "onCreateView");
this.binding = DataBindingUtil.inflate(inflater, R.layout.fragment_conversations_overview, container, false);
@@ -115,16 +132,4 @@ public class ConversationsOverviewFragment extends XmppFragment {
this.activity.xmppConnectionService.populateWithOrderedConversations(this.conversations);
this.conversationsAdapter.notifyDataSetChanged();
}
-
- public static Conversation getSuggestion(Activity activity) {
- Fragment fragment = activity.getFragmentManager().findFragmentById(R.id.main_fragment);
- if (fragment != null && fragment instanceof ConversationsOverviewFragment) {
- List<Conversation> conversations = ((ConversationsOverviewFragment) fragment).conversations;
- if (conversations.size() > 0) {
- return conversations.get(0);
- }
- }
- return null;
-
- }
} \ No newline at end of file