Fix some crashes

This commit is contained in:
Thomas 2020-10-17 10:52:56 +02:00
parent 017bd5a6a2
commit ea102eb485
1 changed files with 8 additions and 4 deletions

View File

@ -182,7 +182,11 @@ public class SepiaSearchActivity extends AppCompatActivity {
LinkedHashMap<Integer, String> categories = new LinkedHashMap<>(peertubeInformation.getCategories()); LinkedHashMap<Integer, String> categories = new LinkedHashMap<>(peertubeInformation.getCategories());
LinkedHashMap<Integer, String> licences = new LinkedHashMap<>(peertubeInformation.getLicences()); LinkedHashMap<Integer, String> licences = new LinkedHashMap<>(peertubeInformation.getLicences());
LinkedHashMap<String, String> languages = new LinkedHashMap<>(peertubeInformation.getLanguages()); LinkedHashMap<String, String> languages = new LinkedHashMap<>(peertubeInformation.getLanguages());
LinkedHashMap<String, String> translations = new LinkedHashMap<>(peertubeInformation.getTranslations()); LinkedHashMap<String, String> translations = null;
if( peertubeInformation.getTranslations() != null) {
translations = new LinkedHashMap<>(peertubeInformation.getTranslations());
}
//Populate catgories //Populate catgories
String[] categoriesA = new String[categories.size()+1]; String[] categoriesA = new String[categories.size()+1];
@ -191,7 +195,7 @@ public class SepiaSearchActivity extends AppCompatActivity {
int i = 1; int i = 1;
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry<Integer, String> pair = it.next(); Map.Entry<Integer, String> pair = it.next();
if (translations.size() == 0 || !translations.containsKey(pair.getValue())) if (translations == null || translations.size() == 0 || !translations.containsKey(pair.getValue()))
categoriesA[i] = pair.getValue(); categoriesA[i] = pair.getValue();
else else
categoriesA[i] = translations.get(pair.getValue()); categoriesA[i] = translations.get(pair.getValue());
@ -210,7 +214,7 @@ public class SepiaSearchActivity extends AppCompatActivity {
i = 1; i = 1;
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry<Integer, String> pair = it.next(); Map.Entry<Integer, String> pair = it.next();
if (translations.size() == 0 || !translations.containsKey(pair.getValue())) if (translations == null || translations.size() == 0 || !translations.containsKey(pair.getValue()))
licensesA[i] = pair.getValue(); licensesA[i] = pair.getValue();
else else
licensesA[i] = translations.get(pair.getValue()); licensesA[i] = translations.get(pair.getValue());
@ -228,7 +232,7 @@ public class SepiaSearchActivity extends AppCompatActivity {
i = 1; i = 1;
while (itl.hasNext()) { while (itl.hasNext()) {
Map.Entry<String, String> pair = itl.next(); Map.Entry<String, String> pair = itl.next();
if (translations.size() == 0 || !translations.containsKey(pair.getValue())) if (translations == null || translations.size() == 0 || !translations.containsKey(pair.getValue()))
languagesA[i] = pair.getValue(); languagesA[i] = pair.getValue();
else else
languagesA[i] = translations.get(pair.getValue()); languagesA[i] = translations.get(pair.getValue());