GridLayoutManager.java 29.6 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 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159
package android.support.v7.widget;

import android.content.Context;
import android.graphics.Rect;
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat;
import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.CollectionItemInfoCompat;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseIntArray;
import android.view.View;
import android.view.View.MeasureSpec;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroup.MarginLayoutParams;
import java.util.Arrays;

public class GridLayoutManager
  extends LinearLayoutManager
{
  public static final int DEFAULT_SPAN_COUNT = -1;
  boolean a = false;
  int b = -1;
  int[] c;
  View[] d;
  final SparseIntArray e = new SparseIntArray();
  final SparseIntArray f = new SparseIntArray();
  SpanSizeLookup g = new DefaultSpanSizeLookup();
  final Rect h = new Rect();
  
  public GridLayoutManager(Context paramContext, int paramInt)
  {
    super(paramContext);
    setSpanCount(paramInt);
  }
  
  public GridLayoutManager(Context paramContext, int paramInt1, int paramInt2, boolean paramBoolean)
  {
    super(paramContext, paramInt2, paramBoolean);
    setSpanCount(paramInt1);
  }
  
  public GridLayoutManager(Context paramContext, AttributeSet paramAttributeSet, int paramInt1, int paramInt2)
  {
    super(paramContext, paramAttributeSet, paramInt1, paramInt2);
    setSpanCount(getProperties(paramContext, paramAttributeSet, paramInt1, paramInt2).spanCount);
  }
  
  private int a(RecyclerView.Recycler paramRecycler, RecyclerView.State paramState, int paramInt)
  {
    if (!paramState.isPreLayout()) {
      return this.g.getSpanGroupIndex(paramInt, this.b);
    }
    int i = paramRecycler.convertPreLayoutPositionToPostLayout(paramInt);
    if (i == -1)
    {
      Log.w("GridLayoutManager", "Cannot find span size for pre layout position. " + paramInt);
      return 0;
    }
    return this.g.getSpanGroupIndex(i, this.b);
  }
  
  private void a(RecyclerView.Recycler paramRecycler, RecyclerView.State paramState, int paramInt, boolean paramBoolean)
  {
    int i;
    int k;
    int j;
    if (paramBoolean)
    {
      i = 1;
      k = 0;
      j = paramInt;
      paramInt = k;
    }
    for (;;)
    {
      k = 0;
      while (paramInt != j)
      {
        View localView = this.d[paramInt];
        LayoutParams localLayoutParams = (LayoutParams)localView.getLayoutParams();
        localLayoutParams.b = c(paramRecycler, paramState, getPosition(localView));
        localLayoutParams.a = k;
        k += localLayoutParams.b;
        paramInt += i;
      }
      j = -1;
      paramInt -= 1;
      i = -1;
    }
  }
  
  private void a(View paramView, int paramInt1, int paramInt2, boolean paramBoolean)
  {
    RecyclerView.LayoutParams localLayoutParams = (RecyclerView.LayoutParams)paramView.getLayoutParams();
    if (paramBoolean) {
      if ((!this.v) || (!RecyclerView.LayoutManager.a(paramView.getMeasuredWidth(), paramInt1, localLayoutParams.width)) || (!RecyclerView.LayoutManager.a(paramView.getMeasuredHeight(), paramInt2, localLayoutParams.height))) {
        paramBoolean = true;
      }
    }
    for (;;)
    {
      if (paramBoolean) {
        paramView.measure(paramInt1, paramInt2);
      }
      return;
      paramBoolean = false;
      continue;
      paramBoolean = a(paramView, paramInt1, paramInt2, localLayoutParams);
    }
  }
  
  private void a(View paramView, int paramInt, boolean paramBoolean)
  {
    LayoutParams localLayoutParams = (LayoutParams)paramView.getLayoutParams();
    Rect localRect = localLayoutParams.d;
    int j = localRect.top + localRect.bottom + localLayoutParams.topMargin + localLayoutParams.bottomMargin;
    int i = localRect.left;
    int k = localRect.right;
    int m = localLayoutParams.leftMargin;
    i = localLayoutParams.rightMargin + (k + i + m);
    k = c(localLayoutParams.a, localLayoutParams.b);
    if (this.i == 1)
    {
      i = getChildMeasureSpec(k, paramInt, i, localLayoutParams.width, false);
      paramInt = getChildMeasureSpec(this.j.getTotalSpace(), getHeightMode(), j, localLayoutParams.height, true);
    }
    for (;;)
    {
      a(paramView, i, paramInt, paramBoolean);
      return;
      paramInt = getChildMeasureSpec(k, paramInt, j, localLayoutParams.height, false);
      i = getChildMeasureSpec(this.j.getTotalSpace(), getWidthMode(), i, localLayoutParams.width, true);
    }
  }
  
  private int b(RecyclerView.Recycler paramRecycler, RecyclerView.State paramState, int paramInt)
  {
    if (!paramState.isPreLayout()) {
      i = this.g.a(paramInt, this.b);
    }
    int j;
    do
    {
      return i;
      j = this.f.get(paramInt, -1);
      i = j;
    } while (j != -1);
    int i = paramRecycler.convertPreLayoutPositionToPostLayout(paramInt);
    if (i == -1)
    {
      Log.w("GridLayoutManager", "Cannot find span size for pre layout position. It is not cached, not in the adapter. Pos:" + paramInt);
      return 0;
    }
    return this.g.a(i, this.b);
  }
  
  private void b(int paramInt)
  {
    int k = 0;
    int[] arrayOfInt2 = this.c;
    int n = this.b;
    int[] arrayOfInt1;
    if ((arrayOfInt2 != null) && (arrayOfInt2.length == n + 1))
    {
      arrayOfInt1 = arrayOfInt2;
      if (arrayOfInt2[(arrayOfInt2.length - 1)] == paramInt) {}
    }
    else
    {
      arrayOfInt1 = new int[n + 1];
    }
    arrayOfInt1[0] = 0;
    int m = paramInt / n;
    int i1 = paramInt % n;
    int i = 1;
    int j = 0;
    paramInt = k;
    if (i <= n)
    {
      paramInt += i1;
      if ((paramInt <= 0) || (n - paramInt >= i1)) {
        break label137;
      }
      k = m + 1;
      paramInt -= n;
    }
    for (;;)
    {
      j += k;
      arrayOfInt1[i] = j;
      i += 1;
      break;
      this.c = arrayOfInt1;
      return;
      label137:
      k = m;
    }
  }
  
  private int c(int paramInt1, int paramInt2)
  {
    if ((this.i == 1) && (isLayoutRTL())) {
      return this.c[(this.b - paramInt1)] - this.c[(this.b - paramInt1 - paramInt2)];
    }
    return this.c[(paramInt1 + paramInt2)] - this.c[paramInt1];
  }
  
  private int c(RecyclerView.Recycler paramRecycler, RecyclerView.State paramState, int paramInt)
  {
    if (!paramState.isPreLayout()) {
      i = this.g.getSpanSize(paramInt);
    }
    int j;
    do
    {
      return i;
      j = this.e.get(paramInt, -1);
      i = j;
    } while (j != -1);
    int i = paramRecycler.convertPreLayoutPositionToPostLayout(paramInt);
    if (i == -1)
    {
      Log.w("GridLayoutManager", "Cannot find span size for pre layout position. It is not cached, not in the adapter. Pos:" + paramInt);
      return 1;
    }
    return this.g.getSpanSize(i);
  }
  
  private void d()
  {
    if (getOrientation() == 1) {}
    for (int i = getWidth() - getPaddingRight() - getPaddingLeft();; i = getHeight() - getPaddingBottom() - getPaddingTop())
    {
      b(i);
      return;
    }
  }
  
  private void e()
  {
    if ((this.d == null) || (this.d.length != this.b)) {
      this.d = new View[this.b];
    }
  }
  
  final View a(RecyclerView.Recycler paramRecycler, RecyclerView.State paramState, int paramInt1, int paramInt2, int paramInt3)
  {
    Object localObject1 = null;
    a();
    int j = this.j.getStartAfterPadding();
    int k = this.j.getEndAfterPadding();
    int i;
    Object localObject2;
    label37:
    View localView;
    if (paramInt2 > paramInt1)
    {
      i = 1;
      localObject2 = null;
      if (paramInt1 == paramInt2) {
        break label162;
      }
      localView = getChildAt(paramInt1);
      int m = getPosition(localView);
      if ((m < 0) || (m >= paramInt3) || (b(paramRecycler, paramState, m) != 0)) {
        break label177;
      }
      if (!((RecyclerView.LayoutParams)localView.getLayoutParams()).isItemRemoved()) {
        break label118;
      }
      if (localObject2 != null) {
        break label177;
      }
      localObject2 = localView;
    }
    label118:
    label162:
    label174:
    label177:
    for (;;)
    {
      paramInt1 += i;
      break label37;
      i = -1;
      break;
      Object localObject3;
      if (this.j.getDecoratedStart(localView) < k)
      {
        localObject3 = localView;
        if (this.j.getDecoratedEnd(localView) >= j) {}
      }
      else
      {
        if (localObject1 != null) {
          break label177;
        }
        localObject1 = localView;
        continue;
        if (localObject1 == null) {
          break label174;
        }
        localObject3 = localObject1;
      }
      return (View)localObject3;
      return (View)localObject2;
    }
  }
  
  final void a(RecyclerView.Recycler paramRecycler, RecyclerView.State paramState, LinearLayoutManager.a parama, int paramInt)
  {
    int i = 1;
    super.a(paramRecycler, paramState, parama, paramInt);
    d();
    if ((paramState.getItemCount() > 0) && (!paramState.isPreLayout()))
    {
      if (paramInt == 1) {}
      for (paramInt = i;; paramInt = 0)
      {
        i = b(paramRecycler, paramState, parama.a);
        if (paramInt == 0) {
          break;
        }
        while ((i > 0) && (parama.a > 0))
        {
          parama.a -= 1;
          i = b(paramRecycler, paramState, parama.a);
        }
      }
      int k = paramState.getItemCount();
      paramInt = parama.a;
      while (paramInt < k - 1)
      {
        int j = b(paramRecycler, paramState, paramInt + 1);
        if (j <= i) {
          break;
        }
        paramInt += 1;
        i = j;
      }
      parama.a = paramInt;
    }
    e();
  }
  
  final void a(RecyclerView.Recycler paramRecycler, RecyclerView.State paramState, LinearLayoutManager.b paramb, LinearLayoutManager.LayoutChunkResult paramLayoutChunkResult)
  {
    int i3 = this.j.getModeInOther();
    int j;
    int k;
    label38:
    boolean bool;
    label58:
    int i;
    int n;
    if (i3 != 1073741824)
    {
      j = 1;
      if (getChildCount() <= 0) {
        break label204;
      }
      k = this.c[this.b];
      if (j != 0) {
        d();
      }
      if (paramb.e != 1) {
        break label210;
      }
      bool = true;
      i = this.b;
      if (bool) {
        break label1122;
      }
      i = b(paramRecycler, paramState, paramb.d) + c(paramRecycler, paramState, paramb.d);
      n = 0;
    }
    for (;;)
    {
      int i1;
      label204:
      label210:
      Object localObject;
      if ((n < this.b) && (paramb.a(paramState)) && (i > 0))
      {
        m = paramb.d;
        i1 = c(paramRecycler, paramState, m);
        if (i1 > this.b)
        {
          throw new IllegalArgumentException("Item at position " + m + " requires " + i1 + " spans but GridLayoutManager has only " + this.b + " spans.");
          j = 0;
          break;
          k = 0;
          break label38;
          bool = false;
          break label58;
        }
        i -= i1;
        if (i >= 0)
        {
          localObject = paramb.a(paramRecycler);
          if (localObject != null)
          {
            this.d[n] = localObject;
            n += 1;
            continue;
          }
        }
      }
      if (n == 0)
      {
        paramLayoutChunkResult.mFinished = true;
        return;
      }
      i = 0;
      float f1 = 0.0F;
      a(paramRecycler, paramState, n, bool);
      int m = 0;
      label321:
      int i2;
      if (m < n)
      {
        paramRecycler = this.d[m];
        if (paramb.k == null) {
          if (bool)
          {
            addView(paramRecycler);
            calculateItemDecorationsForChild(paramRecycler, this.h);
            a(paramRecycler, i3, false);
            i2 = this.j.getDecoratedMeasurement(paramRecycler);
            i1 = i;
            if (i2 > i) {
              i1 = i2;
            }
            paramState = (LayoutParams)paramRecycler.getLayoutParams();
            float f2 = this.j.getDecoratedMeasurementInOther(paramRecycler) * 1.0F / paramState.b;
            if (f2 <= f1) {
              break label1119;
            }
            f1 = f2;
          }
        }
      }
      label539:
      label705:
      label819:
      label1035:
      label1071:
      label1107:
      label1116:
      label1119:
      for (;;)
      {
        m += 1;
        i = i1;
        break;
        addView(paramRecycler, 0);
        break label321;
        if (bool)
        {
          addDisappearingView(paramRecycler);
          break label321;
        }
        addDisappearingView(paramRecycler, 0);
        break label321;
        if (j != 0)
        {
          b(Math.max(Math.round(this.b * f1), k));
          i = 0;
          k = 0;
          j = i;
          if (k >= n) {
            break label539;
          }
          paramRecycler = this.d[k];
          a(paramRecycler, 1073741824, true);
          j = this.j.getDecoratedMeasurement(paramRecycler);
          if (j <= i) {
            break label1116;
          }
          i = j;
        }
        for (;;)
        {
          k += 1;
          break;
          j = i;
          i = 0;
          if (i < n)
          {
            paramRecycler = this.d[i];
            if (this.j.getDecoratedMeasurement(paramRecycler) != j)
            {
              paramState = (LayoutParams)paramRecycler.getLayoutParams();
              localObject = paramState.d;
              m = ((Rect)localObject).top + ((Rect)localObject).bottom + paramState.topMargin + paramState.bottomMargin;
              k = ((Rect)localObject).left;
              k = ((Rect)localObject).right + k + paramState.leftMargin + paramState.rightMargin;
              i1 = c(paramState.a, paramState.b);
              if (this.i != 1) {
                break label705;
              }
              k = getChildMeasureSpec(i1, 1073741824, k, paramState.width, false);
            }
            for (m = View.MeasureSpec.makeMeasureSpec(j - m, 1073741824);; m = getChildMeasureSpec(i1, 1073741824, m, paramState.height, false))
            {
              a(paramRecycler, k, m, true);
              i += 1;
              break;
              k = View.MeasureSpec.makeMeasureSpec(j - k, 1073741824);
            }
          }
          paramLayoutChunkResult.mConsumed = j;
          m = 0;
          if (this.i == 1) {
            if (paramb.f == -1)
            {
              i1 = paramb.b;
              k = 0;
              i = i1;
              j = i1 - j;
              int i4 = 0;
              i1 = k;
              i2 = j;
              i3 = m;
              k = i4;
              m = i;
              j = i1;
              i1 = i2;
              i = i3;
              if (k >= n) {
                break label1107;
              }
              paramRecycler = this.d[k];
              paramState = (LayoutParams)paramRecycler.getLayoutParams();
              if (this.i != 1) {
                break label1071;
              }
              if (!isLayoutRTL()) {
                break label1035;
              }
              j = getPaddingLeft() + this.c[(this.b - paramState.a)];
              i = j - this.j.getDecoratedMeasurementInOther(paramRecycler);
            }
          }
          for (;;)
          {
            layoutDecoratedWithMargins(paramRecycler, i, i1, j, m);
            if ((paramState.isItemRemoved()) || (paramState.isItemChanged())) {
              paramLayoutChunkResult.mIgnoreConsumed = true;
            }
            paramLayoutChunkResult.mFocusable |= paramRecycler.isFocusable();
            k += 1;
            break label819;
            k = paramb.b;
            i = j + k;
            i1 = 0;
            j = k;
            k = i1;
            break;
            if (paramb.f == -1)
            {
              k = paramb.b;
              m = k - j;
              i = 0;
              j = 0;
              break;
            }
            m = paramb.b;
            k = 0;
            i1 = j + m;
            i = 0;
            j = k;
            k = i1;
            break;
            i = getPaddingLeft();
            i = this.c[paramState.a] + i;
            j = i + this.j.getDecoratedMeasurementInOther(paramRecycler);
            continue;
            m = getPaddingTop();
            i1 = this.c[paramState.a] + m;
            m = i1 + this.j.getDecoratedMeasurementInOther(paramRecycler);
          }
          Arrays.fill(this.d, null);
          return;
        }
      }
      label1122:
      n = 0;
    }
  }
  
  final void a(RecyclerView.State paramState, LinearLayoutManager.b paramb, RecyclerView.LayoutManager.LayoutPrefetchRegistry paramLayoutPrefetchRegistry)
  {
    int j = this.b;
    int i = 0;
    while ((i < this.b) && (paramb.a(paramState)) && (j > 0))
    {
      int k = paramb.d;
      paramLayoutPrefetchRegistry.addPosition(k, paramb.g);
      j -= this.g.getSpanSize(k);
      paramb.d += paramb.e;
      i += 1;
    }
  }
  
  public boolean checkLayoutParams(RecyclerView.LayoutParams paramLayoutParams)
  {
    return paramLayoutParams instanceof LayoutParams;
  }
  
  public RecyclerView.LayoutParams generateDefaultLayoutParams()
  {
    if (this.i == 0) {
      return new LayoutParams(-2, -1);
    }
    return new LayoutParams(-1, -2);
  }
  
  public RecyclerView.LayoutParams generateLayoutParams(Context paramContext, AttributeSet paramAttributeSet)
  {
    return new LayoutParams(paramContext, paramAttributeSet);
  }
  
  public RecyclerView.LayoutParams generateLayoutParams(ViewGroup.LayoutParams paramLayoutParams)
  {
    if ((paramLayoutParams instanceof ViewGroup.MarginLayoutParams)) {
      return new LayoutParams((ViewGroup.MarginLayoutParams)paramLayoutParams);
    }
    return new LayoutParams(paramLayoutParams);
  }
  
  public int getColumnCountForAccessibility(RecyclerView.Recycler paramRecycler, RecyclerView.State paramState)
  {
    if (this.i == 1) {
      return this.b;
    }
    if (paramState.getItemCount() <= 0) {
      return 0;
    }
    return a(paramRecycler, paramState, paramState.getItemCount() - 1) + 1;
  }
  
  public int getRowCountForAccessibility(RecyclerView.Recycler paramRecycler, RecyclerView.State paramState)
  {
    if (this.i == 0) {
      return this.b;
    }
    if (paramState.getItemCount() <= 0) {
      return 0;
    }
    return a(paramRecycler, paramState, paramState.getItemCount() - 1) + 1;
  }
  
  public int getSpanCount()
  {
    return this.b;
  }
  
  public SpanSizeLookup getSpanSizeLookup()
  {
    return this.g;
  }
  
  public View onFocusSearchFailed(View paramView, int paramInt, RecyclerView.Recycler paramRecycler, RecyclerView.State paramState)
  {
    View localView = findContainingItemView(paramView);
    if (localView == null) {
      paramRecycler = null;
    }
    LayoutParams localLayoutParams;
    int i4;
    int i5;
    int i8;
    label83:
    int m;
    int k;
    label100:
    int n;
    label118:
    int i;
    int j;
    int i1;
    label129:
    int i6;
    int i7;
    do
    {
      return paramRecycler;
      localLayoutParams = (LayoutParams)localView.getLayoutParams();
      i4 = localLayoutParams.a;
      i5 = localLayoutParams.a + localLayoutParams.b;
      if (super.onFocusSearchFailed(paramView, paramInt, paramRecycler, paramState) == null) {
        return null;
      }
      if (a(paramInt) != 1) {
        break label258;
      }
      i8 = 1;
      if (i8 == this.k) {
        break label264;
      }
      paramInt = 1;
      if (paramInt == 0) {
        break label269;
      }
      paramInt = getChildCount() - 1;
      m = -1;
      k = -1;
      if ((this.i != 1) || (!isLayoutRTL())) {
        break label283;
      }
      n = 1;
      paramView = null;
      i = -1;
      j = 0;
      i1 = paramInt;
      if (i1 == k) {
        break label361;
      }
      paramState = getChildAt(i1);
      if (paramState == localView) {
        break label361;
      }
      if (!paramState.isFocusable()) {
        break label363;
      }
      localLayoutParams = (LayoutParams)paramState.getLayoutParams();
      i6 = localLayoutParams.a;
      i7 = localLayoutParams.a + localLayoutParams.b;
      if (i6 != i4) {
        break;
      }
      paramRecycler = paramState;
    } while (i7 == i5);
    int i3 = 0;
    if (paramView == null)
    {
      paramInt = 1;
      label215:
      if (paramInt == 0) {
        break label363;
      }
      i = localLayoutParams.a;
      paramInt = Math.min(i7, i5) - Math.max(i6, i4);
      paramView = paramState;
    }
    for (;;)
    {
      i1 += m;
      j = paramInt;
      break label129;
      label258:
      i8 = 0;
      break;
      label264:
      paramInt = 0;
      break label83;
      label269:
      k = getChildCount();
      paramInt = 0;
      m = 1;
      break label100;
      label283:
      n = 0;
      break label118;
      paramInt = Math.max(i6, i4);
      int i2 = Math.min(i7, i5) - paramInt;
      if (i2 > j)
      {
        paramInt = 1;
        break label215;
      }
      paramInt = i3;
      if (i2 != j) {
        break label215;
      }
      if (i6 > i) {}
      for (i2 = 1;; i2 = 0)
      {
        paramInt = i3;
        if (n != i2) {
          break;
        }
        paramInt = 1;
        break;
      }
      label361:
      return paramView;
      label363:
      paramInt = j;
    }
  }
  
  public void onInitializeAccessibilityNodeInfoForItem(RecyclerView.Recycler paramRecycler, RecyclerView.State paramState, View paramView, AccessibilityNodeInfoCompat paramAccessibilityNodeInfoCompat)
  {
    ViewGroup.LayoutParams localLayoutParams = paramView.getLayoutParams();
    if (!(localLayoutParams instanceof LayoutParams))
    {
      super.a(paramView, paramAccessibilityNodeInfoCompat);
      return;
    }
    paramView = (LayoutParams)localLayoutParams;
    int i = a(paramRecycler, paramState, paramView.getViewLayoutPosition());
    if (this.i == 0)
    {
      j = paramView.getSpanIndex();
      k = paramView.getSpanSize();
      if ((this.b > 1) && (paramView.getSpanSize() == this.b)) {}
      for (bool = true;; bool = false)
      {
        paramAccessibilityNodeInfoCompat.setCollectionItemInfo(AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(j, k, i, 1, bool, false));
        return;
      }
    }
    int j = paramView.getSpanIndex();
    int k = paramView.getSpanSize();
    if ((this.b > 1) && (paramView.getSpanSize() == this.b)) {}
    for (boolean bool = true;; bool = false)
    {
      paramAccessibilityNodeInfoCompat.setCollectionItemInfo(AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(i, 1, j, k, bool, false));
      return;
    }
  }
  
  public void onItemsAdded(RecyclerView paramRecyclerView, int paramInt1, int paramInt2)
  {
    this.g.invalidateSpanIndexCache();
  }
  
  public void onItemsChanged(RecyclerView paramRecyclerView)
  {
    this.g.invalidateSpanIndexCache();
  }
  
  public void onItemsMoved(RecyclerView paramRecyclerView, int paramInt1, int paramInt2, int paramInt3)
  {
    this.g.invalidateSpanIndexCache();
  }
  
  public void onItemsRemoved(RecyclerView paramRecyclerView, int paramInt1, int paramInt2)
  {
    this.g.invalidateSpanIndexCache();
  }
  
  public void onItemsUpdated(RecyclerView paramRecyclerView, int paramInt1, int paramInt2, Object paramObject)
  {
    this.g.invalidateSpanIndexCache();
  }
  
  public void onLayoutChildren(RecyclerView.Recycler paramRecycler, RecyclerView.State paramState)
  {
    if (paramState.isPreLayout())
    {
      int j = getChildCount();
      int i = 0;
      while (i < j)
      {
        LayoutParams localLayoutParams = (LayoutParams)getChildAt(i).getLayoutParams();
        int k = localLayoutParams.getViewLayoutPosition();
        this.e.put(k, localLayoutParams.getSpanSize());
        this.f.put(k, localLayoutParams.getSpanIndex());
        i += 1;
      }
    }
    super.onLayoutChildren(paramRecycler, paramState);
    this.e.clear();
    this.f.clear();
  }
  
  public void onLayoutCompleted(RecyclerView.State paramState)
  {
    super.onLayoutCompleted(paramState);
    this.a = false;
  }
  
  public int scrollHorizontallyBy(int paramInt, RecyclerView.Recycler paramRecycler, RecyclerView.State paramState)
  {
    d();
    e();
    return super.scrollHorizontallyBy(paramInt, paramRecycler, paramState);
  }
  
  public int scrollVerticallyBy(int paramInt, RecyclerView.Recycler paramRecycler, RecyclerView.State paramState)
  {
    d();
    e();
    return super.scrollVerticallyBy(paramInt, paramRecycler, paramState);
  }
  
  public void setMeasuredDimension(Rect paramRect, int paramInt1, int paramInt2)
  {
    if (this.c == null) {
      super.setMeasuredDimension(paramRect, paramInt1, paramInt2);
    }
    int i = getPaddingLeft();
    int j = getPaddingRight() + i;
    int k = getPaddingTop() + getPaddingBottom();
    if (this.i == 1)
    {
      i = chooseSize(paramInt2, k + paramRect.height(), getMinimumHeight());
      paramInt2 = chooseSize(paramInt1, j + this.c[(this.c.length - 1)], getMinimumWidth());
      paramInt1 = i;
    }
    for (;;)
    {
      setMeasuredDimension(paramInt2, paramInt1);
      return;
      i = chooseSize(paramInt1, j + paramRect.width(), getMinimumWidth());
      paramInt1 = chooseSize(paramInt2, k + this.c[(this.c.length - 1)], getMinimumHeight());
      paramInt2 = i;
    }
  }
  
  public void setSpanCount(int paramInt)
  {
    if (paramInt == this.b) {
      return;
    }
    this.a = true;
    if (paramInt <= 0) {
      throw new IllegalArgumentException("Span count should be at least 1. Provided " + paramInt);
    }
    this.b = paramInt;
    this.g.invalidateSpanIndexCache();
    requestLayout();
  }
  
  public void setSpanSizeLookup(SpanSizeLookup paramSpanSizeLookup)
  {
    this.g = paramSpanSizeLookup;
  }
  
  public void setStackFromEnd(boolean paramBoolean)
  {
    if (paramBoolean) {
      throw new UnsupportedOperationException("GridLayoutManager does not support stack from end. Consider using reverse layout");
    }
    super.setStackFromEnd(false);
  }
  
  public boolean supportsPredictiveItemAnimations()
  {
    return (this.n == null) && (!this.a);
  }
  
  public static final class DefaultSpanSizeLookup
    extends GridLayoutManager.SpanSizeLookup
  {
    public final int getSpanIndex(int paramInt1, int paramInt2)
    {
      return paramInt1 % paramInt2;
    }
    
    public final int getSpanSize(int paramInt)
    {
      return 1;
    }
  }
  
  public static class LayoutParams
    extends RecyclerView.LayoutParams
  {
    public static final int INVALID_SPAN_ID = -1;
    int a = -1;
    int b = 0;
    
    public LayoutParams(int paramInt1, int paramInt2)
    {
      super(paramInt2);
    }
    
    public LayoutParams(Context paramContext, AttributeSet paramAttributeSet)
    {
      super(paramAttributeSet);
    }
    
    public LayoutParams(RecyclerView.LayoutParams paramLayoutParams)
    {
      super();
    }
    
    public LayoutParams(ViewGroup.LayoutParams paramLayoutParams)
    {
      super();
    }
    
    public LayoutParams(ViewGroup.MarginLayoutParams paramMarginLayoutParams)
    {
      super();
    }
    
    public int getSpanIndex()
    {
      return this.a;
    }
    
    public int getSpanSize()
    {
      return this.b;
    }
  }
  
  public static abstract class SpanSizeLookup
  {
    final SparseIntArray a = new SparseIntArray();
    private boolean b = false;
    
    final int a(int paramInt1, int paramInt2)
    {
      int i;
      if (!this.b) {
        i = getSpanIndex(paramInt1, paramInt2);
      }
      int j;
      do
      {
        return i;
        j = this.a.get(paramInt1, -1);
        i = j;
      } while (j != -1);
      paramInt2 = getSpanIndex(paramInt1, paramInt2);
      this.a.put(paramInt1, paramInt2);
      return paramInt2;
    }
    
    public int getSpanGroupIndex(int paramInt1, int paramInt2)
    {
      int n = getSpanSize(paramInt1);
      int k = 0;
      int i = 0;
      int j = 0;
      int m;
      if (k < paramInt1)
      {
        m = getSpanSize(k);
        j += m;
        if (j == paramInt2)
        {
          j = i + 1;
          i = 0;
        }
      }
      for (;;)
      {
        m = k + 1;
        k = i;
        i = j;
        j = k;
        k = m;
        break;
        if (j > paramInt2)
        {
          j = i + 1;
          i = m;
          continue;
          paramInt1 = i;
          if (j + n > paramInt2) {
            paramInt1 = i + 1;
          }
          return paramInt1;
        }
        else
        {
          m = j;
          j = i;
          i = m;
        }
      }
    }
    
    public int getSpanIndex(int paramInt1, int paramInt2)
    {
      int n = getSpanSize(paramInt1);
      if (n == paramInt2) {
        return 0;
      }
      int j;
      int i;
      int k;
      if ((this.b) && (this.a.size() > 0))
      {
        j = this.a.size() - 1;
        i = 0;
        while (i <= j)
        {
          k = i + j >>> 1;
          if (this.a.keyAt(k) < paramInt1) {
            i = k + 1;
          } else {
            j = k - 1;
          }
        }
        i -= 1;
        if ((i >= 0) && (i < this.a.size()))
        {
          i = this.a.keyAt(i);
          if (i < 0) {
            break label216;
          }
          j = this.a.get(i) + getSpanSize(i);
          k = i + 1;
          i = j;
          j = k;
        }
      }
      for (;;)
      {
        label149:
        if (j < paramInt1)
        {
          k = getSpanSize(j);
          int m = i + k;
          if (m == paramInt2) {
            i = 0;
          }
          for (;;)
          {
            j += 1;
            break label149;
            i = -1;
            break;
            i = k;
            if (m <= paramInt2) {
              i = m;
            }
          }
        }
        if (i + n > paramInt2) {
          break;
        }
        return i;
        label216:
        j = 0;
        i = 0;
      }
    }
    
    public abstract int getSpanSize(int paramInt);
    
    public void invalidateSpanIndexCache()
    {
      this.a.clear();
    }
    
    public boolean isSpanIndexCacheEnabled()
    {
      return this.b;
    }
    
    public void setSpanIndexCacheEnabled(boolean paramBoolean)
    {
      this.b = paramBoolean;
    }
  }
}


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