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

The following examples show how to use android.widget.ImageView#post() . 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
@Override
public void setScale(float scale, float focalX, float focalY,
			boolean animate) {
 ImageView imageView = getImageView();

 if (null != imageView) {
  // Check to see if the scale is within bounds
  if (scale < mMinScale || scale > mMaxScale) {
   Log.i(LOG_TAG, "Scale must be within the range of minScale and maxScale");
   return;
  }

  if (animate) {
   imageView.post(new AnimatedZoomRunnable(getScale(), scale, focalX, focalY));
  } else {
   mSuppMatrix.setScale(scale, scale, focalX, focalY);
   checkAndDisplayMatrix();
  }
 }
}
 
Example 2
@Override
public void setScale(float scale, float focalX, float focalY,
                     boolean animate) {
    ImageView imageView = getImageView();

    if (null != imageView) {
        // Check to see if the scale is within bounds
        if (scale < mMinScale || scale > mMaxScale) {
            LogManager
                    .getLogger()
                    .i(LOG_TAG,
                            "Scale must be within the range of minScale and maxScale");
            return;
        }

        if (animate) {
            imageView.post(new AnimatedZoomRunnable(getScale(), scale,
                    focalX, focalY));
        } else {
            mSuppMatrix.setScale(scale, scale, focalX, focalY);
            checkAndDisplayMatrix();
        }
    }
}
 
Example 3
@Override
public void setScale(float scale, float focalX, float focalY,
                     boolean animate) {
    ImageView imageView = getImageView();

    if (null != imageView) {
        // Check to see if the scale is within bounds
        if (scale < mMinScale || scale > mMaxScale) {
            LogManager
                    .getLogger()
                    .i(LOG_TAG,
                            "Scale must be within the range of minScale and maxScale");
            return;
        }

        if (animate) {
            imageView.post(new AnimatedZoomRunnable(getScale(), scale,
                    focalX, focalY));
        } else {
            mSuppMatrix.setScale(scale, scale, focalX, focalY);
            checkAndDisplayMatrix();
        }
    }
}
 
Example 4
Source Project: zone-sdk   File: MeasureUtils.java    License: MIT License 6 votes vote down vote up
/**
 * 这个返回的 imageview show的宽高 既最后展现手机的像素(经过scaleType marix处理后的)
 */
public static void measureImage(final ImageView iv, final ImageListener mImageListener) {
    iv.post(new Runnable() {
        @Override
        public void run() {
            Drawable drawable = iv.getDrawable();
            Rect bounds = drawable.getBounds();
            Matrix mar = iv.getImageMatrix();
            float[] values = new float[9];
            mar.getValues(values);

            int imageShowX = (int) ((bounds.right - bounds.left) * values[0]);
            int imageShowY = (int) ((bounds.bottom - bounds.top) * values[4]);
            mImageListener.imageShowProperty(iv, values[2] < 0 ? 0 : values[2]
                    , values[5] < 0 ? 0 : values[5]
                    , imageShowX > iv.getWidth() ? iv.getWidth() : imageShowX
                    , imageShowY > iv.getHeight() ? iv.getHeight() : imageShowY);
        }
    });
}
 
Example 5
Source Project: MultiView   File: ImageViewScaler.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public void setScale(float scale, float focalX, float focalY,
                     boolean animate) {
    ImageView imageView = getImageView();

    if (null != imageView) {
        // Check to see if the scale is within bounds
        if (scale < mMinScale || scale > mMaxScale) {
            Log
                    .i("Scale must be within the range of minScale and maxScale");
            return;
        }

        if (animate) {
            imageView.post(new AnimatedZoomRunnable(getScale(), scale,
                    focalX, focalY));
        } else {
            mSuppMatrix.setScale(scale, scale, focalX, focalY);
            checkAndDisplayMatrix();
        }
    }
}
 
Example 6
@Override
public void setScale(float scale, float focalX, float focalY,
                     boolean animate) {
    ImageView imageView = getImageView();

    if (null != imageView) {
        // Check to see if the scale is within bounds
        if (scale < mMinScale || scale > mMaxScale) {
            LogManager
                    .getLogger()
                    .i(LOG_TAG,
                            "Scale must be within the range of minScale and maxScale");
            return;
        }

        if (animate) {
            imageView.post(new AnimatedZoomRunnable(getScale(), scale,
                    focalX, focalY));
        } else {
            mSuppMatrix.setScale(scale, scale, focalX, focalY);
            checkAndDisplayMatrix();
        }
    }
}
 
Example 7
@Override
public void setScale(float scale, float focalX, float focalY,
                     boolean animate) {
    ImageView imageView = getImageView();

    if (null != imageView) {
        // Check to see if the scale is within bounds
        if (scale < mMinScale || scale > mMaxScale) {
            LogManager
                    .getLogger()
                    .i(LOG_TAG,
                            "Scale must be within the range of minScale and maxScale");
            return;
        }

        if (animate) {
            imageView.post(new AnimatedZoomRunnable(getScale(), scale,
                    focalX, focalY));
        } else {
            mSuppMatrix.setScale(scale, scale, focalX, focalY);
            checkAndDisplayMatrix();
        }
    }
}
 
Example 8
private void addIndicatorDrawable(View itemView) {
    int indicatorRes = getIndicatorDrawableResource();
    if (indicatorRes != -1) {
        final ImageView imageView = itemView.findViewById(R.id.image);
        final Drawable indicatorOverlay
                = ContextCompat.getDrawable(itemView.getContext(), indicatorRes);
        imageView.post(new Runnable() {
            @Override
            public void run() {
                final int overlayPadding = (int) (imageView.getWidth() * 0.05f);
                final int overlayDimens = (int) (imageView.getWidth() * 0.3f);
                indicatorOverlay.setBounds(
                        imageView.getWidth() - overlayDimens - overlayPadding,
                        imageView.getHeight() - overlayDimens,
                        imageView.getWidth() - overlayPadding,
                        imageView.getHeight());
                imageView.getOverlay().add(indicatorOverlay);
            }
        });
    }
}
 
Example 9
@Override
public void onFling(float startX, float startY, float velocityX,
                          float velocityY) {
    if (DEBUG) {
        LogManager.getLogger().d(
                LOG_TAG,
                "onFling. sX: " + startX + " sY: " + startY + " Vx: "
                        + velocityX + " Vy: " + velocityY);
    }
    ImageView imageView = getImageView();
    mCurrentFlingRunnable = new FlingRunnable(imageView.getContext());
    mCurrentFlingRunnable.fling(getImageViewWidth(imageView),
            getImageViewHeight(imageView), (int) velocityX, (int) velocityY);
    imageView.post(mCurrentFlingRunnable);
}
 
Example 10
Source Project: aurora-imui   File: PhotoViewAttacher.java    License: MIT License 5 votes vote down vote up
@Override
public final void onFling(float startX, float startY, float velocityX, float velocityY) {
	if (DEBUG) {
		Log.d(LOG_TAG, "onFling. sX: " + startX + " sY: " + startY + " Vx: " + velocityX + " Vy: " + velocityY);
	}

	ImageView imageView = getImageView();
	if (hasDrawable(imageView)) {
		mCurrentFlingRunnable = new FlingRunnable(imageView.getContext());
		mCurrentFlingRunnable.fling(imageView.getWidth(), imageView.getHeight(), (int) velocityX, (int) velocityY);
		imageView.post(mCurrentFlingRunnable);
	}
}
 
Example 11
Source Project: Nimingban   File: PhotoViewAttacher.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void onFling(float startX, float startY, float velocityX,
                    float velocityY) {
    if (DEBUG) {
        LogManager.getLogger().d(
                LOG_TAG,
                "onFling. sX: " + startX + " sY: " + startY + " Vx: "
                        + velocityX + " Vy: " + velocityY);
    }
    ImageView imageView = getImageView();
    mCurrentFlingRunnable = new FlingRunnable(imageView.getContext());
    mCurrentFlingRunnable.fling(getImageViewWidth(imageView),
            getImageViewHeight(imageView), (int) velocityX, (int) velocityY);
    imageView.post(mCurrentFlingRunnable);
}
 
Example 12
@Override
protected void populateView(View v, Poem poem, int position) {
    final ImageView image = (ImageView) v.findViewById(R.id.poem_image);
    // TODO optimize that to avoid getIdentifier call
    try {
        final Theme t = Theme.valueOf(poem.getTheme().toUpperCase());
        final int poemImage = t.getImageList().get(poem.getImageId());
        image.post(new Runnable() {
            @Override
            public void run() {
                ImageLoader.getImageLoader().load(poemImage, image);
            }
        });
    } catch (Resources.NotFoundException ex) {
        //In case an identifier is removed from the list
    }

    String poemId = this.getRef(position).getKey();

    final ImageView shareImageView = (ImageView) v.findViewById(R.id.share);
    shareImageView.setTag(poemId);
    shareImageView.setOnClickListener(new OnShareClickListener(poem));

    final ImageView deleteImageView = (ImageView) v.findViewById(R.id.delete);
    deleteImageView.setTag(poemId);
    deleteImageView.setOnClickListener(new OnDeleteClickListener(poem));

    AvenirTextView text = (AvenirTextView) v.findViewById(R.id.poem_text);
    text.setText(poem.getText());

    text = (AvenirTextView) v.findViewById(R.id.poem_theme);
    text.setText("#" + poem.getTheme());
}
 
Example 13
Source Project: school_shop   File: PhotoViewAttacher.java    License: MIT License 5 votes vote down vote up
@Override
public final void onFling(float startX, float startY, float velocityX, float velocityY) {
	if (DEBUG) {
		Log.d(LOG_TAG, "onFling. sX: " + startX + " sY: " + startY + " Vx: " + velocityX + " Vy: " + velocityY);
	}

	ImageView imageView = getImageView();
	if (hasDrawable(imageView)) {
		mCurrentFlingRunnable = new FlingRunnable(imageView.getContext());
		mCurrentFlingRunnable.fling(imageView.getWidth(), imageView.getHeight(), (int) velocityX, (int) velocityY);
		imageView.post(mCurrentFlingRunnable);
	}
}
 
Example 14
public void saveFace(final String url, final ImageView ivGirlDetail) {
    if (!TextUtils.isEmpty(url)) {
        final String fileName = url.substring(url.lastIndexOf("/")+1);

        ivGirlDetail.post(new Runnable() {
            @Override
            public void run() {
                int width = ivGirlDetail.getWidth();
                int height = ivGirlDetail.getHeight();
                saveImageToSdCard(mContext, url, fileName,width,height);
            }
        });
    }
}
 
Example 15
Source Project: monolog-android   File: PhotoViewAttacher.java    License: MIT License 5 votes vote down vote up
@Override
public final void onFling(float startX, float startY, float velocityX, float velocityY) {
	if (DEBUG) {
		Log.d(LOG_TAG, "onFling. sX: " + startX + " sY: " + startY + " Vx: " + velocityX + " Vy: " + velocityY);
	}

	ImageView imageView = getImageView();
	if (hasDrawable(imageView)) {
		mCurrentFlingRunnable = new FlingRunnable(imageView.getContext());
		mCurrentFlingRunnable.fling(imageView.getWidth(), imageView.getHeight(), (int) velocityX, (int) velocityY);
		imageView.post(mCurrentFlingRunnable);
	}
}
 
Example 16
Source Project: monolog-android   File: PhotoViewAttacher.java    License: MIT License 5 votes vote down vote up
@Override
public final void zoomTo(float scale, float focalX, float focalY) {
	ImageView imageView = getImageView();

	if (null != imageView) {
		imageView.post(new AnimatedZoomRunnable(getScale(), scale, focalX, focalY));
	}
}
 
Example 17
Source Project: Social   File: PhotoViewAttacher.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public final void onFling(float startX, float startY, float velocityX, float velocityY) {
	if (DEBUG) {
		Log.d(LOG_TAG, "onFling. sX: " + startX + " sY: " + startY + " Vx: " + velocityX + " Vy: " + velocityY);
	}

	ImageView imageView = getImageView();
	if (hasDrawable(imageView)) {
		mCurrentFlingRunnable = new FlingRunnable(imageView.getContext());
		mCurrentFlingRunnable.fling(imageView.getWidth(), imageView.getHeight(), (int) velocityX, (int) velocityY);
		imageView.post(mCurrentFlingRunnable);
	}
}
 
Example 18
@Override
public void run() {
    while(true)
    {

        ThumbnailTask thumbnailTask = null;
        synchronized (this) {//在此段间隙中,可能poll==null后,add才执行,并在"mThread = null"前错误判断"mThread != null",导致不启动线程
            if(mTaskQueue.size()==0)
            {
                mThread = null;
                return;
            }
            thumbnailTask = mTaskQueue.poll();
            mTaskDoing = thumbnailTask;
            if (thumbnailTask == null)
            {
                mThread = null;
                return;
            }
        }

        Bitmap bitmap = null;

        if(bitmap == null) {
            bitmap = getThumbnail(thumbnailTask.mPath, thumbnailTask.mSize);
            if(bitmap!=null) {
                int itemSize = getBitmapSize(bitmap);
                mCacheLock.lock();
                mCache.add(new CacheItem(bitmap, thumbnailTask.mPath, thumbnailTask.mSize, itemSize));
                mCacheSize += itemSize;
                while (mCacheSize > MAX_CACHE_SIZE) {
                    CacheItem _cacheItem = mCache.poll();
                    if (_cacheItem == null)
                        break;
                    mCacheSize -= _cacheItem.mItemSize;
                }
                mCacheLock.unlock();
            }

        }
        if (bitmap != null&&thumbnailTask.mVisibility) {
            final ImageView imageView = thumbnailTask.mImageView;
            final Bitmap finalBitmap = bitmap;
            imageView.post(new Runnable() {
                @Override
                public void run() {
                    imageView.setImageBitmap(finalBitmap);
                }
            });
        }
    }

}
 
Example 19
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);
}
 
Example 20
/**
 * 设定结束动画,bitmap从透明度0f变为1f
 * @param activity
 */
private static void endBitmapAnimation(Activity activity) {
	final ImageView bitmapImageView = getThumbnailOriginalImageView(activity);
	bitmapImageView.setVisibility(View.INVISIBLE);
	/**
	 * 开始设定view开始时的大小和坐标位置
	 */
	LayoutParams orginalParams = new LayoutParams(
			ActivityOptionsCompatICS.getScreenWidth(activity), 
			ActivityOptionsCompatICS.getScreenHeight(activity));
	
	ViewGroup rootView = (ViewGroup)(activity.getWindow().getDecorView());
	rootView.addView(bitmapImageView, orginalParams);
	bitmapImageView.setX(0);
	bitmapImageView.setY(0);
	/**
	 * 根据两个activity是否是全屏来计算开始的坐标和偏移量
	 * 从全屏切换到不全屏会出现位置偏移,这里进行处理
	 */
	final int finalOffsetY;
	boolean isFinalFullScreen = ActivityOptionsCompatICS.isFullScreen(activity);
	if (mIsStartFullScreen == false && isFinalFullScreen == true) {
		finalOffsetY = ActivityOptionsCompatICS.getStatusBarHeight(activity);
	}
	else {
		finalOffsetY = 0;
	}
	final Rect finalBounds = new Rect(mStartX, mStartY, mStartX + mWidth,mStartY + mHeight);
	/**
	 * 这里可以设置动画的持续时间,开始延迟,添加监听器
	 */
	final ViewAnim anim = new ViewAnim();
	anim.setDuration((long) (mAnimTime));
	anim.setStartDelay(mStartDelay);
	anim.addListener(mViewAnimListener);
	anim.setTimeInterpolator(mInterpolator);
	bitmapImageView.post(new Runnable() {
		
		@Override
		public void run() {
			anim.startViewSimpleAnim(bitmapImageView, finalBounds, 0, finalOffsetY, 0f, 1f);
		}
	});
}