GithubHelp home page GithubHelp logo

stfalcon-studio / stfalconimageviewer Goto Github PK

View Code? Open in Web Editor NEW
2.0K 32.0 251.0 9.74 MB

A simple and customizable Android full-screen image viewer with shared image transition support, "pinch to zoom" and "swipe to dismiss" gestures

Home Page: http://stfalcon.com

License: Apache License 2.0

Java 21.25% Kotlin 78.75%
android imageviewer swipe-to-dismiss transitions pinch-to-zoom zoom android-library viewer gallery photo-gallery

stfalconimageviewer's Introduction

codebeat badge Codacy Badge Download License

Stfalcon ImageViewer

A simple and customizable full-screen image viewer with shared image transition support, "pinch to zoom" and "swipe to dismiss" gestures. Compatible with all of the most popular image processing libraries such as Picasso, Glide etc. Based on PhotoView by chrisbanes.

alt tag alt tag

Who we are

Need iOS and Android apps, MVP development or prototyping? Contact us via [email protected]. We develop software since 2009, and we're known experts in this field. Check out our portfolio and see more libraries from stfalcon-studio.

Requirements

  • A project configured with the AndroidX
  • SDK 19 and and higher

Demo Application

Get it on Google Play

Install

Download via Gradle:

Add this to the project build.gradle file:

allprojects {
    repositories {
        ...
        maven { url "https://jitpack.io" }
    }
}

And then add the dependency to the module build.gradle file:

implementation 'com.github.stfalcon-studio:StfalconImageViewer:v1.0.1'

Download via Maven:

<dependency>
  <groupId>com.github.stfalcon</groupId>
  <artifactId>stfalcon-imageviewer</artifactId>
  <version>latest_version</version>
  <type>pom</type>
</dependency>

Where the latest_version is the value from Download badge.

Usage

Simple usage

All you need to show the viewer is to pass the context, list or array of your image objects and the implementation of the ImageLoader and call the show() method:

StfalconImageViewer.Builder<Image>(context, images) { view, image ->
    Picasso.get().load(image.url).into(view)
}.show()

Piece of cake!

Transition animation

To improve the UX of your app you would like to add a transition when a user opens the viewer. And this is simple as never before! Just tell the viewer which image should be used for animation using withTransitionFrom(myImageView) method and the library will do it for you!

If you need more advanced behavior like updating transition target while changing images in the viewer please see the sample app for how to do this.

Update images list on the fly

There are a lot of common cases (such as pagination, deleting, editing etc.) where you need to update the existing images list while the viewer is running. To do this you can simply update the existing list (or even replace it with a new one) and then call updateImages(images).

Change current image

Images are not always leafed through by the user. Maybe you want to implement some kind of preview list at the bottom of the viewer - setCurrentPosition is here for help. Change images programmatically wherever you want!

Custom overlay view

If you need to show some content over the image (e.g. sharing or download button, description, numeration etc.) you can set your own custom view using the setOverlayView(customView) and bind it with the viewer through the ImageViewer.OnImageChangeListener.

Background

Use the setBackgroundColorRes(colorRes) or setBackgroundColor(colorInt) to set a color of the fading background.

Images margin

Simply add margins between images using the withImagesMargin(context, dimenRes) method for dimensions, or use the withImageMarginPixels(int) for pixels size.

Container padding

Overlay image hides part of the images? Set container padding with dimens using withContainerPadding(context, start, top, end, bottom) or withContainerPadding(context, dimen) for all of the sides evenly. For setting a padding in pixels, just use the withContainerPadding(...) methods variant.

Status bar visibility

Control the status bar visibility of the opened viewer by using the withHiddenStatusBar(boolean) method (true by default)

Gestures

If you need to disable some of the gestures - you can use the allowSwipeToDismiss(boolean) and allowZooming(boolean) methods accordingly.

Options overview

Here is the example with all of the existing options applied:

StfalconImageViewer.Builder<String>(this, images, ::loadImage)
            .withStartPosition(startPosition)
            .withBackgroundColor(color)
            //.withBackgroundColorResource(R.color.color)
            .withOverlayView(view)
            .withImagesMargin(R.dimen.margin)
            //.withImageMarginPixels(margin)
            .withContainerPadding(R.dimen.padding)
            //.withContainerPadding(R.dimen.paddingStart, R.dimen.paddingTop, R.dimen.paddingEnd, R.dimen.paddingBottom)
            //.withContainerPaddingPixels(padding)
            //.withContainerPaddingPixels(paddingStart, paddingTop, paddingEnd, paddingBottom)
            .withHiddenStatusBar(shouldHideStatusBar)
            .allowZooming(isZoomingAllowed)
            .allowSwipeToDismiss(isSwipeToDismissAllowed)
            .withTransitionFrom(targeImageView)
            .withImageChangeListener(::onImageChanged)
            .withDismissListener(::onViewerDismissed)
            .withDismissListener(::onViewerDismissed)

Also, you can take a look at the sample project for more information.

Usage with Fresco

If you use the Fresco library - check out the FrescoImageViewer which was also developed by our team.

License

Copyright (C) 2018 stfalcon.com

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

stfalconimageviewer's People

Contributors

adrianhartanto004 avatar bevzaanton avatar iamareebjamal avatar svank avatar troy379 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

stfalconimageviewer's Issues

OnClickListener on Overlay buttons not working

I have an overlay with a few options: Share,Delete
I set onclick listener as below but the buttons dont respond to click. Instead, the options disappear from the screen as they would when you click on the Imageviewer.

@OverRide
public void onClick(View view) {

                // Inflate the layout for this
                LayoutInflater inflater = LayoutInflater.from(mContext);
                final View frescoView = inflater.inflate(R.layout.activity_image_options, null);

                new StfalconImageViewer.Builder<>(mContext, imageList, new ImageLoader<Decode_images>() {
                    @Override
                    public void loadImage(ImageView imageView, Decode_images image) {
                        //Usage with picasso... you can use glide too
                        Picasso.get().load(URL_UploadPath+image.getResource_name()).into(imageView);

                    }
                })
                .withStartPosition(position)
                .withOverlayView(frescoView)
                .withImageChangeListener(new OnImageChangeListener() {
                    @Override
                    public void onImageChange(final int position) {
                        //Get actual pic name
                        pic_name=imageList.get(position).getResource_name();
                        pic_position=position;

                        //Set onclick listeners to the overlay buttons
                        make_cover = frescoView.findViewById(R.id.make_cover);
                        share_image = frescoView.findViewById(R.id.share_image);
                        delete_image = frescoView.findViewById(R.id.delete_image);

                        **make_cover.setOnClickListener(new View.OnClickListener() {
                            @Override
                            public void onClick(View view) {
                                //Confirm alert
                                AlertDialog alertDialog = new AlertDialog.Builder(mContext).create();
                                alertDialog.setMessage("Make this image house cover image?");

                                alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Ok", new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dialog, int which) {
                                        //
                                        initialize_house_cover();
                                    }
                                });
                                alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
                                    @Override
                                    public void onClick(DialogInterface dialogInterface, int i) {

                                    }
                                });

                                alertDialog.show();
                            }
                        });**

Multiple listeners support

Hi! README example provides following code:
... .withDismissListener(::onViewerDismissed) .withDismissListener(::onViewerDismissed)
But onDismissListener is rewritable field. Could you provide multiple listeners support please.

is it possible to override the click on overlay ?

I am putting an EditText in the overlay, and want to dismiss focus when clicked outside
but clicking outside will hide the overlay, which i want to prevent
is there simple way to do that ? thanks

Looking for the java documentation of that library.

I'm android learner and I'm using java.
What is the java version of that code ?:
new StfalconImageViewer.Builder<>(context, images, new ImageLoader<String>() { @Override public void loadImage(ImageView imageView, String imageUrl) { Glide.with(context).load(imageUrl).into(imageView) } }).show();

When using it in my java code, <> is red marked with message: Cannot infer arguments(unable to resolve constructor)

Thanks.

Usage in Java only Project

I have a java-only Android Project and I wanted to use this library but android studio is giving me error , 'Identitfier expected' in this line StfalconImageViewer.Builder(this, images )
Please provide a comprehensive documentation for its use in java project or include a java sample with this library's use it will be of great help

dialog can not dismiss

To Reproduce

  1. I use this library on the chat page (recyclerView)
  2. Click image into viewer
  3. New message coming to bring the picture out of the screen
  4. Click the back button to exit

I try to track the source code
TransitionImageAnimator handleCloseTransitionEnd

externalImage?.post { onTransitionEnd() }
This line of code didn't work

internalImage.post { onTransitionEnd() }
now,I temporarily used this line of code to solve this problem.

Is it possible to programmaticaly change the curently displayed image (by pos)

The idea is to add a view overlay containing a horizontal thumbs list at the bottom of the screen. So when a user clicks a thumb from the list, the falcon image viewer updates the currently displayed image (maybe with a gesture-like animation as well).

Is this possible?
Maybe i can achieve it by updating the image list on the fly?

Gradle Build Error: Could not find com.github.chrisbanes:PhotoView:2.2.0.

I have tried to implement the simple example in the readme using Glide but I get this error:

Could not find com.github.chrisbanes:PhotoView:2.2.0.
Searched in the following locations:
  - https://dl.google.com/dl/android/maven2/com/github/chrisbanes/PhotoView/2.2.0/PhotoView-2.2.0.pom
  - https://jcenter.bintray.com/com/github/chrisbanes/PhotoView/2.2.0/PhotoView-2.2.0.pom
Required by:
    project :app > com.github.stfalcon:stfalcon-imageviewer:1.0.1

Here is my project and app level build.gradle files:

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    ext {
        kotlin_version = "1.4.10"
    }

    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://jitpack.io" }
    }
    dependencies {
        classpath "com.android.tools.build:gradle:4.0.1"
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
        classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0"
        classpath 'com.google.gms:google-services:4.3.3'

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}
...
    // image display
    implementation 'com.github.stfalcon:stfalcon-imageviewer:1.0.1'
...

And the displaying code:

    private fun displayPhoto(imageUri: Uri) {
        StfalconImageViewer.Builder(context, listOf(imageUri)) { view, image ->
            GlideApp.with(requireContext()).load(image).into(view)
        }.show()
    }

Callback ImageLoader called twice

Describe the bug
The first time you call StfalconImageViewer.show(), the method used to load the image is called 2 times, because of this, the image may suddenly disappear / appear again, which is not nice.
This happens only on the first call, if you scroll through the gallery with gestures, then one call occurs as it should be.

To Reproduce
Steps to reproduce the behavior:
I tried running the demo there this error is reproducible as well.
To do this, just open file "com.stfalcon.sample.features.demo.grid.PostersGridDemoActivity" and replace method "loadPosterImage" to the following code:

    private fun loadPosterImage(imageView: ImageView, poster: Poster?) {
        Log.e("TEST", "loadPosterImage - "+poster?.url)
        imageView.apply {
            background = getDrawableCompat(R.drawable.shape_placeholder)
            loadImage(poster?.url)
        }
    }

Then we start the emulator (api 29), go to this window, open the console to display our error, clear it to remove the outputs loaded in the image grid.
We open any image in the grid, and we see on the console that the open image was loaded 2 times, that is, the callback was called twice.

swipeDismissHandler has not been initialized

Describe the bug
Great library! I'm just here to report a crash that's been popping up more and more on crashlytics in my production app that's coming from this library.

To Reproduce
I'm not sure how to reproduce, but I suspect it's a bug how the swipe dismiss handler is being initialized. Most recent crash was on a Galaxy J7 Crown running Android 9. I've seen a similar crash with "lateinit property transitionImageAnimator has not been initialized
at com.stfalcon.imageviewer.viewer.view.ImageViewerView.dispatchTouchEvent(ImageViewerView.kt:155)" and can file a separate bug if needed.

Fatal Exception: kotlin.UninitializedPropertyAccessException: lateinit property swipeDismissHandler has not been initialized at com.stfalcon.imageviewer.viewer.view.ImageViewerView.close$imageviewer_release(ImageViewerView.kt:205) at com.stfalcon.imageviewer.viewer.dialog.ImageViewerDialog.onDialogKeyEvent(ImageViewerDialog.kt:83) at com.stfalcon.imageviewer.viewer.dialog.ImageViewerDialog.access$onDialogKeyEvent(ImageViewerDialog.kt:27) at com.stfalcon.imageviewer.viewer.dialog.ImageViewerDialog$1.onKey(ImageViewerDialog.kt:47) at android.app.Dialog.dispatchKeyEvent(Dialog.java:965) at androidx.appcompat.app.AppCompatDialog.superDispatchKeyEvent(AppCompatDialog.java:201) at androidx.appcompat.app.AppCompatDialog$1.superDispatchKeyEvent(AppCompatDialog.java:48) at androidx.core.view.KeyEventDispatcher.dispatchKeyEvent(KeyEventDispatcher.java:84) at androidx.appcompat.app.AppCompatDialog.dispatchKeyEvent(AppCompatDialog.java:207) at androidx.appcompat.view.WindowCallbackWrapper.dispatchKeyEvent(WindowCallbackWrapper.java:59) at androidx.appcompat.app.AppCompatDelegateImpl$AppCompatWindowCallback.dispatchKeyEvent(AppCompatDelegateImpl.java:2814) at com.android.internal.policy.DecorView.dispatchKeyEvent(DecorView.java:586) at android.view.ViewRootImpl$ViewPostImeInputStage.processKeyEvent(ViewRootImpl.java:6119) at android.view.ViewRootImpl$ViewPostImeInputStage.onProcess(ViewRootImpl.java:5974) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5427) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5480) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5446) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5605) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5454) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5662) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5427) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5480) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5446) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5454) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5427) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5480) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5446) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5605) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5454) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5662) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5427) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5480) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5446) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5454) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5427) at android.view.ViewRootImpl$InputStage.onDeliverToNext(ViewRootImpl.java:5480) at android.view.ViewRootImpl$InputStage.forward(ViewRootImpl.java:5446) at android.view.ViewRootImpl$AsyncInputStage.forward(ViewRootImpl.java:5605) at android.view.ViewRootImpl$InputStage.apply(ViewRootImpl.java:5454) at android.view.ViewRootImpl$AsyncInputStage.apply(ViewRootImpl.java:5662) at android.view.ViewRootImpl$InputStage.deliver(ViewRootImpl.java:5427) at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:8504) at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:8424) at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:8377) at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:8619) at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:198) at android.os.MessageQueue.nativePollOnce(MessageQueue.java) at android.os.MessageQueue.next(MessageQueue.java:326) at android.os.Looper.loop(Looper.java:181) at android.app.ActivityThread.main(ActivityThread.java:7156) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)

Expected behavior
Don't crash

No image in viewer activity ..

Viewer activity is created but no image to zoom in on. Works fine in sample code downloaded from github but fails to load image when a new android project is created and I add the library. Could you please point me in the right direction ..

Steps to reproduce the behaviour :

  1. Create a new android kotlin project

  2. Update build.gradle(app) : minSDK version to 19, compileSdkVersion : 28

  3. Update build.gradle(app)
    //implementation 'com.android.support:appcompat-v7:28.0.0'
    api 'androidx.appcompat:appcompat:1.0.2'
    api 'androidx.transition:transition:1.0.1'
    implementation 'com.squareup.picasso:picasso:2.71828'
    implementation 'com.github.stfalcon:stfalcon-imageviewer:0.1.0'

  4. Include the following code at the end of onCreate function .. (same thing works fine in the sample code)

     StfalconImageViewer.Builder<String>(this, listOf("http://i.4cdn.org/h/1552306518047.png")) { view, image ->
         Picasso.get().load(image).into(view)
    

Another dead library?

Is this another dead library? No updates in ages.
Still advised to use it or not?

PagerAdapter Item Count Discrepency

Here is the log
java.lang.IllegalStateException: The application's PagerAdapter changed the adapter's contents without calling PagerAdapter#notifyDataSetChanged! Expected adapter item count: 28, found: 36 Pager id: com.a.b.c:id/imagesPager Pager class: class com.stfalcon.imageviewer.common.pager.MultiTouchViewPager Problematic adapter: class com.stfalcon.imageviewer.viewer.adapter.ImagesPagerAdapter at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1143) at androidx.viewpager.widget.ViewPager.populate(ViewPager.java:1092) at androidx.viewpager.widget.ViewPager.onMeasure(ViewPager.java:1622) at android.view.View.measure(View.java:23169) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:23169) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:23169) at android.widget.RelativeLayout.measureChildHorizontal(RelativeLayout.java:715) at android.widget.RelativeLayout.onMeasure(RelativeLayout.java:461) at android.view.View.measure(View.java:23169) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:23169) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:23169) at androidx.appcompat.widget.AlertDialogLayout.tryOnMeasure(AlertDialogLayout.java:134) at androidx.appcompat.widget.AlertDialogLayout.onMeasure(AlertDialogLayout.java:64) at android.view.View.measure(View.java:23169) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at androidx.appcompat.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:143) at android.view.View.measure(View.java:23169) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1535) at android.widget.LinearLayout.measureVertical(LinearLayout.java:825) at android.widget.LinearLayout.onMeasure(LinearLayout.java:704) at android.view.View.measure(View.java:23169) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:23169) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1535) at android.widget.LinearLayout.measureVertical(LinearLayout.java:825) at android.widget.LinearLayout.onMeasure(LinearLayout.java:704) at android.view.View.measure(View.java:23169) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6749) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at com.android.internal.policy.DecorView.onMeasure(DecorView.java:716) at android.view.View.measure(View.java:23169) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2718) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1572) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1855) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1460) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7183) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949) at android.view.Choreographer.doCallbacks(Choreographer.java:761) at android.view.Choreographer.doFrame(Choreographer.java:696) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) 2019-01-27 10:53:25.204 12045-12045/? E/AndroidRuntime: at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6718) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

To Reproduce
Load the image list asynchronously while you are viewing the images

Possible Reference
https://stackoverflow.com/questions/22943658/illegalstateexception-the-applications-pageradapter-changed-the-adapters-cont

Clicking on the background image will not black out

Clicking on the background image will not turn black and will need to click on the photo again to turn black.

        imageView.setOnClickListener(v->{
            new StfalconImageViewer.Builder(context, addresses,
                    new ImageLoader() {
                public void loadImage(ImageView imageView, Object image) {
                    Glide.with(context)
                            .load(addresses.get(position))
                            .fitCenter()
                            .into(imageView);
                }
            })
                    .withBackgroundColorResource(R.color.black)
                    .withBackgroundColor(Color.parseColor("#000000"))
                    .allowSwipeToDismiss(true)
                    .allowSwipeToDismiss(true)
                    .withHiddenStatusBar(true)
                    .withImageChangeListener(position1 -> {

                    })
                    .show(true) ;
//            FullscreenActivity.addresses=addresses;
//            context.startActivity(new Intent(context,FullscreenActivity.class));
        });

I need to make a black background photo after the first click. Thankful

about minSdkVersion 19

I see that the project does not seem to use less than 19 API, why is minSdkVersion 19?

Please make internal classes public

Is your feature request related to a problem? Please describe.
It is a problem because it is not possible to access views and do custom logic

Describe the solution you'd like
remove internal keyword at least for Views

Background color not showing when withTransitionFrom(null)

Problem
Background color is not showing when withTransitionFrom(imageView) is set to withTransitionFrom(null)
To Reproduce
Steps to reproduce the behavior:

  1. Set the viewer background color .withBackgroundColor(Color.BLACK)
  2. Set the viewer method .withTransitionFrom(targetImageView) to .withTransitionFrom(null)
  3. Click on any images in that has been set with the viewer
  4. See error that the background is not totally black

Expected behavior
Background color should be black.

image

Tired of resource not found don't know why it is coming in library

Describe the bug

android.content.res.Resources$NotFoundException: Resource ID #0x0
    at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:237)
    at android.content.res.Resources.loadXmlResourceParser(Resources.java:2281)
    at android.content.res.Resources.getLayout(Resources.java:1175)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:532)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:481)
    at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:555)
    at androidx.appcompat.app.AppCompatDialog.setContentView(AppCompatDialog.java:95)
    at androidx.appcompat.app.AlertController.installContent(AlertController.java:232)
    at androidx.appcompat.app.AlertDialog.onCreate(AlertDialog.java:279)
    at android.app.Dialog.dispatchOnCreate(Dialog.java:421)
    at android.app.Dialog.show(Dialog.java:315)
    at com.stfalcon.imageviewer.viewer.dialog.ImageViewerDialog.show(ImageViewerDialog.kt:57)

Android x is not compatible with my project

Hello, I would love to use this feature in my project, but android x is not compatible with my project's android support. I tried many ways to start my project. What should I do?

WindowLeaked exception on rotate screen

Describe the bug
A WindowLeaked exception is thrown when rotating the screen. The AlertDialog within ImageViewerDialog is not disposed.

To Reproduce
Steps to reproduce the behavior:

  1. Open the ImageViewerDialog for a set of images
  2. Rotate the device
  3. See error:

E/WindowManager: android.view.WindowLeaked:
at android.view.ViewRootImpl.(ViewRootImpl.java:511)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:346)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:93)
at android.app.Dialog.show(Dialog.java:329)
at com.stfalcon.imageviewer.viewer.dialog.ImageViewerDialog.show(ImageViewerDialog.kt:57)
at com.stfalcon.imageviewer.StfalconImageViewer.show(StfalconImageViewer.java:63)
at com.stfalcon.imageviewer.StfalconImageViewer$Builder.show(StfalconImageViewer.java:316)
at com.stfalcon.imageviewer.StfalconImageViewer$Builder.show(StfalconImageViewer.java:305)

Expected behavior
The exception should not be thrown and the ImageViewer objects should be cleared/dismissed when onPause is called for the starting activity

A dismiss function in ImageViewerDialog should include the dismisal of the AlertDialog object

UninitializedPropertyAccessException caused by transitionImageAnimator

Describe the bug
In some cases, ImageViewerView will fail with UninitializedPropertyAccessException because
lateinit property transitionImageAnimator has not been initialized. I've taken a look at the source, and found out that this error is caused by logic error inside ImageViewerView.dispatchTouchEvent(event: MotionEvent): Boolean method, which contains given code:

        if (!this::transitionImageAnimator.isInitialized || transitionImageAnimator.isAnimating) {
            return true
        }

This code fails, because even if !this::transitionImageAnimator.isInitialized returns false (property is not initialized), it still tries to check the second part, requiring the same object to be initialized, which causes an exception.

Suggested fix
Replace failing code with double check, for example:

        when {
            !this::transitionImageAnimator.isInitialized -> return true
            transitionImageAnimator.isAnimating -> return true
        }

Image list navigation hints/arrows and possible gallery on the bottom

Is your feature request related to a problem? Please describe.
When displaying a list of images in fullscreen, It seems a lot of users don't notice that you can scroll to the next image. They close the fullscreen viewer and tap on the next image.

Describe the solution you'd like
A couple of new features I would like to discuss, so I can give a go on them in a PR:

  • Possibility to add arrows buttons to the left/right of the screen, to be able to navigate to the next or previous image. It doesn't seem clear at the moment that this is a possibility. Maybe even enable previous/next navigation as in the infamous "Story" features in social media apps: tapping on the right goes to the next picture, tapping on the left goes to the previous one.
  • Small horizontal list, containing thumbnails of the images. Just like a lot of gallery apps. User can scroll the thumbnails list, tap on an image to see it fullscreen.

Both of these could solve the issue. And I'm willing to give it a go, if this is wanted in the library.

Alternatives
I was thinking of just adding a view overlay in my project and move on.
But I would be happy to share my implementation if it is wanted. So I want to discuss in here first.

Otherwise I can do it just for me, no problem.

Java

Can you give me an implementation example just for one image in Java code?

Transition image with other scale type

Describe the bug
If an imageview that is used in WithTranstionFrom has other scale type than ImageViewer's the transition isn't smooth.

To Reproduce
Steps to reproduce the behavior:

  1. Add imageView with hard-coded height/width and scaleType "centerCrop"
  2. Load image there and show full screen with StfalconImageViewer using that image view in WithTransitionFrom

Expected behavior
Smooth transition

Video with the bug
https://www.dropbox.com/s/27evomzehu12d1j/sample.mov?dl=0

Additional context
It could be an android transition bug, though maybe you know how to workaround or fix as you definitely have an expertise for it.

Unable to pause activity

I get this error in the app after pressing back in rotation.
java.lang.RuntimeException: Unable to pause activity {com.stfalcon.stfalconimageviewersample/com.stfalcon.sample.features.demo.rotation.RotationDemoActivity}: kotlin.UninitializedPropertyAccessException: lateinit property viewer has not been initialized

Updating Images Arraylist on the go

If I want to update the list dynamically during the time when user is interacting with the imageview , won't that refresh the current visible image to the user.

Considering that user is viewing photos in the Viewpager format and now he is watching some picture and suddenly a pagination function adds extra data to the list then what wouls be the behaviour of viewpager!!

Delete image with ImageViewer showing

The documentation tells us to use updateImages(images)
However, I'm getting an error: Cannot resolve method updateImages

delete_image.setOnClickListener(new View.OnClickListener() {
@OverRide
public void onClick(final View view) {
//Confirm alert
AlertDialog alertDialog = new AlertDialog.Builder(mContext).create();
alertDialog.setMessage("Delete this image permanently?");

                alertDialog.setButton(AlertDialog.BUTTON_POSITIVE, "Ok", new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                        //
                        initialize_delete_image();
                        updateImages(imageList);
                    }
                });
                alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "Cancel", new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {

                    }
                });

                alertDialog.show();
            }
        });

Cant load images using Coil library

Hi, i have a problem using Coil library when loading images from url.

The StfalconImageViewer opens, shows photo caption, changes the items, But doesnt load any image (blank/ black screen instead of the image).

Is there any problem with using Coil instead of Picasso and Glide ?

Or, maybe it is because I open the Viewer from Fragment, and not the Activity? (i have single-activity architecture with navigation through fragments)

progress bar

How to display the progress bar before uploading a photo?

Can it be used with a recyclerView?

I have a list of images loaded using Glide inside a RecyclerView. I want that when a user clicks an image, to display it using StfalconImageViewer (like in grid demo). How can I achieve this?

A piece of the RecyclerView's adapter:

 override fun onBindViewHolder(holder: ViewHolder, position: Int) {
        holder.carTitle.text = imageTitleList[position]
        GlideApp.with(context)
                .load(imageUrls[position])
                .placeholder(R.drawable.placeholder_glide)
                .override(300, 150)
                .into(holder.carImage)

        holder.carImage.setOnClickListener {
            StfalconImageViewer.Builder<Image>(context, imageUrls) view, image ->
               // I have no idea how to do this...
            }.show()
        }
    }

screen rotation support

How can I make the code to support screen rotation? When I rotate the device the image viewer closes by itself.

How can I add a long press listener

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

add page indicator

Add a page indicator and customize the style. Can this requirement be added in future iterations?

Viewer hangs when used withTransitionFrom(imageView)

Problem
When the opened image is deleted using the overlay view and if the targetImageView was passed using .withTransitionFrom(targetImageView), then on swiping up or down on the image (i.e Dismissing the view using the swipe gesture), the viewer hangs as the item was removed from the original list.

To Reproduce
Steps to reproduce the behavior:

  1. Make sure the targetImageView is passed to .withTransitionFrom(targetImageView)
  2. Click on any image to open it in full screen.
  3. Delete the image using the delete icon from the overlay view
  4. Remove the deleted item from the original list imagesList.removeAt(itemPos)
  5. Remove the deleted item from the adapter list adapter.onItemDeleted(itemPos)
  6. Pass the updated original list to StfalconImageViewer stfalconImageViewer.updateImages(imagesList)
  7. Swipe Up or Down to dismiss the viewer.

Expected behavior
The view should be dismissed normally without getting hanged.

Screenshots
Attached below in order
sc1
sc2
sc3
sc4

Additional context
I am using RecyclerView to show the list of the images. On clicking an image, the image is opened using StfalconImageViewer where the user has two options - Share and Delete.

Problem with notched devices

If the attribute shouldStatusBarHide == true, the system ui doesn't appear after dismiss on some devices with a notch.
Huawei P Smart 2019 (POT-LX1), 28 api.
photo_2020-02-09_23-07-46
photo_2020-02-09_23-07-48
photo_2020-02-09_23-07-53

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.