Advertisement
Guest User

Untitled

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