summaryrefslogtreecommitdiffstats
path: root/src/com/cyngn/theme/util/Utils.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/cyngn/theme/util/Utils.java')
-rw-r--r--src/com/cyngn/theme/util/Utils.java26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/com/cyngn/theme/util/Utils.java b/src/com/cyngn/theme/util/Utils.java
index 7b885a7..a2169e3 100644
--- a/src/com/cyngn/theme/util/Utils.java
+++ b/src/com/cyngn/theme/util/Utils.java
@@ -24,6 +24,7 @@ import android.graphics.Rect;
import android.os.RemoteException;
import android.provider.Settings;
import android.provider.ThemesContract;
+import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue;
import android.view.IWindowManager;
@@ -32,7 +33,9 @@ import android.view.WindowManager;
import android.view.WindowManagerGlobal;
import com.cyngn.theme.chooser.ChooserActivity;
+import java.io.BufferedInputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@@ -274,6 +277,29 @@ public class Utils {
return BitmapFactory.decodeByteArray(blob, 0, blob.length);
}
+ public static Bitmap loadBitmapFile(Cursor cursor, int columnIdx) {
+ if (columnIdx < 0) {
+ Log.w(TAG, "loadBitmapFile(): Invalid index provided, returning null");
+ return null;
+ }
+ String path = cursor.getString(columnIdx);
+ if (TextUtils.isEmpty(path)) {
+ return null;
+ }
+
+ Bitmap image = null;
+ FileInputStream inputStream;
+ try {
+ inputStream = new FileInputStream(path);
+ image = BitmapFactory.decodeStream(inputStream);
+ inputStream.close();
+ } catch (Exception e) {
+ Log.w(TAG, "Unable to open preview " + path, e);
+ }
+
+ return image;
+ }
+
public static String getBatteryKey(int type) {
switch(type) {
case 2: