public boolean apply(boolean isSecondaryIcon) { if (mMobileVisible && !mIsAirplaneMode) { mMobile.setImageResource(mMobileStrengthId); Drawable mobileDrawable = mMobile.getDrawable(); if (mobileDrawable instanceof Animatable) { Animatable ad = (Animatable) mobileDrawable; if (!ad.isRunning()) { ad.start(); } } mMobileDark.setImageResource(mMobileStrengthId); Drawable mobileDarkDrawable = mMobileDark.getDrawable(); if (mobileDarkDrawable instanceof Animatable) { Animatable ad = (Animatable) mobileDarkDrawable; if (!ad.isRunning()) { ad.start(); } } mMobileType.setImageResource(mMobileTypeId); mMobileGroup.setContentDescription(mMobileTypeDescription + " " + mMobileDescription); mMobileGroup.setVisibility(View.VISIBLE); } else { mMobileGroup.setVisibility(View.GONE); } // When this isn't next to wifi, give it some extra padding between the signals. mMobileGroup.setPaddingRelative(isSecondaryIcon ? mSecondaryTelephonyPadding : 0, 0, 0, 0); mMobile.setPaddingRelative(mIsMobileTypeIconWide ? mWideTypeIconStartPadding : 0, 0, 0, 0); mMobileDark.setPaddingRelative( mIsMobileTypeIconWide ? mWideTypeIconStartPadding : 0, 0, 0, 0); if (DEBUG) Log.d( TAG, String.format( "mobile: %s sig=%d dark=%d typ=%d", (mMobileVisible ? "VISIBLE" : "GONE"), mMobileStrengthId, mMobileDarkStrengthId, mMobileTypeId)); mMobileType.setVisibility(mMobileTypeId != 0 ? View.VISIBLE : View.GONE); return mMobileVisible; }
/** Change the checked state of the view to the inverse of its current state */ public void toggle() { checked = !checked; setImageDrawable(checked ? onDrawable : offDrawable); if (isLollipop()) { Drawable drawable = getDrawable(); if (drawable instanceof Animatable) { Animatable animatable = (Animatable) drawable; if (animatable.isRunning()) { animatable.stop(); } animatable.start(); } } }