1a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal/* 2a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal * Copyright (C) 2016 The Android Open Source Project 3a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal * 4a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal * Licensed under the Apache License, Version 2.0 (the "License"); 5a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal * you may not use this file except in compliance with the License. 6a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal * You may obtain a copy of the License at 7a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal * 8a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal * http://www.apache.org/licenses/LICENSE-2.0 9a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal * 10a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal * Unless required by applicable law or agreed to in writing, software 11a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal * distributed under the License is distributed on an "AS IS" BASIS, 12a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal * See the License for the specific language governing permissions and 14a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal * limitations under the License. 15a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal */ 16a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal 17a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyalpackage com.android.launcher3.util; 18a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal 19a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyalimport android.graphics.Rect; 20a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal 21a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal/** 22a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal * Extension of {@link PillRevealOutlineProvider} which only changes the width of the pill. 23a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal */ 24a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyalpublic class PillWidthRevealOutlineProvider extends PillRevealOutlineProvider { 25a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal 26a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal private final int mStartLeft; 27a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal private final int mStartRight; 28a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal 29a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal public PillWidthRevealOutlineProvider(Rect pillRect, int left, int right) { 30a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal super(0, 0, pillRect); 31a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal mOutline.set(pillRect); 32a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal mStartLeft = left; 33a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal mStartRight = right; 34a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal } 35a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal 36a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal @Override 37a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal public void setProgress(float progress) { 38a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal mOutline.left = (int) (progress * mPillRect.left + (1 - progress) * mStartLeft); 39a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal mOutline.right = (int) (progress * mPillRect.right + (1 - progress) * mStartRight); 40a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal } 41a2454ad2d8dcffa94f670853eb464726c73597f1Sunny Goyal} 42