Subversion Repository Public Repository

Nextrek

Diff Revisions 10 vs 11 for /Android/Minstrek/MinstrekLib/src/nextrek/minstrek/utils/BookUtils.java

Diff revisions: vs.
  @@ -5,12 +5,12 @@
5 5 import java.io.InputStream;
6 6 import java.io.InputStreamReader;
7 7
8 - import nextrek.minstrek.core.ConditionList;
9 8 import android.content.Context;
10 - import android.content.SharedPreferences;
11 9 import android.content.res.AssetManager;
12 10 import android.graphics.Bitmap;
11 + import android.graphics.Bitmap.Config;
13 12 import android.graphics.BitmapFactory;
13 + import android.graphics.BitmapFactory.Options;
14 14 import android.util.Log;
15 15
16 16 public class BookUtils {
  @@ -20,11 +20,15 @@
20 20
21 21 InputStream fis = null;
22 22 try {
23 - fis = context.getAssets().open(strName, AssetManager.ACCESS_STREAMING); // context.openFileInput(strName);
24 - // Log.d(TAG, strName + " loaded");
25 - return BitmapFactory.decodeStream(fis);
23 + fis = context.getAssets().open(strName); // context.openFileInput(strName);
24 + //return JP2.decode(fis);
25 + Options opt = new Options();
26 + opt.inPreferredConfig = Config.RGB_565;
27 + opt.inScaled = false;
28 +
29 + return BitmapFactory.decodeStream(fis, null, opt);
26 30 } catch (IOException e) {
27 - //e.printStackTrace();
31 + e.printStackTrace();
28 32 // ignore it
29 33 } finally {
30 34 try {
  @@ -87,23 +91,4 @@
87 91 }
88 92 }
89 93 }
90 -
91 - public static ConditionList loadConditionList(Context context, SharedPreferences prefs, String sharedPrefsKey, String javascriptFilename, String javascriptKey) {
92 - ConditionList eventsList = null;
93 - String eventsData = prefs.getString(sharedPrefsKey, null);
94 - if (eventsData != null) {
95 - eventsList = ConditionList.CreateFromSharedPrefs(eventsData);
96 - Log.d(TAG, sharedPrefsKey + "(SP): " + eventsData);
97 - } else {
98 - Log.d(TAG, sharedPrefsKey + "(SP): *no savegame*");
99 - eventsData = BookUtils.readStringFile(context, javascriptFilename);
100 - if (eventsData != null) {
101 - eventsList = ConditionList.CreateFromJavascript(javascriptKey, eventsData);
102 - Log.d(TAG, sharedPrefsKey + "(JS): " + eventsData);
103 - } else {
104 - Log.w(TAG, sharedPrefsKey + "(JS): *missing data file*");
105 - }
106 - }
107 - return eventsList;
108 - }
109 94 }