ScrollerProxy.java 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. /*******************************************************************************
  2. * Copyright 2011, 2012 Chris Banes.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. *******************************************************************************/
  16. package uk.co.senab.photoview.scrollerproxy;
  17. import android.content.Context;
  18. import android.os.Build.VERSION;
  19. import android.os.Build.VERSION_CODES;
  20. public abstract class ScrollerProxy {
  21. public static ScrollerProxy getScroller(Context context) {
  22. if (VERSION.SDK_INT < VERSION_CODES.GINGERBREAD) {
  23. return new PreGingerScroller(context);
  24. } else if (VERSION.SDK_INT < VERSION_CODES.ICE_CREAM_SANDWICH) {
  25. return new GingerScroller(context);
  26. } else {
  27. return new IcsScroller(context);
  28. }
  29. }
  30. public abstract boolean computeScrollOffset();
  31. public abstract void fling(int startX, int startY, int velocityX, int velocityY, int minX, int maxX, int minY,
  32. int maxY, int overX, int overY);
  33. public abstract void forceFinished(boolean finished);
  34. public abstract boolean isFinished();
  35. public abstract int getCurrX();
  36. public abstract int getCurrY();
  37. }