Commit 27abcc57 authored by Grigory Fedorov's avatar Grigory Fedorov

ChatViewerFragment menu option chat list set the recent chats page now.

parent aaa57fa1
......@@ -49,7 +49,8 @@ import java.util.HashSet;
*/
public class ChatViewer extends ManagedActivity implements OnChatChangedListener,
OnContactChangedListener, OnAccountChangedListener, ViewPager.OnPageChangeListener,
ChatViewerAdapter.FinishUpdateListener, RecentChatFragment.RecentChatFragmentInteractionListener {
ChatViewerAdapter.FinishUpdateListener, RecentChatFragment.RecentChatFragmentInteractionListener,
ChatViewerFragment.ChatViewerFragmentListener {
/**
* Attention request.
......@@ -398,4 +399,9 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
selectPage(true);
}
@Override
public void onRecentChatsCalled() {
viewPager.setCurrentItem(0, true);
}
}
package com.xabber.android.ui;
import android.app.Activity;
import android.app.Fragment;
import android.content.ClipData;
import android.content.ClipboardManager;
......@@ -76,6 +77,8 @@ public class ChatViewerFragment extends Fragment {
private String account;
private String user;
private ChatViewerFragmentListener listener;
public static ChatViewerFragment newInstance(String account, String user) {
ChatViewerFragment fragment = new ChatViewerFragment();
......@@ -245,6 +248,23 @@ public class ChatViewerFragment extends Fragment {
unregisterForContextMenu(listView);
}
@Override
public void onAttach(Activity activity) {
super.onAttach(activity);
try {
listener = (ChatViewerFragmentListener) activity;
} catch (ClassCastException e) {
throw new ClassCastException(activity.toString() + " must implement ChatViewerFragmentListener");
}
}
@Override
public void onDetach() {
listener = null;
super.onDetach();
}
public void saveInputState() {
ChatManager.getInstance().setTyped(account, user, inputView.getText().toString(),
inputView.getSelectionStart(), inputView.getSelectionEnd());
......@@ -341,7 +361,13 @@ public class ChatViewerFragment extends Fragment {
menu.findItem(R.id.action_edit_contact).setVisible(true)
.setIntent(ContactEditor.createIntent(getActivity(), account, user));
}
menu.findItem(R.id.action_chat_list).setIntent(ChatList.createIntent(getActivity()));
menu.findItem(R.id.action_chat_list).setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
listener.onRecentChatsCalled();
return true;
}
});
menu.findItem(R.id.action_chat_settings)
.setIntent(ChatEditor.createIntent(getActivity(), account, user));
......@@ -602,4 +628,8 @@ public class ChatViewerFragment extends Fragment {
public String getUser() {
return user;
}
public interface ChatViewerFragmentListener {
public void onRecentChatsCalled();
}
}
......@@ -68,6 +68,7 @@ public class RecentChatFragment extends ListFragment {
@Override
public void onDetach() {
listener = null;
super.onDetach();
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment