diff options
Diffstat (limited to 'src/main/java/de/pixart/messenger/ui/ConversationsOverviewFragment.java')
-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 |