Giter VIP home page Giter VIP logo

Comments (17)

saimr avatar saimr commented on June 8, 2024 1

I tried this it might work for you guys. No errors so far.
In PhotoviewAttacher File replace clean up function with the function below

@SuppressLint("NewApi")
    @SuppressWarnings("deprecation")
    public final void cleanup() {
        if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN)
        {
            if (null != mImageView) {
                mImageView.get().getViewTreeObserver().removeOnGlobalLayoutListener(this);
                }

                    if (null != mViewTreeObserver && mViewTreeObserver.isAlive()) {
                         mViewTreeObserver.removeOnGlobalLayoutListener(this);

                    mViewTreeObserver = null;

                    // Clear listeners too
                    mMatrixChangeListener = null;
                    mPhotoTapListener = null;
                    mViewTapListener = null;
                    // Finally, clear ImageView
                    mImageView = null;
                    }

        }
        else
        {
        if (null != mImageView) {
            mImageView.get().getViewTreeObserver().removeGlobalOnLayoutListener(this);
            }

                if (null != mViewTreeObserver && mViewTreeObserver.isAlive()) {
                     mViewTreeObserver.removeGlobalOnLayoutListener(this);

                mViewTreeObserver = null;

                // Clear listeners too
                mMatrixChangeListener = null;
                mPhotoTapListener = null;
                mViewTapListener = null;
                // Finally, clear ImageView
                mImageView = null;
                }
        }
            }

from photoview.

httpdispatch avatar httpdispatch commented on June 8, 2024

This is weird behaviour caused by ImageView WeakReference in PhotoViewAttacher. Weird it is because system decides that ImageView is no more accessible from anywhere and clean the reference

Chris, isn't it strange that you call

imageView.setImageDrawable

but iside that method getImageView throws ImageView no longer exists?

from photoview.

ened avatar ened commented on June 8, 2024

@chrisbanes This change hasn't made it into the maven central release, right?

from photoview.

JayH5 avatar JayH5 commented on June 8, 2024

Unfortunately it seems that Chris hasn't worked on this project in a while :(
Even when using PhotoView instead of attaching to an ImageView I have seen cases when this ISE is thrown. The above commit by Chris was necessary for me to get the library to work reliably.

from photoview.

ened avatar ened commented on June 8, 2024

Yes, same here. It might be mindful to set up a fork / team for this and publish it ourselves.

from photoview.

JayH5 avatar JayH5 commented on June 8, 2024

I don't really have much invested in this project atm. I used it briefly at a company I interned at a couple of months ago. That being said, this is one of the nicer image zoom implementations I've found and with a few fixes I think it could be really great. If you want to organise a fork/team to carry on development then I'd be willing to help out where I can but it would only be in a limited way.

It depends really on what you have in mind. Beyond this pull request I'd also like to see the two I've made (#63, #64) get merged. Would be even better if somebody implements EdgeEffectCompat at some point for an overscroll effect.

Would be good if we could get some feedback from @chrisbanes

from photoview.

andriytam avatar andriytam commented on June 8, 2024

It appears that mViewTreeObserver.isAlive() is false on JellyBean while mImageView.get().getViewTreeObserver().isAlive() is true. I have fixed this issue by removing mViewTreeObserver field and getting ViewTreeObserver from ImageView once it is required.

from photoview.

smarek avatar smarek commented on June 8, 2024

@andriytam can you create pull request against current dev branch please?

from photoview.

shawwinbin avatar shawwinbin commented on June 8, 2024

@saimr thank you .it work for me.

from photoview.

simonbengtsson avatar simonbengtsson commented on June 8, 2024

Updating to the recently released 1.2.2 fixed that bug. I haven't seen the error since I updated at least.

from photoview.

zhangxincheng avatar zhangxincheng commented on June 8, 2024

@saimr thank you .it work for me.

from photoview.

kingideayou avatar kingideayou commented on June 8, 2024

thanks.

from photoview.

mybslj avatar mybslj commented on June 8, 2024

@saimr It's still oocurring!

from photoview.

arlindiDev avatar arlindiDev commented on June 8, 2024

There is no mViewTreeObserver field?

from photoview.

Silence2016 avatar Silence2016 commented on June 8, 2024

i have replace the cleanup function but there is no mViewTreeObserver field,where does it is decareed

from photoview.

UshioYu avatar UshioYu commented on June 8, 2024

Where is mViewTreeObserver?????I can't find it.Could anyone can help me??

from photoview.

aerb avatar aerb commented on June 8, 2024

Think I'm seeing a similar issue on 1.2.4, PhotoView spams my log with:
PhotoViewAttacher: ImageView no longer exists. You should not use this PhotoViewAttacher any more., even though I've called cleanup.

I also found that it was not correctly removing itself form the ViewTreeObserver. For future reference to anyone with the problem the quick-and-dirty fix was:

attacher.cleanup();
getViewTreeObserver().removeOnGlobalLayoutListener(attacher);

from photoview.

Related Issues (20)

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.