Java Code Examples for uk.co.senab.photoview.PhotoView#setImageBitmap()
The following examples show how to use
uk.co.senab.photoview.PhotoView#setImageBitmap() .
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 check out the related API usage on the sidebar.
Example 1
Source File: SamplePagerAdapter.java From KJGallery with Apache License 2.0 | 6 votes |
/** * 加载普通图片 */ 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(); } }); }
Example 2
Source File: FilePhotoFragment.java From secrecy with Apache License 2.0 | 6 votes |
/** * 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; }
Example 3
Source File: PhotoPagerAdapter.java From secrecy with Apache License 2.0 | 6 votes |
/** * 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; }
Example 4
Source File: ImageViewActivity.java From Fishing with GNU General Public License v3.0 | 5 votes |
@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; }
Example 5
Source File: ImageActivity.java From BlackLight with GNU General Public License v3.0 | 5 votes |
@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); } } }
Example 6
Source File: NovelImageActivity.java From light-novel-library_Wenku8_Android with GNU General Public License v2.0 | 5 votes |
@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; }