implement actual pausing functionality

This commit is contained in:
tibbi 2020-11-05 18:40:50 +01:00
parent dab25b08b9
commit 47f68995b2
2 changed files with 14 additions and 2 deletions

View File

@ -74,7 +74,7 @@ class RecorderFragment(context: Context, attributeSet: AttributeSet) : MyViewPag
}
private fun getToggleButtonIcon(): Drawable {
val drawable = if (status == RECORDING_RUNNING) R.drawable.ic_stop_vector else R.drawable.ic_microphone_vector
val drawable = if (status == RECORDING_RUNNING || status == RECORDING_PAUSED) R.drawable.ic_stop_vector else R.drawable.ic_microphone_vector
return resources.getColoredDrawableWithColor(drawable, context.getFABIconColor())
}

View File

@ -147,8 +147,20 @@ class RecorderService : Service() {
amplitudeTimer.scheduleAtFixedRate(getAmplitudeUpdateTask(), 0, AMPLITUDE_UPDATE_MS)
}
@SuppressLint("NewApi")
private fun togglePause() {
try {
if (status == RECORDING_RUNNING) {
recorder?.pause()
status = RECORDING_PAUSED
} else if (status == RECORDING_PAUSED) {
recorder?.resume()
status = RECORDING_RUNNING
}
broadcastStatus()
} catch (e: Exception) {
showErrorToast(e)
}
}
@SuppressLint("InlinedApi")