use of android.widget.ImageView in project weiciyuan by qii.
the class GalleryActivity method onBackPressed.
@Override
public void onBackPressed() {
if (rect == null || urls.size() > 1) {
super.onBackPressed();
return;
}
View view = pager.findViewWithTag(CURRENT_VISIBLE_PAGE);
final PhotoView imageView = (PhotoView) view.findViewById(R.id.image);
if (imageView == null || (!(imageView.getDrawable() instanceof BitmapDrawable))) {
super.onBackPressed();
return;
}
animateClose(imageView);
}
use of android.widget.ImageView in project weiciyuan by qii.
the class GalleryActivity method handlePage.
private void handlePage(int position, View contentView, boolean fromInstantiateItem) {
final PhotoView imageView = (PhotoView) contentView.findViewById(R.id.image);
imageView.setVisibility(View.INVISIBLE);
if (SettingUtility.allowClickToCloseGallery()) {
imageView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
@Override
public void onPhotoTap(View view, float x, float y) {
if (rect == null || imageView == null || (!(imageView.getDrawable() instanceof BitmapDrawable))) {
GalleryActivity.this.finish();
return;
}
animateClose(imageView);
}
});
}
WebView gif = (WebView) contentView.findViewById(R.id.gif);
gif.setBackgroundColor(getResources().getColor(R.color.transparent));
gif.setVisibility(View.INVISIBLE);
WebView large = (WebView) contentView.findViewById(R.id.large);
large.setBackgroundColor(getResources().getColor(R.color.transparent));
large.setVisibility(View.INVISIBLE);
large.setOverScrollMode(View.OVER_SCROLL_NEVER);
if (Utility.doThisDeviceOwnNavigationBar(GalleryActivity.this)) {
imageView.setPadding(0, 0, 0, Utility.dip2px(NAVIGATION_BAR_HEIGHT_DP_UNIT));
//webview has a bug, padding is ignored
gif.setPadding(0, 0, 0, Utility.dip2px(NAVIGATION_BAR_HEIGHT_DP_UNIT));
large.setPadding(0, 0, 0, Utility.dip2px(NAVIGATION_BAR_HEIGHT_DP_UNIT));
}
TextView wait = (TextView) contentView.findViewById(R.id.wait);
TextView readError = (TextView) contentView.findViewById(R.id.error);
String path = FileManager.getFilePathFromUrl(urls.get(position), FileLocationMethod.picture_large);
boolean shouldDownLoadPicture = !fromInstantiateItem || (fromInstantiateItem && Utility.isWifi(GalleryActivity.this));
//sometime picture is not downloaded completely, but android already can read it....
if (ImageUtility.isThisBitmapCanRead(path) && taskMap.get(urls.get(position)) == null && TaskCache.isThisUrlTaskFinished(urls.get(position))) {
wait.setVisibility(View.INVISIBLE);
readPicture(imageView, gif, large, readError, urls.get(position), path);
} else if (shouldDownLoadPicture) {
final CircleProgressView spinner = (CircleProgressView) contentView.findViewById(R.id.loading);
spinner.setVisibility(View.VISIBLE);
if (taskMap.get(urls.get(position)) == null) {
wait.setVisibility(View.VISIBLE);
PicSimpleBitmapWorkerTask task = new PicSimpleBitmapWorkerTask(imageView, gif, large, spinner, wait, readError, urls.get(position), taskMap);
taskMap.put(urls.get(position), task);
task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
} else {
PicSimpleBitmapWorkerTask task = taskMap.get(urls.get(position));
task.setWidget(imageView, gif, spinner, wait, readError);
}
}
}
use of android.widget.ImageView in project weiciyuan by qii.
the class AnimationRect method buildFromImageView.
public static AnimationRect buildFromImageView(ImageView imageView) {
AnimationRect rect = new AnimationRect();
rect.isScreenPortrait = Utility.isDevicePort();
Drawable drawable = imageView.getDrawable();
Bitmap bitmap = null;
if (drawable instanceof BitmapDrawable) {
bitmap = ((BitmapDrawable) drawable).getBitmap();
}
if (bitmap == null) {
return null;
}
rect.widgetWidth = imageView.getWidth();
rect.widgetHeight = imageView.getHeight();
rect.thumbnailWidthHeightRatio = (float) bitmap.getWidth() / (float) bitmap.getHeight();
rect.thumbnailWidth = bitmap.getWidth();
rect.thumbnailHeight = bitmap.getHeight();
rect.imageViewEntireRect = new Rect();
int[] location = new int[2];
imageView.getLocationOnScreen(location);
rect.imageViewEntireRect.left = location[0];
rect.imageViewEntireRect.top = location[1];
rect.imageViewEntireRect.right = rect.imageViewEntireRect.left + imageView.getWidth();
rect.imageViewEntireRect.bottom = rect.imageViewEntireRect.top + imageView.getHeight();
rect.imageViewVisibleRect = new Rect();
boolean isVisible = imageView.getGlobalVisibleRect(rect.imageViewVisibleRect);
boolean checkWidth = rect.imageViewVisibleRect.width() < imageView.getWidth();
boolean checkHeight = rect.imageViewVisibleRect.height() < imageView.getHeight();
rect.isTotalVisible = isVisible && !checkWidth && !checkHeight;
rect.isTotalInvisible = !isVisible;
ImageView.ScaleType scaledType = imageView.getScaleType();
Rect scaledBitmapRect = new Rect(rect.imageViewEntireRect);
int bitmapWidth = bitmap.getWidth();
int bitmapHeight = bitmap.getHeight();
int imageViewWidth = imageView.getWidth();
int imageViewHeight = imageView.getHeight();
float startScale;
int deltaX;
int deltaY;
switch(scaledType) {
case CENTER_CROP:
if ((float) imageViewWidth / bitmapWidth > (float) imageViewHeight / bitmapHeight) {
startScale = (float) imageViewWidth / bitmapWidth;
rect.type = TYPE_CLIP_V;
} else {
startScale = (float) imageViewHeight / bitmapHeight;
rect.type = TYPE_CLIP_H;
}
bitmapHeight = (int) (bitmapHeight * startScale);
bitmapWidth = (int) (bitmapWidth * startScale);
deltaX = (imageViewWidth - bitmapWidth) / 2;
deltaY = (imageViewHeight - bitmapHeight) / 2;
scaledBitmapRect.set(scaledBitmapRect.left + deltaX, scaledBitmapRect.top + deltaY, scaledBitmapRect.right - deltaX, scaledBitmapRect.bottom - deltaY);
break;
case FIT_CENTER:
if ((float) imageViewWidth / bitmapWidth > (float) imageViewHeight / bitmapHeight) {
// Extend start bounds horizontally
startScale = (float) imageViewHeight / bitmapHeight;
rect.type = TYPE_EXTEND_V;
} else {
startScale = (float) imageViewWidth / bitmapWidth;
rect.type = TYPE_EXTEND_H;
}
bitmapHeight = (int) (bitmapHeight * startScale);
bitmapWidth = (int) (bitmapWidth * startScale);
deltaX = (imageViewWidth - bitmapWidth) / 2;
deltaY = (imageViewHeight - bitmapHeight) / 2;
scaledBitmapRect.set(scaledBitmapRect.left + deltaX, scaledBitmapRect.top + deltaY, scaledBitmapRect.right - deltaX, scaledBitmapRect.bottom - deltaY);
break;
}
rect.scaledBitmapRect = scaledBitmapRect;
return rect;
}
use of android.widget.ImageView in project platform_frameworks_base by android.
the class ObjectViewer method onResume.
@Override
protected void onResume() {
super.onResume();
MtpObjectInfo info = mClient.getObjectInfo(mDeviceName, mObjectID);
if (info != null) {
TextView view = (TextView) findViewById(R.id.name);
mFileName = info.getName();
view.setText(mFileName);
view = (TextView) findViewById(R.id.format);
view.setText(Integer.toHexString(info.getFormat()).toUpperCase(Locale.ROOT));
view = (TextView) findViewById(R.id.size);
view.setText(Long.toString(info.getCompressedSize()));
view = (TextView) findViewById(R.id.thumb_width);
view.setText(Long.toString(info.getThumbPixWidth()));
view = (TextView) findViewById(R.id.thumb_height);
view.setText(Long.toString(info.getThumbPixHeight()));
view = (TextView) findViewById(R.id.thumb_size);
view.setText(Long.toString(info.getThumbCompressedSize()));
view = (TextView) findViewById(R.id.width);
view.setText(Long.toString(info.getImagePixWidth()));
view = (TextView) findViewById(R.id.height);
view.setText(Long.toString(info.getImagePixHeight()));
view = (TextView) findViewById(R.id.depth);
view.setText(Long.toString(info.getImagePixDepth()));
view = (TextView) findViewById(R.id.sequence);
view.setText(Long.toString(info.getSequenceNumber()));
view = (TextView) findViewById(R.id.created);
Date date = new Date(info.getDateCreated() * 1000);
view.setText(date.toString());
view = (TextView) findViewById(R.id.modified);
date = new Date(info.getDateModified() * 1000);
view.setText(date.toString());
view = (TextView) findViewById(R.id.keywords);
view.setText(info.getKeywords());
int thumbFormat = info.getThumbFormat();
if (thumbFormat == MtpConstants.FORMAT_EXIF_JPEG || thumbFormat == MtpConstants.FORMAT_JFIF) {
byte[] thumbnail = mClient.getThumbnail(mDeviceName, info.getObjectHandle());
if (thumbnail != null) {
Bitmap bitmap = BitmapFactory.decodeByteArray(thumbnail, 0, thumbnail.length);
if (bitmap != null) {
ImageView thumbView = (ImageView) findViewById(R.id.thumbnail);
thumbView.setImageBitmap(bitmap);
}
}
}
}
}
use of android.widget.ImageView in project platform_frameworks_base by android.
the class MessageBar method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mView = inflater.inflate(R.layout.fragment_message_bar, container, false);
ImageView infoIcon = (ImageView) mView.findViewById(R.id.icon_info);
infoIcon.setImageResource(R.drawable.ic_dialog_info);
ImageView errorIcon = (ImageView) mView.findViewById(R.id.icon_error);
errorIcon.setImageResource(R.drawable.ic_dialog_alert);
Button dismiss = (Button) mView.findViewById(R.id.button_dismiss);
dismiss.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
hide();
}
});
mContainer = container;
return mView;
}
Aggregations