Comments (17)
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.
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.
@chrisbanes This change hasn't made it into the maven central release, right?
from photoview.
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.
Yes, same here. It might be mindful to set up a fork / team for this and publish it ourselves.
from photoview.
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.
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.
@andriytam can you create pull request against current dev branch please?
from photoview.
@saimr thank you .it work for me.
from photoview.
Updating to the recently released 1.2.2 fixed that bug. I haven't seen the error since I updated at least.
from photoview.
@saimr thank you .it work for me.
from photoview.
thanks.
from photoview.
@saimr It's still oocurring!
from photoview.
There is no mViewTreeObserver field?
from photoview.
i have replace the cleanup function but there is no mViewTreeObserver field,where does it is decareed
from photoview.
Where is mViewTreeObserver?????I can't find it.Could anyone can help me??
from photoview.
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)
- Dragging gesture is consumed when used in scrollable composable HOT 5
- Exceptions occur when setZoomable(false) and setScaleType(FIT_XY) are used together HOT 1
- Canvas: trying to draw too large(432000000bytes) bitmap. HOT 1
- Profile
- Way to get location of tap outside view?
- Openharmony application
- Is there a Version Update and Release Plan after 2.3.0 HOT 1
- Picture
- Could not resolve all artifacts HOT 4
- Could not resolve all artifacts - com.github.chrisbanes:PhotoView:2.3.0 HOT 5
- Could not resolve com.github.chrisbanes:PhotoView:2.3.0 HOT 1
- Photo HOT 1
- It seems that the Viewpage that does not support sliding up and down? HOT 1
- Scrolling behavior in ViewPager HOT 1
- Why not Migrate to AndroidX
- 图片放大后 比较模糊 请问如何处理 谢谢 HOT 1
- The picture is blurred after enlarging. How to deal with it HOT 1
- How to use PhotoViewAttacher?
- 库大小i
- 怎么获取图片的缩放状态?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from photoview.