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