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

The following examples show how to use android.widget.ImageView#invalidate() . 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 check out the related API usage on the sidebar.
Example 1
Source File: CatnutUtils.java    From catnut with 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 2
Source File: FlingAnimatorHandler.java    From PinchToZoom with 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 3
Source File: ScaleAnimatorHandler.java    From PinchToZoom with 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 4
Source File: ContentAdapter.java    From droid-stealth with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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 5
Source File: HolographicViewHelper.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
/**
 * Invalidates the pressed/focused states.
 */
void invalidatePressedFocusedStates(ImageView v) {
    mStatesUpdated = false;
    if (v != null) {
        v.invalidate();
    }
}
 
Example 6
Source File: VoIPActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@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 7
Source File: CrossbowImage.java    From CrossBow with 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 8
Source File: VoIPActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@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 9
Source File: ZhihuItemFragment.java    From catnut with 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 10
Source File: StyleFragment.java    From android_maplibui with GNU Lesser General Public License v3.0 5 votes vote down vote up
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 11
Source File: VoIPActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@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 12
Source File: Utils.java    From belvedere with 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 13
Source File: WatermarkImage.java    From AndroidWM with 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 14
Source File: WatermarkBuilder.java    From AndroidWM with 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 15
Source File: VoIPActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@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 16
Source File: Util.java    From floatingsearchview with 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 17
Source File: CameraActivity_OldAPI.java    From microbit with 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 File: CameraActivity_OldAPI.java    From microbit with 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 19
Source File: ScrollBarHelper.java    From sketch with Apache License 2.0 4 votes vote down vote up
private void invalidateView() {
    ImageView imageView = imageZoomer.getImageView();
    if (imageView != null) {
        imageView.invalidate();
    }
}