add a null check to settings ringtone name

This commit is contained in:
tibbi 2017-01-10 20:13:31 +01:00
parent aa827fe2a3
commit 1f6fbda451
1 changed files with 3 additions and 2 deletions

View File

@ -58,10 +58,11 @@ class SettingsActivity : SimpleActivity() {
} }
private fun setupReminderSound() { private fun setupReminderSound() {
val noRingtone = resources.getString(R.string.no_ringtone_selected)
if (config.reminderSound.isEmpty()) { if (config.reminderSound.isEmpty()) {
settings_reminder_sound.text = resources.getString(R.string.no_ringtone_selected) settings_reminder_sound.text = noRingtone
} else { } else {
settings_reminder_sound.text = RingtoneManager.getRingtone(this, Uri.parse(config.reminderSound)).getTitle(this) settings_reminder_sound.text = RingtoneManager.getRingtone(this, Uri.parse(config.reminderSound))?.getTitle(this) ?: noRingtone
} }
settings_reminder_sound_holder.setOnClickListener { settings_reminder_sound_holder.setOnClickListener {
Intent(RingtoneManager.ACTION_RINGTONE_PICKER).apply { Intent(RingtoneManager.ACTION_RINGTONE_PICKER).apply {