Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. Index: src/ru/sawim/view/ChatView.java
  2. IDEA additional info:
  3. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  4. <+>UTF-8
  5. ===================================================================
  6. --- src/ru/sawim/view/ChatView.java (date 1397838109000)
  7. +++ src/ru/sawim/view/ChatView.java (revision )
  8. @@ -72,6 +72,7 @@
  9. private String sharingText;
  10. private boolean sendByEnter;
  11.  
  12. +
  13. private RosterAdapter chatsSpinnerAdapter;
  14. private MessagesAdapter adapter;
  15. private EditText messageEditor;
  16. @@ -445,10 +446,12 @@
  17. if (chat == null) return;
  18. initChat(protocol, contact);
  19. oldChat = chat.getContact().getUserId();
  20. - View item = chatListView.getChildAt(0);
  21. +
  22. chat.scrollPosition = chatListView.getFirstVisiblePosition();
  23. + View item = chatListView.getChildAt(0);
  24. chat.offset = (item == null) ? 0 : Math.abs(item.getBottom());
  25. chat.dividerPosition = chat.getMessCount();
  26. + chat.isBottomScroll = chat.dividerPosition == chatListView.getLastVisiblePosition() + 1;
  27. chat.message = getText().length() == 0 ? null : getText();
  28.  
  29. chat.setVisibleChat(false);
  30. @@ -503,7 +506,14 @@
  31. }
  32. } else {
  33. //chatListView.setSelectionFromTop(chat.scrollPosition + 1, chat.offset - (isLastPosition() ? 0 : chat.offset / 2));
  34. - chatListView.setSelectionFromTop(chat.scrollPosition + (isLastPosition() ? 1 : 2), chat.offset);
  35. + if(!chat.isBottomScroll || unreadMessageCount == 0)
  36. + {
  37. + chatListView.setSelectionFromTop(chat.scrollPosition + 1, chat.offset);
  38. + }
  39. + else
  40. + {
  41. + chatListView.setSelectionFromTop(chat.getMessData().size() - unreadMessageCount,67);
  42. + }
  43. }
  44. adapter.refreshList(chat.getMessData());
  45. chatListView.postDelayed(new Runnable() {
  46. \ No newline at end of file
  47. Index: src/ru/sawim/chat/Chat.java
  48. IDEA additional info:
  49. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  50. <+>UTF-8
  51. ===================================================================
  52. --- src/ru/sawim/chat/Chat.java (date 1397838109000)
  53. +++ src/ru/sawim/chat/Chat.java (revision )
  54. @@ -33,6 +33,7 @@
  55. public int scrollPosition;
  56. public int offset;
  57. public int dividerPosition;
  58. + public boolean isBottomScroll;
  59.  
  60. public Chat(Protocol p, Contact item) {
  61. contact = item;
  62. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement