Search in sources :

Example 6 with SubsamplingScaleImageView

use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project Slide by ccrama.

the class Image method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup rootView = (ViewGroup) inflater.inflate(R.layout.submission_imagecard, container, false);
    final SubsamplingScaleImageView image = (SubsamplingScaleImageView) rootView.findViewById(R.id.image);
    TextView title = (TextView) rootView.findViewById(R.id.title);
    TextView desc = (TextView) rootView.findViewById(R.id.desc);
    title.setVisibility(View.GONE);
    desc.setVisibility(View.GONE);
    ((Reddit) getContext().getApplicationContext()).getImageLoader().loadImage(url, new SimpleImageLoadingListener() {

        @Override
        public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
            image.setImage(ImageSource.bitmap(loadedImage));
        }
    });
    return rootView;
}
Also used : SimpleImageLoadingListener(com.nostra13.universalimageloader.core.listener.SimpleImageLoadingListener) Bitmap(android.graphics.Bitmap) ViewGroup(android.view.ViewGroup) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) TextView(android.widget.TextView) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) TextView(android.widget.TextView) View(android.view.View)

Example 7 with SubsamplingScaleImageView

use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project Camera-Roll-Android-App by kollerlukas.

the class SetWallpaperActivity method setWallpaper.

private void setWallpaper(int which) {
    try {
        WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
        InputStream inputStream = getContentResolver().openInputStream(imageUri);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
            Rect croppedRect = getCroppedRect();
            switch(which) {
                case HOME_SCREEN:
                    wallpaperManager.setStream(inputStream, croppedRect, true, WallpaperManager.FLAG_SYSTEM);
                    break;
                case LOCK_SCREEN:
                    wallpaperManager.setStream(inputStream, croppedRect, true, WallpaperManager.FLAG_LOCK);
                    break;
                case BOTH:
                    wallpaperManager.setStream(inputStream, croppedRect, true);
                    break;
            }
        } else {
            wallpaperManager.setStream(inputStream);
        }
        SubsamplingScaleImageView imageView = findViewById(R.id.imageView);
        imageView.recycle();
        this.finish();
    } catch (IOException | IllegalArgumentException e) {
        e.printStackTrace();
        Toast.makeText(this, R.string.error, Toast.LENGTH_SHORT).show();
    }
}
Also used : Rect(android.graphics.Rect) InputStream(java.io.InputStream) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) IOException(java.io.IOException) WallpaperManager(android.app.WallpaperManager)

Example 8 with SubsamplingScaleImageView

use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project Camera-Roll-Android-App by kollerlukas.

the class SetWallpaperActivity method getCroppedRect.

private Rect getCroppedRect() {
    SubsamplingScaleImageView imageView = findViewById(R.id.imageView);
    PointF center = imageView.getCenter();
    if (center != null) {
        int left = (int) (center.x - imageView.getWidth() / 2);
        return new Rect(left, 0, imageView.getSWidth(), imageView.getSHeight());
    }
    return new Rect(0, 0, imageView.getSWidth(), imageView.getSHeight());
}
Also used : Rect(android.graphics.Rect) PointF(android.graphics.PointF) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView)

Example 9 with SubsamplingScaleImageView

use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project Camera-Roll-Android-App by kollerlukas.

the class PhotoViewHolder method bindImageView.

void bindImageView(View view, final View transitionView) {
    if (albumItem.error) {
        transitionView.setVisibility(View.VISIBLE);
        ItemViewUtil.bindTransitionView((ImageView) transitionView, albumItem);
        return;
    }
    if (imageViewWasBound) {
        return;
    }
    final SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) view;
    // use custom decoders
    imageView.setBitmapDecoderClass(getImageDecoderClass());
    imageView.setRegionDecoderClass(getBitmapRegionDecoderClass());
    imageView.setMinimumTileDpi(196);
    imageView.setMinimumDpi(80);
    // imageView.setDoubleTapZoomDpi(196);
    imageView.setDoubleTapZoomScale(1.0f);
    // imageView.setOrientation(SubsamplingScaleImageView.ORIENTATION_USE_EXIF);
    int orientation = ExifUtil.getExifOrientationAngle(view.getContext(), albumItem);
    imageView.setOrientation(orientation);
    final GestureDetector gestureDetector = new GestureDetector(imageView.getContext(), new GestureDetector.SimpleOnGestureListener() {

        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            PhotoViewHolder.super.imageOnClick(imageView);
            return super.onSingleTapUp(e);
        }
    });
    view.setOnTouchListener(new View.OnTouchListener() {

        @SuppressLint("ClickableViewAccessibility")
        @Override
        public boolean onTouch(View view, MotionEvent motionEvent) {
            return gestureDetector.onTouchEvent(motionEvent);
        }
    });
    ItemViewUtil.bindSubsamplingImageView(imageView, (Photo) albumItem, new SubsamplingScaleImageView.DefaultOnImageEventListener() {

        @Override
        public void onImageLoaded() {
            super.onImageLoaded();
            transitionView.setVisibility(View.INVISIBLE);
            imageViewWasBound = true;
            PhotoViewHolder.this.onImageLoaded();
        }
    });
}
Also used : SuppressLint(android.annotation.SuppressLint) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) GestureDetector(android.view.GestureDetector) ImageView(android.widget.ImageView) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) View(android.view.View) SuppressLint(android.annotation.SuppressLint) MotionEvent(android.view.MotionEvent)

Example 10 with SubsamplingScaleImageView

use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project Camera-Roll-Android-App by kollerlukas.

the class PhotoViewHolder method onDestroy.

@Override
public void onDestroy() {
    final SubsamplingScaleImageView imageView = itemView.findViewById(R.id.subsampling);
    if (imageView != null) {
        imageView.recycle();
    }
    super.onDestroy();
}
Also used : SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView)

Aggregations

SubsamplingScaleImageView (com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView)30 View (android.view.View)18 PointF (android.graphics.PointF)5 Rect (android.graphics.Rect)4 OnClickListener (android.view.View.OnClickListener)4 TextView (android.widget.TextView)4 GestureDetector (android.view.GestureDetector)3 MotionEvent (android.view.MotionEvent)3 ImageView (android.widget.ImageView)2 ImageViewState (com.davemorrissey.labs.subscaleview.ImageViewState)2 SuppressLint (android.annotation.SuppressLint)1 WallpaperManager (android.app.WallpaperManager)1 Intent (android.content.Intent)1 Bitmap (android.graphics.Bitmap)1 RequiresApi (android.support.annotation.RequiresApi)1 ActionBar (android.support.v7.app.ActionBar)1 RecyclerView (android.support.v7.widget.RecyclerView)1 Toolbar (android.support.v7.widget.Toolbar)1 OnTouchListener (android.view.View.OnTouchListener)1 ViewGroup (android.view.ViewGroup)1