Revision eb985085
Added by Leszek Koltunski about 2 years ago
src/main/java/org/distorted/external/RubikFiles.java | ||
---|---|---|
20 | 20 |
package org.distorted.external; |
21 | 21 |
|
22 | 22 |
import java.io.File; |
23 |
import java.io.FileInputStream; |
|
24 |
import java.io.FileNotFoundException; |
|
23 | 25 |
import java.io.FileOutputStream; |
24 | 26 |
import java.io.IOException; |
25 | 27 |
import java.io.InputStream; |
... | ... | |
54 | 56 |
|
55 | 57 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
56 | 58 |
|
57 |
public Bitmap getIcon(Context context, String name)
|
|
59 |
public InputStream openFile(Context context, String name)
|
|
58 | 60 |
{ |
59 | 61 |
File file = new File(context.getFilesDir(), name); |
60 | 62 |
|
63 |
try |
|
64 |
{ |
|
65 |
return new FileInputStream(file); |
|
66 |
} |
|
67 |
catch(FileNotFoundException ex) |
|
68 |
{ |
|
69 |
// ignore |
|
70 |
} |
|
71 |
|
|
72 |
return null; |
|
73 |
} |
|
74 |
|
|
75 |
/////////////////////////////////////////////////////////////////////////////////////////////////// |
|
76 |
|
|
77 |
public Bitmap getIcon(Context context, String name) |
|
78 |
{ |
|
79 |
File dir = context.getFilesDir(); |
|
80 |
File file = new File(dir, name); |
|
81 |
|
|
61 | 82 |
if( file.exists() ) |
62 | 83 |
{ |
63 |
String fname = context.getFilesDir().getAbsolutePath()+"/"+name;
|
|
84 |
String fname = dir.getAbsolutePath()+"/"+name;
|
|
64 | 85 |
return BitmapFactory.decodeFile(fname); |
65 | 86 |
} |
66 | 87 |
|
Also available in: Unified diff
Refactor RubikObject in preparation for creating RubikObjects from DownloadedObjects.