Skip to content

Commit

Permalink
* Implement audio playback animation in Note List
Browse files Browse the repository at this point in the history
* Fix bug: Save button is disabled when creating new memo with paste button and non-empty clipboard value until making changes to the content
  • Loading branch information
tuancoltech committed Aug 11, 2024
1 parent 8e40cb7 commit 0b0f6ff
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ class NotesListAdapter(

holder.btnPlayPause.setOnClickListener {
onPlayPauseClick(note.path.toString(), position) { stopPos ->
showPlayIcon(holder)
showPlaybackIdleState(holder)
(notes[position] as VoiceNote).isPlaying = false
notifyItemChanged(position)
}
Expand All @@ -83,9 +83,9 @@ class NotesListAdapter(
}

if (note.isPlaying) {
showPauseIcon(holder)
showPlayingState(holder)
} else {
showPlayIcon(holder)
showPlaybackIdleState(holder)
}

} else if (note is GraphicNote) {
Expand All @@ -108,36 +108,38 @@ class NotesListAdapter(
) {
when (effect) {
is ArkMediaPlayerSideEffect.StartPlaying -> {
showPauseIcon(holder)
showPlayingState(holder)
}
is ArkMediaPlayerSideEffect.PausePlaying -> {
showPlayIcon(holder)
showPlaybackIdleState(holder)
}
is ArkMediaPlayerSideEffect.StopPlaying -> {
showPlayIcon(holder)
showPlaybackIdleState(holder)
}
is ArkMediaPlayerSideEffect.ResumePlaying -> {
showPauseIcon(holder)
showPlayingState(holder)
}
}
}

private fun showPlayIcon(holder: NoteViewHolder) {
private fun showPlaybackIdleState(holder: NoteViewHolder) {
val playIcon = ResourcesCompat.getDrawable(
activity.resources,
R.drawable.ic_play_circle,
null
)
holder.btnPlayPause.setImageDrawable(playIcon)
holder.layoutAudioView.animAudioPlaying.pauseAnimation()
}

private fun showPauseIcon(holder: NoteViewHolder) {
private fun showPlayingState(holder: NoteViewHolder) {
val playIcon = ResourcesCompat.getDrawable(
activity.resources,
R.drawable.ic_pause_circle,
null
)
holder.btnPlayPause.setImageDrawable(playIcon)
holder.layoutAudioView.animAudioPlaying.playAnimation()
}

fun updateData(newNotes: List<Note>, fromSearch: Boolean? = null, keyword: String? = null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class EditTextNotesFragment: BaseEditNoteFragment() {
hostActivity.showProgressBar(show)
}
}
enableSaveText(false)
enableSaveText(noteStr?.isNotBlank() == true)

binding.tvPaste.setOnClickListener(pasteNoteClickListener)

Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout/media_player_view_v2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
android:layout_height="wrap_content"
android:background="@drawable/bg_audio_view"
android:paddingHorizontal="13dp"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
Expand Down

0 comments on commit 0b0f6ff

Please sign in to comment.