Skip to content

Commit

Permalink
Add back in the viewgroup issue definition since it is still a problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Jawnnypoo committed Apr 5, 2016
1 parent 622cf19 commit 47ba3ae
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 47ba3ae

Please sign in to comment.