1
0
Fork 0
mirror of https://github.com/geometer/FBReaderJ.git synced 2025-10-03 17:59:33 +02:00

refactoring

This commit is contained in:
Nikolay Pultsin 2014-05-03 03:30:54 +01:00
parent 82292cf503
commit ded085bf2b
3 changed files with 27 additions and 17 deletions

View file

@ -19,19 +19,16 @@
package org.geometerplus.android.fbreader.preferences.fileChooser; package org.geometerplus.android.fbreader.preferences.fileChooser;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.preference.Preference; import android.preference.Preference;
import org.geometerplus.zlibrary.core.resources.ZLResource; import org.geometerplus.zlibrary.core.resources.ZLResource;
import org.geometerplus.android.util.FileChooserUtil;
abstract class FileChooserPreference extends Preference { abstract class FileChooserPreference extends Preference {
private final int myRegCode; protected final int myRegCode;
private final ZLResource myResource; protected final ZLResource myResource;
private final boolean myChooseWritableDirectoriesOnly; protected final boolean myChooseWritableDirectoriesOnly;
protected final Runnable myOnValueSetAction; protected final Runnable myOnValueSetAction;
FileChooserPreference(Context context, ZLResource rootResource, String resourceKey, boolean chooseWritableDirectoriesOnly, int regCode, Runnable onValueSetAction) { FileChooserPreference(Context context, ZLResource rootResource, String resourceKey, boolean chooseWritableDirectoriesOnly, int regCode, Runnable onValueSetAction) {
@ -45,17 +42,6 @@ abstract class FileChooserPreference extends Preference {
myOnValueSetAction = onValueSetAction; myOnValueSetAction = onValueSetAction;
} }
@Override
protected void onClick() {
FileChooserUtil.runDirectoryChooser(
(Activity)getContext(),
myRegCode,
myResource.getResource("chooserTitle").getValue(),
getStringValue(),
myChooseWritableDirectoriesOnly
);
}
protected abstract String getStringValue(); protected abstract String getStringValue();
protected abstract void setValueFromIntent(Intent data); protected abstract void setValueFromIntent(Intent data);
} }

View file

@ -22,6 +22,7 @@ package org.geometerplus.android.fbreader.preferences.fileChooser;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -42,6 +43,17 @@ class FileChooserStringListPreference extends FileChooserPreference {
setSummary(getStringValue()); setSummary(getStringValue());
} }
@Override
protected void onClick() {
FileChooserUtil.runDirectoryChooser(
(Activity)getContext(),
myRegCode,
myResource.getResource("chooserTitle").getValue(),
getStringValue(),
myChooseWritableDirectoriesOnly
);
}
@Override @Override
protected String getStringValue() { protected String getStringValue() {
return MiscUtil.join(myOption.getValue(), ", "); return MiscUtil.join(myOption.getValue(), ", ");

View file

@ -19,6 +19,7 @@
package org.geometerplus.android.fbreader.preferences.fileChooser; package org.geometerplus.android.fbreader.preferences.fileChooser;
import android.app.Activity;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
@ -38,6 +39,17 @@ class FileChooserStringPreference extends FileChooserPreference {
setSummary(getStringValue()); setSummary(getStringValue());
} }
@Override
protected void onClick() {
FileChooserUtil.runDirectoryChooser(
(Activity)getContext(),
myRegCode,
myResource.getResource("chooserTitle").getValue(),
getStringValue(),
myChooseWritableDirectoriesOnly
);
}
@Override @Override
protected String getStringValue() { protected String getStringValue() {
return myOption.getValue(); return myOption.getValue();