mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-06 03:50:19 +02:00
PreferenceSet.Reloader usages
This commit is contained in:
parent
a6aa805e81
commit
3e258b410f
2 changed files with 16 additions and 12 deletions
|
@ -108,11 +108,13 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
directoriesScreen.addPreference(myChooserCollection.createPreference(
|
directoriesScreen.addPreference(myChooserCollection.createPreference(
|
||||||
directoriesScreen.Resource, "downloadDir", Paths.DownloadsDirectoryOption, libraryUpdater
|
directoriesScreen.Resource, "downloadDir", Paths.DownloadsDirectoryOption, libraryUpdater
|
||||||
));
|
));
|
||||||
|
final PreferenceSet fontReloader = new PreferenceSet.Reloader();
|
||||||
directoriesScreen.addPreference(myChooserCollection.createPreference(
|
directoriesScreen.addPreference(myChooserCollection.createPreference(
|
||||||
directoriesScreen.Resource, "fontPath", Paths.FontPathOption, null
|
directoriesScreen.Resource, "fontPath", Paths.FontPathOption, fontReloader
|
||||||
));
|
));
|
||||||
|
final PreferenceSet wallpaperReloader = new PreferenceSet.Reloader();
|
||||||
directoriesScreen.addPreference(myChooserCollection.createPreference(
|
directoriesScreen.addPreference(myChooserCollection.createPreference(
|
||||||
directoriesScreen.Resource, "wallpaperPath", Paths.WallpaperPathOption, null
|
directoriesScreen.Resource, "wallpaperPath", Paths.WallpaperPathOption, wallpaperReloader
|
||||||
));
|
));
|
||||||
directoriesScreen.addPreference(myChooserCollection.createPreference(
|
directoriesScreen.addPreference(myChooserCollection.createPreference(
|
||||||
directoriesScreen.Resource, "tempDir", Paths.TempDirectoryOption, null
|
directoriesScreen.Resource, "tempDir", Paths.TempDirectoryOption, null
|
||||||
|
@ -196,7 +198,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onClick() {
|
protected void onClick() {
|
||||||
super.onClick();
|
super.onClick();
|
||||||
einkPreferences.update();
|
einkPreferences.run();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -206,7 +208,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
einkScreen.addPreference(updateIntervalPreference);
|
einkScreen.addPreference(updateIntervalPreference);
|
||||||
|
|
||||||
einkPreferences.add(updateIntervalPreference);
|
einkPreferences.add(updateIntervalPreference);
|
||||||
einkPreferences.update();
|
einkPreferences.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
final Screen textScreen = createPreferenceScreen("text");
|
final Screen textScreen = createPreferenceScreen("text");
|
||||||
|
@ -224,6 +226,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
baseStyle.FontFamilyOption, false
|
baseStyle.FontFamilyOption, false
|
||||||
);
|
);
|
||||||
textScreen.addPreference(fontPreference);
|
textScreen.addPreference(fontPreference);
|
||||||
|
fontReloader.add(fontPreference);
|
||||||
|
|
||||||
textScreen.addPreference(new ZLIntegerRangePreference(
|
textScreen.addPreference(new ZLIntegerRangePreference(
|
||||||
this, textScreen.Resource.getResource("fontSize"),
|
this, textScreen.Resource.getResource("fontSize"),
|
||||||
|
@ -391,15 +394,16 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onDialogClosed(boolean result) {
|
protected void onDialogClosed(boolean result) {
|
||||||
super.onDialogClosed(result);
|
super.onDialogClosed(result);
|
||||||
bgPreferences.update();
|
bgPreferences.run();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
colorsScreen.addPreference(wallpaperPreference);
|
colorsScreen.addPreference(wallpaperPreference);
|
||||||
|
wallpaperReloader.add(wallpaperPreference);
|
||||||
|
|
||||||
bgPreferences.add(
|
bgPreferences.add(
|
||||||
colorsScreen.addOption(profile.BackgroundOption, "backgroundColor")
|
colorsScreen.addOption(profile.BackgroundOption, "backgroundColor")
|
||||||
);
|
);
|
||||||
bgPreferences.update();
|
bgPreferences.run();
|
||||||
colorsScreen.addOption(profile.HighlightingOption, "highlighting");
|
colorsScreen.addOption(profile.HighlightingOption, "highlighting");
|
||||||
colorsScreen.addOption(profile.RegularTextOption, "text");
|
colorsScreen.addOption(profile.RegularTextOption, "text");
|
||||||
colorsScreen.addOption(profile.HyperlinkTextOption, "hyperlink");
|
colorsScreen.addOption(profile.HyperlinkTextOption, "hyperlink");
|
||||||
|
@ -440,7 +444,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
@Override
|
@Override
|
||||||
protected void onDialogClosed(boolean result) {
|
protected void onDialogClosed(boolean result) {
|
||||||
super.onDialogClosed(result);
|
super.onDialogClosed(result);
|
||||||
footerPreferences.update();
|
footerPreferences.run();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -458,7 +462,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
this, statusLineScreen.Resource, "font",
|
this, statusLineScreen.Resource, "font",
|
||||||
footerOptions.Font, false
|
footerOptions.Font, false
|
||||||
)));
|
)));
|
||||||
footerPreferences.update();
|
footerPreferences.run();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
final Screen colorProfileScreen = createPreferenceScreen("colorProfile");
|
final Screen colorProfileScreen = createPreferenceScreen("colorProfile");
|
||||||
|
@ -498,7 +502,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
keyBindings.bindKey(KeyEvent.KEYCODE_VOLUME_DOWN, false, FBReaderApp.NoAction);
|
keyBindings.bindKey(KeyEvent.KEYCODE_VOLUME_DOWN, false, FBReaderApp.NoAction);
|
||||||
keyBindings.bindKey(KeyEvent.KEYCODE_VOLUME_UP, false, FBReaderApp.NoAction);
|
keyBindings.bindKey(KeyEvent.KEYCODE_VOLUME_UP, false, FBReaderApp.NoAction);
|
||||||
}
|
}
|
||||||
volumeKeysPreferences.update();
|
volumeKeysPreferences.run();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
volumeKeysPreferences.add(scrollingScreen.addPreference(new ZLCheckBoxPreference(
|
volumeKeysPreferences.add(scrollingScreen.addPreference(new ZLCheckBoxPreference(
|
||||||
|
@ -522,7 +526,7 @@ public class PreferenceActivity extends ZLPreferenceActivity {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
volumeKeysPreferences.update();
|
volumeKeysPreferences.run();
|
||||||
|
|
||||||
scrollingScreen.addOption(pageTurningOptions.Animation, "animation");
|
scrollingScreen.addOption(pageTurningOptions.Animation, "animation");
|
||||||
scrollingScreen.addPreference(new AnimationSpeedPreference(
|
scrollingScreen.addPreference(new AnimationSpeedPreference(
|
||||||
|
|
|
@ -23,14 +23,14 @@ import java.util.LinkedList;
|
||||||
|
|
||||||
import android.preference.Preference;
|
import android.preference.Preference;
|
||||||
|
|
||||||
abstract class PreferenceSet<T> {
|
abstract class PreferenceSet<T> implements Runnable {
|
||||||
private final LinkedList<Preference> myPreferences = new LinkedList<Preference>();
|
private final LinkedList<Preference> myPreferences = new LinkedList<Preference>();
|
||||||
|
|
||||||
final void add(Preference preference) {
|
final void add(Preference preference) {
|
||||||
myPreferences.add(preference);
|
myPreferences.add(preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
final void update() {
|
public final void run() {
|
||||||
final T state = detectState();
|
final T state = detectState();
|
||||||
for (Preference preference : myPreferences) {
|
for (Preference preference : myPreferences) {
|
||||||
update(preference, state);
|
update(preference, state);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue