`

The full error is: java.lang.IllegalState

阅读更多

ImageView no longer exists. You should not use this PhotoViewAttacher any more.

The full error is:

写道
java.lang.IllegalStateException: ImageView no longer exists. You should not use this PhotoViewAttacher any more.
uk.co.senab.photoview.PhotoViewAttacher.getImageView(PhotoViewAttacher.java:209)
uk.co.senab.photoview.PhotoViewAttacher.onSingleTapConfirmed(PhotoViewAttacher.java:351)
android.view.GestureDetector$GestureHandler.handleMessage(GestureDetector.java:320)
 
在PhotoViewAttacher  文件中 更改cleanup方法
 参考

https://github.com/chrisbanes/PhotoView/issues/67

 

定位到找到cleanup()代码,
//
写道
@SuppressWarnings("deprecation")
// public final void cleanup() {
// if (null != mImageView) {
// mImageView.get().getViewTreeObserver().removeGlobalOnLayoutListener(this);
// }
// mViewTreeObserver = null;
//
// // Clear listeners too
// mMatrixChangeListener = null;
// mPhotoTapListener = null;
// mViewTapListener = null;
//
// // Finally, clear ImageView
// mImageView = null;
// }
 

修改成

 

 写道

@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;
}
}
}
 
分享到:
评论
1 楼 cao1922113 2015-01-04  
不管用,问题依然存在,坐等楼主解答!

相关推荐

    Failed to load ApplicationContext

    java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.context.cache.DefaultCacheAwareContextLoaderDelegate.loadContext(DefaultCacheAwareContextLoaderDelegate....

    java中ThreadPoolExecutor常识汇总

    Java 中 ThreadPoolExecutor 常识汇总 ThreadPoolExecutor 是 Java 中的一种线程池实现,用于管理线程池中的线程,提高系统的并发处理能力。在 Java 中,线程池技术广泛应用于并发编程中,通过调用 ...

    Android 重写ViewGroup 分析onMeasure()和onLayout()方法

    如果没有这么做,会触发一个 IllegalState异常。 在 onMeasure() 方法中,还需要调用孩子的 measure() 方法,来测量出 view 的大小。父 view 使用 width 参数和 height 参数来提供约束信息。实际上,view 的测量...

    Java容器类源码详解 Deque与ArrayDeque

    Java 容器类源码详解 Deque 与 ArrayDeque Java 容器类源码详解 Deque 与 ArrayDeque 主要介绍了 Java 容器类源码详解 Deque 与 ArrayDeque,Deque 接口继承自 Queue 接口,但 Deque 支持同时从两端添加或移除元素...

Global site tag (gtag.js) - Google Analytics