Project: cow
package com.actionbarsherlock.internal.widget;
 
import android.view.View; 
import android.view.View.MeasureSpec; 
 
final class IcsView { 
    //No instances 
    private IcsView() {} 
 
    /**
     * Utility to reconcile a desired size and state, with constraints imposed 
     * by a MeasureSpec.  Will take the desired size, unless a different size 
     * is imposed by the constraints.  The returned value is a compound integer, 
     * with the resolved size in the {@link #MEASURED_SIZE_MASK} bits and 
     * optionally the bit {@link #MEASURED_STATE_TOO_SMALL} set if the resulting 
     * size is smaller than the size the view wants to be. 
     * 
     * @param size How big the view wants to be 
     * @param measureSpec Constraints imposed by the parent 
     * @return Size information bit mask as defined by 
     * {@link #MEASURED_SIZE_MASK} and {@link #MEASURED_STATE_TOO_SMALL}. 
     */
 
    public static int resolveSizeAndState(int size, int measureSpec, int childMeasuredState) { 
        int result = size; 
        int specMode = MeasureSpec.getMode(measureSpec); 
        int specSize =  MeasureSpec.getSize(measureSpec); 
        switch (specMode) { 
        case MeasureSpec.UNSPECIFIED: 
            result = size; 
            break
        case MeasureSpec.AT_MOST: 
            if (specSize < size) { 
                result = specSize | View.MEASURED_STATE_TOO_SMALL; 
            } else { 
                result = size; 
            } 
            break
        case MeasureSpec.EXACTLY: 
            result = specSize; 
            break
        } 
        return result | (childMeasuredState&View.MEASURED_STATE_MASK); 
    } 
 
    /**
     * Return only the state bits of {@link #getMeasuredWidthAndState()} 
     * and {@link #getMeasuredHeightAndState()}, combined into one integer. 
     * The width component is in the regular bits {@link #MEASURED_STATE_MASK} 
     * and the height component is at the shifted bits 
     * {@link #MEASURED_HEIGHT_STATE_SHIFT}>>{@link #MEASURED_STATE_MASK}. 
     */
 
    public static int getMeasuredStateInt(View child) { 
        return (child.getMeasuredWidth()&View.MEASURED_STATE_MASK) 
                | ((child.getMeasuredHeight()>>View.MEASURED_HEIGHT_STATE_SHIFT) 
                        & (View.MEASURED_STATE_MASK>>View.MEASURED_HEIGHT_STATE_SHIFT)); 
    } 
}