Rework to avoid using preferences object to retrieve options

This commit is contained in:
Guillaume Tâche
2024-09-22 21:59:10 +02:00
parent 7f99c48e2c
commit c59619da2d
115 changed files with 2294 additions and 765 deletions

View File

@@ -14,13 +14,13 @@ public class CombinedResourceBundle extends ResourceBundle {
private final Map<String, String> resources;
private final Locale locale;
public CombinedResourceBundle(final ResourceBundle... resourceBundles) {
this(Arrays.asList(resourceBundles));
public CombinedResourceBundle(final ResourceBundle... bundles) {
this(Arrays.asList(bundles));
}
public CombinedResourceBundle(final List<ResourceBundle> resourceBundles) {
final var filteredBundles = resourceBundles.stream().filter(Objects::nonNull).toList();
if (filteredBundles.size() != resourceBundles.size()) {
public CombinedResourceBundle(final Collection<ResourceBundle> bundles) {
final var filteredBundles = bundles.stream().filter(Objects::nonNull).toList();
if (filteredBundles.size() != bundles.size()) {
logger.warn("There was one or more null bundles in the inner bundles");
}
if (filteredBundles.isEmpty()) {

View File

@@ -5,5 +5,6 @@ import java.util.spi.ResourceBundleProvider;
/**
* Provider for MainBundle
*/
@FunctionalInterface
public interface MainBundleProvider extends ResourceBundleProvider {
}

View File

@@ -5,5 +5,6 @@ import java.util.spi.ResourceBundleProvider;
/**
* Provider for ParametersBundle
*/
@FunctionalInterface
public interface ParametersBundleProvider extends ResourceBundleProvider {
}

View File

@@ -5,5 +5,6 @@ import java.util.spi.ResourceBundleProvider;
/**
* Provider for SetupBundle
*/
@FunctionalInterface
public interface SetupBundleProvider extends ResourceBundleProvider {
}

View File

@@ -5,5 +5,6 @@ import java.util.spi.ResourceBundleProvider;
/**
* Provider for SubtitlesBundle
*/
@FunctionalInterface
public interface SubtitlesBundleProvider extends ResourceBundleProvider {
}

View File

@@ -5,5 +5,6 @@ import java.util.spi.ResourceBundleProvider;
/**
* Provider for WorkBundle
*/
@FunctionalInterface
public interface WorkBundleProvider extends ResourceBundleProvider {
}

View File

@@ -31,6 +31,9 @@ public final class GuiCoreModule {
@Play
static byte[] providesPlayImage() {
try (final var in = GuiCoreModule.class.getResourceAsStream("/com/github/gtache/autosubtitle/gui/impl/play_64.png")) {
if (in == null) {
throw new UncheckedIOException(new IOException("Resource not found : /com/github/gtache/autosubtitle/gui/impl/play_64.png"));
}
return in.readAllBytes();
} catch (final IOException e) {
throw new UncheckedIOException(e);
@@ -41,6 +44,9 @@ public final class GuiCoreModule {
@Pause
static byte[] providesPauseImage() {
try (final var in = GuiCoreModule.class.getResourceAsStream("/com/github/gtache/autosubtitle/gui/impl/pause_64.png")) {
if (in == null) {
throw new UncheckedIOException(new IOException("Resource not found : /com/github/gtache/autosubtitle/gui/impl/pause_64.png"));
}
return in.readAllBytes();
} catch (final IOException e) {
throw new UncheckedIOException(e);