9ff97fec4710fc3ba7ac580b671e4c198edae23c.svn-base 1006 B

12345678910111213141516171819202122232425262728293031
  1. package eVVM.apk.widget;
  2. import android.content.Context;
  3. import android.support.v4.view.ViewPager;
  4. import android.util.AttributeSet;
  5. import android.view.MotionEvent;
  6. /**
  7. * desc : ViewPager 中使用 PhotoView 时出现 pointerIndex out of range 异常
  8. */
  9. public final class PhotoViewPager extends ViewPager {
  10. public PhotoViewPager(Context context) {
  11. super(context);
  12. }
  13. public PhotoViewPager(Context context, AttributeSet attrs) {
  14. super(context, attrs);
  15. }
  16. @Override
  17. public boolean onInterceptTouchEvent(MotionEvent ev) {
  18. // 当PhotoView 和 ViewPager 组合时 ,用双指进行放大时 是没有问题的,但是用双指进行缩小的时候,程序就会崩掉
  19. // 并且抛出java.lang.IllegalArgumentException: pointerIndex out of range
  20. try {
  21. return super.onInterceptTouchEvent(ev);
  22. } catch (IllegalArgumentException | ArrayIndexOutOfBoundsException ignored) {
  23. return false;
  24. }
  25. }
  26. }