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;
|
final boolean mainNeedsRefresh;
|
||||||
if (conversationFragment == null) {
|
if (conversationFragment == null) {
|
||||||
mainNeedsRefresh = false;
|
mainNeedsRefresh = false;
|
||||||
|
Fragment mainFragment = getFragmentManager().findFragmentById(R.id.main_fragment);
|
||||||
|
if (mainFragment != null && mainFragment instanceof ConversationFragment) {
|
||||||
|
conversationFragment = (ConversationFragment) mainFragment;
|
||||||
|
} else {
|
||||||
conversationFragment = new ConversationFragment();
|
conversationFragment = new ConversationFragment();
|
||||||
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
|
||||||
fragmentTransaction.replace(R.id.main_fragment, conversationFragment);
|
fragmentTransaction.replace(R.id.main_fragment, conversationFragment);
|
||||||
fragmentTransaction.addToBackStack(null);
|
fragmentTransaction.addToBackStack(null);
|
||||||
fragmentTransaction.commit();
|
fragmentTransaction.commit();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
mainNeedsRefresh = true;
|
mainNeedsRefresh = true;
|
||||||
}
|
}
|
||||||
conversationFragment.reInit(conversation);
|
conversationFragment.reInit(conversation);
|
||||||
if (mainNeedsRefresh) {
|
if (mainNeedsRefresh) {
|
||||||
refreshFragment(R.id.main_fragment);
|
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
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
|
@ -54,13 +54,23 @@ import eu.siacs.conversations.ui.util.PendingItem;
|
||||||
|
|
||||||
public class ConversationsOverviewFragment extends XmppFragment implements EnhancedListView.OnDismissCallback {
|
public class ConversationsOverviewFragment extends XmppFragment implements EnhancedListView.OnDismissCallback {
|
||||||
|
|
||||||
private FragmentConversationsOverviewBinding binding;
|
|
||||||
|
|
||||||
private final List<Conversation> conversations = new ArrayList<>();
|
private final List<Conversation> conversations = new ArrayList<>();
|
||||||
|
private final PendingItem<Conversation> swipedConversation = new PendingItem<>();
|
||||||
|
private FragmentConversationsOverviewBinding binding;
|
||||||
private ConversationAdapter conversationsAdapter;
|
private ConversationAdapter conversationsAdapter;
|
||||||
private XmppActivity activity;
|
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
|
@Override
|
||||||
public void onAttach(Activity activity) {
|
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
|
@Override
|
||||||
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
public View onCreateView(final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
Log.d(Config.LOGTAG, "onCreateView");
|
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 a new issue