Java Code Examples for android.widget.ImageView.invalidate()

The following are Jave code examples for showing how to use invalidate() of the android.widget.ImageView class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: Oblique   File: ObliqueView.java   View Source Code Vote up 7 votes
private void setupBitmap(ImageView imageView, float width, float height) {
    Drawable drawable = imageView.getDrawable();
    if (drawable == null) {
        return;
    }
    try {
        bitmap = (drawable instanceof BitmapDrawable) ?
                ((BitmapDrawable) drawable).getBitmap() :
                Bitmap.createBitmap(drawable.getIntrinsicWidth(),
                        drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
    } catch (Exception e) {
        e.printStackTrace();
    }
    if (bitmap == null) {
        imageView.invalidate();
        return;
    }
    paint = new Paint(ANTI_ALIAS_FLAG);
    bitmapShader = new BitmapShader(bitmap, Shader.TileMode.CLAMP, Shader.TileMode.CLAMP);
    paint.setShader(bitmapShader);
    if (imageView.getScaleType() != ImageView.ScaleType.CENTER_CROP && imageView.getScaleType() != ImageView.ScaleType.FIT_XY) {
        imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
    }
    bitmapShader.setLocalMatrix(setUpScaleType(bitmap, imageView, width, height));
    imageView.invalidate();
}
 
Example 2
Project: PinchToZoom   File: FlingAnimatorHandler.java   View Source Code Vote up 7 votes
@Override
public void onAnimationUpdate(ValueAnimator animation) {
    ImageMatrixCorrector corrector = getCorrector();
    ImageView imageView = corrector.getImageView();
    Matrix matrix = imageView.getImageMatrix();
    float[] values = getValues();
    matrix.getValues(values);

    float dx = (float) animation.getAnimatedValue(PROPERTY_TRANSLATE_X);
    dx = corrector.correctAbsolute(Matrix.MTRANS_X, dx) - values[Matrix.MTRANS_X];

    float dy = (float) animation.getAnimatedValue(PROPERTY_TRANSLATE_Y);
    dy = corrector.correctAbsolute(Matrix.MTRANS_Y, dy) - values[Matrix.MTRANS_Y];

    matrix.postTranslate(dx, dy);
    imageView.invalidate();
}
 
Example 3
Project: PinchToZoom   File: ScaleAnimatorHandler.java   View Source Code Vote up 7 votes
@Override
public void onAnimationUpdate(ValueAnimator animation) {
    ImageMatrixCorrector corrector = getCorrector();
    ImageView imageView = corrector.getImageView();
    if(imageView.getDrawable() != null) {
        Matrix matrix = imageView.getImageMatrix();
        float[] values = getValues();
        matrix.getValues(values);

        float sx = (float) animation.getAnimatedValue();
        sx = corrector.correctAbsolute(Matrix.MSCALE_X, sx) / values[Matrix.MSCALE_X];

        if (translate) {
            matrix.postScale(sx, sx, px, py);
        } else {
            matrix.postScale(sx, sx);
        }
        corrector.performAbsoluteCorrections();
        imageView.invalidate();
    }
}
 
Example 4
Project: SnakeViewMaker   File: SnakeViewMaker.java   View Source Code Vote up 6 votes
public void updateSnakeImage() {
    if (null == mTargetView) return;
    updateTargetViewCache();
    for (ImageView child : mChildren) {
        child.setImageBitmap(mTargetBitmap);
        child.invalidate();
    }
}
 
Example 5
Project: ListItemView   File: ViewUtils.java   View Source Code Vote up 5 votes
public static void setIconColor(ImageView iconHolder, int color) {
    Drawable wrappedDrawable = DrawableCompat.wrap(iconHolder.getDrawable());
    DrawableCompat.setTint(wrappedDrawable, color);
    iconHolder.setImageDrawable(wrappedDrawable);
    iconHolder.invalidate();
}
 
Example 6
Project: microbit   File: CameraActivity_OldAPI.java   View Source Code Vote up 5 votes
public void onShutter() {
    ImageView blinkRect = (ImageView) findViewById(R.id.blink_rectangle);
    blinkRect.setVisibility(View.VISIBLE);
    blinkRect.bringToFront();
    blinkRect.invalidate();
}
 
Example 7
Project: microbit   File: CameraActivity_OldAPI.java   View Source Code Vote up 5 votes
void DrawBlink() {
    SystemClock.sleep(500);
    ImageView blinkRect = (ImageView) findViewById(R.id.blink_rectangle);
    blinkRect.setVisibility(View.INVISIBLE);
    blinkRect.invalidate();
}