1/* 2 * Copyright (C) 2014 The Android Open Source Project 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 */ 16package android.support.v4.view; 17 18import android.animation.Animator; 19import android.animation.AnimatorListenerAdapter; 20import android.view.View; 21 22class ViewPropertyAnimatorCompatJB { 23 24 public static void withStartAction(View view, Runnable runnable) { 25 view.animate().withStartAction(runnable); 26 } 27 28 public static void withEndAction(View view, Runnable runnable) { 29 view.animate().withEndAction(runnable); 30 } 31 32 public static void withLayer(View view) { 33 view.animate().withLayer(); 34 } 35 36 public static void setListener(final View view, 37 final ViewPropertyAnimatorListener listener) { 38 if (listener != null) { 39 view.animate().setListener(new AnimatorListenerAdapter() { 40 @Override 41 public void onAnimationCancel(Animator animation) { 42 listener.onAnimationCancel(view); 43 } 44 45 @Override 46 public void onAnimationEnd(Animator animation) { 47 listener.onAnimationEnd(view); 48 } 49 50 @Override 51 public void onAnimationStart(Animator animation) { 52 listener.onAnimationStart(view); 53 } 54 }); 55 } else { 56 view.animate().setListener(null); 57 } 58 } 59} 60