Skip to content

Commit

Permalink
Add methods to check equality in version utils
Browse files Browse the repository at this point in the history
Now, each method has an alternate method with a boolean parameter
to check for equality for a specific version of Android.
  • Loading branch information
pranavpandey committed Feb 9, 2018
1 parent 5267b39 commit 520c64a
Show file tree
Hide file tree
Showing 3 changed files with 221 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ public class DynamicBitmapUtils {
*
* @return The bitmap from the supplied drawable.
*/
public @Nullable static Bitmap getBitmapFormDrawable(@NonNull Drawable drawable) {
try {
Bitmap bitmap;

bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);

Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);

return bitmap;
} catch (Exception ignored) {
public @Nullable static Bitmap getBitmapFormDrawable(@Nullable Drawable drawable) {
if (drawable != null) {
try {
Bitmap bitmap = Bitmap.createBitmap(drawable.getIntrinsicWidth(),
drawable.getIntrinsicHeight(), Bitmap.Config.ARGB_8888);

Canvas canvas = new Canvas(bitmap);
drawable.setBounds(0, 0, canvas.getWidth(), canvas.getHeight());
drawable.draw(canvas);

return bitmap;
} catch (Exception ignored) {
}
}

return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,8 @@ public static void executeTask(@Nullable AsyncTask asyncTask) {
try {
if (asyncTask != null &&
asyncTask.getStatus() != AsyncTask.Status.RUNNING) {
if (DynamicVersionUtils.isHoneycomb()) {
asyncTask.executeOnExecutor(
AsyncTask.THREAD_POOL_EXECUTOR, (Object[]) null);
} else {
asyncTask.execute((Object[]) null);
}
asyncTask.executeOnExecutor(
AsyncTask.THREAD_POOL_EXECUTOR, (Object[]) null);
}
} catch (Exception ignored) {
}
Expand Down
Loading

0 comments on commit 520c64a

Please sign in to comment.