mirror of
				https://github.com/SimpleMobileTools/Simple-Clock.git
				synced 2025-06-05 22:19:17 +02:00 
			
		
		
		
	catch and show exceptions thrown at playing sounds
This commit is contained in:
		| @@ -11,6 +11,7 @@ import com.simplemobiletools.clock.activities.SimpleActivity | |||||||
| import com.simplemobiletools.clock.extensions.getAlarms | import com.simplemobiletools.clock.extensions.getAlarms | ||||||
| import com.simplemobiletools.clock.models.AlarmSound | import com.simplemobiletools.clock.models.AlarmSound | ||||||
| import com.simplemobiletools.commons.extensions.setupDialogStuff | import com.simplemobiletools.commons.extensions.setupDialogStuff | ||||||
|  | import com.simplemobiletools.commons.extensions.showErrorToast | ||||||
| import kotlinx.android.synthetic.main.dialog_select_alarm_sound.view.* | import kotlinx.android.synthetic.main.dialog_select_alarm_sound.view.* | ||||||
|  |  | ||||||
| class SelectAlarmSoundDialog(val activity: SimpleActivity, val currentUri: String, val audioStream: Int, val callback: (alarmSound: AlarmSound) -> Unit) { | class SelectAlarmSoundDialog(val activity: SimpleActivity, val currentUri: String, val audioStream: Int, val callback: (alarmSound: AlarmSound) -> Unit) { | ||||||
| @@ -26,6 +27,7 @@ class SelectAlarmSoundDialog(val activity: SimpleActivity, val currentUri: Strin | |||||||
|                     isChecked = alarmSound.uri == currentUri |                     isChecked = alarmSound.uri == currentUri | ||||||
|                     id = index |                     id = index | ||||||
|                     setOnClickListener { |                     setOnClickListener { | ||||||
|  |                         try { | ||||||
|                             mediaPlayer.stop() |                             mediaPlayer.stop() | ||||||
|                             mediaPlayer = MediaPlayer().apply { |                             mediaPlayer = MediaPlayer().apply { | ||||||
|                                 setAudioStreamType(audioStream) |                                 setAudioStreamType(audioStream) | ||||||
| @@ -33,6 +35,9 @@ class SelectAlarmSoundDialog(val activity: SimpleActivity, val currentUri: Strin | |||||||
|                                 prepare() |                                 prepare() | ||||||
|                                 start() |                                 start() | ||||||
|                             } |                             } | ||||||
|  |                         } catch (e: Exception) { | ||||||
|  |                             activity.showErrorToast(e) | ||||||
|  |                         } | ||||||
|                     } |                     } | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user