Commit cbfed8d2 authored by Grigory Fedorov's avatar Grigory Fedorov

ChatViewer: options menu moved from ChatViewerFragment.

Light refactoring.
parent 78d01152
......@@ -646,9 +646,8 @@ public abstract class AbstractChat extends BaseEntity {
int count = PRELOADED_MESSAGES
+ NotificationManager.getInstance()
.getNotificationMessageCount(account, user);
Iterator<MessageItem> iterator = messages.iterator();
while (iterator.hasNext())
if (iterator.next().isIncoming()) {
for (MessageItem message : messages)
if (message.isIncoming()) {
count -= 1;
if (count <= 0)
return 0;
......
......@@ -22,6 +22,8 @@ import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.support.v7.app.ActionBar;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
......@@ -31,25 +33,32 @@ import android.widget.ImageView;
import com.xabber.android.data.ActivityManager;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.account.AccountManager;
import com.xabber.android.data.account.OnAccountChangedListener;
import com.xabber.android.data.entity.BaseEntity;
import com.xabber.android.data.extension.archive.MessageArchiveManager;
import com.xabber.android.data.extension.attention.AttentionManager;
import com.xabber.android.data.extension.muc.MUCManager;
import com.xabber.android.data.extension.muc.RoomChat;
import com.xabber.android.data.extension.muc.RoomState;
import com.xabber.android.data.extension.otr.OTRManager;
import com.xabber.android.data.extension.otr.SecurityLevel;
import com.xabber.android.data.intent.EntityIntentBuilder;
import com.xabber.android.data.message.AbstractChat;
import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.message.OnChatChangedListener;
import com.xabber.android.data.message.RegularChat;
import com.xabber.android.data.notification.NotificationManager;
import com.xabber.android.data.roster.AbstractContact;
import com.xabber.android.data.roster.OnContactChangedListener;
import com.xabber.android.data.roster.RosterManager;
import com.xabber.android.ui.adapter.ChatViewerAdapter;
import com.xabber.android.ui.dialog.ChatExportDialogFragment;
import com.xabber.android.ui.helper.ContactTitleInflater;
import com.xabber.android.ui.helper.ManagedActivity;
import com.xabber.android.ui.preferences.ChatEditor;
import com.xabber.androiddev.R;
import java.util.Collection;
......@@ -63,8 +72,7 @@ import java.util.HashSet;
*/
public class ChatViewer extends ManagedActivity implements OnChatChangedListener,
OnContactChangedListener, OnAccountChangedListener, ViewPager.OnPageChangeListener,
ChatViewerAdapter.FinishUpdateListener, RecentChatFragment.RecentChatFragmentInteractionListener,
ChatViewerFragment.ChatViewerFragmentListener {
ChatViewerAdapter.FinishUpdateListener, RecentChatFragment.RecentChatFragmentInteractionListener {
/**
* Attention request.
......@@ -75,6 +83,8 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
private static final String SAVED_USER = "com.xabber.android.ui.ChatViewer.SAVED_USER";
private static final String SAVED_EXIT_ON_SEND = "com.xabber.android.ui.ChatViewer.EXIT_ON_SEND";
private static final int MINIMUM_MESSAGES_TO_LOAD = 10;
private boolean exitOnSend;
private String extraText = null;
......@@ -96,6 +106,9 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
private Animation shakeAnimation;
private boolean isChatSelected;
private Menu menu = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
......@@ -142,19 +155,24 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
actionBarView = LayoutInflater.from(this).inflate(R.layout.chat_viewer_action_bar, null);
actionBarView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
scrollChat();
}
});
actionBar.setCustomView(actionBarView, new ActionBar.LayoutParams(
ActionBar.LayoutParams.MATCH_PARENT, ActionBar.LayoutParams.MATCH_PARENT));
setContentView(R.layout.activity_chat_viewer);
if (account != null && user != null) {
chatViewerAdapter = new ChatViewerAdapter(getFragmentManager(),
account, user, this);
chatViewerAdapter = new ChatViewerAdapter(getFragmentManager(), account, user, this);
isChatSelected = true;
} else {
chatViewerAdapter = new ChatViewerAdapter(getFragmentManager(), this);
isChatSelected = false;
}
viewPager = (ViewPager) findViewById(R.id.pager);
......@@ -164,6 +182,92 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
selectPage(account, user, false);
}
private void scrollChat() {
if (!isChatSelected) {
return;
}
for (ChatViewerFragment chat : registeredChats) {
if (chat.isEqual(actionWithAccount, actionWithUser)) {
chat.scrollChat();
}
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
this.menu = menu;
createOptionsMenu();
return true;
}
private void createOptionsMenu() {
if (menu == null) {
return;
}
menu.clear();
if (!isChatSelected) {
return;
}
getMenuInflater().inflate(R.menu.chat, menu);
final String account = actionWithAccount;
final String user = actionWithUser;
AbstractChat abstractChat = MessageManager.getInstance().getChat(account, user);
if (abstractChat instanceof RoomChat) {
RoomState chatState = ((RoomChat) abstractChat).getState();
if (chatState == RoomState.available) {
menu.findItem(R.id.action_list_of_occupants).setVisible(true);
}
if (chatState == RoomState.unavailable) {
menu.findItem(R.id.action_join_conference).setVisible(true);
menu.findItem(R.id.action_close_chat).setVisible(true);
} else {
menu.findItem(R.id.action_invite_to_chat).setVisible(true);
if (chatState == RoomState.error) {
menu.findItem(R.id.action_authorization_settings).setVisible(true);
} else {
menu.findItem(R.id.action_leave_conference).setVisible(true);
}
}
}
if (abstractChat instanceof RegularChat) {
menu.findItem(R.id.action_edit_contact).setVisible(true);
SecurityLevel securityLevel = OTRManager.getInstance().getSecurityLevel(account, user);
if (securityLevel == SecurityLevel.plain) {
menu.findItem(R.id.action_start_encryption).setVisible(true)
.setEnabled(SettingsManager.securityOtrMode() != SettingsManager.SecurityOtrMode.disabled);
} else {
menu.findItem(R.id.action_restart_encryption).setVisible(true);
}
boolean isEncrypted = securityLevel != SecurityLevel.plain;
menu.findItem(R.id.action_stop_encryption).setEnabled(isEncrypted);
menu.findItem(R.id.action_verify_with_fingerprint).setEnabled(isEncrypted);
menu.findItem(R.id.action_verify_with_question).setEnabled(isEncrypted);
menu.findItem(R.id.action_verify_with_shared_secret).setEnabled(isEncrypted);
}
}
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
super.onPrepareOptionsMenu(menu);
createOptionsMenu();
return true;
}
@Override
protected void onResume() {
super.onResume();
......@@ -220,6 +324,163 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
selectPage(account, user, false);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
final String account = actionWithAccount;
final String user = actionWithUser;
switch (item.getItemId()) {
case R.id.action_edit_contact:
startActivity(ContactEditor.createIntent(this, account, user));
return true;
case R.id.action_chat_list:
selectRecentChatsPage();
return true;
case R.id.action_chat_settings:
startActivity(ChatEditor.createIntent(this, account, user));
return true;
case R.id.action_show_history:
showHistory(account, user);
return true;
case R.id.action_authorization_settings:
startActivity(MUCEditor.createIntent(this, account, user));
return true;
case R.id.action_close_chat:
closeChat(account, user);
return true;
case R.id.action_clear_text:
cleatInputText(account, user);
return true;
case R.id.action_clear_history:
clearHistory(account, user);
return true;
case R.id.action_export_chat:
ChatExportDialogFragment.newInstance(account, user).show(getFragmentManager(), "CHAT_EXPORT");
return true;
case R.id.action_call_attention:
callAttention(account, user);
return true;
/* conferences */
case R.id.action_join_conference:
MUCManager.getInstance().joinRoom(account, user, true);
return true;
case R.id.action_invite_to_chat:
startActivity(ContactList.createRoomInviteIntent(this, account, user));
return true;
case R.id.action_leave_conference:
leaveConference(account, user);
return true;
case R.id.action_list_of_occupants:
startActivity(OccupantList.createIntent(this, account, user));
return true;
/* encryption */
case R.id.action_start_encryption:
startEncryption(account, user);
return true;
case R.id.action_restart_encryption:
restartEncryption(account, user);
return true;
case R.id.action_stop_encryption:
stopEncryption(account, user);
return true;
case R.id.action_verify_with_fingerprint:
startActivity(FingerprintViewer.createIntent(this, account, user));
return true;
case R.id.action_verify_with_question:
startActivity(QuestionViewer.createIntent(this, account, user, true, false, null));
return true;
case R.id.action_verify_with_shared_secret:
startActivity(QuestionViewer.createIntent(this, account, user, false, false, null));
return true;
default:
return super.onOptionsItemSelected(item);
}
}
private void cleatInputText(String account, String user) {
for (ChatViewerFragment chat : registeredChats) {
if (chat.isEqual(account, user)) {
chat.clearInputView();
}
}
}
private void stopEncryption(String account, String user) {
try {
OTRManager.getInstance().endSession(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
}
private void restartEncryption(String account, String user) {
try {
OTRManager.getInstance().refreshSession(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
}
private void startEncryption(String account, String user) {
try {
OTRManager.getInstance().startSession(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
}
private void callAttention(String account, String user) {
try {
AttentionManager.getInstance().sendAttention(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
}
private void clearHistory(String account, String user) {
MessageManager.getInstance().clearHistory(account, user);
updateRegisteredChats();
}
private void closeChat(String account, String user) {
MessageManager.getInstance().closeChat(account, user);
NotificationManager.getInstance().removeMessageNotification(account, user);
close();
}
private void leaveConference(String account, String user) {
MUCManager.getInstance().leaveRoom(account, user);
closeChat(account, user);
}
private void showHistory(String account, String user) {
MessageManager.getInstance().requestToLoadLocalHistory(account, user);
MessageArchiveManager.getInstance().requestHistory(account, user, MINIMUM_MESSAGES_TO_LOAD, 0);
updateRegisteredChats();
}
private void selectPage(String account, String user, boolean smoothScroll) {
int position = chatViewerAdapter.getPageNumber(account, user);
selectPage(position, smoothScroll);
......@@ -375,7 +636,19 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
public void onPageSelected(int position) {
AbstractChat selectedChat = chatViewerAdapter.getChatByPageNumber(position);
if (selectedChat == null) {
isChatSelected = selectedChat != null;
if (isChatSelected) {
actionWithAccount = selectedChat.getAccount();
actionWithUser = selectedChat.getUser();
} else {
actionWithAccount = null;
actionWithUser = null;
}
createOptionsMenu();
if (!isChatSelected) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
window.setStatusBarColor(defaultStatusBarColor);
}
......@@ -387,21 +660,15 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
return;
}
String account = selectedChat.getAccount();
String user = selectedChat.getUser();
updateActionBar(account, user);
updateActionBar(actionWithAccount, actionWithUser);
MessageManager.getInstance().setVisibleChat(account, user);
MessageManager.getInstance().setVisibleChat(actionWithAccount, actionWithUser);
MessageArchiveManager.getInstance().requestHistory(
account, user, 0,
MessageManager.getInstance().getChat(account, user).getRequiredMessageCount());
actionWithAccount, actionWithUser, 0,
MessageManager.getInstance().getChat(actionWithAccount, actionWithUser).getRequiredMessageCount());
NotificationManager.getInstance().removeMessageNotification(account, user);
actionWithAccount = account;
actionWithUser = user;
NotificationManager.getInstance().removeMessageNotification(actionWithAccount, actionWithUser);
}
private void updateActionBar(String account, String user) {
......@@ -497,8 +764,7 @@ public class ChatViewer extends ManagedActivity implements OnChatChangedListener
selectPage(chat.getAccount(), chat.getUser(), true);
}
@Override
public void onRecentChatsCalled() {
public void selectRecentChatsPage() {
viewPager.setCurrentItem(chatViewerAdapter.getRecentChatsPosition(), true);
}
......
package com.xabber.android.ui;
import android.app.Activity;
import android.app.Fragment;
import android.content.ClipData;
import android.content.ClipboardManager;
......@@ -11,7 +10,6 @@ import android.text.TextWatcher;
import android.view.ContextMenu;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
......@@ -25,26 +23,12 @@ import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import com.xabber.android.data.Application;
import com.xabber.android.data.NetworkException;
import com.xabber.android.data.SettingsManager;
import com.xabber.android.data.extension.archive.MessageArchiveManager;
import com.xabber.android.data.extension.attention.AttentionManager;
import com.xabber.android.data.extension.cs.ChatStateManager;
import com.xabber.android.data.extension.muc.MUCManager;
import com.xabber.android.data.extension.muc.RoomChat;
import com.xabber.android.data.extension.muc.RoomState;
import com.xabber.android.data.extension.otr.OTRManager;
import com.xabber.android.data.extension.otr.SecurityLevel;
import com.xabber.android.data.message.AbstractChat;
import com.xabber.android.data.message.MessageItem;
import com.xabber.android.data.message.MessageManager;
import com.xabber.android.data.message.RegularChat;
import com.xabber.android.data.message.chat.ChatManager;
import com.xabber.android.data.notification.NotificationManager;
import com.xabber.android.ui.adapter.ChatMessageAdapter;
import com.xabber.android.ui.dialog.ChatExportDialogFragment;
import com.xabber.android.ui.preferences.ChatEditor;
import com.xabber.androiddev.R;
public class ChatViewerFragment extends Fragment {
......@@ -52,8 +36,6 @@ public class ChatViewerFragment extends Fragment {
public static final String ARGUMENT_ACCOUNT = "ARGUMENT_ACCOUNT";
public static final String ARGUMENT_USER = "ARGUMENT_USER";
private static final int MINIMUM_MESSAGES_TO_LOAD = 10;
private TextView pageView;
private EditText inputView;
private ListView listView;
......@@ -64,8 +46,6 @@ 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();
......@@ -119,7 +99,6 @@ public class ChatViewerFragment extends Fragment {
listView.setAdapter(chatMessageAdapter);
pageView = (TextView) view.findViewById(R.id.chat_page);
// titleView = view.findViewById(R.id.title);
inputView = (EditText) view.findViewById(R.id.chat_input);
view.findViewById(R.id.chat_send).setOnClickListener(
......@@ -131,16 +110,7 @@ public class ChatViewerFragment extends Fragment {
}
});
// titleView.setOnClickListener(new View.OnClickListener() {
//
// @Override
// public void onClick(View v) {
// int size = listView.getCount();
// if (size > 0)
// listView.setSelection(size - 1);
// }
//
// });
inputView.setOnKeyListener(new View.OnKeyListener() {
@Override
......@@ -189,8 +159,6 @@ public class ChatViewerFragment extends Fragment {
});
setHasOptionsMenu(true);
updateView();
chatMessageAdapter.onChange();
......@@ -231,23 +199,6 @@ 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());
......@@ -295,211 +246,6 @@ public class ChatViewerFragment extends Fragment {
chatMessageAdapter.onChange();
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
final String account = chatMessageAdapter.getAccount();
final String user = chatMessageAdapter.getUser();
AbstractChat abstractChat = MessageManager.getInstance().getChat(account, user);
inflater.inflate(R.menu.chat, menu);
if (abstractChat != null && abstractChat instanceof RoomChat) {
if (((RoomChat) abstractChat).getState() == RoomState.unavailable) {
MenuItem item = menu.findItem(R.id.action_join_conference);
item.setVisible(true);
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
MUCManager.getInstance().joinRoom(account, user, true);
return true;
}
});
} else {
menu.findItem(R.id.action_invite_to_chat).setVisible(true)
.setIntent(ContactList.createRoomInviteIntent(getActivity(), account, user));
}
} else {
menu.findItem(R.id.action_edit_contact).setVisible(true)
.setIntent(ContactEditor.createIntent(getActivity(), account, user));
}
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));
menu.findItem(R.id.action_show_history).setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
MessageManager.getInstance().requestToLoadLocalHistory(account, user);
MessageArchiveManager.getInstance()
.requestHistory(account, user, MINIMUM_MESSAGES_TO_LOAD, 0);
updateChat();
return true;
}
});
if (abstractChat != null && abstractChat instanceof RoomChat
&& ((RoomChat) abstractChat).getState() != RoomState.unavailable) {
if (((RoomChat) abstractChat).getState() == RoomState.error) {
menu.findItem(R.id.action_authorization_settings).setVisible(true)
.setIntent(MUCEditor.createIntent(getActivity(), account, user));
} else {
menu.findItem(R.id.action_leave_conference).setVisible(true).setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
MUCManager.getInstance().leaveRoom(account, user);
MessageManager.getInstance().closeChat(account, user);
NotificationManager.getInstance()
.removeMessageNotification(account, user);
((ChatViewer) getActivity()).close();
return true;
}
});
}
} else {
menu.findItem(R.id.action_close_chat).setVisible(true)
.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
MessageManager.getInstance().closeChat(account, user);
NotificationManager.getInstance()
.removeMessageNotification(account, user);
((ChatViewer) getActivity()).close();
return true;
}
});
}
menu.findItem(R.id.action_clear_text).setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
inputView.getText().clear();
return true;
}
});
menu.findItem(R.id.action_clear_history).setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
MessageManager.getInstance()
.clearHistory(account, user);
updateChat();
return false;
}
});
menu.findItem(R.id.action_export_chat).setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
ChatExportDialogFragment.newInstance(account, user).show(getActivity().getFragmentManager(), "CHAT_EXPORT");
return true;
}
});
if (abstractChat != null && abstractChat instanceof RegularChat) {
menu.findItem(R.id.action_call_attention).setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
try {
AttentionManager.getInstance().sendAttention(
account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
return true;
}
});
SecurityLevel securityLevel = OTRManager.getInstance()
.getSecurityLevel(abstractChat.getAccount(),
abstractChat.getUser());
if (securityLevel == SecurityLevel.plain) {
menu.findItem(R.id.action_start_encryption).setVisible(true)
.setEnabled(SettingsManager.securityOtrMode() != SettingsManager.SecurityOtrMode.disabled)
.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
try {
OTRManager.getInstance().startSession(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
return true;
}
});
} else {
menu.findItem(R.id.action_restart_encryption).setVisible(true)
.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
try {
OTRManager.getInstance().refreshSession(
account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
return true;
}
});
}
menu.findItem(R.id.action_stop_encryption)
.setEnabled(securityLevel != SecurityLevel.plain)
.setOnMenuItemClickListener(
new MenuItem.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
try {
OTRManager.getInstance().endSession(account, user);
} catch (NetworkException e) {
Application.getInstance().onError(e);
}
return true;
}
});
menu.findItem(R.id.action_verify_with_fingerprint)
.setEnabled(securityLevel != SecurityLevel.plain)
.setIntent(FingerprintViewer.createIntent(getActivity(), account, user));
menu.findItem(R.id.action_verify_with_question)
.setEnabled(securityLevel != SecurityLevel.plain)
.setIntent(QuestionViewer
.createIntent(getActivity(), account, user, true, false, null));
menu.findItem(R.id.action_verify_with_shared_secret)
.setEnabled(securityLevel != SecurityLevel.plain)
.setIntent(QuestionViewer
.createIntent(getActivity(), account, user, false, false, null));
}
if (abstractChat != null && abstractChat instanceof RoomChat
&& ((RoomChat) abstractChat).getState() == RoomState.available)
menu.findItem(R.id.action_list_of_occupants).setVisible(true).setIntent(
OccupantList.createIntent(getActivity(), account, user));
}
@Override
public void onCreateContextMenu(ContextMenu menu, View view,
ContextMenu.ContextMenuInfo menuInfo) {
......@@ -585,7 +331,14 @@ public class ChatViewerFragment extends Fragment {
return user;
}
public interface ChatViewerFragmentListener {
public void onRecentChatsCalled();
public void clearInputView() {
inputView.getText().clear();
}
public void scrollChat() {
int size = listView.getCount();
if (size > 0) {
listView.setSelection(size - 1);
}
}
}
......@@ -29,8 +29,6 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter {
private FinishUpdateListener finishUpdateListener;
private Fragment currentFragment;
private static final int TOTAL_COUNT = 200;
private static final int OFFSET = TOTAL_COUNT / 2;
......@@ -165,15 +163,6 @@ public class ChatViewerAdapter extends FragmentStatePagerAdapter {
return realPosition - 1;
}
@Override
public void startUpdate(ViewGroup container) {
if (currentFragment instanceof ChatViewerFragment) {
((ChatViewerFragment)currentFragment).saveInputState();
}
super.startUpdate(container);
}
@Override
public void finishUpdate(ViewGroup container) {
super.finishUpdate(container);
......
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