-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ImageView no longer exists. You should not use this PhotoViewAttacher any more. #50
Comments
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? |
@chrisbanes This change hasn't made it into the maven central release, right? |
Unfortunately it seems that Chris hasn't worked on this project in a while :( |
Yes, same here. It might be mindful to set up a fork / team for this and publish it ourselves. |
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 |
I tried this it might work for you guys. No errors so far. @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;
}
}
} |
It appears that |
@andriytam can you create pull request against current dev branch please? |
@saimr thank you .it work for me. |
Updating to the recently released 1.2.2 fixed that bug. I haven't seen the error since I updated at least. |
@saimr thank you .it work for me. |
thanks. |
@saimr It's still oocurring! |
There is no mViewTreeObserver field? |
i have replace the cleanup function but there is no mViewTreeObserver field,where does it is decareed |
Where is mViewTreeObserver?????I can't find it.Could anyone can help me?? |
Think I'm seeing a similar issue on 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); |
05-02 17:21:59.583: E/AndroidRuntime(6325): FATAL EXCEPTION: main
05-02 17:21:59.583: E/AndroidRuntime(6325): java.lang.IllegalStateException: ImageView no longer exists. You should not use this PhotoViewAttacher any more.
05-02 17:21:59.583: E/AndroidRuntime(6325): at com.yijian.app.view.photoview.PhotoViewAttacher.getImageView(PhotoViewAttacher.java:210)
05-02 17:21:59.583: E/AndroidRuntime(6325): at com.yijian.app.view.photoview.PhotoViewAttacher.update(PhotoViewAttacher.java:482)
05-02 17:21:59.583: E/AndroidRuntime(6325): at com.yijian.app.view.photoview.PhotoView.setImageDrawable(PhotoView.java:114)
05-02 17:21:59.583: E/AndroidRuntime(6325): at android.widget.ImageView.setImageBitmap(ImageView.java:377)
05-02 17:21:59.583: E/AndroidRuntime(6325): at com.yijian.app.activity.GalleryActivity$TestAdapter$1.onLoadingComplete(GalleryActivity.java:287)
05-02 17:21:59.583: E/AndroidRuntime(6325): at com.nostra13.universalimageloader.core.DisplayBitmapTask.run(DisplayBitmapTask.java:64)
05-02 17:21:59.583: E/AndroidRuntime(6325): at android.os.Handler.handleCallback(Handler.java:605)
05-02 17:21:59.583: E/AndroidRuntime(6325): at android.os.Handler.dispatchMessage(Handler.java:92)
05-02 17:21:59.583: E/AndroidRuntime(6325): at android.os.Looper.loop(Looper.java:137)
05-02 17:21:59.583: E/AndroidRuntime(6325): at android.app.ActivityThread.main(ActivityThread.java:4424)
05-02 17:21:59.583: E/AndroidRuntime(6325): at java.lang.reflect.Method.invokeNative(Native Method)
05-02 17:21:59.583: E/AndroidRuntime(6325): at java.lang.reflect.Method.invoke(Method.java:511)
05-02 17:21:59.583: E/AndroidRuntime(6325): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:787)
05-02 17:21:59.583: E/AndroidRuntime(6325): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:554)
05-02 17:21:59.583: E/AndroidRuntime(6325): at dalvik.system.NativeStart.main(Native Method)
The text was updated successfully, but these errors were encountered: