parse color in try/catch block

This commit is contained in:
tobiasKaminsky 2017-06-14 12:57:07 +02:00
parent 350d54f614
commit 9bdaf17b81
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
2 changed files with 6 additions and 4 deletions

View file

@ -778,8 +778,10 @@ public class ExtendedListFragment extends Fragment
getContext().getContentResolver());
OCCapability capability = storageManager.getCapability(account.name);
if (capability != null && !capability.getServerColor().isEmpty()) {
try {
primaryColor = Color.parseColor(capability.getServerColor());
} catch (Exception e) {
primaryColor = getResources().getColor(R.color.primary);
}
}

View file

@ -728,7 +728,7 @@ public class DisplayUtils {
public static String getDefaultDisplayNameForRootFolder() {
OCCapability capability = getCapability();
if (capability.getServerSlogan().isEmpty()) {
if (capability.getServerSlogan() == null || capability.getServerSlogan().isEmpty()) {
return MainApp.getAppContext().getResources().getString(R.string.default_display_name_for_root_folder);
} else {
return capability.getServerSlogan();
@ -769,9 +769,9 @@ public class DisplayUtils {
public static int primaryDarkColor() {
OCCapability capability = getCapability();
if (!capability.getServerColor().isEmpty()) {
try {
return adjustLightness(-0.2f, Color.parseColor(capability.getServerColor()));
} else {
} catch (Exception e) {
return MainApp.getAppContext().getResources().getColor(R.color.primary_dark);
}
}