Ejemplo n.º 1
0
        public int getLayoutDimension(int index, string name)
        {
            if (mRecycled)
            {
                throw new Exception("Cannot make calls to a recycled instance!");
            }
            index *= AssetManager.STYLE_NUM_ENTRIES;
            int[] data = mData;
            int   type = data[index + AssetManager.STYLE_TYPE];

            if (type >= TypedValue.TYPE_FIRST_INT &&
                type <= TypedValue.TYPE_LAST_INT)
            {
                return(data[index + AssetManager.STYLE_DATA]);
            }
            else if (type == TypedValue.TYPE_DIMENSION)
            {
                return(TypedValue.complexToDimensionPixelSize(
                           data[index + AssetManager.STYLE_DATA], mMetrics));
            }
            else if (type == TypedValue.TYPE_ATTRIBUTE)
            {
                throw new Exception("Failed to resolve attribute at index " + index);
            }

            //throw new Exception(getPositionDescription() + ": You must supply a " + name + " attribute.");
            throw new Exception("You must supply a " + name + " attribute.");
        }
Ejemplo n.º 2
0
        public int getLayoutDimension(int index, int defValue)
        {
            if (mRecycled)
            {
                throw new Exception("Cannot make calls to a recycled instance!");
            }

            index *= AssetManager.STYLE_NUM_ENTRIES;
            int[] data = mData;
            int   type = data[index + AssetManager.STYLE_TYPE];

            if (type >= TypedValue.TYPE_FIRST_INT && type <= TypedValue.TYPE_LAST_INT)
            {
                return(data[index + AssetManager.STYLE_DATA]);
            }

            else if (type == TypedValue.TYPE_DIMENSION)
            {
                return(TypedValue.complexToDimensionPixelSize(data[index + AssetManager.STYLE_DATA], mMetrics));
            }

            return(defValue);
        }
Ejemplo n.º 3
0
        public int getDimensionPixelSize(int index, int defValue)
        {
            if (mRecycled)
            {
                throw new Exception("Cannot make calls to a recycled instance!");
            }
            index *= AssetManager.STYLE_NUM_ENTRIES;
            int[] data = mData;
            int   type = data[index + AssetManager.STYLE_TYPE];

            if (type == TypedValue.TYPE_NULL)
            {
                return(defValue);
            }
            else if (type == TypedValue.TYPE_DIMENSION)
            {
                return(TypedValue.complexToDimensionPixelSize(data[index + AssetManager.STYLE_DATA], mMetrics));
            }
            else if (type == TypedValue.TYPE_ATTRIBUTE)
            {
                throw new Exception("Failed to resolve attribute at index " + index);
            }
            throw new Exception("Can't convert to dimension: type=0x" + type.ToString("X"));
        }