Skip to content

Commit

Permalink
clear recorder's WaveDrawable when record is deleted'
Browse files Browse the repository at this point in the history
  • Loading branch information
or-else committed Dec 22, 2022
1 parent 797d8fa commit fd7ce30
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app/src/main/java/co/tinode/tindroid/MessagesFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -690,7 +690,7 @@ public void onLongPress(@NonNull MotionEvent e) {

view.findViewById(R.id.deleteRecording).setOnClickListener(v -> {
WaveDrawable wd = (WaveDrawable) wave.getBackground();
wd.stop();
wd.release();
releaseAudio(false);
setSendPanelVisible(activity, R.id.sendMessagePanel);
});
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/co/tinode/tindroid/widgets/WaveDrawable.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ public void stop() {
unscheduleSelf(this);
}

// Stop playing and seek to zero.
public void reset() {
stop();
seekTo(0);
Expand All @@ -217,6 +218,18 @@ public void reset() {
}
}

// Stop playing and clear all accumulated data making it ready for reuse.
public void release() {
stop();
mSeekPosition = -1;
mDuration = 0;
mFrameDuration = 0;
mContains = 0;
mIndex = 0;
mBars = null;
mOriginal = null;
}

private void nextFrame() {
unscheduleSelf(this);
scheduleSelf(this, SystemClock.uptimeMillis() + mFrameDuration);
Expand Down

0 comments on commit fd7ce30

Please sign in to comment.