Commit 1d614671 authored by Grigory Fedorov's avatar Grigory Fedorov

ChatViewerFragment: input text state fixed.

parent 4ba3b54a
...@@ -220,17 +220,36 @@ public class ChatViewerFragment extends Fragment implements ChatViewer.CurrentUp ...@@ -220,17 +220,36 @@ public class ChatViewerFragment extends Fragment implements ChatViewer.CurrentUp
((ChatViewer)getActivity()).registerChat(this); ((ChatViewer)getActivity()).registerChat(this);
registerForContextMenu(listView); registerForContextMenu(listView);
restoreInputState();
}
private void restoreInputState() {
skipOnTextChanges = true;
inputView.setText(ChatManager.getInstance().getTypedMessage(account, user));
inputView.setSelection(ChatManager.getInstance().getSelectionStart(account, user),
ChatManager.getInstance().getSelectionEnd(account, user));
skipOnTextChanges = false;
} }
@Override @Override
public void onPause() { public void onPause() {
super.onPause(); super.onPause();
saveInputState();
((ChatViewer)getActivity()).unregisterChat(this); ((ChatViewer)getActivity()).unregisterChat(this);
unregisterForContextMenu(listView); unregisterForContextMenu(listView);
} }
public void saveInputState() {
ChatManager.getInstance().setTyped(account, user, inputView.getText().toString(),
inputView.getSelectionStart(), inputView.getSelectionEnd());
}
private void sendMessage() { private void sendMessage() {
String text = inputView.getText().toString(); String text = inputView.getText().toString();
int start = 0; int start = 0;
...@@ -277,14 +296,6 @@ public class ChatViewerFragment extends Fragment implements ChatViewer.CurrentUp ...@@ -277,14 +296,6 @@ public class ChatViewerFragment extends Fragment implements ChatViewer.CurrentUp
private void updateView() { private void updateView() {
final AbstractContact abstractContact = RosterManager.getInstance().getBestContact(account, user); final AbstractContact abstractContact = RosterManager.getInstance().getBestContact(account, user);
skipOnTextChanges = true;
inputView.setText(ChatManager.getInstance().getTypedMessage(account, user));
inputView.setSelection(ChatManager.getInstance().getSelectionStart(account, user),
ChatManager.getInstance().getSelectionEnd(account, user));
skipOnTextChanges = false;
ContactTitleInflater.updateTitle(titleView, getActivity(), abstractContact); ContactTitleInflater.updateTitle(titleView, getActivity(), abstractContact);
avatarInflaterHelper.updateAvatar((ImageView) titleView.findViewById(R.id.avatar), abstractContact); avatarInflaterHelper.updateAvatar((ImageView) titleView.findViewById(R.id.avatar), abstractContact);
......
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