/TalkBack/src/com/google/android/marvin/talkback/AccessibilityEventCompatUtils.java
Java | 52 lines | 16 code | 6 blank | 30 comment | 0 complexity | 8293a1dda6b90867c7811a12171344e5 MD5 | raw file
1/* 2 * Copyright (C) 2011 Google Inc. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 5 * use this file except in compliance with the License. You may obtain a copy of 6 * 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, WITHOUT 12 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 13 * License for the specific language governing permissions and limitations under 14 * the License. 15 */ 16 17package com.google.android.marvin.talkback; 18 19import android.view.accessibility.AccessibilityEvent; 20 21import java.lang.reflect.Method; 22 23/** 24 * Provides backward-compatible access to method in {@link AccessibilityEvent}. 25 * 26 * @author alanv@google.com (Alan Viverette) 27 */ 28public class AccessibilityEventCompatUtils { 29 private static final Class<?> CLASS_AccessibilityEvent = AccessibilityEvent.class; 30 private static final Method METHOD_getMaxScrollX = CompatUtils.getMethod( 31 CLASS_AccessibilityEvent, "getMaxScrollX"); 32 private static final Method METHOD_getMaxScrollY = CompatUtils.getMethod( 33 CLASS_AccessibilityEvent, "getMaxScrollY"); 34 35 /** 36 * Gets the max scroll offset of the source left edge in pixels. 37 * 38 * @return The max scroll. 39 */ 40 public static int getMaxScrollX(AccessibilityEvent receiver) { 41 return (Integer) CompatUtils.invoke(receiver, -1, METHOD_getMaxScrollX); 42 } 43 44 /** 45 * Gets the max scroll offset of the source top edge in pixels. 46 * 47 * @return The max scroll. 48 */ 49 public static int getMaxScrollY(AccessibilityEvent receiver) { 50 return (Integer) CompatUtils.invoke(receiver, -1, METHOD_getMaxScrollY); 51 } 52}