本文整理匯總了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;
}