下面列出了android.widget.Filterable#android.os.Build.VERSION 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
private Rect getCroppedRect(Size cameraPreviewSize, Rect visibleRect, int rotation) {
final int previewWidth = cameraPreviewSize.width;
final int previewHeight = cameraPreviewSize.height;
if (rotation % 180 > 0) rotateRect(visibleRect);
float scale = (float) previewWidth / visibleRect.width();
if (visibleRect.height() * scale > previewHeight) {
scale = (float) previewHeight / visibleRect.height();
}
final float newWidth = visibleRect.width() * scale;
final float newHeight = visibleRect.height() * scale;
final float centerX = (VERSION.SDK_INT < 14 || isTroublemaker()) ? previewWidth - newWidth / 2 : previewWidth / 2;
final float centerY = previewHeight / 2;
visibleRect.set((int) (centerX - newWidth / 2),
(int) (centerY - newHeight / 2),
(int) (centerX + newWidth / 2),
(int) (centerY + newHeight / 2));
if (rotation % 180 > 0) rotateRect(visibleRect);
return visibleRect;
}
/**
* Create a bitmap from a specified vector drawable
*
* @param vectorDrawable vector drawable to convert to a bitmap
*/
public static Bitmap getBitmapFromVectorDrawable(Drawable vectorDrawable)
{
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP)
{
vectorDrawable = (DrawableCompat.wrap(vectorDrawable)).mutate();
}
Bitmap bitmap = Bitmap.createBitmap(vectorDrawable.getIntrinsicWidth(),
vectorDrawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
vectorDrawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
vectorDrawable.draw(canvas);
return bitmap;
}
/**
* Set the radius of this button group
*
* @param radius value of new corner radius, in pixels
*/
public void setRadius(final int radius)
{
this.radius = radius;
// Update radius for each button
for (SegmentedButton button : buttons)
{
button.setBackgroundRadius(radius);
button.setupBackgroundClipPath();
button.invalidate();
}
// Update border for new radius
GradientDrawable borderDrawable = (GradientDrawable)borderView.getBackground();
if (borderDrawable != null)
borderDrawable.setCornerRadius(radius - borderWidth / 2.0f);
// Invalidate shadow outline so that it will be updated to follow the new radius
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP)
invalidateOutline();
}
public void onLocationChanged(Location location) {
startMoveLocationAndMap(location);
float verticalAccuracyMeter = 0.0f;
if (VERSION.SDK_INT >= 26) {
verticalAccuracyMeter = location.getVerticalAccuracyMeters();
}
X8PressureGpsInfo.getInstance().setmLongitude(location.getLongitude());
X8PressureGpsInfo.getInstance().setmLatitude(location.getLatitude());
X8PressureGpsInfo.getInstance().setmAltitude(location.getAltitude());
X8PressureGpsInfo.getInstance().setmHorizontalAccuracyMeters(location.getAccuracy());
X8PressureGpsInfo.getInstance().setmVerticalAccuracyMeters(verticalAccuracyMeter);
X8PressureGpsInfo.getInstance().setmSpeed(location.getSpeed());
X8PressureGpsInfo.getInstance().setmBearing(location.getBearing());
X8PressureGpsInfo.getInstance().setHasLocation(true);
this.accuracy = location.getAccuracy();
getCityThread(location);
}
@SuppressLint({"WrongConstant"})
public void onDraw(Canvas canvas) {
float src;
super.onDraw(canvas);
if (VERSION.SDK_INT <= 19) {
this.mPaint.setColor(Color.argb(1, 0, 0, 0));
}
canvas.saveLayer(0.0f, 0.0f, (float) getWidth(), (float) getHeight(), null, 31);
Rect dst = new Rect();
dst.left = 0;
dst.top = 0;
dst.right = getWidth();
dst.bottom = getHeight();
canvas.drawBitmap(this.mBitmap, null, dst, null);
this.mPaint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
if (this.percent == 0) {
src = 1.0f;
} else {
src = (100.0f - (((((float) this.percent) / 100.0f) * 85.0f) + 15.0f)) / 100.0f;
}
canvas.drawRect(new Rect((int) (((float) getWidth()) - (((float) getWidth()) * src)), 0, getWidth(), getHeight()), this.mPaint);
this.mPaint.setXfermode(null);
}
@TargetApi(13)
public void setDataSource(FileDescriptor fd) throws IOException, IllegalArgumentException, IllegalStateException {
if (VERSION.SDK_INT < 12) {
try {
Field f = fd.getClass().getDeclaredField("descriptor");
f.setAccessible(true);
_setDataSourceFd(f.getInt(fd));
return;
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e2) {
throw new RuntimeException(e2);
}
}
ParcelFileDescriptor pfd = ParcelFileDescriptor.dup(fd);
try {
_setDataSourceFd(pfd.getFd());
} finally {
pfd.close();
}
}
public void launch(@NonNull Context context) {
Intent i = getIntent(context);
if (context instanceof Activity) {
if (options == null && sharedElements != null) {
options = getOptionsBundle((Activity) context, sharedElements);
}
if (options != null && VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
context.startActivity(i, options);
} else {
context.startActivity(i);
}
if (enterAnim != 0 && exitAnim != 0) {
((Activity) context).overridePendingTransition(enterAnim, exitAnim);
}
if (direction != 0) {
overridePendingTransition((Activity) context, direction);
}
} else {
context.startActivity(i);
}
}
@TargetApi(16)
public void dumpProfileLevels(String mimeType) {
if (VERSION.SDK_INT >= 16) {
try {
CodecCapabilities caps = this.mCodecInfo.getCapabilitiesForType(mimeType);
int maxProfile = 0;
int maxLevel = 0;
if (!(caps == null || caps.profileLevels == null)) {
for (CodecProfileLevel profileLevel : caps.profileLevels) {
if (profileLevel != null) {
maxProfile = Math.max(maxProfile, profileLevel.profile);
maxLevel = Math.max(maxLevel, profileLevel.level);
}
}
}
Log.i(TAG, String.format(Locale.US, "%s", new Object[]{getProfileLevelName(maxProfile, maxLevel)}));
} catch (Throwable th) {
Log.i(TAG, "profile-level: exception");
}
}
}
public void dispatchDraw(Canvas canvas) {
if (VERSION.SDK_INT < 8) {
scrollChanged(getFirstVisiblePosition());
}
positionSelectorRect();
if (!this.mAreHeadersSticky || this.mHeader == null) {
super.dispatchDraw(canvas);
return;
}
if (!this.mDrawingListUnderStickyHeader) {
this.mClippingRect.set(0, this.mHeaderBottomPosition, getWidth(), getHeight());
canvas.save();
canvas.clipRect(this.mClippingRect);
}
super.dispatchDraw(canvas);
if (!this.mDrawingListUnderStickyHeader) {
canvas.restore();
}
drawStickyHeader(canvas);
}
@RequiresApi(api = 24)
public static void changeAppLanguage(Context context, Locale setLocale) {
Resources resources = context.getApplicationContext().getResources();
DisplayMetrics dm = resources.getDisplayMetrics();
Configuration config = resources.getConfiguration();
Locale locale = getLocaleByLanguage(setLocale);
config.locale = locale;
if (VERSION.SDK_INT >= 24) {
LocaleList localeList = new LocaleList(new Locale[]{locale});
LocaleList.setDefault(localeList);
config.setLocales(localeList);
context.getApplicationContext().createConfigurationContext(config);
Locale.setDefault(locale);
}
resources.updateConfiguration(config, dm);
}
public void launch(@NonNull Fragment f, int requestCode) {
Activity a = f.getActivity();
Intent i = getIntent(a);
if (options == null && sharedElements != null) {
options = getOptionsBundle(a, sharedElements);
}
if (options != null && VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
f.startActivityForResult(i, requestCode, options);
} else {
f.startActivityForResult(i, requestCode);
}
if (enterAnim != 0 && exitAnim != 0 && a != null) {
a.overridePendingTransition(enterAnim, exitAnim);
}
if (direction != 0) {
overridePendingTransition(a, direction);
}
}
public void launch(@NonNull Activity activity, int requestCode) {
Intent i = getIntent(activity);
if (options == null && sharedElements != null) {
options = getOptionsBundle(activity, sharedElements);
}
if (options != null && VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
activity.startActivityForResult(i, requestCode, options);
} else {
activity.startActivityForResult(i, requestCode);
}
if (enterAnim != 0 && exitAnim != 0) {
activity.overridePendingTransition(enterAnim, exitAnim);
}
if (direction != 0) {
overridePendingTransition(activity, direction);
}
}
public static void setColor(Activity activity, @ColorInt int color, int statusBarAlpha) {
if (VERSION.SDK_INT >= 21) {
activity.getWindow().addFlags(Integer.MIN_VALUE);
activity.getWindow().clearFlags(NTLMConstants.FLAG_UNIDENTIFIED_9);
activity.getWindow().setStatusBarColor(calculateStatusColor(color, statusBarAlpha));
} else if (VERSION.SDK_INT >= 19) {
activity.getWindow().addFlags(NTLMConstants.FLAG_UNIDENTIFIED_9);
ViewGroup decorView = (ViewGroup) activity.getWindow().getDecorView();
int count = decorView.getChildCount();
if (count <= 0 || !(decorView.getChildAt(count - 1) instanceof StatusBarView)) {
decorView.addView(createStatusBarView(activity, color, statusBarAlpha));
} else {
decorView.getChildAt(count - 1).setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
setRootView(activity);
}
}
/**
* Map from permission code of {@link PermissionHelper} to string in {@link Manifest}.
*
* @param permission permission code
* @return permission name
*/
public static String map(@Permission int permission) {
switch (permission) {
case Permission.STORAGE: return Manifest.permission.WRITE_EXTERNAL_STORAGE;
case Permission.PHONE_STATE: return Manifest.permission.READ_PHONE_STATE;
case Permission.LOCATION: return Manifest.permission.ACCESS_FINE_LOCATION;
case Permission.MICROPHONE: return Manifest.permission.RECORD_AUDIO;
case Permission.SMS: return Manifest.permission.SEND_SMS;
case Permission.SENSORS:
if (VERSION.SDK_INT >= VERSION_CODES.KITKAT_WATCH) {
return Manifest.permission.BODY_SENSORS;
}
return "android.permission.BODY_SENSORS";
case Permission.CONTACTS: return Manifest.permission.READ_CONTACTS;
case Permission.CAMERA: return Manifest.permission.CAMERA;
case Permission.CALENDAR: return Manifest.permission.READ_CALENDAR;
default:throw new IllegalArgumentException("Unrecognized permission code " + permission);
}
}
public static void setColorForDrawerLayout(Activity activity, DrawerLayout drawerLayout, @ColorInt int color, int statusBarAlpha) {
if (VERSION.SDK_INT >= 19) {
if (VERSION.SDK_INT >= 21) {
activity.getWindow().addFlags(Integer.MIN_VALUE);
activity.getWindow().clearFlags(NTLMConstants.FLAG_UNIDENTIFIED_9);
activity.getWindow().setStatusBarColor(0);
} else {
activity.getWindow().addFlags(NTLMConstants.FLAG_UNIDENTIFIED_9);
}
ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
if (contentLayout.getChildCount() <= 0 || !(contentLayout.getChildAt(0) instanceof StatusBarView)) {
contentLayout.addView(createStatusBarView(activity, color), 0);
} else {
contentLayout.getChildAt(0).setBackgroundColor(calculateStatusColor(color, statusBarAlpha));
}
if (!((contentLayout instanceof LinearLayout) || contentLayout.getChildAt(1) == null)) {
contentLayout.getChildAt(1).setPadding(contentLayout.getPaddingLeft(), getStatusBarHeight(activity) + contentLayout.getPaddingTop(), contentLayout.getPaddingRight(), contentLayout.getPaddingBottom());
}
setDrawerLayoutProperty(drawerLayout, contentLayout);
addTranslucentView(activity, statusBarAlpha);
}
}
@Deprecated
public static void setColorForDrawerLayoutDiff(Activity activity, DrawerLayout drawerLayout, @ColorInt int color) {
if (VERSION.SDK_INT >= 19) {
activity.getWindow().addFlags(NTLMConstants.FLAG_UNIDENTIFIED_9);
ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
if (contentLayout.getChildCount() <= 0 || !(contentLayout.getChildAt(0) instanceof StatusBarView)) {
contentLayout.addView(createStatusBarView(activity, color), 0);
} else {
contentLayout.getChildAt(0).setBackgroundColor(calculateStatusColor(color, 0));
}
if (!((contentLayout instanceof LinearLayout) || contentLayout.getChildAt(1) == null)) {
contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
}
setDrawerLayoutProperty(drawerLayout, contentLayout);
}
}
public static void setTransparentForDrawerLayout(Activity activity, DrawerLayout drawerLayout) {
if (VERSION.SDK_INT >= 19) {
if (VERSION.SDK_INT >= 21) {
activity.getWindow().addFlags(Integer.MIN_VALUE);
activity.getWindow().clearFlags(NTLMConstants.FLAG_UNIDENTIFIED_9);
activity.getWindow().setStatusBarColor(0);
} else {
activity.getWindow().addFlags(NTLMConstants.FLAG_UNIDENTIFIED_9);
}
ViewGroup contentLayout = (ViewGroup) drawerLayout.getChildAt(0);
if (!((contentLayout instanceof LinearLayout) || contentLayout.getChildAt(1) == null)) {
contentLayout.getChildAt(1).setPadding(0, getStatusBarHeight(activity), 0, 0);
}
setDrawerLayoutProperty(drawerLayout, contentLayout);
}
}
public FramesSequenceAnimation(ImageView imageView, int[] frames, int fps) {
this.mFrames = frames;
this.mIndex = -1;
this.mSoftReferenceImageView = new SoftReference(imageView);
this.mShouldRun = false;
this.mIsRunning = false;
this.mDelayMillis = 100;
imageView.setImageResource(this.mFrames[0]);
if (VERSION.SDK_INT >= 11) {
Bitmap bmp = ((BitmapDrawable) imageView.getDrawable()).getBitmap();
this.mBitmap = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), bmp.getConfig());
this.mBitmapOptions = new Options();
this.mBitmapOptions.inBitmap = this.mBitmap;
this.mBitmapOptions.inMutable = true;
this.mBitmapOptions.inSampleSize = 1;
this.mBitmapOptions.inPreferredConfig = Config.RGB_565;
}
}
@TargetApi(13)
public void setDataSource(FileDescriptor fd) throws IOException, IllegalArgumentException, IllegalStateException {
if (VERSION.SDK_INT < 12) {
try {
Field f = fd.getClass().getDeclaredField("descriptor");
f.setAccessible(true);
_setDataSourceFd(f.getInt(fd));
return;
} catch (NoSuchFieldException e) {
throw new RuntimeException(e);
} catch (IllegalAccessException e2) {
throw new RuntimeException(e2);
}
}
ParcelFileDescriptor pfd = ParcelFileDescriptor.dup(fd);
try {
_setDataSourceFd(pfd.getFd());
} finally {
pfd.close();
}
}
@TargetApi(16)
public void bindToMediaPlayer(IMediaPlayer mp) {
if (mp != null) {
if (VERSION.SDK_INT < 16 || !(mp instanceof ISurfaceTextureHolder)) {
mp.setSurface(openSurface());
return;
}
ISurfaceTextureHolder textureHolder = (ISurfaceTextureHolder) mp;
this.mTextureView.mSurfaceCallback.setOwnSurfaceTecture(false);
SurfaceTexture surfaceTexture = textureHolder.getSurfaceTexture();
if (surfaceTexture != null) {
this.mTextureView.setSurfaceTexture(surfaceTexture);
} else {
textureHolder.setSurfaceTexture(this.mSurfaceTexture);
}
}
}
@TargetApi(16)
public void dumpProfileLevels(String mimeType) {
if (VERSION.SDK_INT >= 16) {
try {
CodecCapabilities caps = this.mCodecInfo.getCapabilitiesForType(mimeType);
int maxProfile = 0;
int maxLevel = 0;
if (!(caps == null || caps.profileLevels == null)) {
for (CodecProfileLevel profileLevel : caps.profileLevels) {
if (profileLevel != null) {
maxProfile = Math.max(maxProfile, profileLevel.profile);
maxLevel = Math.max(maxLevel, profileLevel.level);
}
}
}
Log.i(TAG, String.format(Locale.US, "%s", new Object[]{getProfileLevelName(maxProfile, maxLevel)}));
} catch (Throwable th) {
Log.i(TAG, "profile-level: exception");
}
}
}
public void onSuccess(Object responseObj) {
Uri data;
DownloadApkService.this.handler.sendEmptyMessage(1);
Toast.makeText(DownloadApkService.this, R.string.fimi_sdk_apk_down_success, 0).show();
Intent intent = new Intent("android.intent.action.VIEW");
intent.setFlags(NTLMConstants.FLAG_UNIDENTIFIED_11);
if (VERSION.SDK_INT >= 24) {
data = FileProvider.getUriForFile(DownloadApkService.this, DownloadApkService.this.getPackageName() + ".fileprovider", new File(DownloadApkService.this.path));
intent.addFlags(1);
} else {
data = Uri.fromFile(new File(DownloadApkService.this.path));
}
intent.setDataAndType(data, "application/vnd.android.package-archive");
DownloadApkService.this.startActivity(intent);
DownloadApkService.this.notificationManager.cancel(DownloadApkService.NOTIFACTION_ID);
DownloadApkService.isDownApking = false;
DownloadApkService.this.stopSelf();
}
private int fixedFirstVisibleItem(int firstVisibleItem) {
if (VERSION.SDK_INT >= 11) {
return firstVisibleItem;
}
for (int i = 0; i < getChildCount(); i++) {
if (getChildAt(i).getBottom() >= 0) {
firstVisibleItem += i;
break;
}
}
if (!this.mClippingToPadding.booleanValue() && getPaddingTop() > 0 && super.getChildAt(0).getTop() > 0 && firstVisibleItem > 0) {
firstVisibleItem--;
}
return firstVisibleItem;
}
@Override
protected InputStream loadResource(Uri uri, ContentResolver contentResolver)
throws FileNotFoundException
{
if (VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH) {
return ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, uri, true);
} else {
return ContactsContract.Contacts.openContactPhotoInputStream(contentResolver, uri);
}
}
@TargetApi(VERSION_CODES.KITKAT)
public static boolean isLowMemory(Context context) {
ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
return (VERSION.SDK_INT >= VERSION_CODES.KITKAT && activityManager.isLowRamDevice()) ||
activityManager.getLargeMemoryClass() <= 64;
}
@TargetApi(14)
private void onCameraReady(final @NonNull Camera camera) {
final Parameters parameters = camera.getParameters();
if (VERSION.SDK_INT >= 14) {
parameters.setRecordingHint(true);
final List<String> focusModes = parameters.getSupportedFocusModes();
if (focusModes.contains(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
} else if (focusModes.contains(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO)) {
parameters.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_VIDEO);
}
}
displayOrientation = CameraUtils.getCameraDisplayOrientation(getActivity(), getCameraInfo());
camera.setDisplayOrientation(displayOrientation);
camera.setParameters(parameters);
enqueueTask(new PostInitializationTask<Void>() {
@Override
protected Void onRunBackground() {
try {
camera.setPreviewDisplay(surface.getHolder());
startPreview(parameters);
} catch (Exception e) {
Log.w(TAG, "couldn't set preview display", e);
}
return null;
}
});
}
public static void postOnAnimation(View view, Runnable runnable) {
if (VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN) {
postOnAnimationJellyBean(view, runnable);
} else {
view.postDelayed(runnable, SIXTY_FPS_INTERVAL);
}
}
private void setupStarWarsPButtonGroup()
{
SegmentedButtonGroup buttonGroup = new SegmentedButtonGroup(this);
buttonGroup.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
((LinearLayout.LayoutParams)buttonGroup.getLayoutParams()).setMargins((int)dpToPx(4), (int)dpToPx(4),
(int)dpToPx(4), (int)dpToPx(4));
((LayoutParams)buttonGroup.getLayoutParams()).gravity = Gravity.CENTER_HORIZONTAL;
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP)
buttonGroup.setElevation(dpToPx(2));
buttonGroup.setBackground(getResources().getColor(R.color.red_400));
buttonGroup.setRadius((int)dpToPx(2));
buttonGroup.setRipple(getResources().getColor(R.color.red_200));
buttonGroup.setSelectedBackground(getResources().getColor(R.color.green_200));
buttonGroup.setDivider(Color.WHITE, (int)dpToPx(2), (int)dpToPx(10), (int)dpToPx(10));
SegmentedButton button1 = new SegmentedButton(this);
button1.setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
button1.setPadding((int)dpToPx(20), (int)dpToPx(6), (int)dpToPx(20), (int)dpToPx(6));
button1.setDrawable(getResources().getDrawable(R.drawable.ic_b8));
buttonGroup.addView(button1);
SegmentedButton button2 = new SegmentedButton(this);
button2.setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 2));
button2.setPadding((int)dpToPx(45), (int)dpToPx(6), (int)dpToPx(45), (int)dpToPx(6));
button2.setDrawable(getResources().getDrawable(R.drawable.ic_b9));
buttonGroup.addView(button2);
SegmentedButton button3 = new SegmentedButton(this);
button3.setLayoutParams(new LinearLayout.LayoutParams(0, LayoutParams.WRAP_CONTENT, 1));
button3.setPadding((int)dpToPx(20), (int)dpToPx(6), (int)dpToPx(20), (int)dpToPx(6));
button3.setDrawable(getResources().getDrawable(R.drawable.ic_b11));
buttonGroup.addView(button3);
buttonGroup.setPosition(1, false);
linearLayout.addView(buttonGroup);
starWarsPButtonGroup = buttonGroup;
}
private Drawable readCompatDrawable(Context context, int drawableResId)
{
Drawable drawable = AppCompatResources.getDrawable(context, drawableResId);
// API 28 has a bug with vector drawables where the selected tint color is always applied to the drawable
// To prevent this, the vector drawable is converted to a bitmap
if ((VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && drawable instanceof VectorDrawable)
|| drawable instanceof VectorDrawableCompat)
{
Bitmap bitmap = getBitmapFromVectorDrawable(drawable);
return new BitmapDrawable(context.getResources(), bitmap);
}
else
return drawable;
}
/**
* Setup the selected button clip path to round the corners of the selected button
*
* This function should be called if the selected button radius is changed
*/
void setupSelectedButtonClipPath()
{
// Setup selected button radii
// Object allocated here rather than in onDraw to increase performance
selectedButtonRadii = new float[] {
selectedButtonRadius, selectedButtonRadius, selectedButtonRadius,
selectedButtonRadius, selectedButtonRadius, selectedButtonRadius, selectedButtonRadius,
selectedButtonRadius
};
if (selectedButtonRadius > 0)
{
// Canvas.clipPath, used in onDraw for drawing the selected button clip path is not supported with
// hardware acceleration until API 18. Thus, this switches to software acceleration if current Android
// API version is less than 18.
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2)
{
setLayerType(LAYER_TYPE_SOFTWARE, null);
}
}
// Update background bitmaps
setupBackgroundBitmaps();
invalidate();
}