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

The following examples show how to use android.widget.ImageView#removeCallbacks() . 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: bither-android   File: RawDataDiceView.java    License: Apache License 2.0 6 votes vote down vote up
public void removeAllData() {
    int size = data.size();
    data.clear();
    for (int i = 0;
         i < size;
         i++) {
        final ImageView iv = (ImageView) ((FrameLayout) getChildAt(i)).getChildAt(0);
        if (iv.getVisibility() == View.VISIBLE) {
            ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF,
                    0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
            anim.setDuration(300);
            anim.setFillAfter(true);
            iv.startAnimation(anim);
            if (iv.getTag() != null && iv.getTag() instanceof HideIvRunnable) {
                iv.removeCallbacks((Runnable) iv.getTag());
            }
            HideIvRunnable r = new HideIvRunnable(iv);
            iv.setTag(r);
            iv.postDelayed(r, 300);
        }
    }
}
 
Example 2
Source Project: bither-android   File: RawDataDiceView.java    License: Apache License 2.0 6 votes vote down vote up
public void deleteLast() {
    int size = data.size();
    if (size <= 0) {
        return;
    }
    data.remove(size - 1);
    final ImageView iv = (ImageView) ((FrameLayout) getChildAt(size - 1)).getChildAt(0);
    if (iv.getVisibility() == View.VISIBLE) {
        ScaleAnimation anim = new ScaleAnimation(1, 0, 1, 0, Animation.RELATIVE_TO_SELF,
                0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        anim.setDuration(300);
        anim.setFillAfter(true);
        iv.startAnimation(anim);
        if (iv.getTag() != null && iv.getTag() instanceof HideIvRunnable) {
            iv.removeCallbacks((Runnable) iv.getTag());
        }
        HideIvRunnable r = new HideIvRunnable(iv);
        iv.setTag(r);
        iv.postDelayed(r, 300);
    }
}
 
Example 3
Source Project: bither-android   File: RawDataDiceView.java    License: Apache License 2.0 6 votes vote down vote up
public void addData(Dice d) {
    if (data.size() < dataLength()) {
        ImageView iv = (ImageView) ((FrameLayout) getChildAt(data.size())).getChildAt(0);
        if (iv.getTag() != null && iv.getTag() instanceof HideIvRunnable) {
            iv.removeCallbacks((Runnable) iv.getTag());
        }
        data.add(d);
        iv.setVisibility(View.INVISIBLE);
        iv.setImageResource(getDrawable(d));
        ScaleAnimation anim = new ScaleAnimation(0, 1, 0, 1, Animation.RELATIVE_TO_SELF,
                0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        anim.setDuration(300);
        iv.startAnimation(anim);
        iv.setVisibility(View.VISIBLE);
    }
}
 
Example 4
Source Project: sketch   File: LocationRunner.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 定位到预览图上指定的位置
 */
void location(int startX, int startY, int endX, int endY) {
    currentX = startX;
    currentY = startY;

    scroller.startScroll(startX, startY, endX - startX, endY - startY, 300);

    ImageView imageView = imageZoomer.getImageView();
    imageView.removeCallbacks(this);
    imageView.post(this);
}
 
Example 5
Source Project: sketch   File: LocationRunner.java    License: Apache License 2.0 4 votes vote down vote up
void cancel() {
    scroller.forceFinished(true);
    ImageView imageView = imageZoomer.getImageView();
    imageView.removeCallbacks(this);
}
 
Example 6
Source Project: sketch   File: FlingRunner.java    License: Apache License 2.0 4 votes vote down vote up
void fling(int velocityX, int velocityY) {
    if (!imageZoomer.isWorking()) {
        SLog.w(ImageZoomer.NAME, "not working. fling");
        return;
    }

    RectF drawRectF = new RectF();
    scaleDragHelper.getDrawRect(drawRectF);
    if (drawRectF.isEmpty()) {
        return;
    }

    Size viewSize = imageZoomer.getViewSize();
    final int imageViewWidth = viewSize.getWidth();
    final int imageViewHeight = viewSize.getHeight();

    final int startX = Math.round(-drawRectF.left);
    final int minX, maxX, minY, maxY;
    if (imageViewWidth < drawRectF.width()) {
        minX = 0;
        maxX = Math.round(drawRectF.width() - imageViewWidth);
    } else {
        minX = maxX = startX;
    }

    final int startY = Math.round(-drawRectF.top);
    if (imageViewHeight < drawRectF.height()) {
        minY = 0;
        maxY = Math.round(drawRectF.height() - imageViewHeight);
    } else {
        minY = maxY = startY;
    }

    if (SLog.isLoggable(SLog.LEVEL_DEBUG | SLog.TYPE_ZOOM)) {
        SLog.d(ImageZoomer.NAME, "fling. start=%dx %d, min=%dx%d, max=%dx%d",
                startX, startY, minX, minY, maxX, maxY);
    }

    // If we actually can move, fling the scroller
    if (startX != maxX || startY != maxY) {
        currentX = startX;
        currentY = startY;
        scroller.fling(startX, startY, velocityX, velocityY, minX,
                maxX, minY, maxY, 0, 0);
    }

    ImageView imageView = imageZoomer.getImageView();
    imageView.removeCallbacks(this);
    imageView.post(this);
}