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; 21import android.view.animation.Interpolator; 22 23class ViewPropertyAnimatorCompatICS { 24 25 public static void setDuration(View view, long value) { 26 view.animate().setDuration(value); 27 } 28 29 public static void alpha(View view, float value) { 30 view.animate().alpha(value); 31 } 32 33 public static void translationX(View view, float value) { 34 view.animate().translationX(value); 35 } 36 37 public static void translationY(View view, float value) { 38 view.animate().translationY(value); 39 } 40 41 public static long getDuration(View view) { 42 return view.animate().getDuration(); 43 } 44 45 public static void setInterpolator(View view, Interpolator value) { 46 view.animate().setInterpolator(value); 47 } 48 49 public static void setStartDelay(View view, long value) { 50 view.animate().setStartDelay(value); 51 } 52 53 public static long getStartDelay(View view) { 54 return view.animate().getStartDelay(); 55 } 56 57 public static void alphaBy(View view, float value) { 58 view.animate().alphaBy(value); 59 } 60 61 public static void rotation(View view, float value) { 62 view.animate().rotation(value); 63 } 64 65 public static void rotationBy(View view, float value) { 66 view.animate().rotationBy(value); 67 } 68 69 public static void rotationX(View view, float value) { 70 view.animate().rotationX(value); 71 } 72 73 public static void rotationXBy(View view, float value) { 74 view.animate().rotationXBy(value); 75 } 76 77 public static void rotationY(View view, float value) { 78 view.animate().rotationY(value); 79 } 80 81 public static void rotationYBy(View view, float value) { 82 view.animate().rotationYBy(value); 83 } 84 85 public static void scaleX(View view, float value) { 86 view.animate().scaleX(value); 87 } 88 89 public static void scaleXBy(View view, float value) { 90 view.animate().scaleXBy(value); 91 } 92 93 public static void scaleY(View view, float value) { 94 view.animate().scaleY(value); 95 } 96 97 public static void scaleYBy(View view, float value) { 98 view.animate().scaleYBy(value); 99 } 100 101 public static void cancel(View view) { 102 view.animate().cancel(); 103 } 104 105 public static void x(View view, float value) { 106 view.animate().x(value); 107 } 108 109 public static void xBy(View view, float value) { 110 view.animate().xBy(value); 111 } 112 113 public static void y(View view, float value) { 114 view.animate().y(value); 115 } 116 117 public static void yBy(View view, float value) { 118 view.animate().yBy(value); 119 } 120 121 public static void translationXBy(View view, float value) { 122 view.animate().translationXBy(value); 123 } 124 125 public static void translationYBy(View view, float value) { 126 view.animate().translationYBy(value); 127 } 128 129 public static void start(View view) { 130 view.animate().start(); 131 } 132 133 public static void setListener(final View view, 134 final ViewPropertyAnimatorListener listener) { 135 if (listener != null) { 136 view.animate().setListener(new AnimatorListenerAdapter() { 137 @Override 138 public void onAnimationCancel(Animator animation) { 139 listener.onAnimationCancel(view); 140 } 141 142 @Override 143 public void onAnimationEnd(Animator animation) { 144 listener.onAnimationEnd(view); 145 } 146 147 @Override 148 public void onAnimationStart(Animator animation) { 149 listener.onAnimationStart(view); 150 } 151 }); 152 } else { 153 view.animate().setListener(null); 154 } 155 } 156} 157