Skip to content

Any idea how to create an elegant ripple effect for audio recording button - as in Google Keep #13

Description

@yccheok

Thank you for creating VoiceRipple library.

Google Keep's audio recording dialog, as a nice ripple effect around the recording button, when you perform voice recording.

https://i.stack.imgur.com/032Ly.png

I was wondering, what is the right way to implement such elegant ripple effect.

When I test run the demo, I found it isn't as smooth, and as elegant as Google Keep's

The technique, which the library is using, is doing a 50ms delayed busy looping call - https://github.com/wotomas/VoiceRipple/blob/master/ripplelibrary/src/main/java/info/kimjihyok/ripplelibrary/VoiceRippleView.java#L334

private Runnable updateRipple = new Runnable() {
    @Override
    public void run() {
        if (isRecording) {
            drop(recorder.getMaxAmplitude());
            currentRecordedTime = currentRecordedTime + 50;
            if (currentRenderer instanceof TimerCircleRippleRenderer) {
                ((TimerCircleRippleRenderer)currentRenderer).setCurrentTimeMilliseconds(currentRecordedTime);
            }
            handler.postDelayed(this, 50);  // updates the visualizer every 50 milliseconds
        }
    }
};

That doesn't sound like an optimal solution to me. Not only the effect is not elegant, it consumes a lot of battery/cpu resource.

Do you have any idea, what is a proper way, to achieve such elegant ripple effect?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions