public AnalogClock(android.content.Context context, android.util.AttributeSet attrs , int defStyle) : base(context, attrs, defStyle) { mIntentReceiver = new _BroadcastReceiver_236(this); android.content.res.Resources r = mContext.getResources(); android.content.res.TypedArray a = context.obtainStyledAttributes(attrs, [email protected] .styleable.AnalogClock, defStyle, 0); mDial = a.getDrawable([email protected]_dial); if (mDial == null) { mDial = r.getDrawable([email protected]_dial); } mHourHand = a.getDrawable([email protected]_hand_hour); if (mHourHand == null) { mHourHand = r.getDrawable([email protected]_hand_hour); } mMinuteHand = a.getDrawable([email protected]_hand_minute ); if (mMinuteHand == null) { mMinuteHand = r.getDrawable([email protected]_hand_minute); } mCalendar = new android.text.format.Time(); mDialWidth = mDial.getIntrinsicWidth(); mDialHeight = mDial.getIntrinsicHeight(); }
private void init(android.content.Context context) { android.content.res.Resources res = context.getResources(); mShiftIcon = res.getDrawable([email protected]_keyboard_shift); mShiftLockIcon = res.getDrawable([email protected]_keyboard_shift_locked ); sSpacebarVerticalCorrection = res.getDimensionPixelOffset([email protected] .password_keyboard_spacebar_vertical_correction); }
/// <summary> /// @brief Retrieve drawable from resources of application given by package name /// /// Drawable is retrieved using PackageManager. /// </summary> /// <param name="packageName"> package name of the application to retrieve drawables from </param> /// <param name="drawableId"> id of the drawable to retrieve /// </param> /// <returns> Drawable or null in case of problems </returns> public virtual Drawable getApplicationDrawable(string packageName, int drawableId) { Context context = Context; if (null == context) { Log.w(TAG, "Cannot retrieve drawable from application (" + packageName + ") " + "as the context is null"); return(null); } if (drawableId < 0) { Log.w(TAG, "Cannot retrieve drawable of negative Id"); return(null); } PackageManager pm = context.PackageManager; Drawable drawable = null; try { Resources res = pm.getResourcesForApplication(packageName); drawable = res.getDrawable(drawableId); } catch (PackageManager.NameNotFoundException) { Log.w(TAG, "Cannot retrieve drawable from application (" + packageName + "): " + "name not found"); } return(drawable); }
/// <summary>Construct a new EdgeEffect with a theme appropriate for the provided context. /// </summary> /// <remarks>Construct a new EdgeEffect with a theme appropriate for the provided context. /// </remarks> /// <param name="context">Context used to provide theming and resource information for the EdgeEffect /// </param> public EdgeEffect(android.content.Context context) { // Time it will take the effect to fully recede in ms // Time it will take before a pulled glow begins receding in ms // Time it will take in ms for a pulled glow to decay to partial strength before release // Minimum velocity that will be absorbed // How much dragging should effect the height of the edge image. // Number determined by user testing. // How much dragging should effect the height of the glow image. // Number determined by user testing. android.content.res.Resources res = context.getResources(); mEdge = res.getDrawable([email protected]_edge); mGlow = res.getDrawable([email protected]_glow); mMinWidth = (int)(context.getResources().getDisplayMetrics().density *MIN_WIDTH + 0.5f); mInterpolator = new android.view.animation.DecelerateInterpolator(); }
public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs) { base.inflate(r, parser, attrs); int type; int low = 0; int innerDepth = parser.getDepth() + 1; int depth; while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT && ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG )) { if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG) { continue; } if (depth > innerDepth || !parser.getName().Equals("item")) { continue; } android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected]. styleable.LevelListDrawableItem); low = a.getInt([email protected]_minLevel, 0); int high = a.getInt([email protected]_maxLevel, 0); int drawableRes = a.getResourceId([email protected]_drawable , 0); a.recycle(); if (high < 0) { throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() + ": <item> tag requires a 'maxLevel' attribute"); } android.graphics.drawable.Drawable dr; if (drawableRes != 0) { dr = r.getDrawable(drawableRes); } else { while ((type = parser.next()) == org.xmlpull.v1.XmlPullParserClass.TEXT) { } if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG) { throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() + ": <item> tag requires a 'drawable' attribute or " + "child tag defining a drawable" ); } dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs); } mLevelListState.addLevel(low, high, dr); } onLevelChange(getLevel()); }
/// <summary>Allows enter key resources to be overridden</summary> /// <param name="res">resources to grab given items from</param> /// <param name="previewId">preview drawable shown on enter key</param> /// <param name="iconId">normal drawable shown on enter key</param> /// <param name="labelId">string shown on enter key</param> internal virtual void setEnterKeyResources(android.content.res.Resources res, int previewId, int iconId, int labelId) { if (mEnterKey != null) { // Reset some of the rarely used attributes. mEnterKey.popupCharacters = null; mEnterKey.popupResId = 0; mEnterKey.text = null; mEnterKey.iconPreview = res.getDrawable(previewId); mEnterKey.icon = res.getDrawable(iconId); mEnterKey.label = res.getText(labelId); // Set the initial size of the preview icon if (mEnterKey.iconPreview != null) { mEnterKey.iconPreview.setBounds(0, 0, mEnterKey.iconPreview.getIntrinsicWidth(), mEnterKey.iconPreview.getIntrinsicHeight()); } } }
private void initTabWidget() { setChildrenDrawingOrderEnabled(true); android.content.Context context = mContext; android.content.res.Resources resources = context.getResources(); // Tests the target Sdk version, as set in the Manifest. Could not be set using styles.xml // in a values-v? directory which targets the current platform Sdk version instead. if (context.getApplicationInfo().targetSdkVersion <= android.os.Build.VERSION_CODES .DONUT) { // Donut apps get old color scheme if (mLeftStrip == null) { mLeftStrip = resources.getDrawable([email protected]_bottom_left_v4 ); } if (mRightStrip == null) { mRightStrip = resources.getDrawable([email protected]_bottom_right_v4 ); } } else { // Use modern color scheme for Eclair and beyond if (mLeftStrip == null) { mLeftStrip = resources.getDrawable([email protected]_bottom_left); } if (mRightStrip == null) { mRightStrip = resources.getDrawable([email protected]_bottom_right ); } } // Deal with focus, as we don't want the focus to go by default // to a tab other than the current tab setFocusable(true); setOnFocusChangeListener(this); }
public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs) { android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected]. styleable.AnimatedRotateDrawable); base.inflateWithAttributes(r, parser, a, [email protected]_visible ); android.util.TypedValue tv = a.peekValue([email protected]_pivotX ); bool pivotXRel = tv.type == android.util.TypedValue.TYPE_FRACTION; float pivotX = pivotXRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat(); tv = a.peekValue([email protected]_pivotY); bool pivotYRel = tv.type == android.util.TypedValue.TYPE_FRACTION; float pivotY = pivotYRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat(); setFramesCount(a.getInt([email protected]_framesCount , 12)); setFramesDuration(a.getInt([email protected]_frameDuration , 150)); int res = a.getResourceId([email protected]_drawable , 0); android.graphics.drawable.Drawable drawable = null; if (res > 0) { drawable = r.getDrawable(res); } a.recycle(); int outerDepth = parser.getDepth(); int type; while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT && (type != org.xmlpull.v1.XmlPullParserClass.END_TAG || parser.getDepth() > outerDepth )) { if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG) { continue; } if ((drawable = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs)) == null) { android.util.Log.w("drawable", "Bad element under <animated-rotate>: " + parser.getName ()); } } if (drawable == null) { android.util.Log.w("drawable", "No drawable specified for <animated-rotate>"); } android.graphics.drawable.AnimatedRotateDrawable.AnimatedRotateState rotateState = mState; rotateState.mDrawable = drawable; rotateState.mPivotXRel = pivotXRel; rotateState.mPivotX = pivotX; rotateState.mPivotYRel = pivotYRel; rotateState.mPivotY = pivotY; init(); if (drawable != null) { drawable.setCallback(this); } }
public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs) { base.inflate(r, parser, attrs); int type; android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected]. styleable.LayerDrawable); mOpacityOverride = a.getInt([email protected]_opacity, android.graphics.PixelFormat.UNKNOWN); a.recycle(); int innerDepth = parser.getDepth() + 1; int depth; while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT && ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG )) { if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG) { continue; } if (depth > innerDepth || !parser.getName().Equals("item")) { continue; } a = r.obtainAttributes(attrs, [email protected]); int left = a.getDimensionPixelOffset([email protected]_left , 0); int top = a.getDimensionPixelOffset([email protected]_top , 0); int right = a.getDimensionPixelOffset([email protected]_right , 0); int bottom = a.getDimensionPixelOffset([email protected]_bottom , 0); int drawableRes = a.getResourceId([email protected]_drawable , 0); int id = a.getResourceId([email protected]_id, android.view.View .NO_ID); a.recycle(); android.graphics.drawable.Drawable dr; if (drawableRes != 0) { dr = r.getDrawable(drawableRes); } else { while ((type = parser.next()) == org.xmlpull.v1.XmlPullParserClass.TEXT) { } if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG) { throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() + ": <item> tag requires a 'drawable' attribute or " + "child tag defining a drawable" ); } dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs); } addLayer(dr, id, left, top, right, bottom); } ensurePadding(); onStateChange(getState()); }
public TargetDrawable(android.content.res.Resources res, int resId) : this(res, resId == 0 ? null : res.getDrawable(resId)) { }
private void resolveUri() { if (mDrawable != null) { return; } android.content.res.Resources rsrc = getResources(); if (rsrc == null) { return; } android.graphics.drawable.Drawable d = null; if (mResource != 0) { try { d = rsrc.getDrawable(mResource); } catch (System.Exception e) { android.util.Log.w("ImageView", "Unable to find resource: " + mResource, e); // Don't try again. mUri = null; } } else { if (mUri != null) { string scheme = mUri.Scheme; if (android.content.ContentResolver.SCHEME_ANDROID_RESOURCE.Equals(scheme)) { try { // Load drawable through Resources, to get the source density information android.content.ContentResolver.OpenResourceIdResult r = mContext.getContentResolver ().getResourceId(mUri); d = r.r.getDrawable(r.id); } catch (System.Exception e) { android.util.Log.w("ImageView", "Unable to open content: " + mUri, e); } } else { if (android.content.ContentResolver.SCHEME_CONTENT.Equals(scheme) || android.content.ContentResolver .SCHEME_FILE.Equals(scheme)) { try { d = android.graphics.drawable.Drawable.createFromStream(mContext.getContentResolver ().openInputStream(mUri), null); } catch (System.Exception e) { android.util.Log.w("ImageView", "Unable to open content: " + mUri, e); } } else { d = android.graphics.drawable.Drawable.createFromPath(mUri.ToString()); } } if (d == null) { java.io.Console.Out.println("resolveUri failed on bad bitmap uri: " + mUri); // Don't try again. mUri = null; } } else { return; } } updateDrawable(d); }
public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs) { android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected]. styleable.AnimationDrawable); base.inflateWithAttributes(r, parser, a, [email protected]_visible ); mAnimationState.setVariablePadding(a.getBoolean([email protected]_variablePadding , false)); mAnimationState.mOneShot = a.getBoolean([email protected]_oneshot , false); a.recycle(); int type; int innerDepth = parser.getDepth() + 1; int depth; while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT && ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG )) { if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG) { continue; } if (depth > innerDepth || !parser.getName().Equals("item")) { continue; } a = r.obtainAttributes(attrs, [email protected] ); int duration = a.getInt([email protected]_duration , -1); if (duration < 0) { throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() + ": <item> tag requires a 'duration' attribute"); } int drawableRes = a.getResourceId([email protected]_drawable , 0); a.recycle(); android.graphics.drawable.Drawable dr; if (drawableRes != 0) { dr = r.getDrawable(drawableRes); } else { while ((type = parser.next()) == org.xmlpull.v1.XmlPullParserClass.TEXT) { } // Empty if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG) { throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() + ": <item> tag requires a 'drawable' attribute or child tag" + " defining a drawable" ); } dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs); } mAnimationState.addFrame(dr, duration); if (dr != null) { dr.setCallback(this); } } setFrame(0, true, false); }
public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs) { android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected]. styleable.StateListDrawable); base.inflateWithAttributes(r, parser, a, [email protected]_visible ); mStateListState.setVariablePadding(a.getBoolean([email protected]_variablePadding , false)); mStateListState.setConstantSize(a.getBoolean([email protected]_constantSize , false)); mStateListState.setEnterFadeDuration(a.getInt([email protected]_enterFadeDuration , 0)); mStateListState.setExitFadeDuration(a.getInt([email protected]_exitFadeDuration , 0)); setDither(a.getBoolean([email protected]_dither, DEFAULT_DITHER )); a.recycle(); int type; int innerDepth = parser.getDepth() + 1; int depth; while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT && ((depth = parser.getDepth()) >= innerDepth || type != org.xmlpull.v1.XmlPullParserClass.END_TAG )) { if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG) { continue; } if (depth > innerDepth || !parser.getName().Equals("item")) { continue; } int drawableRes = 0; int i; int j = 0; int numAttrs = attrs.getAttributeCount(); int[] states = new int[numAttrs]; for (i = 0; i < numAttrs; i++) { int stateResId = attrs.getAttributeNameResource(i); if (stateResId == 0) { break; } if (stateResId == [email protected]) { drawableRes = attrs.getAttributeResourceValue(i, 0); } else { states[j++] = attrs.getAttributeBooleanValue(i, false) ? stateResId : -stateResId; } } states = android.util.StateSet.trimStateSet(states, j); android.graphics.drawable.Drawable dr; if (drawableRes != 0) { dr = r.getDrawable(drawableRes); } else { while ((type = parser.next()) == org.xmlpull.v1.XmlPullParserClass.TEXT) { } if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG) { throw new org.xmlpull.v1.XmlPullParserException(parser.getPositionDescription() + ": <item> tag requires a 'drawable' attribute or " + "child tag defining a drawable" ); } dr = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs); } mStateListState.addStateSet(states, dr); } onStateChange(getState()); }
public override void inflate(android.content.res.Resources r, org.xmlpull.v1.XmlPullParser parser, android.util.AttributeSet attrs) { android.content.res.TypedArray a = r.obtainAttributes(attrs, [email protected]. styleable.RotateDrawable); base.inflateWithAttributes(r, parser, a, [email protected]_visible ); android.util.TypedValue tv = a.peekValue([email protected]_pivotX ); bool pivotXRel; float pivotX; if (tv == null) { pivotXRel = true; pivotX = 0.5f; } else { pivotXRel = tv.type == android.util.TypedValue.TYPE_FRACTION; pivotX = pivotXRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat(); } tv = a.peekValue([email protected]_pivotY); bool pivotYRel; float pivotY; if (tv == null) { pivotYRel = true; pivotY = 0.5f; } else { pivotYRel = tv.type == android.util.TypedValue.TYPE_FRACTION; pivotY = pivotYRel ? tv.getFraction(1.0f, 1.0f) : tv.getFloat(); } float fromDegrees = a.getFloat([email protected]_fromDegrees , 0.0f); float toDegrees = a.getFloat([email protected]_toDegrees , 360.0f); int res = a.getResourceId([email protected]_drawable, 0); android.graphics.drawable.Drawable drawable = null; if (res > 0) { drawable = r.getDrawable(res); } a.recycle(); int outerDepth = parser.getDepth(); int type; while ((type = parser.next()) != org.xmlpull.v1.XmlPullParserClass.END_DOCUMENT && (type != org.xmlpull.v1.XmlPullParserClass.END_TAG || parser.getDepth() > outerDepth )) { if (type != org.xmlpull.v1.XmlPullParserClass.START_TAG) { continue; } if ((drawable = android.graphics.drawable.Drawable.createFromXmlInner(r, parser, attrs)) == null) { android.util.Log.w("drawable", "Bad element under <rotate>: " + parser.getName()); } } if (drawable == null) { android.util.Log.w("drawable", "No drawable specified for <rotate>"); } mState.mDrawable = drawable; mState.mPivotXRel = pivotXRel; mState.mPivotX = pivotX; mState.mPivotYRel = pivotYRel; mState.mPivotY = pivotY; mState.mFromDegrees = mState.mCurrentDegrees = fromDegrees; mState.mToDegrees = toDegrees; if (drawable != null) { drawable.setCallback(this); } }