uk.co.senab.photoview.PhotoView Java Examples
The following examples show how to use
uk.co.senab.photoview.PhotoView.
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: ImageLoaderDemo.java From android-open-project-demo with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_integration); PhotoView photoView = (PhotoView) findViewById(R.id.photoview); ImageLoader.getInstance().init( ImageLoaderConfiguration.createDefault(this)); /** * The Image URL is comes from my space. If it is invalid, you can * change to any other picture url. */ ImageLoader.getInstance().displayImage( "http://dk-exp.qiniudn.com/saya.jpg", photoView); }
Example #2
Source File: ImageFragment.java From OmniList with GNU Affero General Public License v3.0 | 6 votes |
private void displayMedia(PhotoView photoView) { Glide.with(getContext()) .load(FileHelper.getThumbnailUri(getContext(), attachment.getUri())) .asBitmap() .diskCacheStrategy(DiskCacheStrategy.SOURCE) .thumbnail(0.5f) .transform(new RotateTransformation(getContext(), 0, false)) .animate(R.anim.fade_in_support) .into(photoView); photoView.setOnClickListener(v -> { if (attachment != null && Constants.MIME_TYPE_VIDEO.equals(attachment.getMineType())){ Intent intent = new Intent(Intent.ACTION_VIEW); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setDataAndType(attachment.getUri(), FileHelper.getMimeType(getContext(), attachment.getUri())); startActivity(intent); } }); }
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: 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 #5
Source File: ImgShowDialog.java From AndroidPickPhotoDialog with Apache License 2.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.dialog_photo_show_layout); photoView = (PhotoView) findViewById(R.id.photoview); Glide.with(context).load(imgpath).into(photoView); mAttacher = new PhotoViewAttacher(photoView); mAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float x, float y) { } @Override public void onOutsidePhotoTap() { } }); }
Example #6
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 #7
Source File: ViewPagerPhotoViewFragment.java From RotatePhotoView with Apache License 2.0 | 6 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { PhotoView photoView = new PhotoView(container.getContext()); photoView.setImageResource(sDrawables[position]); PhotoViewAttacher attacher = new PhotoViewAttacher(photoView); attacher.setRotatable(true); attacher.setToRightAngle(true); attacher.setOnRotateListener(new PhotoViewAttacher.OnRotateListener() { @Override public void onRotate(int degree) { //do something } }); attacher.update(); // Now just add PhotoView to ViewPager and return it container.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); return photoView; }
Example #8
Source File: ImageBrowserAdapter.java From BigApp_Discuz_Android with Apache License 2.0 | 6 votes |
@Override public View instantiateItem(ViewGroup container, int position) { // View convertView = View.inflate(context, // R.layout.item_imageslooker_photoview, null); PhotoView photoView =new PhotoView(context); String path = mPhotos.get(position % mPhotos.size()).path; if (path.startsWith("http://") || path.startsWith("https://")) { // 这里进行图片的缓存操作 Glide.with(context).load(path).into(photoView); } else { Glide.with(context).load(new File(path)).into(photoView); } container.addView(photoView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); return photoView; }
Example #9
Source File: ImagePickerPagerAdapter.java From FamilyChat with Apache License 2.0 | 6 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { PhotoView photoView = new PhotoView(mActivity); photoView.setScaleType(ImageView.ScaleType.FIT_CENTER); photoView.setEnabled(true); ImageBean imageItem = mAllmageList.get(position); mImagePicker.getOptions().getDisplayer().display(mActivity, photoView, imageItem.getImagePath(), mScreenWidth, mScreenHeight); photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float x, float y) { if (mListener != null) mListener.OnPhotoTapListener(view, x, y); } }); container.addView(photoView); return photoView; }
Example #10
Source File: NewsPhotoDetailActivity.java From ZZShow with Apache License 2.0 | 6 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { PhotoView photoView = new PhotoView(NewsPhotoDetailActivity.this); Glide.with(NewsPhotoDetailActivity.this).load(mPictureList.get(position).getImgPath()) .placeholder(R.mipmap.ic_loading) .error(R.mipmap.ic_load_fail) .diskCacheStrategy(DiskCacheStrategy.ALL) .into(photoView); photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float v, float v1) { hideToolBarAndTextView(); hideOrShowStatusBar(); } @Override public void onOutsidePhotoTap() { } }); container.addView(photoView, ViewPager.LayoutParams.MATCH_PARENT, ViewPager.LayoutParams.MATCH_PARENT); return photoView; }
Example #11
Source File: GalleryActivity.java From C9MJ with Apache License 2.0 | 6 votes |
/** * 初始化ViewPager */ private void initViewPager() { for (String url : imgList) { PhotoView photoView = new PhotoView(context); ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); photoView.setLayoutParams(lp); Glide.with(context).load(url) .fitCenter() .thumbnail(0.1f) .into(photoView); viewList.add(photoView); viewPager.setCurrentItem(index); tv_index.setText((index + 1) + "/" + imgList.size()); } adapter = new GalleryAdapter(viewList); viewPager.setAdapter(adapter); viewPager.setOffscreenPageLimit(2); viewPager.addOnPageChangeListener(this); }
Example #12
Source File: ImagePagerAdapter.java From ImageChooser with Apache License 2.0 | 5 votes |
@Override public View instantiateItem(ViewGroup container, int position) { PhotoView photoView = new PhotoView(container.getContext()); photoView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); String imgPath = (String)getItem(position); mImageLoader.displayImage(FileUtil.getFormatFilePath(imgPath), (ImageView)photoView, mOptions, null); // Now just add PhotoView to ViewPager and return it container.addView(photoView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); return photoView; }
Example #13
Source File: GalleryActivity.java From HeartBeat with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_gallery); long eventId = getIntent().getLongExtra(EVENT_ID, -1); String path = ""; if (eventId == -1) { path = getIntent().getStringExtra(PATH); } Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setBackgroundColor(Color.BLACK); toolbar.setTitle(""); toolbar.setAlpha(0.6f); setSupportActionBar(toolbar); getSupportActionBar().setDisplayHomeAsUpEnabled(true); mImage = (PhotoView) findViewById(R.id.imageview); mImage.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float x, float y) { finish(); } }); if (eventId != -1) { String imagePath = ImageUtils.getImageByEventId(this, eventId).getPath(); Glide.with(this).load(GalleryUtils.getImagePath(imagePath)).into(mImage); } else { Glide.with(this).load(GalleryUtils.getImagePath(path)).into(mImage); } }
Example #14
Source File: SamplePagerAdapter.java From KJGallery with Apache License 2.0 | 5 votes |
@Override public View instantiateItem(ViewGroup container, int position) { View root = View.inflate(aty, R.layout.item_pager, null); final PhotoView photoView = (PhotoView) root.findViewById(R.id.images); final GifImageView gifView = (GifImageView) root.findViewById(R.id.gifimage); final ProgressBar mProgressBar = (ProgressBar) root.findViewById(R.id.progress); GifRequest request = new GifRequest(imageUrls[position], new HttpCallBack() { @Override public void onPreStart() { super.onPreStart(); mProgressBar.setVisibility(View.VISIBLE); } @Override public void onSuccess(byte[] t) { super.onSuccess(t); //根据图片类型的不同选择不同的加载方案 if (TYPE_GIF == getType(t)) { displayGif(gifView, t); } else { displayImage(photoView, t); } } @Override public void onFinish() { super.onFinish(); mProgressBar.setVisibility(View.GONE); } }); kjh.doRequest(request); container.addView(root, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams .MATCH_PARENT); return root; }
Example #15
Source File: SinglePhotoViewFragment.java From RotatePhotoView with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(View view, Bundle savedInstanceState) { mPhotoView = (PhotoView) view.findViewById(R.id.photoview); mAttacher = new PhotoViewAttacher(mPhotoView); mAttacher.setRotatable(true); mAttacher.setToRightAngle(true); mPhotoView.setOnRotateListener(new PhotoViewAttacher.OnRotateListener() { @Override public void onRotate(int degree) { //do something } }); }
Example #16
Source File: ImageViewDialogFragment.java From 4pdaClient-plus with Apache License 2.0 | 5 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { View v = getActivity().getLayoutInflater().inflate(R.layout.image_view_dialog, null); m_PhotoView=(PhotoView)v.findViewById(R.id.iv_photo); //m_PhotoView.setScaleType(ImageView.ScaleType.FIT_CENTER); m_PhotoView.setMaximumScale(10f); m_ProgressView=v.findViewById(R.id.progressBar); MaterialDialog builder= new MaterialDialog.Builder(getActivity()) .title(mTitle) .customView(v,false) .negativeText(R.string.close) .positiveText(R.string.full_size) .callback(new MaterialDialog.ButtonCallback() { @Override public void onPositive(MaterialDialog dialog) { String url = mUrl; try { URI uri = new URI(mUrl); if (!uri.isAbsolute()) url = "https://4pda.ru" + url; } catch (URISyntaxException e) { e.printStackTrace(); } // ImageViewActivity.startActivity(getActivity(), url); ImgViewer.startActivity(getActivity(), url); } }).build(); builder.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE); builder.show(); return builder; }
Example #17
Source File: ImagePagerAdapter.java From MultiImagePicker with MIT License | 5 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { final ImageEntry imageEntry = mAlbumEntry.imageList.get(position); final PhotoView view = new PhotoView(mFragment.getActivity()); view.setOnViewTapListener(mTapListener); Glide.with(mFragment) .load(imageEntry.path) .asBitmap() .into(view); container.addView(view, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); return view; }
Example #18
Source File: PicassoDemo.java From android-open-project-demo with Apache License 2.0 | 5 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_integration); PhotoView photoView = (PhotoView) findViewById(R.id.photoview); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); Picasso.with(this).load("http://dk-exp.qiniudn.com/saya.jpg") .centerInside().resize(dm.widthPixels, dm.heightPixels).tag(this).into(photoView); }
Example #19
Source File: PotoViewPagerUsed.java From AndJie with GNU General Public License v2.0 | 5 votes |
@Override public View instantiateItem(ViewGroup container, int position) { PhotoView photoView = new PhotoView(container.getContext()); AffixForShowBean bean = imgList.get(position); imageLoader.displayImage( JieContant.URL_Img_Base + bean.getAffixFolder(), photoView, options); // Now just add PhotoView to ViewPager and return it container.addView(photoView, LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); return photoView; }
Example #20
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 #21
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; }
Example #22
Source File: ViewPagerActivity.java From evercam-android with GNU Affero General Public License v3.0 | 5 votes |
@Override public View instantiateItem(ViewGroup container, int position) { PhotoView photoView = new PhotoView(container.getContext()); photoView.setImageURI(Uri.parse(mImagePathList.get(position))); // Now just add PhotoView to ViewPager and return it container.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); return photoView; }
Example #23
Source File: ImageLoadDoneEvent.java From secrecy with Apache License 2.0 | 5 votes |
public ImageLoadDoneEvent(Integer mNum, PhotoView imageView, Bitmap bitmap, ProgressBar progressBar, EncryptedFile encryptedFile) { this.mNum = mNum; this.imageView = imageView; this.bitmap = bitmap; this.progressBar = progressBar; this.encryptedFile = encryptedFile; }
Example #24
Source File: ImageLoadJob.java From secrecy with Apache License 2.0 | 5 votes |
public ImageLoadJob(Integer mNum, EncryptedFile encryptedFile, PhotoView imageView, ProgressBar pBar) { super(new Params(PRIORITY)); this.mNum = mNum; this.encryptedFile = encryptedFile; this.imageView = imageView; this.pBar = pBar; options = new BitmapFactory.Options(); }
Example #25
Source File: ImagePageAdapter.java From ImagePicker with Apache License 2.0 | 5 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { PhotoView photoView = new PhotoView(mActivity); ImageItem imageItem = images.get(position); imagePicker.getImageLoader().displayImagePreview(mActivity, imageItem.path, photoView, screenWidth, screenHeight); photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float x, float y) { if (listener != null) listener.OnPhotoTapListener(view, x, y); } }); container.addView(photoView); return photoView; }
Example #26
Source File: PhotoBrowseActivity.java From star-zone-android with Apache License 2.0 | 5 votes |
@Override public void onDestroy() { if (!ToolUtil.isListEmpty(viewBuckets)) { for (PhotoView photoView : viewBuckets) { photoView.destroy(); } } Glide.get(this).clearMemory(); super.onDestroy(); }
Example #27
Source File: ImagePageAdapter.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { PhotoView photoView = new PhotoView(mActivity); ImageItem imageItem = images.get(position); imagePicker.getImageLoader().displayImages(mActivity, imageItem.path, photoView, screenWidth, screenHeight); photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float x, float y) { if (listener != null) listener.OnPhotoTapListener(view, x, y); } }); container.addView(photoView); return photoView; }
Example #28
Source File: PhotoPickerFragment.java From InstagramPhotoPicker with MIT License | 5 votes |
private void initView(View view) { toolbar = (Toolbar) view.findViewById(R.id.tool_bar); parentLayout = (CoordinatorLinearLayout) view.findViewById(R.id.parent_layout); photoRecyclerView = (CoordinatorRecyclerView) view.findViewById(R.id.photo_recycler_view); albumTextView = (TextView) view.findViewById(R.id.album_text_view); photoView = (PhotoView) view.findViewById(R.id.photo_view); setLayoutSize(); initToolBar(); initRecyclerView(); }
Example #29
Source File: BoxingRawImageFragment.java From boxing with Apache License 2.0 | 5 votes |
@Override public void onViewCreated(final View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mProgress = (ProgressBar) view.findViewById(R.id.loading); mImageView = (PhotoView) view.findViewById(R.id.photo_view); mAttacher = new PhotoViewAttacher(mImageView); mAttacher.setRotatable(true); mAttacher.setToRightAngle(true); }
Example #30
Source File: ZoomableImageActivity.java From droidconat-2016 with Apache License 2.0 | 5 votes |
@Override protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); ZoomableImageActivityIntentBuilder.inject(getIntent(), this); PhotoView view = new PhotoView(this); // No drawable-nodpi venue_rooms file // view.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.venue_rooms)); view.setBackgroundColor(ContextCompat.getColor(this, android.R.color.white)); getSupportActionBar().setTitle(R.string.venue_see_rooms); setContentView(view); }