From 82369a16126a1030c1c9203dc62b33c2598add89 Mon Sep 17 00:00:00 2001 From: Michael Jurka Date: Thu, 12 Jan 2012 08:08:38 -0800 Subject: Delete dead code Change-Id: Iabe9cf9a4254ce4d90849f6fb9bd82a043beba2a --- .../android/launcher2/AppsCustomizePagedView.java | 120 +----------------- .../launcher2/HolographicPagedViewIcon.java | 55 -------- src/com/android/launcher2/PagedView.java | 76 ----------- src/com/android/launcher2/PagedViewIcon.java | 141 +-------------------- src/com/android/launcher2/PagedViewWidget.java | 114 +---------------- 5 files changed, 9 insertions(+), 497 deletions(-) delete mode 100644 src/com/android/launcher2/HolographicPagedViewIcon.java (limited to 'src') diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java index 7f0edde75..96cf1dc4e 100644 --- a/src/com/android/launcher2/AppsCustomizePagedView.java +++ b/src/com/android/launcher2/AppsCustomizePagedView.java @@ -75,8 +75,7 @@ interface AsyncTaskCallback { */ class AsyncTaskPageData { enum Type { - LoadWidgetPreviewData, - LoadHolographicIconsData + LoadWidgetPreviewData } AsyncTaskPageData(int p, ArrayList l, ArrayList si, AsyncTaskCallback bgR, @@ -226,7 +225,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen // Previews & outlines ArrayList mRunningTasks; - private HolographicOutlineHelper mHolographicOutlineHelper; private static final int sPageSleepDelay = 200; public AppsCustomizePagedView(Context context, AttributeSet attrs) { @@ -236,7 +234,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen mApps = new ArrayList(); mWidgets = new ArrayList(); mIconCache = ((LauncherApplication) context.getApplicationContext()).getIconCache(); - mHolographicOutlineHelper = new HolographicOutlineHelper(); mCanvas = new Canvas(); mRunningTasks = new ArrayList(); @@ -759,7 +756,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen ApplicationInfo info = mApps.get(i); PagedViewIcon icon = (PagedViewIcon) mLayoutInflater.inflate( R.layout.apps_customize_application, layout, false); - icon.applyFromApplicationInfo(info, true, mHolographicOutlineHelper); + icon.applyFromApplicationInfo(info, true); icon.setOnClickListener(this); icon.setOnLongClickListener(this); icon.setOnTouchListener(this); @@ -775,12 +772,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen } layout.createHardwareLayers(); - - /* TEMPORARILY DISABLE HOLOGRAPHIC ICONS - if (mFadeInAdjacentScreens) { - prepareGenerateHoloOutlinesTask(page, items, images); - } - */ } /** @@ -883,79 +874,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen t.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, pageData); mRunningTasks.add(t); } - /** - * Creates and executes a new AsyncTask to load the outlines for a page of content. - */ - private void prepareGenerateHoloOutlinesTask(int page, ArrayList items, - ArrayList images) { - // Prune old tasks for this page - Iterator iter = mRunningTasks.iterator(); - while (iter.hasNext()) { - AppsCustomizeAsyncTask task = (AppsCustomizeAsyncTask) iter.next(); - int taskPage = task.page; - if ((taskPage == page) && - (task.dataType == AsyncTaskPageData.Type.LoadHolographicIconsData)) { - task.cancel(false); - iter.remove(); - } - } - - AsyncTaskPageData pageData = new AsyncTaskPageData(page, items, images, - new AsyncTaskCallback() { - @Override - public void run(AppsCustomizeAsyncTask task, AsyncTaskPageData data) { - try { - // Ensure that this task starts running at the correct priority - task.syncThreadPriority(); - - ArrayList images = data.generatedImages; - ArrayList srcImages = data.sourceImages; - int count = srcImages.size(); - Canvas c = new Canvas(); - for (int i = 0; i < count && !task.isCancelled(); ++i) { - // Before work on each item, ensure that this task is running at the correct - // priority - task.syncThreadPriority(); - - Bitmap b = srcImages.get(i); - Bitmap outline = Bitmap.createBitmap(b.getWidth(), b.getHeight(), - Bitmap.Config.ARGB_8888); - - c.setBitmap(outline); - c.save(); - c.drawBitmap(b, 0, 0, null); - c.restore(); - c.setBitmap(null); - - images.add(outline); - } - } finally { - if (task.isCancelled()) { - data.cleanup(true); - } - } - } - }, - new AsyncTaskCallback() { - @Override - public void run(AppsCustomizeAsyncTask task, AsyncTaskPageData data) { - try { - mRunningTasks.remove(task); - if (task.isCancelled()) return; - onHolographicPageItemsLoaded(data); - } finally { - data.cleanup(task.isCancelled()); - } - } - }); - - // Ensure that the outline task always runs in the background, serially - AppsCustomizeAsyncTask t = - new AppsCustomizeAsyncTask(page, AsyncTaskPageData.Type.LoadHolographicIconsData); - t.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); - t.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, pageData); - mRunningTasks.add(t); - } /* * Widgets PagedView implementation @@ -1120,8 +1038,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen AppWidgetProviderInfo info = (AppWidgetProviderInfo) rawInfo; createItemInfo = new PendingAddWidgetInfo(info, null, null); int[] cellSpans = mLauncher.getSpanForWidget(info, null); - widget.applyFromAppWidgetProviderInfo(info, -1, cellSpans, - mHolographicOutlineHelper); + widget.applyFromAppWidgetProviderInfo(info, -1, cellSpans); widget.setTag(createItemInfo); } else if (rawInfo instanceof ResolveInfo) { // Fill in the shortcuts information @@ -1130,7 +1047,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen createItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT; createItemInfo.componentName = new ComponentName(info.activityInfo.packageName, info.activityInfo.name); - widget.applyFromResolveInfo(mPackageManager, info, mHolographicOutlineHelper); + widget.applyFromResolveInfo(mPackageManager, info); widget.setTag(createItemInfo); } widget.setOnClickListener(this); @@ -1231,12 +1148,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen layout.createHardwareLayer(); invalidate(); - /* TEMPORARILY DISABLE HOLOGRAPHIC ICONS - if (mFadeInAdjacentScreens) { - prepareGenerateHoloOutlinesTask(data.page, data.items, data.generatedImages); - } - */ - // Update all thread priorities Iterator iter = mRunningTasks.iterator(); while (iter.hasNext()) { @@ -1245,29 +1156,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen task.setThreadPriority(getThreadPriorityForPage(pageIndex)); } } - private void onHolographicPageItemsLoaded(AsyncTaskPageData data) { - // Invalidate early to short-circuit children invalidates - invalidate(); - - int page = data.page; - ViewGroup layout = (ViewGroup) getPageAt(page); - if (layout instanceof PagedViewCellLayout) { - PagedViewCellLayout cl = (PagedViewCellLayout) layout; - int count = cl.getPageChildCount(); - if (count != data.generatedImages.size()) return; - for (int i = 0; i < count; ++i) { - PagedViewIcon icon = (PagedViewIcon) cl.getChildOnPageAt(i); - icon.setHolographicOutline(data.generatedImages.get(i)); - } - } else { - int count = layout.getChildCount(); - if (count != data.generatedImages.size()) return; - for (int i = 0; i < count; ++i) { - View v = layout.getChildAt(i); - ((PagedViewWidget) v).setHolographicOutline(data.generatedImages.get(i)); - } - } - } @Override public void syncPages() { diff --git a/src/com/android/launcher2/HolographicPagedViewIcon.java b/src/com/android/launcher2/HolographicPagedViewIcon.java deleted file mode 100644 index dda233e37..000000000 --- a/src/com/android/launcher2/HolographicPagedViewIcon.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.launcher2; - -import android.content.Context; -import android.graphics.Bitmap; -import android.graphics.Canvas; -import android.graphics.Paint; -import android.widget.TextView; - - - -/** - * An icon on a PagedView, specifically for items in the launcher's paged view (with compound - * drawables on the top). - */ -public class HolographicPagedViewIcon extends TextView { - PagedViewIcon mOriginalIcon; - Paint mPaint; - - public HolographicPagedViewIcon(Context context, PagedViewIcon original) { - super(context); - mOriginalIcon = original; - mPaint = new Paint(); - } - - @Override - protected void onDraw(Canvas canvas) { - Bitmap overlay = mOriginalIcon.getHolographicOutline(); - if (overlay != null) { - final int offset = getScrollX(); - final int compoundPaddingLeft = getCompoundPaddingLeft(); - final int compoundPaddingRight = getCompoundPaddingRight(); - int hspace = getWidth() - compoundPaddingRight - compoundPaddingLeft; - canvas.drawBitmap(overlay, - offset + compoundPaddingLeft + (hspace - overlay.getWidth()) / 2, - mOriginalIcon.getPaddingTop(), - mPaint); - } - } -} diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java index ef360427b..bf66767e3 100644 --- a/src/com/android/launcher2/PagedView.java +++ b/src/com/android/launcher2/PagedView.java @@ -151,15 +151,6 @@ public abstract class PagedView extends ViewGroup { protected ArrayList mDirtyPageContent; - // choice modes - protected static final int CHOICE_MODE_NONE = 0; - protected static final int CHOICE_MODE_SINGLE = 1; - // Multiple selection mode is not supported by all Launcher actions atm - protected static final int CHOICE_MODE_MULTIPLE = 2; - - protected int mChoiceMode; - private ActionMode mActionMode; - // If true, syncPages and syncPageItems will be called to refresh pages protected boolean mContentIsRefreshable = true; @@ -206,7 +197,6 @@ public abstract class PagedView extends ViewGroup { public PagedView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - mChoiceMode = CHOICE_MODE_NONE; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.PagedView, defStyle, 0); @@ -1645,72 +1635,6 @@ public abstract class PagedView extends ViewGroup { return Math.min(page + 1, count - 1); } - protected void startChoiceMode(int mode, ActionMode.Callback callback) { - if (isChoiceMode(CHOICE_MODE_NONE)) { - mChoiceMode = mode; - mActionMode = startActionMode(callback); - } - } - - public void endChoiceMode() { - if (!isChoiceMode(CHOICE_MODE_NONE)) { - mChoiceMode = CHOICE_MODE_NONE; - resetCheckedGrandchildren(); - if (mActionMode != null) mActionMode.finish(); - mActionMode = null; - } - } - - protected boolean isChoiceMode(int mode) { - return mChoiceMode == mode; - } - - protected ArrayList getCheckedGrandchildren() { - ArrayList checked = new ArrayList(); - final int childCount = getChildCount(); - for (int i = 0; i < childCount; ++i) { - Page layout = (Page) getPageAt(i); - final int grandChildCount = layout.getPageChildCount(); - for (int j = 0; j < grandChildCount; ++j) { - final View v = layout.getChildOnPageAt(j); - if (v instanceof Checkable && ((Checkable) v).isChecked()) { - checked.add((Checkable) v); - } - } - } - return checked; - } - - /** - * If in CHOICE_MODE_SINGLE and an item is checked, returns that item. - * Otherwise, returns null. - */ - protected Checkable getSingleCheckedGrandchild() { - if (mChoiceMode != CHOICE_MODE_MULTIPLE) { - final int childCount = getChildCount(); - for (int i = 0; i < childCount; ++i) { - Page layout = (Page) getPageAt(i); - final int grandChildCount = layout.getPageChildCount(); - for (int j = 0; j < grandChildCount; ++j) { - final View v = layout.getChildOnPageAt(j); - if (v instanceof Checkable && ((Checkable) v).isChecked()) { - return (Checkable) v; - } - } - } - } - return null; - } - - protected void resetCheckedGrandchildren() { - // loop through children, and set all of their children to _not_ be checked - final ArrayList checked = getCheckedGrandchildren(); - for (int i = 0; i < checked.size(); ++i) { - final Checkable c = checked.get(i); - c.setChecked(false); - } - } - /** * This method is called ONLY to synchronize the number of pages that the paged view has. * To actually fill the pages with information, implement syncPageItems() below. It is diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java index af10f189c..63f91b7f0 100644 --- a/src/com/android/launcher2/PagedViewIcon.java +++ b/src/com/android/launcher2/PagedViewIcon.java @@ -23,37 +23,19 @@ import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Paint; import android.util.AttributeSet; -import android.widget.Checkable; import android.widget.TextView; import com.android.launcher.R; - /** * An icon on a PagedView, specifically for items in the launcher's paged view (with compound * drawables on the top). */ -public class PagedViewIcon extends TextView implements Checkable { +public class PagedViewIcon extends TextView { private static final String TAG = "PagedViewIcon"; - // holographic outline - private final Paint mPaint = new Paint(); - private Bitmap mCheckedOutline; - private Bitmap mHolographicOutline; private Bitmap mIcon; - private int mAlpha = 255; - private int mHolographicAlpha; - - private boolean mIsChecked; - private ObjectAnimator mCheckedAlphaAnimator; - private float mCheckedAlpha = 1.0f; - private int mCheckedFadeInDuration; - private int mCheckedFadeOutDuration; - - HolographicPagedViewIcon mHolographicOutlineView; - private HolographicOutlineHelper mHolographicOutlineHelper; - public PagedViewIcon(Context context) { this(context, null); } @@ -64,131 +46,12 @@ public class PagedViewIcon extends TextView implements Checkable { public PagedViewIcon(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - - // Set up fade in/out constants - final Resources r = context.getResources(); - final int alpha = r.getInteger(R.integer.config_dragAppsCustomizeIconFadeAlpha); - if (alpha > 0) { - mCheckedAlpha = r.getInteger(R.integer.config_dragAppsCustomizeIconFadeAlpha) / 256.0f; - mCheckedFadeInDuration = - r.getInteger(R.integer.config_dragAppsCustomizeIconFadeInDuration); - mCheckedFadeOutDuration = - r.getInteger(R.integer.config_dragAppsCustomizeIconFadeOutDuration); - } - - mHolographicOutlineView = new HolographicPagedViewIcon(context, this); - } - - protected HolographicPagedViewIcon getHolographicOutlineView() { - return mHolographicOutlineView; } - protected Bitmap getHolographicOutline() { - return mHolographicOutline; - } - - public void applyFromApplicationInfo(ApplicationInfo info, boolean scaleUp, - HolographicOutlineHelper holoOutlineHelper) { - mHolographicOutlineHelper = holoOutlineHelper; + public void applyFromApplicationInfo(ApplicationInfo info, boolean scaleUp) { mIcon = info.iconBitmap; setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null); setText(info.title); setTag(info); } - - public void setHolographicOutline(Bitmap holoOutline) { - mHolographicOutline = holoOutline; - getHolographicOutlineView().invalidate(); - } - - @Override - public void setAlpha(float alpha) { - final float viewAlpha = HolographicOutlineHelper.viewAlphaInterpolator(alpha); - final float holographicAlpha = HolographicOutlineHelper.highlightAlphaInterpolator(alpha); - int newViewAlpha = (int) (viewAlpha * 255); - int newHolographicAlpha = (int) (holographicAlpha * 255); - if ((mAlpha != newViewAlpha) || (mHolographicAlpha != newHolographicAlpha)) { - mAlpha = newViewAlpha; - mHolographicAlpha = newHolographicAlpha; - super.setAlpha(viewAlpha); - } - } - - public void invalidateCheckedImage() { - if (mCheckedOutline != null) { - mCheckedOutline.recycle(); - mCheckedOutline = null; - } - } - - @Override - protected void onDraw(Canvas canvas) { - if (mAlpha > 0) { - super.onDraw(canvas); - } - - Bitmap overlay = null; - - // draw any blended overlays - if (mCheckedOutline != null) { - mPaint.setAlpha(255); - overlay = mCheckedOutline; - } - - if (overlay != null) { - final int offset = getScrollX(); - final int compoundPaddingLeft = getCompoundPaddingLeft(); - final int compoundPaddingRight = getCompoundPaddingRight(); - int hspace = getWidth() - compoundPaddingRight - compoundPaddingLeft; - canvas.drawBitmap(overlay, - offset + compoundPaddingLeft + (hspace - overlay.getWidth()) / 2, - mPaddingTop, - mPaint); - } - } - - @Override - public boolean isChecked() { - return mIsChecked; - } - - void setChecked(boolean checked, boolean animate) { - if (mIsChecked != checked) { - mIsChecked = checked; - - float alpha; - int duration; - if (mIsChecked) { - alpha = mCheckedAlpha; - duration = mCheckedFadeInDuration; - } else { - alpha = 1.0f; - duration = mCheckedFadeOutDuration; - } - - // Initialize the animator - if (mCheckedAlphaAnimator != null) { - mCheckedAlphaAnimator.cancel(); - } - if (animate) { - mCheckedAlphaAnimator = ObjectAnimator.ofFloat(this, "alpha", getAlpha(), alpha); - mCheckedAlphaAnimator.setDuration(duration); - mCheckedAlphaAnimator.start(); - } else { - setAlpha(alpha); - } - - invalidate(); - } - } - - @Override - public void setChecked(boolean checked) { - setChecked(checked, true); - } - - @Override - public void toggle() { - setChecked(!mIsChecked); - } } diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java index 8fcfa8fed..e2b02a34f 100644 --- a/src/com/android/launcher2/PagedViewWidget.java +++ b/src/com/android/launcher2/PagedViewWidget.java @@ -29,7 +29,6 @@ import android.graphics.RectF; import android.util.AttributeSet; import android.view.KeyEvent; import android.view.MotionEvent; -import android.widget.Checkable; import android.widget.ImageView; import android.widget.LinearLayout; import android.widget.TextView; @@ -39,28 +38,17 @@ import com.android.launcher.R; /** * The linear layout used strictly for the widget/wallpaper tab of the customization tray */ -public class PagedViewWidget extends LinearLayout implements Checkable { +public class PagedViewWidget extends LinearLayout { static final String TAG = "PagedViewWidgetLayout"; private static boolean sDeletePreviewsWhenDetachedFromWindow = true; private final Paint mPaint = new Paint(); - private Bitmap mHolographicOutline; - private HolographicOutlineHelper mHolographicOutlineHelper; private ImageView mPreviewImageView; private final RectF mTmpScaleRect = new RectF(); private String mDimensionsFormatString; - private int mAlpha = 255; - private int mHolographicAlpha; - - private boolean mIsChecked; - private ObjectAnimator mCheckedAlphaAnimator; - private float mCheckedAlpha = 1.0f; - private int mCheckedFadeInDuration; - private int mCheckedFadeOutDuration; - public PagedViewWidget(Context context) { this(context, null); } @@ -72,16 +60,7 @@ public class PagedViewWidget extends LinearLayout implements Checkable { public PagedViewWidget(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); - // Set up fade in/out constants final Resources r = context.getResources(); - final int alpha = r.getInteger(R.integer.config_dragAppsCustomizeIconFadeAlpha); - if (alpha > 0) { - mCheckedAlpha = r.getInteger(R.integer.config_dragAppsCustomizeIconFadeAlpha) / 256.0f; - mCheckedFadeInDuration = - r.getInteger(R.integer.config_dragAppsCustomizeIconFadeInDuration); - mCheckedFadeOutDuration = - r.getInteger(R.integer.config_dragAppsCustomizeIconFadeOutDuration); - } mDimensionsFormatString = r.getString(R.string.widget_dims_format); setWillNotDraw(false); @@ -109,8 +88,7 @@ public class PagedViewWidget extends LinearLayout implements Checkable { } public void applyFromAppWidgetProviderInfo(AppWidgetProviderInfo info, - int maxWidth, int[] cellSpan, HolographicOutlineHelper holoOutlineHelper) { - mHolographicOutlineHelper = holoOutlineHelper; + int maxWidth, int[] cellSpan) { final ImageView image = (ImageView) findViewById(R.id.widget_preview); if (maxWidth > -1) { image.setMaxWidth(maxWidth); @@ -125,9 +103,7 @@ public class PagedViewWidget extends LinearLayout implements Checkable { } } - public void applyFromResolveInfo(PackageManager pm, ResolveInfo info, - HolographicOutlineHelper holoOutlineHelper) { - mHolographicOutlineHelper = holoOutlineHelper; + public void applyFromResolveInfo(PackageManager pm, ResolveInfo info) { CharSequence label = info.loadLabel(pm); final ImageView image = (ImageView) findViewById(R.id.widget_preview); image.setContentDescription(label); @@ -159,11 +135,6 @@ public class PagedViewWidget extends LinearLayout implements Checkable { } } - public void setHolographicOutline(Bitmap holoOutline) { - mHolographicOutline = holoOutline; - invalidate(); - } - @Override public boolean onTouchEvent(MotionEvent event) { // We eat up the touch events here, since the PagedView (which uses the same swiping @@ -176,27 +147,6 @@ public class PagedViewWidget extends LinearLayout implements Checkable { return super.onTouchEvent(event) || true; } - @Override - protected void onDraw(Canvas canvas) { - if (mAlpha > 0) { - super.onDraw(canvas); - } - - // draw any blended overlays - if (mHolographicOutline != null && mHolographicAlpha > 0) { - // Calculate how much to scale the holographic preview - mTmpScaleRect.set(0,0,1,1); - mPreviewImageView.getImageMatrix().mapRect(mTmpScaleRect); - - mPaint.setAlpha(mHolographicAlpha); - canvas.save(); - canvas.scale(mTmpScaleRect.right, mTmpScaleRect.bottom); - canvas.drawBitmap(mHolographicOutline, mPreviewImageView.getLeft(), - mPreviewImageView.getTop(), mPaint); - canvas.restore(); - } - } - @Override protected boolean onSetAlpha(int alpha) { return true; @@ -208,62 +158,4 @@ public class PagedViewWidget extends LinearLayout implements Checkable { getChildAt(i).setAlpha(alpha); } } - @Override - public void setAlpha(float alpha) { - final float viewAlpha = mHolographicOutlineHelper.viewAlphaInterpolator(alpha); - final float holographicAlpha = mHolographicOutlineHelper.highlightAlphaInterpolator(alpha); - int newViewAlpha = (int) (viewAlpha * 255); - int newHolographicAlpha = (int) (holographicAlpha * 255); - if ((mAlpha != newViewAlpha) || (mHolographicAlpha != newHolographicAlpha)) { - mAlpha = newViewAlpha; - mHolographicAlpha = newHolographicAlpha; - setChildrenAlpha(viewAlpha); - super.setAlpha(viewAlpha); - } - } - - void setChecked(boolean checked, boolean animate) { - if (mIsChecked != checked) { - mIsChecked = checked; - - float alpha; - int duration; - if (mIsChecked) { - alpha = mCheckedAlpha; - duration = mCheckedFadeInDuration; - } else { - alpha = 1.0f; - duration = mCheckedFadeOutDuration; - } - - // Initialize the animator - if (mCheckedAlphaAnimator != null) { - mCheckedAlphaAnimator.cancel(); - } - if (animate) { - mCheckedAlphaAnimator = ObjectAnimator.ofFloat(this, "alpha", getAlpha(), alpha); - mCheckedAlphaAnimator.setDuration(duration); - mCheckedAlphaAnimator.start(); - } else { - setAlpha(alpha); - } - - invalidate(); - } - } - - @Override - public void setChecked(boolean checked) { - setChecked(checked, true); - } - - @Override - public boolean isChecked() { - return mIsChecked; - } - - @Override - public void toggle() { - setChecked(!mIsChecked); - } } -- cgit v1.2.3