use of android.graphics.drawable.Drawable in project platform_frameworks_base by android.
the class ApduServiceInfo method loadBanner.
public Drawable loadBanner(PackageManager pm) {
Resources res;
try {
res = pm.getResourcesForApplication(mService.serviceInfo.packageName);
Drawable banner = res.getDrawable(mBannerResourceId);
return banner;
} catch (NotFoundException e) {
Log.e(TAG, "Could not load banner.");
return null;
} catch (NameNotFoundException e) {
Log.e(TAG, "Could not load banner.");
return null;
}
}
use of android.graphics.drawable.Drawable in project platform_frameworks_base by android.
the class ChangeImageTransform method createAnimator.
/**
* Creates an Animator for ImageViews moving, changing dimensions, and/or changing
* {@link android.widget.ImageView.ScaleType}.
*
* @param sceneRoot The root of the transition hierarchy.
* @param startValues The values for a specific target in the start scene.
* @param endValues The values for the target in the end scene.
* @return An Animator to move an ImageView or null if the View is not an ImageView,
* the Drawable changed, the View is not VISIBLE, or there was no change.
*/
@Override
public Animator createAnimator(ViewGroup sceneRoot, TransitionValues startValues, TransitionValues endValues) {
if (startValues == null || endValues == null) {
return null;
}
Rect startBounds = (Rect) startValues.values.get(PROPNAME_BOUNDS);
Rect endBounds = (Rect) endValues.values.get(PROPNAME_BOUNDS);
if (startBounds == null || endBounds == null) {
return null;
}
Matrix startMatrix = (Matrix) startValues.values.get(PROPNAME_MATRIX);
Matrix endMatrix = (Matrix) endValues.values.get(PROPNAME_MATRIX);
boolean matricesEqual = (startMatrix == null && endMatrix == null) || (startMatrix != null && startMatrix.equals(endMatrix));
if (startBounds.equals(endBounds) && matricesEqual) {
return null;
}
ImageView imageView = (ImageView) endValues.view;
Drawable drawable = imageView.getDrawable();
int drawableWidth = drawable.getIntrinsicWidth();
int drawableHeight = drawable.getIntrinsicHeight();
ObjectAnimator animator;
if (drawableWidth == 0 || drawableHeight == 0) {
animator = createNullAnimator(imageView);
} else {
if (startMatrix == null) {
startMatrix = Matrix.IDENTITY_MATRIX;
}
if (endMatrix == null) {
endMatrix = Matrix.IDENTITY_MATRIX;
}
ANIMATED_TRANSFORM_PROPERTY.set(imageView, startMatrix);
animator = createMatrixAnimator(imageView, startMatrix, endMatrix);
}
return animator;
}
use of android.graphics.drawable.Drawable in project platform_frameworks_base by android.
the class DynamicDrawableSpan method getSize.
@Override
public int getSize(Paint paint, CharSequence text, int start, int end, Paint.FontMetricsInt fm) {
Drawable d = getCachedDrawable();
Rect rect = d.getBounds();
if (fm != null) {
fm.ascent = -rect.bottom;
fm.descent = 0;
fm.top = fm.ascent;
fm.bottom = 0;
}
return rect.right;
}
use of android.graphics.drawable.Drawable in project platform_frameworks_base by android.
the class DynamicDrawableSpan method draw.
@Override
public void draw(Canvas canvas, CharSequence text, int start, int end, float x, int top, int y, int bottom, Paint paint) {
Drawable b = getCachedDrawable();
canvas.save();
int transY = bottom - b.getBounds().bottom;
if (mVerticalAlignment == ALIGN_BASELINE) {
transY -= paint.getFontMetricsInt().descent;
}
canvas.translate(x, transY);
b.draw(canvas);
canvas.restore();
}
use of android.graphics.drawable.Drawable in project platform_frameworks_base by android.
the class ExpandableListView method drawDivider.
@Override
void drawDivider(Canvas canvas, Rect bounds, int childIndex) {
int flatListPosition = childIndex + mFirstPosition;
// all items, then the item below it has to be a group)
if (flatListPosition >= 0) {
final int adjustedPosition = getFlatPositionForConnector(flatListPosition);
PositionMetadata pos = mConnector.getUnflattenedPos(adjustedPosition);
// If this item is a child, or it is a non-empty group that is expanded
if ((pos.position.type == ExpandableListPosition.CHILD) || (pos.isExpanded() && pos.groupMetadata.lastChildFlPos != pos.groupMetadata.flPos)) {
// These are the cases where we draw the child divider
final Drawable divider = mChildDivider;
divider.setBounds(bounds);
divider.draw(canvas);
pos.recycle();
return;
}
pos.recycle();
}
// Otherwise draw the default divider
super.drawDivider(canvas, bounds, flatListPosition);
}
Aggregations