From 33a69ad463d637f0915f1b34cebb4d6c22bcd64c Mon Sep 17 00:00:00 2001 From: Yuriy Liskov Date: Mon, 2 Nov 2020 21:45:40 +0200 Subject: [PATCH] refactor --- .../presenters/settings/PlayerSettingsPresenter.java | 2 +- .../smartyoutubetv2/common/prefs/MainUIData.java | 8 +++----- .../smartyoutubetv2/common/prefs/PlayerData.java | 10 ++++------ 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/settings/PlayerSettingsPresenter.java b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/settings/PlayerSettingsPresenter.java index 44ae8aa160..25bc7ae5f2 100644 --- a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/settings/PlayerSettingsPresenter.java +++ b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/app/presenters/settings/PlayerSettingsPresenter.java @@ -62,7 +62,7 @@ private void appendUIAutoHideCategory(AppSettingsPresenter settingsPresenter) { option -> mPlayerUIData.setUIHideTimoutSec(PlayerData.AUTO_HIDE_NEVER), mPlayerUIData.getUIHideTimoutSec() == PlayerData.AUTO_HIDE_NEVER)); - for (int i = 1; i <= 10; i++) { + for (int i = 1; i <= 15; i++) { int timeoutSec = i; options.add(UiOptionItem.from( String.format("%s sec", i), diff --git a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/prefs/MainUIData.java b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/prefs/MainUIData.java index 0aae4207d1..ef59fe4371 100644 --- a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/prefs/MainUIData.java +++ b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/prefs/MainUIData.java @@ -37,14 +37,12 @@ public boolean isAnimatedPreviewsEnabled() { private void restoreData() { String data = mPrefs.getMainUIData(); - if (data != null) { - String[] split = data.split(","); + String[] split = Helpers.split(data); - mIsAnimatedPreviewsEnabled = Helpers.parseBoolean(split, 0, true); - } + mIsAnimatedPreviewsEnabled = Helpers.parseBoolean(split, 0, true); } private void persistData() { - mPrefs.setMainUIData(String.format("%s", mIsAnimatedPreviewsEnabled)); + mPrefs.setMainUIData(Helpers.merge(mIsAnimatedPreviewsEnabled)); } } diff --git a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/prefs/PlayerData.java b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/prefs/PlayerData.java index 22a07d59d3..40522ac303 100644 --- a/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/prefs/PlayerData.java +++ b/common/src/main/java/com/liskovsoft/smartyoutubetv2/common/prefs/PlayerData.java @@ -51,15 +51,13 @@ public int getUIHideTimoutSec() { private void restoreData() { String data = mPrefs.getPlayerData(); - if (data != null) { - String[] split = data.split(","); + String[] split = Helpers.split(data); - mOKButtonBehavior = Helpers.parseInt(split, 0, ONLY_UI); - mUIHideTimeoutSec = Helpers.parseInt(split, 1, 3); - } + mOKButtonBehavior = Helpers.parseInt(split, 0, ONLY_UI); + mUIHideTimeoutSec = Helpers.parseInt(split, 1, 3); } private void persistData() { - mPrefs.setPlayerData(String.format("%s,%s", mOKButtonBehavior, mUIHideTimeoutSec)); + mPrefs.setPlayerData(Helpers.merge(mOKButtonBehavior, mUIHideTimeoutSec)); } }