1 /* 2 * Copyright (C) 2017 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 com.android.launcher3.folder; 17 18 import android.graphics.drawable.Drawable; 19 20 /** 21 * Manages the parameters used to draw a Folder preview item. 22 */ 23 class PreviewItemDrawingParams { 24 float transX; 25 float transY; 26 float scale; 27 float overlayAlpha; 28 FolderPreviewItemAnim anim; 29 public boolean hidden; 30 Drawable drawable; 31 PreviewItemDrawingParams(float transX, float transY, float scale, float overlayAlpha)32 PreviewItemDrawingParams(float transX, float transY, float scale, float overlayAlpha) { 33 this.transX = transX; 34 this.transY = transY; 35 this.scale = scale; 36 this.overlayAlpha = overlayAlpha; 37 } 38 update(float transX, float transY, float scale)39 public void update(float transX, float transY, float scale) { 40 // We ensure the update will not interfere with an animation on the layout params 41 // If the final values differ, we cancel the animation. 42 if (anim != null) { 43 if (anim.finalState[1] == transX || anim.finalState[2] == transY 44 || anim.finalState[0] == scale) { 45 return; 46 } 47 anim.cancel(); 48 } 49 50 this.transX = transX; 51 this.transY = transY; 52 this.scale = scale; 53 } 54 } 55