| /* |
| * Copyright (C) 2011 The Android Open Source Project |
| * |
| * Licensed under the Apache License, Version 2.0 (the "License"); |
| * you may not use this file except in compliance with the License. |
| * You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, software |
| * distributed under the License is distributed on an "AS IS" BASIS, |
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| * See the License for the specific language governing permissions and |
| * limitations under the License. |
| */ |
| |
| package android.support.v4.view; |
| |
| import android.os.Build; |
| import android.view.View; |
| import android.view.ViewGroup; |
| import android.view.accessibility.AccessibilityEvent; |
| |
| /** |
| * Helper for accessing features in {@link ViewGroup} |
| * introduced after API level 4 in a backwards compatible fashion. |
| */ |
| public class ViewGroupCompat { |
| |
| interface ViewGroupCompatImpl { |
| public boolean onRequestSendAccessibilityEvent(ViewGroup group, View child, |
| AccessibilityEvent event); |
| } |
| |
| static class ViewGroupCompatStubImpl implements ViewGroupCompatImpl { |
| public boolean onRequestSendAccessibilityEvent( |
| ViewGroup group, View child, AccessibilityEvent event) { |
| return true; |
| } |
| } |
| |
| static class ViewGroupCompatIcsImpl extends ViewGroupCompatStubImpl { |
| @Override |
| public boolean onRequestSendAccessibilityEvent( |
| ViewGroup group, View child, AccessibilityEvent event) { |
| return ViewGroupCompatIcs.onRequestSendAccessibilityEvent(group, child, event); |
| } |
| } |
| |
| static final ViewGroupCompatImpl IMPL; |
| static { |
| if (Build.VERSION.SDK_INT >= 14) { |
| IMPL = new ViewGroupCompatIcsImpl(); |
| } else { |
| IMPL = new ViewGroupCompatStubImpl(); |
| } |
| } |
| |
| /* |
| * Hide the constructor. |
| */ |
| private ViewGroupCompat() { |
| |
| } |
| |
| /** |
| * Called when a child has requested sending an {@link AccessibilityEvent} and |
| * gives an opportunity to its parent to augment the event. |
| * <p> |
| * If an {@link AccessibilityDelegateCompat} has been specified via calling |
| * {@link ViewCompat#setAccessibilityDelegate(View, AccessibilityDelegateCompat)} its |
| * {@link AccessibilityDelegateCompat#onRequestSendAccessibilityEvent(ViewGroup, View, |
| * AccessibilityEvent)} is responsible for handling this call. |
| * </p> |
| * |
| * @param group The group whose method to invoke. |
| * @param child The child which requests sending the event. |
| * @param event The event to be sent. |
| * @return True if the event should be sent. |
| */ |
| public static boolean onRequestSendAccessibilityEvent(ViewGroup group, View child, |
| AccessibilityEvent event) { |
| return IMPL.onRequestSendAccessibilityEvent(group, child, event); |
| } |
| } |