1d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd/* 2d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Copyright (C) 2015 The Android Open Source Project 3d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * 4d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Licensed under the Apache License, Version 2.0 (the "License"); 5d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * you may not use this file except in compliance with the License. 6d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * You may obtain a copy of the License at 7d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * 8d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * http://www.apache.org/licenses/LICENSE-2.0 9d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * 10d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * Unless required by applicable law or agreed to in writing, software 11d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * distributed under the License is distributed on an "AS IS" BASIS, 12d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * See the License for the specific language governing permissions and 14d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * limitations under the License. 15d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd */ 16d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddpackage com.android.messaging.ui.animation; 17d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 18d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.animation.RectEvaluator; 19d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.animation.TypeEvaluator; 20d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport android.graphics.Rect; 21d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 22d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddimport com.android.messaging.util.OsUtil; 23d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 24d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd/** 25d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * This evaluator can be used to perform type interpolation between <code>Rect</code> values. 26d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd * It's backward compatible to Api Level 11. 27d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd */ 28d3b009ae55651f1e60950342468e3c37fdeb0796Mike Doddpublic class RectEvaluatorCompat implements TypeEvaluator<Rect> { 29d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd public static TypeEvaluator<Rect> create() { 30d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd if (OsUtil.isAtLeastJB_MR2()) { 31d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd return new RectEvaluator(); 32d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } else { 33d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd return new RectEvaluatorCompat(); 34d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 35d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 36d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd 37d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd @Override 38d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd public Rect evaluate(float fraction, Rect startValue, Rect endValue) { 39d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int left = startValue.left + (int) ((endValue.left - startValue.left) * fraction); 40d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int top = startValue.top + (int) ((endValue.top - startValue.top) * fraction); 41d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int right = startValue.right + (int) ((endValue.right - startValue.right) * fraction); 42d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd int bottom = startValue.bottom + (int) ((endValue.bottom - startValue.bottom) * fraction); 43d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd return new Rect(left, top, right, bottom); 44d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd } 45d3b009ae55651f1e60950342468e3c37fdeb0796Mike Dodd} 46