diff options
author | Christian Schneppe <christian@pix-art.de> | 2018-03-29 22:41:26 +0200 |
---|---|---|
committer | Christian Schneppe <christian@pix-art.de> | 2018-03-29 22:41:26 +0200 |
commit | 770d01ae66b6e0643df072a1fd310e3b3e77379a (patch) | |
tree | a48fd9a390b22a53b205f431e0926853f7a6d1ff /src/main/java/de/pixart/messenger/ui/ConversationsOverviewFragment.java | |
parent | 2868db3c0f611b0d154206cf7c425effad9e4f50 (diff) |
handle view conversation action when ConversationFragment is already open
Diffstat (limited to '')
-rw-r--r-- | src/main/java/de/pixart/messenger/ui/ConversationsOverviewFragment.java | 31 |
1 files changed, 18 insertions, 13 deletions
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 |