uk.co.senab.photoview.PhotoViewAttacher Java Examples
The following examples show how to use
uk.co.senab.photoview.PhotoViewAttacher.
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: PhotoBrowseActivity.java From star-zone-android with Apache License 2.0 | 6 votes |
private void preInitData() { photoBrowseInfo = getIntent().getParcelableExtra("photoinfo"); viewBuckets = new LinkedList<>(); final int photoCount = photoBrowseInfo.getPhotosCount(); for (int i = 0; i < photoCount; i++) { GalleryPhotoView photoView = new GalleryPhotoView(this); photoView.setCleanOnDetachedFromWindow(false); photoView.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() { @Override public void onViewTap(View view, float x, float y) { finish(); } }); viewBuckets.add(photoView); } }
Example #2
Source File: MeAvatarShowerAty.java From myapplication with Apache License 2.0 | 6 votes |
private void eventDeal() { AppUser appUser = BmobUser.getCurrentUser(AppUser.class); String avatarUrl = appUser.getUserAvatarUrl(); Glide.with(MeAvatarShowerAty.this) .load(avatarUrl) .error(R.drawable.app_icon) .diskCacheStrategy(DiskCacheStrategy.ALL) .into(avatarImv); photoViewAttacher = new PhotoViewAttacher(avatarImv); photoViewAttacher.setOnLongClickListener(new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { String[] choices = {"保存至本地"}; //包含多个选项的对话框 AlertDialog dialog = new AlertDialog.Builder(MeAvatarShowerAty.this) .setItems(choices, onselect).create(); dialog.show(); return true; } }); }
Example #3
Source File: ImagesDetailActivity.java From SimplifyReader with Apache License 2.0 | 6 votes |
@Override protected void initViewsAndEvents() { mSmoothImageView.setOriginalInfo(mWidth, mHeight, mLocationX, mLocationY); mSmoothImageView.transformIn(); ImageLoader.getInstance().displayImage(mImageUrl, mSmoothImageView); mSmoothImageView.setOnTransformListener(new SmoothImageView.TransformListener() { @Override public void onTransformComplete(int mode) { if (mode == 2) { finish(); } } }); mSmoothImageView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float v, float v2) { mSmoothImageView.transformOut(); } }); }
Example #4
Source File: PhotoActivity.java From Android-Application-ZJB with Apache License 2.0 | 6 votes |
private void initView() { Intent intent = getIntent(); String imagePath = intent.getStringExtra(KEY_IMAGE_PATH); mImageView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float x, float y) { PhotoActivity.this.finish(); } @Override public void onOutsidePhotoTap() { } }); ViewUtils.showImage(mImageView, imagePath); }
Example #5
Source File: PhotoActivity.java From GankLock with GNU General Public License v3.0 | 6 votes |
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); //如果没有虚拟按键则设置为全屏 if (!UIUtil.isHasNavigationBar(this)) { getWindow().getDecorView().setSystemUiVisibility( View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LOW_PROFILE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_FULLSCREEN); } if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) { Window window = getWindow(); window.addFlags(LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(R.color.black); } mAttacher = new PhotoViewAttacher(mPhoto); mAttacher.setOnViewTapListener(new OnViewTapListener() { @Override public void onViewTap(View view, float x, float y) { hideBottomOption(); } }); }
Example #6
Source File: ImageReviewActivity.java From talk-android with MIT License | 6 votes |
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.activity_image_review); ButterKnife.inject(this); attacher = new PhotoViewAttacher(image); attacher.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() { @Override public void onViewTap(View view, float v, float v2) { finish(); } }); final String path = getIntent().getExtras().getString("path"); displayImage("file://" + path, image); }
Example #7
Source File: PostActivity.java From chaoli-forum-for-android-2 with GNU General Public License v3.0 | 6 votes |
@SuppressWarnings("ConstantConditions") private void showPhotoView() { mShowPhotoView = true; binding.photoView.setImageDrawable(viewModel.clickedImageView.getDrawable()); binding.photoView.setVisibility(View.VISIBLE); binding.photoView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE); mToolbarOffset = binding.appbar.getOffset(); appBarLayout.setExpanded(false, false); reply.hide(); binding.photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float x, float y) { } @Override public void onOutsidePhotoTap() { hidePhotoView(); } }); }
Example #8
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 #9
Source File: MeizhiActivity.java From Gank.io with GNU General Public License v3.0 | 6 votes |
private void initMeizhiView() { setTitle(DateUtil.toDateTimeStr(meizi.publishedAt)); ivMeizhi.setImageDrawable(ShareElement.shareDrawable); ViewCompat.setTransitionName(ivMeizhi, PanConfig.TRANSLATE_GIRL_VIEW); attacher = new PhotoViewAttacher(ivMeizhi); Glide.with(this).load(meizi.url).asBitmap().into(new SimpleTarget<Bitmap>() { @Override public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { ivMeizhi.setImageBitmap(resource); attacher.update(); girl = resource; } @Override public void onLoadFailed(Exception e, Drawable errorDrawable) { ivMeizhi.setImageDrawable(errorDrawable); } }); attacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float x, float y) { hideOrShowToolBar(); } }); }
Example #10
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 #11
Source File: BoxingRawImageFragment.java From boxing with Apache License 2.0 | 6 votes |
@Override public void onSuccess() { if (mWr.get() == null || mWr.get().mImageView == null) { return; } mWr.get().dismissProgressDialog(); Drawable drawable = mWr.get().mImageView.getDrawable(); PhotoViewAttacher attacher = mWr.get().mAttacher; if (attacher != null) { if (drawable.getIntrinsicHeight() > (drawable.getIntrinsicWidth() << 2)) { // handle the super height image. int scale = drawable.getIntrinsicHeight() / drawable.getIntrinsicWidth(); scale = Math.min(MAX_SCALE, scale); attacher.setMaximumScale(scale); attacher.setScale(scale, true); } attacher.update(); } BoxingViewActivity activity = mWr.get().getThisActivity(); if (activity != null && activity.mGallery != null) { activity.mGallery.setVisibility(View.VISIBLE); } }
Example #12
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 #13
Source File: ViewPagerAdapter.java From MediaGallery with Apache License 2.0 | 6 votes |
private void onTap() { mPhotoViewAttacher = new PhotoViewAttacher(imageView); mPhotoViewAttacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float x, float y) { if (isShowing) { isShowing = false; toolbar.animate().translationY(-toolbar.getBottom()).setInterpolator(new AccelerateInterpolator()).start(); imagesHorizontalList.animate().translationY(imagesHorizontalList.getBottom()).setInterpolator(new AccelerateInterpolator()).start(); } else { isShowing = true; toolbar.animate().translationY(0).setInterpolator(new DecelerateInterpolator()).start(); imagesHorizontalList.animate().translationY(0).setInterpolator(new DecelerateInterpolator()).start(); } } @Override public void onOutsidePhotoTap() { } }); }
Example #14
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 #15
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 #16
Source File: ImageActivity.java From KJFrameForAndroid with Apache License 2.0 | 6 votes |
@Override public void initWidget() { super.initWidget(); kjb.display(mImg, url, new BitmapCallBack() { @Override public void onPreLoad() { super.onPreLoad(); mProgressBar.setVisibility(View.VISIBLE); } @Override public void onFinish() { super.onFinish(); mProgressBar.setVisibility(View.GONE); } }); mImg.setOnFinishListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float x, float y) { ImageActivity.this.finish(); } }); }
Example #17
Source File: LookDetailActivity.java From Devred-PE-2014 with Apache License 2.0 | 5 votes |
private void init() { mListView = (ListView) findViewById(R.id.test); mImageView = (ImageView) findViewById(R.id.look_detail_activity_look_image); mAttacher = new PhotoViewAttacher(mImageView); mAdapter = new LookItemAdapter(LookDetailActivity.this, mLook.getLookItems()); final View headerView = getLayoutInflater().inflate(R.layout.header_look_detail, mListView, false); mListView.addHeaderView(headerView); loadLookImage(); initListViewPaddingTop(); }
Example #18
Source File: PhotoViewerFragment.java From glimmr with Apache License 2.0 | 5 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { if (BuildConfig.DEBUG) Log.d(getLogTag(), "onCreateView"); mLayout = (RelativeLayout) inflater.inflate( R.layout.photoviewer_fragment, container, false); mVideoButton = (ImageView) mLayout.findViewById( R.id.play_video_overlay); mImageView = (ImageView) mLayout.findViewById(R.id.image); mAttacher = new PhotoViewAttacher(mImageView); mTextViewTitle = (TextView) mLayout.findViewById(R.id.textViewTitle); mTextViewAuthor = (TextView) mLayout.findViewById(R.id.textViewAuthor); mProgress = (ProgressBar) mLayout.findViewById(R.id.progress); mAttacher.setOnPhotoTapListener(new OnPhotoTapListener() { @Override public void onPhotoTap(View view, float x, float y) { BusProvider.getInstance().post( new PhotoViewerVisibilityChangeEvent( !mActionBar.isShowing(), PhotoViewerFragment.this) ); } }); /* If this fragment is new as part of a set, update it's overlay * visibility based on the state of the actionbar */ setOverlayVisibility(mActionBar.isShowing()); displayImage(); return mLayout; }
Example #19
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 #20
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 #21
Source File: NetworkPhotoView.java From android-discourse with Apache License 2.0 | 5 votes |
public NetworkPhotoView(Context context, AttributeSet attr, int defStyle) { super(context, attr, defStyle); super.setScaleType(ScaleType.MATRIX); mAttacher = new PhotoViewAttacher(this); if (null != mPendingScaleType) { setScaleType(mPendingScaleType); mPendingScaleType = null; } }
Example #22
Source File: PictureFragment.java From Tweetin with Apache License 2.0 | 5 votes |
private void load() { progressWheel.setVisibility(View.VISIBLE); reloadView.setVisibility(View.GONE); pictureView.setVisibility(View.GONE); ImageRequest imageRequest = new ImageRequest( pictureURL, new Response.Listener<Bitmap>() { @Override public void onResponse(Bitmap bitmap) { originBitmap = bitmap; pictureView.setImageBitmap(bitmap); PhotoViewAttacher photoViewAttacher = new PhotoViewAttacher(pictureView); photoViewAttacher.setZoomable(true); photoViewAttacher.update(); progressWheel.setVisibility(View.GONE); reloadView.setVisibility(View.GONE); pictureView.setVisibility(View.VISIBLE); } }, 0, 0, Bitmap.Config.ARGB_8888, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError volleyError) { progressWheel.setVisibility(View.GONE); reloadView.setVisibility(View.VISIBLE); pictureView.setVisibility(View.GONE); } } ); requestQueue.add(imageRequest); }
Example #23
Source File: MediaPreviewCameraActivity.java From BigApp_WordPress_Android with Apache License 2.0 | 5 votes |
@Override public void onLoadingFailed(String imageUri, View view, FailReason failReason) { mImageView.setScaleType(ImageView.ScaleType.CENTER); mProgress.setVisibility(View.GONE); PhotoViewAttacher photo = new PhotoViewAttacher(mImageView); photo.setMaxScale(8); }
Example #24
Source File: MediaDetailFragment.java From BigApp_WordPress_Android with Apache License 2.0 | 5 votes |
@Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { mImageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); mProgress.setVisibility(View.GONE); PhotoViewAttacher photo = new PhotoViewAttacher(mImageView); photo.setMaxScale(10); photo.setOnPhotoTapListener(this); photo.setOnViewTapListener(this); }
Example #25
Source File: MediaPreviewCameraActivity.java From BigApp_WordPress_Android with Apache License 2.0 | 5 votes |
@Override public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) { mImageView.setScaleType(ImageView.ScaleType.CENTER_INSIDE); mProgress.setVisibility(View.GONE); PhotoViewAttacher photo = new PhotoViewAttacher(mImageView); photo.setMaxScale(10); }
Example #26
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 #27
Source File: DetailFragment.java From Meizi with Apache License 2.0 | 5 votes |
@Override public void initSubViews(View view) { super.initSubViews(view); ImageLoader.loadImage(getArguments().getString("url"), meiziImageView, getContext()); mAttacher = new PhotoViewAttacher(meiziImageView); mAttacher.update(); }
Example #28
Source File: HxImageDetailAdapter.java From FamilyChat with Apache License 2.0 | 5 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { PhotoView photoView = new PhotoView(mActivity); photoView.setBackgroundColor(Color.BLACK); photoView.setScaleType(ImageView.ScaleType.FIT_CENTER); photoView.setEnabled(true); EMImageMessageBody messageBody = (EMImageMessageBody) mDataList.get(position).getBody(); String localUrl = messageBody.getLocalUrl(); String remoteUrl = messageBody.getRemoteUrl(); if (StringUtil.isNotEmpty(localUrl) && new File(localUrl).exists()) CommonUtils.getInstance().getImageDisplayer().display(mActivity, photoView, localUrl, mScreenWidth, mScreenHeight , R.drawable.pic_image_detail_place_holder, R.drawable.pic_image_detail_fail); else CommonUtils.getInstance().getImageDisplayer().display(mActivity, photoView, remoteUrl, mScreenWidth, mScreenHeight , R.drawable.pic_image_detail_place_holder, R.drawable.pic_image_detail_fail); 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 #29
Source File: PhotoDetailActivity.java From ZZShow with Apache License 2.0 | 5 votes |
@Override public void initViews() { Picasso.with(this) .load(mPhotoUrl) .placeholder(R.mipmap.ic_loading) .error(R.mipmap.ic_load_fail) .into(mImgIv); mPhotoIv.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float v, float v1) { hideToolBarAndTextView(); hideOrShowStatusBar(); } @Override public void onOutsidePhotoTap() { } }); // Glide.with(this).load(mPhotoUrl) // .asBitmap() // .format(DecodeFormat.PREFER_ARGB_8888) // .placeholder(R.mipmap.ic_loading) // .error(R.mipmap.ic_load_fail) // .diskCacheStrategy(DiskCacheStrategy.ALL) // .into(new SimpleTarget<Bitmap>() { // @Override // public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) { // Log.d("ThreadName","----------------"+Thread.currentThread().getName()); // mImgIv.setImageBitmap(resource); // } // }); initLazyLoadView(); }
Example #30
Source File: PDFPagerAdapter.java From BookReader with Apache License 2.0 | 5 votes |
@Override @SuppressWarnings("NewApi") public Object instantiateItem(ViewGroup container, int position) { View v = inflater.inflate(R.layout.view_pdf_page, container, false); ImageView iv = (ImageView) v.findViewById(R.id.imageView); if (renderer == null || getCount() < position) { return v; } PdfRenderer.Page page = getPDFPage(renderer, position); Bitmap bitmap = bitmapContainer.get(position); page.render(bitmap, null, null, PdfRenderer.Page.RENDER_MODE_FOR_DISPLAY); page.close(); PhotoViewAttacher attacher = new PhotoViewAttacher(iv); attacher.setScale(scale.getScale(), scale.getCenterX(), scale.getCenterY(), true); attacher.setOnMatrixChangeListener(this); attachers.put(position, new WeakReference<PhotoViewAttacher>(attacher)); iv.setImageBitmap(bitmap); attacher.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() { @Override public void onPhotoTap(View view, float x, float y) { if (pageClickListener != null) { pageClickListener.onPageTap(view, x, y); } } }); attacher.update(); container.addView(v, 0); return v; }