@Override public void onResume() { super.onResume(); eventBus.register(this); Optional<Chat> chat = userProfile.getChat(chatId); if (chat.isPresent() && !chat.get().messages.isEmpty()) { setData(chat.get()); } }
/** ************************ ListFragment Overrides * ************************ */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Bundle arguments = getArguments(); if (arguments.containsKey(ARG_ITEM_ID)) { chatId = (String) arguments.get(ARG_ITEM_ID); Optional<Chat> chat = userProfile.getChat(chatId); if (chat.isPresent() && !chat.get().messages.isEmpty()) { messageAdapter = new MessageListArrayAdapter(getActivity(), new ArrayList<>(chat.get().messages)); } else { messageAdapter = new MessageListArrayAdapter(getActivity()); worker.getChatMessages(chatId); } setListAdapter(messageAdapter); } }