Advertisement
Guest User

Untitled

a guest
May 17th, 2014
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.17 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 1400331337000)
  7. +++ src/ru/sawim/view/ChatView.java (revision )
  8. @@ -443,11 +443,13 @@
  9.          if (chat == null) return;
  10.          initChat(protocol, contact);
  11.          oldChat = chat.getContact().getUserId();
  12. +        View item = chatListView.getChildAt(0);
  13.          chat.scrollPosition = chatListView.getFirstVisiblePosition();
  14. -        chat.offset = chatListView.getHeight() / 4;
  15. +        chat.offset = (item == null) ? 0 : Math.abs(item.getBottom());
  16.          chat.dividerPosition = chat.getMessCount();
  17.          chat.lastVisiblePosition = chatListView.getLastVisiblePosition() + 1;
  18.          chat.message = getText().length() == 0 ? null : getText();
  19. +        chat.isBottomScroll = (chat.lastVisiblePosition == chat.dividerPosition);
  20.  
  21.          chat.setVisibleChat(false);
  22.          RosterHelper.getInstance().setOnUpdateChat(null);
  23. @@ -489,7 +491,8 @@
  24.      }
  25.  
  26.      private void setPosition(int unreadMessageCount) {
  27. -        boolean hasHistory = chat.getHistory() != null && chat.getHistory().getHistorySize() > 0 && !chat.isBlogBot();
  28. +        boolean hasHistory;
  29. +        hasHistory = chat.getHistory() != null && chat.getHistory().getHistorySize() > 0 && !chat.isBlogBot();
  30.          adapter.setPosition(chat.dividerPosition);
  31.          int position = chat.getMessData().size() - unreadMessageCount;
  32.          if (chat.dividerPosition == -1) {
  33. @@ -500,15 +503,11 @@
  34.                  chatListView.setSelection(position);
  35.              }
  36.          } else {
  37. -            boolean isBottomScroll = chat.lastVisiblePosition == chat.dividerPosition;
  38. -            if (isBottomScroll && unreadMessageCount == 0 && isLastPosition()) {
  39. -                chatListView.setSelectionFromTop(chat.lastVisiblePosition, -(chat.offset * 4));
  40. -            } else {
  41. -                if (!isBottomScroll || unreadMessageCount == 0) {
  42. +
  43. +            if (!chat.isBottomScroll || unreadMessageCount == 0) {
  44. -                    chatListView.setSelectionFromTop(chat.scrollPosition + 1, chat.offset);
  45. -                } else {
  46. +                chatListView.setSelectionFromTop(chat.scrollPosition + 1, chat.offset);
  47. +            } else {
  48. -                    chatListView.setSelectionFromTop(position, chat.offset);
  49. -                }
  50. +                chatListView.setSelectionFromTop(chat.getMessData().size() - unreadMessageCount,chatListView.getHeight() / 4 );
  51.              }
  52.          }
  53.      }
  54. \ No newline at end of file
  55. Index: src/ru/sawim/chat/Chat.java
  56. IDEA additional info:
  57. Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
  58. <+>UTF-8
  59. ===================================================================
  60. --- src/ru/sawim/chat/Chat.java (date 1400331337000)
  61. +++ src/ru/sawim/chat/Chat.java (revision )
  62. @@ -32,6 +32,7 @@
  63.      public int offset;
  64.      public int dividerPosition = -1;
  65.      public int lastVisiblePosition;
  66. +    public boolean isBottomScroll;
  67.  
  68.      public Chat(Protocol p, Contact item) {
  69.          contact = item;
  70. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement