From 47ba3aefc0543616bdc1c5aa3a2f39c842b2ebcf Mon Sep 17 00:00:00 2001 From: Jawnnypoo Date: Mon, 4 Apr 2016 22:47:13 -0500 Subject: [PATCH] Add back in the viewgroup issue definition since it is still a problem --- README.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/README.md b/README.md index 8f9bcec0..0770ea2b 100755 --- a/README.md +++ b/README.md @@ -59,10 +59,32 @@ public void onCreate(Bundle savedInstanceState) { mAttacher.update(); ``` +## Issues With ViewGroups +There are some ViewGroups (ones that utilize onInterceptTouchEvent) that throw exceptions when a PhotoView is placed within them, most notably [ViewPager](http://developer.android.com/reference/android/support/v4/view/ViewPager.html) and [DrawerLayout](https://developer.android.com/reference/android/support/v4/widget/DrawerLayout.html). This is a framework issue that has not been resolved. In order to prevent this exception (which typically occurs when you zoom out), take a look at [HackyDrawerLayout](https://github.com/chrisbanes/PhotoView/blob/master/sample/src/main/java/uk/co/senab/photoview/sample/HackyDrawerLayout.java) and you can see the solution is to simply catch the exception. Any ViewGroup which uses onInterceptTouchEvent will also need to be extended and exceptions caught. Use the [HackyDrawerLayout](https://github.com/chrisbanes/PhotoView/blob/master/sample/src/main/java/uk/co/senab/photoview/sample/HackyDrawerLayout.java) as a template of how to do so. The basic implementation is: +```java +public class HackyProblematicViewGroup extends ProblematicViewGroup { + + public HackyProblematicViewGroup(Context context) { + super(context); + } + + @Override + public boolean onInterceptTouchEvent(MotionEvent ev) { + try { + return super.onInterceptTouchEvent(ev); + } catch (IllegalArgumentException e) { + e.printStackTrace(); + return false; + } + } +} +``` + ## Pull Requests / Contribution Development happens in **develop** branch of this repository, and Pull Requests should be filled against that branch. Any Pull Request against **master** will be rejected + ## License Copyright 2011, 2012 Chris Banes