From 6d04e5fa449d86e9bed85a87c4d7b1f63ec91afd Mon Sep 17 00:00:00 2001 From: ZaneYork Date: Thu, 19 Mar 2020 20:05:50 +0800 Subject: [PATCH] Crash fix --- app/build.gradle | 2 +- .../com/zane/smapiinstaller/ui/config/ConfigViewModel.java | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 0577111..c0208c3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -10,7 +10,7 @@ android { applicationId "com.zane.smapiinstaller" minSdkVersion 19 targetSdkVersion 28 - versionCode 15 + versionCode 16 versionName "1.3.2" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/com/zane/smapiinstaller/ui/config/ConfigViewModel.java b/app/src/main/java/com/zane/smapiinstaller/ui/config/ConfigViewModel.java index ba6ad19..efa07e2 100644 --- a/app/src/main/java/com/zane/smapiinstaller/ui/config/ConfigViewModel.java +++ b/app/src/main/java/com/zane/smapiinstaller/ui/config/ConfigViewModel.java @@ -7,6 +7,7 @@ import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import com.google.common.collect.Sets; import com.hjq.language.LanguagesManager; import com.zane.smapiinstaller.MainApplication; import com.zane.smapiinstaller.constant.AppConfigKey; @@ -52,7 +53,7 @@ class ConfigViewModel extends ViewModel { ).build(); List translationResults = query.list(); ImmutableMap translateMap = Maps.uniqueIndex(translationResults, TranslationResult::getOrigin); - List untranslatedText = Lists.newArrayList(Iterables.filter(Iterables.transform(modList, mod -> { + List untranslatedText = Lists.newArrayList(Sets.newHashSet(Iterables.filter(Iterables.transform(modList, mod -> { assert mod != null; if (translateMap.containsKey(mod.getDescription())) { mod.setTranslatedDescription(translateMap.get(mod.getDescription()).getTranslation()); @@ -60,7 +61,7 @@ class ConfigViewModel extends ViewModel { } else { return mod.getDescription(); } - }), item -> item != null)); + }), item -> item != null))); if (untranslatedText.size() > 0) { TranslateUtil.translateText(untranslatedText, translator, language, (results) -> { daoSession.getTranslationResultDao().insertOrReplaceInTx(results);