Search in sources :

Example 6 with PhotoView

use of uk.co.senab.photoview.PhotoView in project weiciyuan by qii.

the class GalleryActivity method handlePage.

private void handlePage(int position, View contentView, boolean fromInstantiateItem) {
    final PhotoView imageView = (PhotoView) contentView.findViewById(R.id.image);
    imageView.setVisibility(View.INVISIBLE);
    if (SettingUtility.allowClickToCloseGallery()) {
        imageView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {

            @Override
            public void onPhotoTap(View view, float x, float y) {
                if (rect == null || imageView == null || (!(imageView.getDrawable() instanceof BitmapDrawable))) {
                    GalleryActivity.this.finish();
                    return;
                }
                animateClose(imageView);
            }
        });
    }
    WebView gif = (WebView) contentView.findViewById(R.id.gif);
    gif.setBackgroundColor(getResources().getColor(R.color.transparent));
    gif.setVisibility(View.INVISIBLE);
    WebView large = (WebView) contentView.findViewById(R.id.large);
    large.setBackgroundColor(getResources().getColor(R.color.transparent));
    large.setVisibility(View.INVISIBLE);
    large.setOverScrollMode(View.OVER_SCROLL_NEVER);
    if (Utility.doThisDeviceOwnNavigationBar(GalleryActivity.this)) {
        imageView.setPadding(0, 0, 0, Utility.dip2px(NAVIGATION_BAR_HEIGHT_DP_UNIT));
        // webview has a bug, padding is ignored
        gif.setPadding(0, 0, 0, Utility.dip2px(NAVIGATION_BAR_HEIGHT_DP_UNIT));
        large.setPadding(0, 0, 0, Utility.dip2px(NAVIGATION_BAR_HEIGHT_DP_UNIT));
    }
    TextView wait = (TextView) contentView.findViewById(R.id.wait);
    TextView readError = (TextView) contentView.findViewById(R.id.error);
    String path = FileManager.getFilePathFromUrl(urls.get(position), FileLocationMethod.picture_large);
    boolean shouldDownLoadPicture = !fromInstantiateItem || (fromInstantiateItem && Utility.isWifi(GalleryActivity.this));
    // sometime picture is not downloaded completely, but android already can read it....
    if (ImageUtility.isThisBitmapCanRead(path) && taskMap.get(urls.get(position)) == null && TaskCache.isThisUrlTaskFinished(urls.get(position))) {
        wait.setVisibility(View.INVISIBLE);
        readPicture(imageView, gif, large, readError, urls.get(position), path);
    } else if (shouldDownLoadPicture) {
        final CircleProgressView spinner = (CircleProgressView) contentView.findViewById(R.id.loading);
        spinner.setVisibility(View.VISIBLE);
        if (taskMap.get(urls.get(position)) == null) {
            wait.setVisibility(View.VISIBLE);
            PicSimpleBitmapWorkerTask task = new PicSimpleBitmapWorkerTask(imageView, gif, large, spinner, wait, readError, urls.get(position), taskMap);
            taskMap.put(urls.get(position), task);
            task.executeOnExecutor(MyAsyncTask.THREAD_POOL_EXECUTOR);
        } else {
            PicSimpleBitmapWorkerTask task = taskMap.get(urls.get(position));
            task.setWidget(imageView, gif, spinner, wait, readError);
        }
    }
}
Also used : BitmapDrawable(android.graphics.drawable.BitmapDrawable) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) ImageView(android.widget.ImageView) View(android.view.View) WebView(android.webkit.WebView) TextView(android.widget.TextView) CircleProgressView(org.qii.weiciyuan.support.lib.CircleProgressView) PhotoView(uk.co.senab.photoview.PhotoView) PhotoView(uk.co.senab.photoview.PhotoView) TextView(android.widget.TextView) WebView(android.webkit.WebView) CircleProgressView(org.qii.weiciyuan.support.lib.CircleProgressView)

Example 7 with PhotoView

use of uk.co.senab.photoview.PhotoView in project JustAndroid by chinaltz.

the class PictureImagePreviewFragment method onCreateView.

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View contentView = inflater.inflate(R.layout.picture_fragment_image_preview, container, false);
    final PhotoView imageView = (PhotoView) contentView.findViewById(R.id.preview_image);
    LocalMedia media = (LocalMedia) getArguments().getSerializable(PictureConfig.EXTRA_MEDIA);
    if (media.isCompressed()) {
        // 压缩过,或者裁剪同时压缩过,以最终压缩过图片为准
        path = media.getCompressPath();
    } else {
        path = media.getPath();
    }
    String pictureType = media.getPictureType();
    isSave = getArguments().getBoolean("isSave");
    directory_path = getArguments().getString(PictureConfig.DIRECTORY_PATH);
    if (!isSave && path.startsWith("http")) {
        showPleaseDialog();
    }
    boolean isGif = PictureMimeType.isGif(pictureType);
    // 压缩过的gif就不是gif了
    if (isGif && !media.isCompressed()) {
        Glide.with(container.getContext()).load(path).asGif().override(480, 800).diskCacheStrategy(DiskCacheStrategy.SOURCE).priority(Priority.HIGH).into(imageView);
        dismissDialog();
    } else {
        Glide.with(container.getContext()).load(path).asBitmap().diskCacheStrategy(DiskCacheStrategy.RESULT).into(new SimpleTarget<Bitmap>(480, 800) {

            @Override
            public void onResourceReady(Bitmap resource, GlideAnimation<? super Bitmap> glideAnimation) {
                imageView.setImageBitmap(resource);
                dismissDialog();
            }
        });
    }
    imageView.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {

        @Override
        public void onViewTap(View view, float x, float y) {
            getActivity().finish();
            getActivity().overridePendingTransition(0, R.anim.a3);
        }
    });
    imageView.setOnLongClickListener(new View.OnLongClickListener() {

        @Override
        public boolean onLongClick(View v) {
            // 内部预览不保存
            if (!isSave) {
                if (hasPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE)) {
                    showDownLoadDialog(path);
                } else {
                    requestPermission(Constant.WRITE_EXTERNAL_STORAGE, Manifest.permission.WRITE_EXTERNAL_STORAGE);
                }
            }
            return true;
        }
    });
    return contentView;
}
Also used : View(android.view.View) PhotoView(uk.co.senab.photoview.PhotoView) TextView(android.widget.TextView) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) PhotoView(uk.co.senab.photoview.PhotoView) Bitmap(android.graphics.Bitmap) LocalMedia(com.ningcui.mylibrary.viewLib.Imagepicker.entity.LocalMedia) Nullable(android.support.annotation.Nullable)

Example 8 with PhotoView

use of uk.co.senab.photoview.PhotoView in project SeriesGuide by UweTrottmann.

the class FullscreenImageActivity method setupViews.

private void setupViews() {
    photoView = (PhotoView) findViewById(R.id.fullscreen_content);
    // try to immediately show cached preview image
    String previewImagePath = getIntent().getStringExtra(EXTRA_PREVIEW_IMAGE);
    if (!TextUtils.isEmpty(previewImagePath)) {
        ServiceUtils.loadWithPicasso(this, previewImagePath).networkPolicy(NetworkPolicy.OFFLINE).into(photoView, new Callback() {

            @Override
            public void onSuccess() {
                loadLargeImage(true);
            }

            @Override
            public void onError() {
                loadLargeImage(false);
            }
        });
    } else {
        loadLargeImage(false);
    }
    // Set up an instance of SystemUiHider to control the system UI for
    // this activity.
    systemUiHider = SystemUiHider.getInstance(this, photoView, SystemUiHider.FLAG_FULLSCREEN);
    systemUiHider.setup();
    photoView.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {

        @Override
        public void onViewTap(View view, float x, float y) {
            systemUiHider.toggle();
        }
    });
}
Also used : Callback(com.squareup.picasso.Callback) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) ImageView(android.widget.ImageView) PhotoView(uk.co.senab.photoview.PhotoView) View(android.view.View)

Example 9 with PhotoView

use of uk.co.senab.photoview.PhotoView in project Douya by DreaminginCodeZH.

the class GalleryAdapter method instantiateItem.

@Override
public View instantiateItem(ViewGroup container, int position) {
    View layout = ViewUtils.inflate(R.layout.gallery_item, container);
    PhotoView imageView = ButterKnife.findById(layout, R.id.image);
    final TextView errorText = ButterKnife.findById(layout, R.id.error);
    final ProgressBar progressBar = ButterKnife.findById(layout, R.id.progress);
    imageView.setOnViewTapListener(new PhotoViewAttacher.OnViewTapListener() {

        @Override
        public void onViewTap(View view, float x, float y) {
            if (mOnTapListener != null) {
                mOnTapListener.onTap();
            }
        }
    });
    ImageUtils.loadImage(imageView, mImageList.get(position), new RequestListener<String, GlideDrawable>() {

        @Override
        public boolean onException(Exception e, String model, Target<GlideDrawable> target, boolean isFirstResource) {
            (e != null ? e : new NullPointerException()).printStackTrace();
            int errorRes = e != null && e.getCause() instanceof TimeoutError ? R.string.gallery_load_timeout : R.string.gallery_load_error;
            errorText.setText(errorRes);
            ViewUtils.crossfade(progressBar, errorText);
            return false;
        }

        @Override
        public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
            ViewUtils.fadeOut(progressBar);
            return false;
        }
    });
    container.addView(layout);
    return layout;
}
Also used : TimeoutError(com.android.volley.TimeoutError) PhotoView(uk.co.senab.photoview.PhotoView) TextView(android.widget.TextView) View(android.view.View) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher) PhotoView(uk.co.senab.photoview.PhotoView) TextView(android.widget.TextView) ProgressBar(android.widget.ProgressBar) GlideDrawable(com.bumptech.glide.load.resource.drawable.GlideDrawable)

Example 10 with PhotoView

use of uk.co.senab.photoview.PhotoView in project PhotoNoter by yydcdut.

the class PhotoDetailPagerAdapter method instantiateItem.

@Override
public View instantiateItem(ViewGroup container, int position) {
    final PhotoView photoView = new PhotoView(container.getContext());
    ImageLoaderManager.displayImage("file:/" + mPhotoPathList.get(position), photoView, ImageLoaderManager.getGalleryOptions());
    container.addView(photoView, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    photoView.setOnPhotoTapListener(this);
    return photoView;
}
Also used : PhotoView(uk.co.senab.photoview.PhotoView)

Aggregations

PhotoView (uk.co.senab.photoview.PhotoView)16 View (android.view.View)12 PhotoViewAttacher (uk.co.senab.photoview.PhotoViewAttacher)8 Bitmap (android.graphics.Bitmap)4 ImageView (android.widget.ImageView)4 TextView (android.widget.TextView)4 AnimatorSet (android.animation.AnimatorSet)2 Rect (android.graphics.Rect)2 BitmapDrawable (android.graphics.drawable.BitmapDrawable)2 Bundle (android.os.Bundle)2 Nullable (android.support.annotation.Nullable)2 ViewTreeObserver (android.view.ViewTreeObserver)2 AccelerateDecelerateInterpolator (android.view.animation.AccelerateDecelerateInterpolator)2 WebView (android.webkit.WebView)2 File (java.io.File)2 AnimationRect (org.qii.weiciyuan.support.lib.AnimationRect)2 CircleProgressView (org.qii.weiciyuan.support.lib.CircleProgressView)2 ProgressDialog (android.app.ProgressDialog)1 DialogInterface (android.content.DialogInterface)1 Intent (android.content.Intent)1