2929import android .view .ViewGroup ;
3030import android .view .accessibility .AccessibilityEvent ;
3131import android .view .accessibility .AccessibilityNodeInfo ;
32-
3332import com .android .internal .R ;
33+ import android .widget .RemoteViews .RemoteView ;
3434
3535import java .lang .reflect .Array ;
3636import java .util .ArrayList ;
146146 * @attr ref android.R.styleable#GridLayout_rowOrderPreserved
147147 * @attr ref android.R.styleable#GridLayout_columnOrderPreserved
148148 */
149+ @ RemoteView
149150public class GridLayout extends ViewGroup {
150151
151152 // Public constants
@@ -234,7 +235,6 @@ public class GridLayout extends ViewGroup {
234235
235236 final Axis horizontalAxis = new Axis (true );
236237 final Axis verticalAxis = new Axis (false );
237- boolean layoutParamsValid = false ;
238238 int orientation = DEFAULT_ORIENTATION ;
239239 boolean useDefaultMargins = DEFAULT_USE_DEFAULT_MARGINS ;
240240 int alignmentMode = DEFAULT_ALIGNMENT_MODE ;
@@ -713,12 +713,10 @@ private void validateLayoutParams() {
713713
714714 minor = minor + minorSpan ;
715715 }
716- lastLayoutParamsHashCode = computeLayoutParamsHashCode ();
717- invalidateStructure ();
718716 }
719717
720718 private void invalidateStructure () {
721- layoutParamsValid = false ;
719+ lastLayoutParamsHashCode = UNINITIALIZED_HASH ;
722720 horizontalAxis .invalidateStructure ();
723721 verticalAxis .invalidateStructure ();
724722 // This can end up being done twice. Better twice than not at all.
@@ -742,10 +740,6 @@ protected void onSetLayoutParams(View child, ViewGroup.LayoutParams layoutParams
742740 }
743741
744742 final LayoutParams getLayoutParams (View c ) {
745- if (!layoutParamsValid ) {
746- validateLayoutParams ();
747- layoutParamsValid = true ;
748- }
749743 return (LayoutParams ) c .getLayoutParams ();
750744 }
751745
@@ -874,20 +868,22 @@ private int computeLayoutParamsHashCode() {
874868 return result ;
875869 }
876870
877- private void checkForLayoutParamsModification () {
878- int layoutParamsHashCode = computeLayoutParamsHashCode ();
879- if ( lastLayoutParamsHashCode != UNINITIALIZED_HASH &&
880- lastLayoutParamsHashCode != layoutParamsHashCode ) {
881- invalidateStructure ();
871+ private void consistencyCheck () {
872+ if ( lastLayoutParamsHashCode == UNINITIALIZED_HASH ) {
873+ validateLayoutParams ();
874+ lastLayoutParamsHashCode = computeLayoutParamsHashCode ();
875+ } else if ( lastLayoutParamsHashCode != computeLayoutParamsHashCode ()) {
882876 Log .w (TAG , "The fields of some layout parameters were modified in between layout " +
883877 "operations. Check the javadoc for GridLayout.LayoutParams#rowSpec." );
878+ invalidateStructure ();
879+ consistencyCheck ();
884880 }
885881 }
886882
887883 // Measurement
888884
889885 private void measureChildWithMargins2 (View child , int parentWidthSpec , int parentHeightSpec ,
890- int childWidth , int childHeight ) {
886+ int childWidth , int childHeight ) {
891887 int childWidthSpec = getChildMeasureSpec (parentWidthSpec ,
892888 mPaddingLeft + mPaddingRight + getTotalMargin (child , true ), childWidth );
893889 int childHeightSpec = getChildMeasureSpec (parentHeightSpec ,
@@ -923,7 +919,7 @@ private void measureChildrenWithMargins(int widthSpec, int heightSpec, boolean f
923919
924920 @ Override
925921 protected void onMeasure (int widthSpec , int heightSpec ) {
926- checkForLayoutParamsModification ();
922+ consistencyCheck ();
927923
928924 /** If we have been called by {@link View#measure(int, int)}, one of width or height
929925 * is likely to have changed. We must invalidate if so. */
@@ -993,7 +989,7 @@ the grid (respectively!).
993989 */
994990 @ Override
995991 protected void onLayout (boolean changed , int left , int top , int right , int bottom ) {
996- checkForLayoutParamsModification ();
992+ consistencyCheck ();
997993
998994 int targetWidth = right - left ;
999995 int targetHeight = bottom - top ;
@@ -1250,7 +1246,7 @@ private PackedMap<Interval, MutableInt> getBackwardLinks() {
12501246 }
12511247
12521248 private void include (List <Arc > arcs , Interval key , MutableInt size ,
1253- boolean ignoreIfAlreadyPresent ) {
1249+ boolean ignoreIfAlreadyPresent ) {
12541250 /*
12551251 Remove self referential links.
12561252 These appear:
@@ -1429,8 +1425,8 @@ private String arcsToString(List<Arc> arcs) {
14291425 int dst = arc .span .max ;
14301426 int value = arc .value .value ;
14311427 result .append ((src < dst ) ?
1432- var + dst + " - " + var + src + " > " + value :
1433- var + src + " - " + var + dst + " < " + -value );
1428+ var + dst + "- " + var + src + ">= " + value :
1429+ var + src + "- " + var + dst + "<= " + -value );
14341430
14351431 }
14361432 return result .toString ();
0 commit comments