添加解码选择

This commit is contained in:
seven332 committed 2014-09-06 19:40:18 +08:00
1 parent b562ec2b50
commit 2e188a2cc3
8 files changed
+58 -12

No files matched your search

+3
View File
@@ -202,6 +202,9 @@
<string name="read_settings_title">阅读</string>
<string name="gallery_show_clock_title">显示时间</string>
<string name="gallery_show_battery_title">显示电量</string>
<string name="custom_codec_title">自定义解码</string>
<string name="custom_codec_summary">自定义解码可能会更使用更少内存,解码更快</string>
<string name="custom_codec_summary_not">自定义解码暂不支持 x86, mips</string>
<string name="download_settings_title">下载</string>
<string name="download_path_title">下载路径</string>
+5
View File
@@ -43,4 +43,9 @@
android:title="@string/gallery_show_battery_title"
android:defaultValue="true" />
<CheckBoxPreference
android:key="custom_codec"
android:title="@string/custom_codec_title"
android:summary="@string/custom_codec_summary" />
</PreferenceScreen>
@@ -743,8 +743,10 @@ public class GalleryView extends GLView
return false;
ShowItem showItem;
if (showItems[NEXT_TARGET_INDEX] != null)
if (showItems[NEXT_TARGET_INDEX] != null) {
showItems[NEXT_TARGET_INDEX].recycle();
showItems[NEXT_TARGET_INDEX] = null;
}
showItems[NEXT_TARGET_INDEX] = showItems[CUR_TARGET_INDEX];
showItems[CUR_TARGET_INDEX] = showItems[PRE_TARGET_INDEX];
showItems[PRE_TARGET_INDEX] = null;
@@ -780,8 +782,10 @@ public class GalleryView extends GLView
return false;
ShowItem showItem;
if (showItems[PRE_TARGET_INDEX] != null)
if (showItems[PRE_TARGET_INDEX] != null) {
showItems[PRE_TARGET_INDEX].recycle();
showItems[PRE_TARGET_INDEX] = null;
}
showItems[PRE_TARGET_INDEX] = showItems[CUR_TARGET_INDEX];
showItems[CUR_TARGET_INDEX] = showItems[NEXT_TARGET_INDEX];
showItems[NEXT_TARGET_INDEX] = null;
@@ -819,12 +823,18 @@ public class GalleryView extends GLView
return goToNextPage();
} else {
// Free
if (showItems[PRE_TARGET_INDEX] != null)
if (showItems[PRE_TARGET_INDEX] != null) {
showItems[PRE_TARGET_INDEX].recycle();
if (showItems[CUR_TARGET_INDEX] != null)
showItems[PRE_TARGET_INDEX] = null;
}
if (showItems[CUR_TARGET_INDEX] != null) {
showItems[CUR_TARGET_INDEX].recycle();
if (showItems[NEXT_TARGET_INDEX] != null)
showItems[CUR_TARGET_INDEX] = null;
}
if (showItems[NEXT_TARGET_INDEX] != null) {
showItems[NEXT_TARGET_INDEX].recycle();
showItems[NEXT_TARGET_INDEX] = null;
}
mCurIndex = index;
setState();
@@ -841,16 +851,21 @@ public class GalleryView extends GLView
}
}
public synchronized void free() {
for (int i = 0; i < TARGET_INDEX_SIZE; i++) {
if (showItems[i] != null) {
showItems[i].recycle();
showItems[i] = null;
}
}
}
@Override
protected boolean onTouch(MotionEvent event) {
mGestureRecognizer.onTouchEvent(event);
return true;
}
private void setTouchLocked(boolean locked) {
}
private class MyGestureListener implements GestureRecognizer.Listener {
private boolean isScale = false;
@@ -203,7 +203,7 @@ public class ImageSet implements ExDownloader.ListenerForImageSet {
String pathName = Utils.getPathName(mDir.getPath(), decodeInfo.filename);
Object res = null;
if (Utils.SUPPORT_IMAGE) {
if (Utils.SUPPORT_IMAGE && Config.getCustomCodec()) {
res = Image.decodeFile(pathName, GL11.GL_RGB);
} else {
if (Utils.getExtension(pathName, "jpg").equals("gif"))
@@ -73,7 +73,6 @@ public class GalleryActivity extends AbsActivity
private ValueAnimator mShowAnimator;
private ValueAnimator mHideAnimator;
private long mHideTaskTimeStamp;
@Override
public void onOrientationChanged(int paddingTop, int paddingBottom) {
@@ -266,6 +265,8 @@ public class GalleryActivity extends AbsActivity
if (mImageSet != null)
mImageSet.free();
if (mGalleryView != null)
mGalleryView.free();
}
@Override
@@ -447,10 +447,23 @@ public class SettingsActivity extends AbsPreferenceActivity {
implements Preference.OnPreferenceChangeListener,
Preference.OnPreferenceClickListener {
private static final String KEY_CUSTOM_CODEC = "custom_codec";
private Preference mCustomCodec;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.read_settings);
mCustomCodec = findPreference(KEY_CUSTOM_CODEC);
if (!Utils.SUPPORT_IMAGE) {
mCustomCodec.setEnabled(false);
mCustomCodec.setDefaultValue(false);
mCustomCodec.setSummary(R.string.custom_codec_summary_not);
} else {
mCustomCodec.setDefaultValue(true);
}
}
@Override
+9
View File
@@ -477,13 +477,18 @@ public class Config {
private static final String KEY_PAGE_SCALING = "page_scaling";
private static final String DEFAULT_PAGE_SCALING = "3";
private static final String KEY_START_POSITION = "start_position";
private static final String DEFAULT_START_POSITION = "1";
private static final String KEY_GALLERY_SHOW_TIME = "gallery_show_clock";
private static final boolean DEFAULT_GALLERY_SHOW_TIME = true;
private static final String KEY_GALLERY_SHOW_BATTERY = "gallery_show_battery";
private static final boolean DEFAULT_GALLERY_SHOW_BATTERY = true;
private static final String KEY_CUSTOM_CODEC = "custom_codec";
public static int getPageScalingMode() {
int pageScalingMode = 3;
try {
@@ -516,6 +521,10 @@ public class Config {
return mConfigPre.getBoolean(KEY_GALLERY_SHOW_BATTERY, DEFAULT_GALLERY_SHOW_BATTERY);
}
public static boolean getCustomCodec() {
return mConfigPre.getBoolean(KEY_CUSTOM_CODEC, Utils.SUPPORT_IMAGE);
}
/****** Download ******/
+1 -1
View File
@@ -51,7 +51,7 @@ public final class Utils {
static {
String cpu = Build.CPU_ABI;
SUPPORT_IMAGE = cpu.startsWith("armeabi") || cpu.equals("mips");
SUPPORT_IMAGE = cpu.equals("armeabi") || cpu.equals("armeabi-v7a");
}
/**