aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorChristian Schneppe <christian@pix-art.de>2018-03-29 22:41:26 +0200
committerChristian Schneppe <christian@pix-art.de>2018-03-29 22:41:26 +0200
commit770d01ae66b6e0643df072a1fd310e3b3e77379a (patch)
treea48fd9a390b22a53b205f431e0926853f7a6d1ff /src
parent2868db3c0f611b0d154206cf7c425effad9e4f50 (diff)
handle view conversation action when ConversationFragment is already open
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