handle view conversation action when ConversationFragment is already open
This commit is contained in:
parent
6cfc6af886
commit
46feb7bf42
|
@ -168,17 +168,24 @@ public class ConversationActivity extends XmppActivity implements OnConversation
|
|||
final boolean mainNeedsRefresh;
|
||||
if (conversationFragment == null) {
|
||||
mainNeedsRefresh = false;
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -727,6 +727,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);
|
||||
|
|
|
@ -54,13 +54,23 @@ import eu.siacs.conversations.ui.util.PendingItem;
|
|||
|
||||
public class ConversationsOverviewFragment extends XmppFragment implements EnhancedListView.OnDismissCallback {
|
||||
|
||||
private FragmentConversationsOverviewBinding binding;
|
||||
|
||||
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) {
|
||||
|
@ -73,6 +83,12 @@ public class ConversationsOverviewFragment extends XmppFragment implements Enhan
|
|||
}
|
||||
}
|
||||
|
||||
@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");
|
||||
|
@ -191,16 +207,4 @@ public class ConversationsOverviewFragment extends XmppFragment implements Enhan
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue