ListPopupWindow.java 28.4 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052
package android.support.v7.widget;

import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.database.DataSetObserver;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.os.Handler;
import android.support.annotation.AttrRes;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.annotation.RestrictTo;
import android.support.annotation.StyleRes;
import android.support.v4.view.ViewCompat;
import android.support.v4.widget.PopupWindowCompat;
import android.support.v7.appcompat.R.attr;
import android.support.v7.appcompat.R.styleable;
import android.support.v7.view.menu.ShowableListMenu;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.KeyEvent;
import android.view.KeyEvent.DispatcherState;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.View.OnTouchListener;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.PopupWindow;
import android.widget.PopupWindow.OnDismissListener;
import gp;
import java.lang.reflect.Method;

public class ListPopupWindow
  implements ShowableListMenu
{
  public static final int INPUT_METHOD_FROM_FOCUSABLE = 0;
  public static final int INPUT_METHOD_NEEDED = 1;
  public static final int INPUT_METHOD_NOT_NEEDED = 2;
  public static final int MATCH_PARENT = -1;
  public static final int POSITION_PROMPT_ABOVE = 0;
  public static final int POSITION_PROMPT_BELOW = 1;
  public static final int WRAP_CONTENT = -2;
  private static Method a;
  private static Method b;
  private static Method c;
  private AdapterView.OnItemSelectedListener A;
  private final d B = new d();
  private final c C = new c();
  private final a D = new a();
  private Runnable E;
  private final Rect F = new Rect();
  private Rect G;
  private boolean H;
  private Context d;
  gp e;
  int f = Integer.MAX_VALUE;
  final e g = new e();
  final Handler h;
  PopupWindow i;
  private ListAdapter j;
  private int k = -2;
  private int l = -2;
  private int m;
  private int n;
  private int o = 1002;
  private boolean p;
  private boolean q = true;
  private int r = 0;
  private boolean s = false;
  private boolean t = false;
  private View u;
  private int v = 0;
  private DataSetObserver w;
  private View x;
  private Drawable y;
  private AdapterView.OnItemClickListener z;
  
  static
  {
    try
    {
      a = PopupWindow.class.getDeclaredMethod("setClipToScreenEnabled", new Class[] { Boolean.TYPE });
    }
    catch (NoSuchMethodException localNoSuchMethodException1)
    {
      try
      {
        for (;;)
        {
          b = PopupWindow.class.getDeclaredMethod("getMaxAvailableHeight", new Class[] { View.class, Integer.TYPE, Boolean.TYPE });
          try
          {
            c = PopupWindow.class.getDeclaredMethod("setEpicenterBounds", new Class[] { Rect.class });
            return;
          }
          catch (NoSuchMethodException localNoSuchMethodException3)
          {
            Log.i("ListPopupWindow", "Could not find method setEpicenterBounds(Rect) on PopupWindow. Oh well.");
          }
          localNoSuchMethodException1 = localNoSuchMethodException1;
          Log.i("ListPopupWindow", "Could not find method setClipToScreenEnabled() on PopupWindow. Oh well.");
        }
      }
      catch (NoSuchMethodException localNoSuchMethodException2)
      {
        for (;;)
        {
          Log.i("ListPopupWindow", "Could not find method getMaxAvailableHeight(View, int, boolean) on PopupWindow. Oh well.");
        }
      }
    }
  }
  
  public ListPopupWindow(@NonNull Context paramContext)
  {
    this(paramContext, null, R.attr.listPopupWindowStyle);
  }
  
  public ListPopupWindow(@NonNull Context paramContext, @Nullable AttributeSet paramAttributeSet)
  {
    this(paramContext, paramAttributeSet, R.attr.listPopupWindowStyle);
  }
  
  public ListPopupWindow(@NonNull Context paramContext, @Nullable AttributeSet paramAttributeSet, @AttrRes int paramInt)
  {
    this(paramContext, paramAttributeSet, paramInt, 0);
  }
  
  public ListPopupWindow(@NonNull Context paramContext, @Nullable AttributeSet paramAttributeSet, @AttrRes int paramInt1, @StyleRes int paramInt2)
  {
    this.d = paramContext;
    this.h = new Handler(paramContext.getMainLooper());
    TypedArray localTypedArray = paramContext.obtainStyledAttributes(paramAttributeSet, R.styleable.ListPopupWindow, paramInt1, paramInt2);
    this.m = localTypedArray.getDimensionPixelOffset(R.styleable.ListPopupWindow_android_dropDownHorizontalOffset, 0);
    this.n = localTypedArray.getDimensionPixelOffset(R.styleable.ListPopupWindow_android_dropDownVerticalOffset, 0);
    if (this.n != 0) {
      this.p = true;
    }
    localTypedArray.recycle();
    if (Build.VERSION.SDK_INT >= 11) {}
    for (this.i = new AppCompatPopupWindow(paramContext, paramAttributeSet, paramInt1, paramInt2);; this.i = new AppCompatPopupWindow(paramContext, paramAttributeSet, paramInt1))
    {
      this.i.setInputMethodMode(1);
      return;
    }
  }
  
  private int a(View paramView, int paramInt, boolean paramBoolean)
  {
    if (b != null) {
      try
      {
        int i1 = ((Integer)b.invoke(this.i, new Object[] { paramView, Integer.valueOf(paramInt), Boolean.valueOf(paramBoolean) })).intValue();
        return i1;
      }
      catch (Exception localException)
      {
        Log.i("ListPopupWindow", "Could not call getMaxAvailableHeightMethod(View, int, boolean) on PopupWindow. Using the public version.");
      }
    }
    return this.i.getMaxAvailableHeight(paramView, paramInt);
  }
  
  private void a()
  {
    if (this.u != null)
    {
      ViewParent localViewParent = this.u.getParent();
      if ((localViewParent instanceof ViewGroup)) {
        ((ViewGroup)localViewParent).removeView(this.u);
      }
    }
  }
  
  private static boolean a(int paramInt)
  {
    return (paramInt == 66) || (paramInt == 23);
  }
  
  @NonNull
  gp a(Context paramContext, boolean paramBoolean)
  {
    return new gp(paramContext, paramBoolean);
  }
  
  public void clearListSelection()
  {
    gp localgp = this.e;
    if (localgp != null)
    {
      localgp.setListSelectionHidden(true);
      localgp.requestLayout();
    }
  }
  
  public View.OnTouchListener createDragToOpenListener(View paramView)
  {
    new ForwardingListener(paramView) {};
  }
  
  public void dismiss()
  {
    this.i.dismiss();
    a();
    this.i.setContentView(null);
    this.e = null;
    this.h.removeCallbacks(this.g);
  }
  
  @Nullable
  public View getAnchorView()
  {
    return this.x;
  }
  
  @StyleRes
  public int getAnimationStyle()
  {
    return this.i.getAnimationStyle();
  }
  
  @Nullable
  public Drawable getBackground()
  {
    return this.i.getBackground();
  }
  
  public int getHeight()
  {
    return this.k;
  }
  
  public int getHorizontalOffset()
  {
    return this.m;
  }
  
  public int getInputMethodMode()
  {
    return this.i.getInputMethodMode();
  }
  
  @Nullable
  public ListView getListView()
  {
    return this.e;
  }
  
  public int getPromptPosition()
  {
    return this.v;
  }
  
  @Nullable
  public Object getSelectedItem()
  {
    if (!isShowing()) {
      return null;
    }
    return this.e.getSelectedItem();
  }
  
  public long getSelectedItemId()
  {
    if (!isShowing()) {
      return Long.MIN_VALUE;
    }
    return this.e.getSelectedItemId();
  }
  
  public int getSelectedItemPosition()
  {
    if (!isShowing()) {
      return -1;
    }
    return this.e.getSelectedItemPosition();
  }
  
  @Nullable
  public View getSelectedView()
  {
    if (!isShowing()) {
      return null;
    }
    return this.e.getSelectedView();
  }
  
  public int getSoftInputMode()
  {
    return this.i.getSoftInputMode();
  }
  
  public int getVerticalOffset()
  {
    if (!this.p) {
      return 0;
    }
    return this.n;
  }
  
  public int getWidth()
  {
    return this.l;
  }
  
  @RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
  public boolean isDropDownAlwaysVisible()
  {
    return this.s;
  }
  
  public boolean isInputMethodNotNeeded()
  {
    return this.i.getInputMethodMode() == 2;
  }
  
  public boolean isModal()
  {
    return this.H;
  }
  
  public boolean isShowing()
  {
    return this.i.isShowing();
  }
  
  public boolean onKeyDown(int paramInt, @NonNull KeyEvent paramKeyEvent)
  {
    int i4;
    int i3;
    int i1;
    int i2;
    if ((isShowing()) && (paramInt != 62) && ((this.e.getSelectedItemPosition() >= 0) || (!a(paramInt))))
    {
      i4 = this.e.getSelectedItemPosition();
      ListAdapter localListAdapter;
      if (!this.i.isAboveAnchor())
      {
        i3 = 1;
        localListAdapter = this.j;
        i1 = Integer.MAX_VALUE;
        i2 = Integer.MIN_VALUE;
        if (localListAdapter != null)
        {
          boolean bool = localListAdapter.areAllItemsEnabled();
          if (!bool) {
            break label162;
          }
          i1 = 0;
          label87:
          if (!bool) {
            break label175;
          }
        }
      }
      label162:
      label175:
      for (i2 = localListAdapter.getCount() - 1;; i2 = this.e.lookForSelectablePosition(localListAdapter.getCount() - 1, false))
      {
        if (((i3 == 0) || (paramInt != 19) || (i4 > i1)) && ((i3 != 0) || (paramInt != 20) || (i4 < i2))) {
          break label197;
        }
        clearListSelection();
        this.i.setInputMethodMode(1);
        show();
        return true;
        i3 = 0;
        break;
        i1 = this.e.lookForSelectablePosition(0, true);
        break label87;
      }
      label197:
      this.e.setListSelectionHidden(false);
      if (!this.e.onKeyDown(paramInt, paramKeyEvent)) {
        break label282;
      }
      this.i.setInputMethodMode(2);
      this.e.requestFocusFromTouch();
      show();
      switch (paramInt)
      {
      }
    }
    label282:
    do
    {
      do
      {
        return false;
        if ((i3 == 0) || (paramInt != 20)) {
          break;
        }
      } while (i4 != i2);
      return true;
    } while ((i3 != 0) || (paramInt != 19) || (i4 != i1));
    return true;
  }
  
  public boolean onKeyPreIme(int paramInt, @NonNull KeyEvent paramKeyEvent)
  {
    if ((paramInt == 4) && (isShowing()))
    {
      Object localObject = this.x;
      if ((paramKeyEvent.getAction() == 0) && (paramKeyEvent.getRepeatCount() == 0))
      {
        localObject = ((View)localObject).getKeyDispatcherState();
        if (localObject != null) {
          ((KeyEvent.DispatcherState)localObject).startTracking(paramKeyEvent, this);
        }
        return true;
      }
      if (paramKeyEvent.getAction() == 1)
      {
        localObject = ((View)localObject).getKeyDispatcherState();
        if (localObject != null) {
          ((KeyEvent.DispatcherState)localObject).handleUpEvent(paramKeyEvent);
        }
        if ((paramKeyEvent.isTracking()) && (!paramKeyEvent.isCanceled()))
        {
          dismiss();
          return true;
        }
      }
    }
    return false;
  }
  
  public boolean onKeyUp(int paramInt, @NonNull KeyEvent paramKeyEvent)
  {
    if ((isShowing()) && (this.e.getSelectedItemPosition() >= 0))
    {
      boolean bool = this.e.onKeyUp(paramInt, paramKeyEvent);
      if ((bool) && (a(paramInt))) {
        dismiss();
      }
      return bool;
    }
    return false;
  }
  
  public boolean performItemClick(int paramInt)
  {
    if (isShowing())
    {
      if (this.z != null)
      {
        gp localgp = this.e;
        View localView = localgp.getChildAt(paramInt - localgp.getFirstVisiblePosition());
        ListAdapter localListAdapter = localgp.getAdapter();
        this.z.onItemClick(localgp, localView, paramInt, localListAdapter.getItemId(paramInt));
      }
      return true;
    }
    return false;
  }
  
  public void postShow()
  {
    this.h.post(this.E);
  }
  
  public void setAdapter(@Nullable ListAdapter paramListAdapter)
  {
    if (this.w == null) {
      this.w = new b();
    }
    for (;;)
    {
      this.j = paramListAdapter;
      if (this.j != null) {
        paramListAdapter.registerDataSetObserver(this.w);
      }
      if (this.e != null) {
        this.e.setAdapter(this.j);
      }
      return;
      if (this.j != null) {
        this.j.unregisterDataSetObserver(this.w);
      }
    }
  }
  
  public void setAnchorView(@Nullable View paramView)
  {
    this.x = paramView;
  }
  
  public void setAnimationStyle(@StyleRes int paramInt)
  {
    this.i.setAnimationStyle(paramInt);
  }
  
  public void setBackgroundDrawable(@Nullable Drawable paramDrawable)
  {
    this.i.setBackgroundDrawable(paramDrawable);
  }
  
  public void setContentWidth(int paramInt)
  {
    Drawable localDrawable = this.i.getBackground();
    if (localDrawable != null)
    {
      localDrawable.getPadding(this.F);
      this.l = (this.F.left + this.F.right + paramInt);
      return;
    }
    setWidth(paramInt);
  }
  
  @RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
  public void setDropDownAlwaysVisible(boolean paramBoolean)
  {
    this.s = paramBoolean;
  }
  
  public void setDropDownGravity(int paramInt)
  {
    this.r = paramInt;
  }
  
  @RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
  public void setEpicenterBounds(Rect paramRect)
  {
    this.G = paramRect;
  }
  
  @RestrictTo({android.support.annotation.RestrictTo.Scope.LIBRARY_GROUP})
  public void setForceIgnoreOutsideTouch(boolean paramBoolean)
  {
    this.t = paramBoolean;
  }
  
  public void setHeight(int paramInt)
  {
    this.k = paramInt;
  }
  
  public void setHorizontalOffset(int paramInt)
  {
    this.m = paramInt;
  }
  
  public void setInputMethodMode(int paramInt)
  {
    this.i.setInputMethodMode(paramInt);
  }
  
  public void setListSelector(Drawable paramDrawable)
  {
    this.y = paramDrawable;
  }
  
  public void setModal(boolean paramBoolean)
  {
    this.H = paramBoolean;
    this.i.setFocusable(paramBoolean);
  }
  
  public void setOnDismissListener(@Nullable PopupWindow.OnDismissListener paramOnDismissListener)
  {
    this.i.setOnDismissListener(paramOnDismissListener);
  }
  
  public void setOnItemClickListener(@Nullable AdapterView.OnItemClickListener paramOnItemClickListener)
  {
    this.z = paramOnItemClickListener;
  }
  
  public void setOnItemSelectedListener(@Nullable AdapterView.OnItemSelectedListener paramOnItemSelectedListener)
  {
    this.A = paramOnItemSelectedListener;
  }
  
  public void setPromptPosition(int paramInt)
  {
    this.v = paramInt;
  }
  
  public void setPromptView(@Nullable View paramView)
  {
    boolean bool = isShowing();
    if (bool) {
      a();
    }
    this.u = paramView;
    if (bool) {
      show();
    }
  }
  
  public void setSelection(int paramInt)
  {
    gp localgp = this.e;
    if ((isShowing()) && (localgp != null))
    {
      localgp.setListSelectionHidden(false);
      localgp.setSelection(paramInt);
      if ((Build.VERSION.SDK_INT >= 11) && (localgp.getChoiceMode() != 0)) {
        localgp.setItemChecked(paramInt, true);
      }
    }
  }
  
  public void setSoftInputMode(int paramInt)
  {
    this.i.setSoftInputMode(paramInt);
  }
  
  public void setVerticalOffset(int paramInt)
  {
    this.n = paramInt;
    this.p = true;
  }
  
  public void setWidth(int paramInt)
  {
    this.l = paramInt;
  }
  
  public void setWindowLayoutType(int paramInt)
  {
    this.o = paramInt;
  }
  
  public void show()
  {
    boolean bool3 = true;
    boolean bool2 = true;
    Object localObject2;
    boolean bool1;
    Object localObject1;
    View localView;
    LinearLayout.LayoutParams localLayoutParams;
    label250:
    int i2;
    int i1;
    if (this.e == null)
    {
      localObject2 = this.d;
      this.E = new Runnable()
      {
        public final void run()
        {
          View localView = ListPopupWindow.this.getAnchorView();
          if ((localView != null) && (localView.getWindowToken() != null)) {
            ListPopupWindow.this.show();
          }
        }
      };
      if (!this.H)
      {
        bool1 = true;
        this.e = a((Context)localObject2, bool1);
        if (this.y != null) {
          this.e.setSelector(this.y);
        }
        this.e.setAdapter(this.j);
        this.e.setOnItemClickListener(this.z);
        this.e.setFocusable(true);
        this.e.setFocusableInTouchMode(true);
        this.e.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener()
        {
          public final void onItemSelected(AdapterView<?> paramAnonymousAdapterView, View paramAnonymousView, int paramAnonymousInt, long paramAnonymousLong)
          {
            if (paramAnonymousInt != -1)
            {
              paramAnonymousAdapterView = ListPopupWindow.this.e;
              if (paramAnonymousAdapterView != null) {
                paramAnonymousAdapterView.setListSelectionHidden(false);
              }
            }
          }
          
          public final void onNothingSelected(AdapterView<?> paramAnonymousAdapterView) {}
        });
        this.e.setOnScrollListener(this.C);
        if (this.A != null) {
          this.e.setOnItemSelectedListener(this.A);
        }
        localObject1 = this.e;
        localView = this.u;
        if (localView == null) {
          break label1290;
        }
        localObject2 = new LinearLayout((Context)localObject2);
        ((LinearLayout)localObject2).setOrientation(1);
        localLayoutParams = new LinearLayout.LayoutParams(-1, 0, 1.0F);
        switch (this.v)
        {
        default: 
          Log.e("ListPopupWindow", "Invalid hint position " + this.v);
          if (this.l >= 0)
          {
            i2 = this.l;
            i1 = Integer.MIN_VALUE;
            label266:
            localView.measure(View.MeasureSpec.makeMeasureSpec(i2, i1), 0);
            localObject1 = (LinearLayout.LayoutParams)localView.getLayoutParams();
            i1 = localView.getMeasuredHeight();
            i2 = ((LinearLayout.LayoutParams)localObject1).topMargin;
            i1 = ((LinearLayout.LayoutParams)localObject1).bottomMargin + (i1 + i2);
            localObject1 = localObject2;
          }
          break;
        }
      }
    }
    for (;;)
    {
      this.i.setContentView((View)localObject1);
      for (;;)
      {
        label322:
        localObject1 = this.i.getBackground();
        if (localObject1 != null)
        {
          ((Drawable)localObject1).getPadding(this.F);
          i2 = this.F.top + this.F.bottom;
          if (this.p) {
            break label1282;
          }
          this.n = (-this.F.top);
        }
        label381:
        label395:
        label468:
        label481:
        label502:
        label516:
        label540:
        label724:
        label893:
        label921:
        label926:
        label931:
        label969:
        label992:
        label1002:
        label1012:
        label1226:
        label1282:
        for (;;)
        {
          int i4;
          int i3;
          if (this.i.getInputMethodMode() == 2)
          {
            bool1 = true;
            i4 = a(getAnchorView(), this.n, bool1);
            if ((!this.s) && (this.k != -1)) {
              break label724;
            }
            i1 = i4 + i2;
            bool1 = isInputMethodNotNeeded();
            PopupWindowCompat.setWindowLayoutType(this.i, this.o);
            if (!this.i.isShowing()) {
              break label992;
            }
            if (this.l != -1) {
              break label893;
            }
            i2 = -1;
            if (this.k != -1) {
              break label969;
            }
            if (!bool1) {
              break label921;
            }
            if (!bool1) {
              break label931;
            }
            localObject1 = this.i;
            if (this.l != -1) {
              break label926;
            }
            i3 = -1;
            ((PopupWindow)localObject1).setWidth(i3);
            this.i.setHeight(0);
          }
          for (;;)
          {
            localObject1 = this.i;
            if ((!this.t) && (!this.s))
            {
              bool1 = bool2;
              ((PopupWindow)localObject1).setOutsideTouchable(bool1);
              localObject1 = this.i;
              localObject2 = getAnchorView();
              i4 = this.m;
              int i5 = this.n;
              i3 = i2;
              if (i2 < 0) {
                i3 = -1;
              }
              i2 = i1;
              if (i1 < 0) {
                i2 = -1;
              }
              ((PopupWindow)localObject1).update((View)localObject2, i4, i5, i3, i2);
            }
            for (;;)
            {
              return;
              bool1 = false;
              break;
              ((LinearLayout)localObject2).addView((View)localObject1, localLayoutParams);
              ((LinearLayout)localObject2).addView(localView);
              break label250;
              ((LinearLayout)localObject2).addView(localView);
              ((LinearLayout)localObject2).addView((View)localObject1, localLayoutParams);
              break label250;
              i1 = 0;
              i2 = 0;
              break label266;
              this.i.getContentView();
              localObject1 = this.u;
              if (localObject1 == null) {
                break label1285;
              }
              localObject2 = (LinearLayout.LayoutParams)((View)localObject1).getLayoutParams();
              i1 = ((View)localObject1).getMeasuredHeight();
              i2 = ((LinearLayout.LayoutParams)localObject2).topMargin;
              i1 = ((LinearLayout.LayoutParams)localObject2).bottomMargin + (i1 + i2);
              break label322;
              this.F.setEmpty();
              i2 = 0;
              break label381;
              bool1 = false;
              break label395;
              switch (this.l)
              {
              default: 
                i3 = View.MeasureSpec.makeMeasureSpec(this.l, 1073741824);
              }
              for (;;)
              {
                i4 = this.e.measureHeightOfChildrenCompat(i3, 0, -1, i4 - i1, -1);
                i3 = i1;
                if (i4 > 0) {
                  i3 = i1 + (this.e.getPaddingTop() + this.e.getPaddingBottom() + i2);
                }
                i1 = i4 + i3;
                break;
                i3 = View.MeasureSpec.makeMeasureSpec(this.d.getResources().getDisplayMetrics().widthPixels - (this.F.left + this.F.right), Integer.MIN_VALUE);
                continue;
                i3 = View.MeasureSpec.makeMeasureSpec(this.d.getResources().getDisplayMetrics().widthPixels - (this.F.left + this.F.right), 1073741824);
              }
              if (this.l == -2)
              {
                i2 = getAnchorView().getWidth();
                break label468;
              }
              i2 = this.l;
              break label468;
              i1 = -1;
              break label481;
              i3 = 0;
              break label502;
              localObject1 = this.i;
              if (this.l == -1) {}
              for (i3 = -1;; i3 = 0)
              {
                ((PopupWindow)localObject1).setWidth(i3);
                this.i.setHeight(-1);
                break;
              }
              if (this.k != -2)
              {
                i1 = this.k;
                break label516;
                bool1 = false;
                break label540;
                if (this.l == -1)
                {
                  i2 = -1;
                  if (this.k != -1) {
                    break label1226;
                  }
                  i1 = -1;
                  this.i.setWidth(i2);
                  this.i.setHeight(i1);
                  if (a == null) {}
                }
                try
                {
                  a.invoke(this.i, new Object[] { Boolean.valueOf(true) });
                  localObject1 = this.i;
                  if ((!this.t) && (!this.s))
                  {
                    bool1 = bool3;
                    ((PopupWindow)localObject1).setOutsideTouchable(bool1);
                    this.i.setTouchInterceptor(this.B);
                    if (c == null) {}
                  }
                }
                catch (Exception localException1)
                {
                  try
                  {
                    for (;;)
                    {
                      c.invoke(this.i, new Object[] { this.G });
                      PopupWindowCompat.showAsDropDown(this.i, getAnchorView(), this.m, this.n, this.r);
                      this.e.setSelection(-1);
                      if ((!this.H) || (this.e.isInTouchMode())) {
                        clearListSelection();
                      }
                      if (this.H) {
                        break;
                      }
                      this.h.post(this.D);
                      return;
                      if (this.l == -2)
                      {
                        i2 = getAnchorView().getWidth();
                        break label1002;
                      }
                      i2 = this.l;
                      break label1002;
                      if (this.k == -2) {
                        break label1012;
                      }
                      i1 = this.k;
                      break label1012;
                      localException1 = localException1;
                      Log.i("ListPopupWindow", "Could not call setClipToScreenEnabled() on PopupWindow. Oh well.");
                    }
                    bool1 = false;
                  }
                  catch (Exception localException2)
                  {
                    for (;;)
                    {
                      Log.e("ListPopupWindow", "Could not invoke setEpicenterBounds on PopupWindow", localException2);
                    }
                  }
                }
              }
            }
          }
        }
        label1285:
        i1 = 0;
      }
      label1290:
      i1 = 0;
    }
  }
  
  final class a
    implements Runnable
  {
    a() {}
    
    public final void run()
    {
      ListPopupWindow.this.clearListSelection();
    }
  }
  
  final class b
    extends DataSetObserver
  {
    b() {}
    
    public final void onChanged()
    {
      if (ListPopupWindow.this.isShowing()) {
        ListPopupWindow.this.show();
      }
    }
    
    public final void onInvalidated()
    {
      ListPopupWindow.this.dismiss();
    }
  }
  
  final class c
    implements AbsListView.OnScrollListener
  {
    c() {}
    
    public final void onScroll(AbsListView paramAbsListView, int paramInt1, int paramInt2, int paramInt3) {}
    
    public final void onScrollStateChanged(AbsListView paramAbsListView, int paramInt)
    {
      if ((paramInt == 1) && (!ListPopupWindow.this.isInputMethodNotNeeded()) && (ListPopupWindow.this.i.getContentView() != null))
      {
        ListPopupWindow.this.h.removeCallbacks(ListPopupWindow.this.g);
        ListPopupWindow.this.g.run();
      }
    }
  }
  
  final class d
    implements View.OnTouchListener
  {
    d() {}
    
    public final boolean onTouch(View paramView, MotionEvent paramMotionEvent)
    {
      int i = paramMotionEvent.getAction();
      int j = (int)paramMotionEvent.getX();
      int k = (int)paramMotionEvent.getY();
      if ((i == 0) && (ListPopupWindow.this.i != null) && (ListPopupWindow.this.i.isShowing()) && (j >= 0) && (j < ListPopupWindow.this.i.getWidth()) && (k >= 0) && (k < ListPopupWindow.this.i.getHeight())) {
        ListPopupWindow.this.h.postDelayed(ListPopupWindow.this.g, 250L);
      }
      for (;;)
      {
        return false;
        if (i == 1) {
          ListPopupWindow.this.h.removeCallbacks(ListPopupWindow.this.g);
        }
      }
    }
  }
  
  final class e
    implements Runnable
  {
    e() {}
    
    public final void run()
    {
      if ((ListPopupWindow.this.e != null) && (ViewCompat.isAttachedToWindow(ListPopupWindow.this.e)) && (ListPopupWindow.this.e.getCount() > ListPopupWindow.this.e.getChildCount()) && (ListPopupWindow.this.e.getChildCount() <= ListPopupWindow.this.f))
      {
        ListPopupWindow.this.i.setInputMethodMode(2);
        ListPopupWindow.this.show();
      }
    }
  }
}


/* Location:              /home/merong/decompile/hackery-dex2jar.jar!/android/support/v7/widget/ListPopupWindow.class
 * Java compiler version: 6 (50.0)
 * JD-Core Version:       0.7.1
 */