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

The following examples show how to use android.widget.ImageView#invalidate() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: PinchToZoom   File: FlingAnimatorHandler.java    License: MIT License 6 votes vote down vote up
@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 2
Source Project: PinchToZoom   File: ScaleAnimatorHandler.java    License: MIT License 6 votes vote down vote up
@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 3
/**
 * Sets the thumbnail of given file, but only if there is a view for it at the moment
 *
 * @param file the file to display the thumbnail of
 */
private void displayThumbnail(IndexedFile file) {
	// Get the view associated with this file. However, note that the view might be assigned to
	// some other item already... so let's also check if the information is still up to date
	View v = mItemToView.get(file);
	int i = mViewToPositions.get(v);
	if (mContentItems.get(i) != file) {
		return; // information was out of date
	}

	if (file.getThumbnail() != null) {
		v.findViewById(R.id.content_texts).setVisibility(View.INVISIBLE);
		ImageView thumbImage = (ImageView) v.findViewById(R.id.file_preview);
		thumbImage.setImageBitmap(file.getThumbnail());
		thumbImage.invalidate();
	}
	else {
		Utils.d("We failed to get the bitmap :(");
	}
}
 
Example 4
Source Project: catnut   File: CatnutUtils.java    License: MIT License 6 votes vote down vote up
/**
 * inject a image touch overley
 * @param v
 * @param event
 */
public static boolean imageOverlay(View v, MotionEvent event) {
	ImageView view = (ImageView) v;
	switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:
			// overlay is black with transparency of 0x77 (119)
			view.getDrawable().setColorFilter(0x77000000, PorterDuff.Mode.SRC_ATOP);
			view.invalidate();
			break;
		case MotionEvent.ACTION_UP:
		case MotionEvent.ACTION_CANCEL: {
			// clear the overlay
			view.getDrawable().clearColorFilter();
			view.invalidate();
			break;
		}
	}
	return false;
}
 
Example 5
@Override
public void didReceivedNotification(int id, int account, Object... args){
    if(id==NotificationCenter.emojiDidLoaded){
        for(ImageView iv:keyEmojiViews){
            iv.invalidate();
        }
    }
    if(id==NotificationCenter.closeInCallActivity){
        finish();
    }
}
 
Example 6
@Override
public void didReceivedNotification(int id, int account, Object... args){
    if(id==NotificationCenter.emojiDidLoaded){
        for(ImageView iv:keyEmojiViews){
            iv.invalidate();
        }
    }
    if(id==NotificationCenter.closeInCallActivity){
        finish();
    }
}
 
Example 7
Source Project: AndroidWM   File: WatermarkBuilder.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * load a bitmap as background image from a ImageView.
 *
 * @param imageView the {@link ImageView} we need to use.
 */
private void backgroundFromImageView(ImageView imageView) {
    imageView.invalidate();
    if (imageView.getDrawable() != null) {
        BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
        if (resizeBackgroundImg) {
            backgroundImg = resizeBitmap(drawable.getBitmap(), MAX_IMAGE_SIZE);
        } else {
            backgroundImg = drawable.getBitmap();
        }
    }
}
 
Example 8
Source Project: AndroidWM   File: WatermarkImage.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * load a bitmap as watermark image from a ImageView.
 *
 * @param imageView the ImageView we need to use.
 */
private void watermarkFromImageView(ImageView imageView) {
    imageView.invalidate();
    BitmapDrawable drawable = (BitmapDrawable) imageView.getDrawable();
    // set the limitation of input bitmap.
    this.image = resizeBitmap(drawable.getBitmap(), MAX_IMAGE_SIZE);
}
 
Example 9
Source Project: belvedere   File: Utils.java    License: Apache License 2.0 5 votes vote down vote up
static void internalSetTint(ImageView imageView, int color) {
    if(imageView == null) {
        return;
    }

    Drawable d = DrawableCompat.wrap(imageView.getDrawable());
    if(d != null) {
        DrawableCompat.setTint(d.mutate(), color);
    }

    imageView.invalidate();
}
 
Example 10
/**
 * Invalidates the pressed/focused states.
 */
void invalidatePressedFocusedStates(ImageView v) {
    mStatesUpdated = false;
    if (v != null) {
        v.invalidate();
    }
}
 
Example 11
private static void setColor(ImageView image, TextView text, int color) {
    // set color
    GradientDrawable sd = (GradientDrawable) image.getDrawable();
    sd.setColor(color);
    image.invalidate();

    // set color name
    text.setText(getColorName(color));
}
 
Example 12
Source Project: catnut   File: ZhihuItemFragment.java    License: MIT License 5 votes vote down vote up
@Override
public void onClick(View v) {
	ImageView image = (ImageView) v;
	((ImageView) v).getDrawable().clearColorFilter();
	image.invalidate();
	Integer index = (Integer) v.getTag();
	Intent intent = SingleFragmentActivity.getIntent(getActivity(), SingleFragmentActivity.GALLERY);
	intent.putExtra(GalleryPagerFragment.CUR_INDEX, index);
	intent.putExtra(GalleryPagerFragment.URLS, mImageUrls);
	intent.putExtra(GalleryPagerFragment.TITLE, getString(R.string.view_photos));
	startActivity(intent);
}
 
Example 13
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.emojiDidLoad) {
        for (ImageView iv : keyEmojiViews) {
            iv.invalidate();
        }
    }
    if (id == NotificationCenter.closeInCallActivity) {
        finish();
    }
}
 
Example 14
Source Project: CrossBow   File: CrossbowImage.java    License: Apache License 2.0 5 votes vote down vote up
public void load() {
    ImageView imageView = this.imageView.get();
    if (imageView != null) {

        if(inProgressLoads.containsKey(imageView)) {
            inProgressLoads.get(imageView).cancelRequest();
            inProgressLoads.remove(imageView);
        }

        inProgressLoads.put(imageView, this);

        imageView.getViewTreeObserver().addOnPreDrawListener(this);
        imageView.invalidate(dirtyRect);
    }
}
 
Example 15
@Override
public void didReceivedNotification(int id, int account, Object... args) {
    if (id == NotificationCenter.emojiDidLoad) {
        for (ImageView iv : keyEmojiViews) {
            iv.invalidate();
        }
    }
    if (id == NotificationCenter.closeInCallActivity) {
        finish();
    }
}
 
Example 16
Source Project: microbit   File: CameraActivity_OldAPI.java    License: Apache License 2.0 4 votes vote down vote up
public void onShutter() {
    ImageView blinkRect = (ImageView) findViewById(R.id.blink_rectangle);
    blinkRect.setVisibility(View.VISIBLE);
    blinkRect.bringToFront();
    blinkRect.invalidate();
}
 
Example 17
Source Project: microbit   File: CameraActivity_OldAPI.java    License: Apache License 2.0 4 votes vote down vote up
void DrawBlink() {
    SystemClock.sleep(500);
    ImageView blinkRect = (ImageView) findViewById(R.id.blink_rectangle);
    blinkRect.setVisibility(View.INVISIBLE);
    blinkRect.invalidate();
}
 
Example 18
Source Project: floatingsearchview   File: Util.java    License: Apache License 2.0 4 votes vote down vote up
public static void setIconColor(ImageView iconHolder, int color) {
    Drawable wrappedDrawable = DrawableCompat.wrap(iconHolder.getDrawable());
    DrawableCompat.setTint(wrappedDrawable, color);
    iconHolder.setImageDrawable(wrappedDrawable);
    iconHolder.invalidate();
}
 
Example 19
Source Project: sketch   File: ScrollBarHelper.java    License: Apache License 2.0 4 votes vote down vote up
private void invalidateView() {
    ImageView imageView = imageZoomer.getImageView();
    if (imageView != null) {
        imageView.invalidate();
    }
}