|
17 | 17 |
|
18 | 18 | package com.android.ex.chips; |
19 | 19 |
|
20 | | -import android.app.Activity; |
21 | 20 | import android.app.Dialog; |
22 | 21 | import android.content.ClipData; |
23 | 22 | import android.content.ClipDescription; |
|
63 | 62 | import android.text.util.Rfc822Tokenizer; |
64 | 63 | import android.util.AttributeSet; |
65 | 64 | import android.util.Log; |
66 | | -import android.util.TypedValue; |
67 | 65 | import android.view.ActionMode; |
68 | 66 | import android.view.ActionMode.Callback; |
69 | 67 | import android.view.DragEvent; |
@@ -141,7 +139,6 @@ public class RecipientEditTextView extends MultiAutoCompleteTextView implements |
141 | 139 | private static final int MAX_CHIPS_PARSED = 50; |
142 | 140 |
|
143 | 141 | private static int sSelectedTextColor = -1; |
144 | | - private static int sVisibleDisplayFrameTop = -1; |
145 | 142 |
|
146 | 143 | // Work variables to avoid re-allocation on every typed character. |
147 | 144 | private final Rect mRect = new Rect(); |
@@ -497,24 +494,6 @@ public void onFocusChanged(boolean hasFocus, int direction, Rect previous) { |
497 | 494 | } |
498 | 495 | } |
499 | 496 |
|
500 | | - // sVisibleDisplayFrameTop is computed on a on-demand basis because the view needs to be fully |
501 | | - // measured and created in order to calculate the visible display frame. |
502 | | - private int getVisibleDisplayFrameTop() { |
503 | | - if (sVisibleDisplayFrameTop == -1) { |
504 | | - final TypedValue tv = new TypedValue(); |
505 | | - final Context context = getContext(); |
506 | | - // Visible top is our visible display (due to status bar) plus the height of action bar. |
507 | | - if (context.getTheme().resolveAttribute(android.R.attr.actionBarSize, tv, true)) { |
508 | | - sVisibleDisplayFrameTop = TypedValue.complexToDimensionPixelSize(tv.data, |
509 | | - getResources().getDisplayMetrics()); |
510 | | - } |
511 | | - // Compute the status bar height, or rather where our visible display starts |
512 | | - getWindowVisibleDisplayFrame(mRect); |
513 | | - sVisibleDisplayFrameTop += mRect.top; |
514 | | - } |
515 | | - return sVisibleDisplayFrameTop; |
516 | | - } |
517 | | - |
518 | 497 | @Override |
519 | 498 | public <T extends ListAdapter & Filterable> void setAdapter(T adapter) { |
520 | 499 | super.setAdapter(adapter); |
@@ -568,7 +547,8 @@ protected void scrollBottomIntoView() { |
568 | 547 | // content. |
569 | 548 | final int height = getHeight(); |
570 | 549 | final int currentPos = mCoords[1] + height; |
571 | | - final int desiredPos = getVisibleDisplayFrameTop() + height / getLineCount(); |
| 550 | + mScrollView.getLocationInWindow(mCoords); |
| 551 | + final int desiredPos = mCoords[1] + height / getLineCount(); |
572 | 552 | if (currentPos > desiredPos) { |
573 | 553 | mScrollView.scrollBy(0, currentPos - desiredPos); |
574 | 554 | } |
|
0 commit comments