Search in sources :

Example 26 with SubsamplingScaleImageView

use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project subsampling-scale-image-view by davemorrissey.

the class ImageDisplayRotateFragment method onCreateView.

@Override
public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View rootView = inflater.inflate(layout.imagedisplay_rotate_fragment, container, false);
    final SubsamplingScaleImageView imageView = rootView.findViewById(id.imageView);
    imageView.setImage(ImageSource.asset("swissroad.jpg"));
    imageView.setOrientation(90);
    final ImageDisplayActivity activity = (ImageDisplayActivity) getActivity();
    if (activity != null) {
        rootView.findViewById(id.previous).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                activity.previous();
            }
        });
        rootView.findViewById(id.next).setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                activity.next();
            }
        });
    }
    rootView.findViewById(id.rotate).setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            imageView.setOrientation((imageView.getOrientation() + 90) % 360);
        }
    });
    return rootView;
}
Also used : SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) View(android.view.View)

Example 27 with SubsamplingScaleImageView

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

the class ItemActivity method onSaveInstanceState.

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (albumItem instanceof Photo) {
        View itemView = viewPager.findViewWithTag(albumItem.getPath());
        if (itemView != null) {
            View view = itemView.findViewById(R.id.subsampling);
            if (view instanceof SubsamplingScaleImageView) {
                SubsamplingScaleImageView imageView = (SubsamplingScaleImageView) view;
                ImageViewState state = imageView.getState();
                if (state != null) {
                    outState.putSerializable(IMAGE_VIEW_SAVED_STATE, state);
                }
            }
        }
    }
    // outState.putParcelable(ALBUM, album);
    outState.putParcelable(ALBUM_ITEM, albumItem);
    outState.putBoolean(WAS_SYSTEM_UI_HIDDEN, !systemUiVisible);
    outState.putBoolean(INFO_DIALOG_SHOWN, infoDialog != null);
}
Also used : Photo(us.koller.cameraroll.data.models.Photo) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) ImageView(android.widget.ImageView) View(android.view.View) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) RecyclerView(android.support.v7.widget.RecyclerView) ImageViewState(com.davemorrissey.labs.subscaleview.ImageViewState)

Example 28 with SubsamplingScaleImageView

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

the class SetWallpaperActivity method onSaveInstanceState.

@Override
protected void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    SubsamplingScaleImageView imageView = findViewById(R.id.imageView);
    outState.putSerializable(IMAGE_VIEW_STATE, imageView.getState());
}
Also used : SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView)

Example 29 with SubsamplingScaleImageView

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

the class SetWallpaperActivity method onCreate.

@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_set_wallpaper);
    Intent intent = getIntent();
    if (intent == null) {
        return;
    }
    final Toolbar toolbar = findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setTitle("");
        actionBar.setDisplayHomeAsUpEnabled(true);
    }
    imageUri = intent.getData();
    if (!MediaType.suitableAsWallpaper(this, imageUri)) {
        Toast.makeText(this, R.string.wallpaper_file_format_not_supported, Toast.LENGTH_SHORT).show();
        finish();
    }
    final SubsamplingScaleImageView imageView = findViewById(R.id.imageView);
    ImageViewState imageViewState = null;
    if (savedInstanceState != null && savedInstanceState.containsKey(IMAGE_VIEW_STATE)) {
        imageViewState = (ImageViewState) savedInstanceState.getSerializable(IMAGE_VIEW_STATE);
    }
    imageView.setMinimumTileDpi(196);
    // use custom decoders
    imageView.setRegionDecoderClass(CustomRegionDecoder.class);
    imageView.setImage(ImageSource.uri(imageUri), imageViewState);
    imageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_CROP);
    if (imageViewState == null) {
        imageView.setOnImageEventListener(new SubsamplingScaleImageView.DefaultOnImageEventListener() {

            @Override
            public void onImageLoaded() {
                super.onImageLoaded();
                float scale = imageView.getScale();
                PointF center = new PointF(imageView.getWidth() / 2, 0.0f);
                imageView.setScaleAndCenter(scale, center);
            }
        });
    }
    // setting window insets manually
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT_WATCH) {
        toolbar.setOnApplyWindowInsetsListener(new View.OnApplyWindowInsetsListener() {

            @Override
            @RequiresApi(api = Build.VERSION_CODES.KITKAT_WATCH)
            public WindowInsets onApplyWindowInsets(View view, WindowInsets insets) {
                // clear this listener so insets aren't re-applied
                toolbar.setOnApplyWindowInsetsListener(null);
                toolbar.setPadding(toolbar.getPaddingStart() + insets.getSystemWindowInsetLeft(), toolbar.getPaddingTop() + insets.getSystemWindowInsetTop(), toolbar.getPaddingEnd() + insets.getSystemWindowInsetRight(), toolbar.getPaddingBottom());
                return insets.consumeSystemWindowInsets();
            }
        });
    } else {
        toolbar.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

            @Override
            public void onGlobalLayout() {
                toolbar.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                // hacky way of getting window insets on pre-Lollipop
                // somewhat works...
                int[] screenSize = Util.getScreenSize(SetWallpaperActivity.this);
                int[] windowInsets = new int[] { Math.abs(screenSize[0] - toolbar.getLeft()), Math.abs(screenSize[1] - toolbar.getTop()), Math.abs(screenSize[2] - toolbar.getRight()), Math.abs(0) };
                toolbar.setPadding(toolbar.getPaddingStart() + windowInsets[0], toolbar.getPaddingTop() + windowInsets[1], toolbar.getPaddingEnd() + windowInsets[2], toolbar.getPaddingBottom());
            }
        });
    }
    // needed to achieve transparent navBar
    getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE);
}
Also used : PointF(android.graphics.PointF) Intent(android.content.Intent) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) ImageViewState(com.davemorrissey.labs.subscaleview.ImageViewState) View(android.view.View) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) WindowInsets(android.view.WindowInsets) RequiresApi(android.support.annotation.RequiresApi) ViewTreeObserver(android.view.ViewTreeObserver) ActionBar(android.support.v7.app.ActionBar) Toolbar(android.support.v7.widget.Toolbar)

Example 30 with SubsamplingScaleImageView

use of com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView in project LeafPic by HoraApps.

the class ImageFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    if (PreferenceUtil.getInstance(getContext()).getBoolean(getString(R.string.preference_sub_scaling), false)) {
        SubsamplingScaleImageView imageView = new SubsamplingScaleImageView(getContext());
        imageView.setImage(ImageSource.uri(img.getUri()));
        imageView.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                ((SingleMediaActivity) getActivity()).toggleSystemUI();
            }
        });
        return imageView;
    } else {
        PhotoView photoView = new PhotoView(getContext());
        displayMedia(photoView, true);
        photoView.setOnPhotoTapListener(new PhotoViewAttacher.OnPhotoTapListener() {

            @Override
            public void onPhotoTap(View view, float x, float y) {
                ((SingleMediaActivity) getActivity()).toggleSystemUI();
            }

            @Override
            public void onOutsidePhotoTap() {
                ((SingleMediaActivity) getActivity()).toggleSystemUI();
            }
        });
        photoView.setMaximumScale(5.0F);
        photoView.setMediumScale(3.0F);
        return photoView;
    }
}
Also used : PhotoView(uk.co.senab.photoview.PhotoView) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) PhotoView(uk.co.senab.photoview.PhotoView) SubsamplingScaleImageView(com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView) View(android.view.View) PhotoViewAttacher(uk.co.senab.photoview.PhotoViewAttacher)

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