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 */ 16 package android.transition; 17 18 import android.content.Context; 19 import android.graphics.Path; 20 import android.util.AttributeSet; 21 22 /** 23 * This base class can be extended to provide motion along a Path to Transitions. 24 * 25 * <p> 26 * Transitions such as {@link android.transition.ChangeBounds} move Views, typically 27 * in a straight path between the start and end positions. Applications that desire to 28 * have these motions move in a curve can change how Views interpolate in two dimensions 29 * by extending PathMotion and implementing {@link #getPath(float, float, float, float)}. 30 * </p> 31 * <p>This may be used in XML as an element inside a transition.</p> 32 * <pre> 33 * {@code 34 * <changeBounds> 35 * <pathMotion class="my.app.transition.MyPathMotion"/> 36 * </changeBounds> 37 * } 38 * </pre> 39 */ 40 public abstract class PathMotion { 41 PathMotion()42 public PathMotion() {} 43 PathMotion(Context context, AttributeSet attrs)44 public PathMotion(Context context, AttributeSet attrs) {} 45 46 /** 47 * Provide a Path to interpolate between two points <code>(startX, startY)</code> and 48 * <code>(endX, endY)</code>. This allows controlled curved motion along two dimensions. 49 * 50 * @param startX The x coordinate of the starting point. 51 * @param startY The y coordinate of the starting point. 52 * @param endX The x coordinate of the ending point. 53 * @param endY The y coordinate of the ending point. 54 * @return A Path along which the points should be interpolated. The returned Path 55 * must start at point <code>(startX, startY)</code>, typically using 56 * {@link android.graphics.Path#moveTo(float, float)} and end at <code>(endX, endY)</code>. 57 */ getPath(float startX, float startY, float endX, float endY)58 public abstract Path getPath(float startX, float startY, float endX, float endY); 59 } 60