本文整理汇总了Java中uk.co.senab.photoview.PhotoView.setImageBitmap方法的典型用法代码示例。如果您正苦于以下问题:Java PhotoView.setImageBitmap方法的具体用法?Java PhotoView.setImageBitmap怎么用?Java PhotoView.setImageBitmap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类uk.co.senab.photoview.PhotoView
的用法示例。
在下文中一共展示了PhotoView.setImageBitmap方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onActivityCreated
import uk.co.senab.photoview.PhotoView; //导入方法依赖的package包/类
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (getView() != null) {
imageView = (PhotoView) getView().findViewById(R.id.layout_preview_img_img);
}
final String url = getArguments().getString("imagePath");
if (ImageCache.getInstance().get(key_prefix + url) == null) {
bp = ImageUtils.compressImgBySize(url, 480, 800);
ImageCache.getInstance().put(key_prefix + url, bp);
} else {
bp = ImageCache.getInstance().get(key_prefix + url);
}
imageView.setImageBitmap(bp);
imageView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
@Override
public void onPhotoTap(View view, float x, float y) {
if (listener != null)
listener.onImgClick();
}
});
}
示例2: displayImage
import uk.co.senab.photoview.PhotoView; //导入方法依赖的package包/类
/**
* 加载普通图片
*/
private void displayImage(PhotoView photoView, byte[] res) {
photoView.setVisibility(View.VISIBLE);
Bitmap bitmap = byteArrayToBitmap(res);
if (bitmap == null) {
photoView.setImageResource(R.mipmap.default_img_rect);
} else {
photoView.setImageBitmap(bitmap);
}
photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {
@Override
public void onPhotoTap(View view, float x, float y) {
aty.finish();
}
});
}
示例3: onCreateView
import uk.co.senab.photoview.PhotoView; //导入方法依赖的package包/类
/**
* The Fragment's UI is just a simple text view showing its
* instance number.
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Util.log("onCreateView!!");
final RelativeLayout relativeLayout = new RelativeLayout(container.getContext());
final File file = files.get(mNum);
final PhotoView photoView = new PhotoView(container.getContext());
this.photoView = photoView;
relativeLayout.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
photoView.setImageBitmap(file.getThumb(150));
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
final ProgressBar pBar = new ProgressBar(container.getContext());
pBar.setIndeterminate(false);
relativeLayout.addView(pBar, layoutParams);
CustomApp.jobManager.addJobInBackground(new ImageLoadJob(mNum, file, photoView, pBar));
return relativeLayout;
}
示例4: onCreateView
import uk.co.senab.photoview.PhotoView; //导入方法依赖的package包/类
/**
* The Fragment's UI is just a simple text view showing its
* instance number.
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
Util.log("onCreateView!!");
final RelativeLayout relativeLayout = new RelativeLayout(container.getContext());
final EncryptedFile encryptedFile = encryptedFiles.get(mNum);
final PhotoView photoView = new PhotoView(container.getContext());
relativeLayout.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
try {
photoView.setImageBitmap(encryptedFile.getEncryptedThumbnail().getThumb(150));
} catch (SecrecyFileException e) {
Util.log("No bitmap available!");
}
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
final ProgressBar pBar = new ProgressBar(container.getContext());
pBar.setIndeterminate(false);
relativeLayout.addView(pBar, layoutParams);
imageLoadJob = new ImageLoadJob(mNum, encryptedFile, photoView, pBar);
CustomApp.jobManager.addJobInBackground(imageLoadJob);
return relativeLayout;
}
示例5: onCreateView
import uk.co.senab.photoview.PhotoView; //导入方法依赖的package包/类
/**
* The Fragment's UI is just a simple text view showing its
* instance number.
*/
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
final RelativeLayout relativeLayout = new RelativeLayout(container.getContext());
final EncryptedFile encryptedFile = encryptedFiles.get(mNum);
final PhotoView photoView = new PhotoView(container.getContext());
relativeLayout.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
try {
photoView.setImageBitmap(encryptedFile.getEncryptedThumbnail().getThumb(150));
} catch (SecrecyFileException e) {
Util.log("No bitmap available!");
}
RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
layoutParams.addRule(RelativeLayout.CENTER_IN_PARENT, RelativeLayout.TRUE);
final ProgressBar pBar = new ProgressBar(container.getContext());
pBar.setIndeterminate(false);
relativeLayout.addView(pBar, layoutParams);
imageLoadJob = new ImageLoadJob(mNum, encryptedFile, photoView, pBar);
CustomApp.jobManager.addJobInBackground(imageLoadJob);
return relativeLayout;
}
示例6: showExcessPic
import uk.co.senab.photoview.PhotoView; //导入方法依赖的package包/类
/** 展示过度图片 */
private void showExcessPic(ImageInfo imageInfo, PhotoView imageView) {
//先获取大图的缓存图片
Bitmap cacheImage = NineGridView.getImageLoader().getCacheImage(imageInfo.bigImageUrl);
//如果大图的缓存不存在,在获取小图的缓存
if (cacheImage == null) cacheImage = NineGridView.getImageLoader().getCacheImage(imageInfo.thumbnailUrl);
//如果没有任何缓存,使用默认图片,否者使用缓存
if (cacheImage == null) {
imageView.setImageResource(R.drawable.ic_default_image);
} else {
imageView.setImageBitmap(cacheImage);
}
}
示例7: instantiateItem
import uk.co.senab.photoview.PhotoView; //导入方法依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, final int position) {
View itemView = setupPager(container, position);
final PhotoView pvComic = (PhotoView) itemView.findViewById(R.id.ivComic);
final TextView tvAlt = (TextView) itemView.findViewById(R.id.tvAlt);
final TextView tvTitle = (TextView) itemView.findViewById(R.id.tvTitle);
tvAlt.setText(prefHelper.getAlt(favorites[position]));
tvTitle.setText(Html.fromHtml(prefHelper.getTitle(favorites[position])));
if (getGifId(favorites[position] - 1) != 0)
Glide.with(getActivity())
.load(getGifId(favorites[position] - 1))
.into(new GlideDrawableImageViewTarget(pvComic));
else {
Bitmap bitmap = ((OfflineComic) comicMap.get(position)).getBitmap();
if (themePrefs.invertColors(false) && themePrefs.bitmapContainsColor(bitmap, position+1))
pvComic.clearColorFilter();
if (bitmap != null)
pvComic.setImageBitmap(bitmap);
else
new RedownloadFavorite().execute(comicMap.get(position).getComicNumber()); // If the image is gone download it and refresh the fragment
}
if (Arrays.binarySearch(mContext.getResources().getIntArray(R.array.large_comics), favorites[favoriteIndex]) >= 0)
pvComic.setMaximumScale(13.0f);
container.addView(itemView);
return itemView;
}
示例8: instantiateItem
import uk.co.senab.photoview.PhotoView; //导入方法依赖的package包/类
@Override
public View instantiateItem(ViewGroup container, int position) {
View view = LayoutInflater.from(ImageViewActivity.this).inflate(R.layout.item_imagepage, container, false);
final PhotoView photoView = (PhotoView) view.findViewById(R.id.photoview);
final View wheel = view.findViewById(R.id.wheel);
photoView.setOnPhotoTapListener((view1, v, v1) -> finish());
ImagePipeline imagePipeline = Fresco.getImagePipeline();
ImageRequest request = ImageRequestBuilder.newBuilderWithSource(urls.get(position))
.setResizeOptions(new ResizeOptions(768, 768))
.build();
DataSource<CloseableReference<CloseableImage>>
dataSource = imagePipeline.fetchDecodedImage(request,this);
DataSubscriber dataSubscriber = new BaseBitmapDataSubscriber() {
@Override
protected void onNewResultImpl(Bitmap bitmap) {
photoView.setImageBitmap(bitmap);
wheel.setVisibility(View.GONE);
}
@Override
protected void onFailureImpl(DataSource<CloseableReference<CloseableImage>> closeableReferenceDataSource) {
}
};
dataSource.subscribe(dataSubscriber, new Executor() {
@Override
public void execute(Runnable command) {
handler.post(command);
}
});
container.addView(view);
return view;
}
示例9: onPostExecute
import uk.co.senab.photoview.PhotoView; //导入方法依赖的package包/类
@Override
protected void onPostExecute(Object[] result) {
super.onPostExecute(result);
ViewGroup v = (ViewGroup) result[0];
Object img = result[1];
if (img != null) {
v.removeAllViews();
if (img instanceof Bitmap) {
PhotoView p = new PhotoView(ImageActivity.this);
// Disable hardware acceleration if too large
Bitmap image = (Bitmap) img;
int maxSize = Utility.getSupportedMaxPictureSize();
if (image.getWidth() > maxSize || image.getHeight() > maxSize) {
p.setLayerType(View.LAYER_TYPE_SOFTWARE, null);
if (DEBUG) {
Log.d(TAG, "Image too large, hardware acceleration disabled. max size: " + maxSize);
}
}
p.setImageBitmap(image);
p.setOnPhotoTapListener(ImageActivity.this);
v.addView(p, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
} else if (img instanceof Movie) {
GifView g = new GifView(ImageActivity.this);
g.setMovie((Movie) img);
v.addView(g, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
}
}
}
示例10: onCreate
import uk.co.senab.photoview.PhotoView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_image);
mSwipeBackLayout = getSwipeBackLayout();
mSwipeBackLayout.setScrimColor(Color.TRANSPARENT);
mSwipeBackLayout.setEdgeTrackingEnabled(SwipeBackLayout.EDGE_LEFT);
imgPath = getIntent().getStringExtra("path");
if (imgPath == null || imgPath.length() == 0) {
Toast.makeText(this, "No image path error", Toast.LENGTH_LONG).show();
return;
}
if (imgPath == null || imgPath.length() == 0)
return;
// load image file first
byte[] imgContent = LightCache.loadFile(imgPath);
Bitmap bm = BitmapFactory.decodeByteArray(imgContent, 0, imgContent.length);
//BitmapDrawable bd= new BitmapDrawable(getResources(), bm);
// show in View
PhotoView iv = (PhotoView) this.findViewById(R.id.image_photoview);
iv.setImageBitmap(bm);
//ImageLoader.getInstance().displayImage("file://" + imgPath, iv);
return;
}
示例11: init
import uk.co.senab.photoview.PhotoView; //导入方法依赖的package包/类
public void init(){
if (animator != null) {
animator.cancel();
}
container = (ContentFrameLayout) activity.findViewById(android.R.id.content);
copyImageView = new PhotoView(activity);
int matchParent = FrameLayout.LayoutParams.MATCH_PARENT;
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(matchParent, matchParent);
copyImageView.setLayoutParams(params);
r = new RelativeLayout(activity);
r.setLayoutParams(params);
r.setBackgroundColor(Color.BLACK);
if (originalView instanceof ImageView) {
copyImageView.setImageDrawable(((ImageView) originalView).getDrawable());
} else {
Bitmap bm = view2Bitmap(originalView);
if (bm != null) {
copyImageView.setImageBitmap(bm);
}
}
copyImageView.setVisibility(View.GONE);
r.setVisibility(View.GONE);
container.addView(r);
container.addView(copyImageView);
startRect = new Rect();
endRect = new Rect();
Point offsetPoint = new Point();
originalView.getGlobalVisibleRect(startRect);
/**
* r 是 绝对(global)坐标参数,包含状态栏、ActionBar、底部虚拟键
* globalOffset 用于将global坐标转换成local坐标,这里的local坐标,是相对于内容区的坐标,也就是除了状态栏和action bar和虚拟按键的区域。
* */
container.getGlobalVisibleRect(endRect, offsetPoint);
startRect.offset(-offsetPoint.x, -offsetPoint.y);
endRect.offset(-offsetPoint.x, -offsetPoint.y);
float scaleSize;
float startScaleFinal;
Log.d("garyhu","width == "+endRect.width());
Log.d("garyhu","height == "+endRect.height());
if ((float) endRect.width() / (float) endRect.height() > (float) startRect.width() / (float) startRect.height()) {
startScale = (float) startRect.height() / (float) endRect.height();
scaleSize = startScale * (float) endRect.width();
startScaleFinal = (scaleSize - (float) startRect.width()) / 2.0F;
startRect.left = (int) ((float) startRect.left - startScaleFinal);
startRect.right = (int) ((float) startRect.right + startScaleFinal);
} else {
startScale = (float) startRect.width() / (float) endRect.width();
scaleSize = startScale * (float) endRect.height();
startScaleFinal = (scaleSize - (float) startRect.height()) / 2.0F;
startRect.top = (int) ((float) startRect.top - startScaleFinal);
startRect.bottom = (int) ((float) startRect.bottom + startScaleFinal);
}
}
示例12: instantiateItem
import uk.co.senab.photoview.PhotoView; //导入方法依赖的package包/类
@Override
public Object instantiateItem(ViewGroup container, final int position) {
View itemView = setupPager(container, position);
PhotoView pvComic = (PhotoView) itemView.findViewById(R.id.ivComic);
TextView tvAlt = (TextView) itemView.findViewById(R.id.tvAlt);
TextView tvTitle = (TextView) itemView.findViewById(R.id.tvTitle);
comicMap.put(position + 1, new OfflineComic(position + 1, getActivity(), ((MainActivity) getActivity()).getPrefHelper()));
tvTitle.setText(Html.fromHtml(comicMap.get(position + 1).getComicData()[0]));
tvAlt.setText(comicMap.get(position + 1).getComicData()[1]);
if (fromSearch) {
fromSearch = false;
transition = ActivityTransition.with(getActivity().getIntent()).duration(300).to(pvComic).start(null);
}
if (getGifId(position) != 0)
Glide.with(getActivity())
.load(getGifId(position))
.into(new GlideDrawableImageViewTarget(pvComic));
else {
Bitmap bitmap = ((OfflineComic) comicMap.get(position + 1)).getBitmap();
if (themePrefs.invertColors(false) && themePrefs.bitmapContainsColor(bitmap, position+1))
pvComic.clearColorFilter();
pvComic.setImageBitmap(bitmap);
}
if (randomSelected && position == lastComicNumber - 1) {
Animation animation = AnimationUtils.loadAnimation(getActivity().getApplicationContext(), android.R.anim.fade_in);
itemView.setAnimation(animation);
randomSelected = false;
}
if (Arrays.binarySearch(mContext.getResources().getIntArray(R.array.large_comics), position+1) >= 0)
pvComic.setMaximumScale(15.0f);
if (position == lastComicNumber - 1)
animateToolbar();
container.addView(itemView);
return itemView;
}