dc418caa677b88edb3b486ca2184e12273fe258b
[android_pandora.git] /
1 package org.openintents.filemanager.compatibility;\r
2 \r
3 import android.content.res.Resources;\r
4 import android.graphics.Bitmap;\r
5 import android.graphics.drawable.BitmapDrawable;\r
6 \r
7 public class BitmapDrawable_Compatible {\r
8         \r
9         private static boolean use_SDK_1_6 = true;\r
10         \r
11         /**\r
12          * Replaces "new BitmapDrawable(context.getResources(), bitmap)" available only in SDK 1.6 and higher.\r
13          * \r
14          * @param resources\r
15          * @param bitmap\r
16          * @return\r
17          */\r
18         public static BitmapDrawable getNewBitmapDrawable(Resources resources, Bitmap bitmap) {\r
19                 BitmapDrawable b = null;\r
20                 if (use_SDK_1_6) {\r
21                         try {\r
22                                 // SDK 1.6 compatible version\r
23                                 b = BitmapDrawable_SDK_1_6.getNewBitmapDrawable(resources, bitmap);\r
24                         } catch (VerifyError e) {\r
25                                 // SDK 1.5 compatible version:\r
26                                 use_SDK_1_6 = false;\r
27                                 b = new BitmapDrawable(bitmap);\r
28                         }\r
29                 } else {\r
30                         // SDK 1.5 compatible version:\r
31                         b = new BitmapDrawable(bitmap);\r
32                 }\r
33                 return b;\r
34         }\r
35 }\r