How can I cancel the DelayedConfirmationView?

As with the standard Android Wear UI, I'm trying to reverse the confirmation animation to DelayedConfirmationView

when the user clicks on it again before the timer ends. However, there is only a method start()

that is reflected in the API link (downloadable here ).

I tried a workaround, setting setTotalTimeMs()

to 0 on canceling, which ends the animation immediately, but now the border of whole circles is displayed forever! There is no method setCircleBorderWidth()

through which I can reduce the border to 0, even if there is a corresponding xml declaration app:circle_border_width

. The method setProgress()

in the superclass CircleImageView does nothing either.

Has anyone found a way to reverse the confirmation animation directly, or at least a workaround that sets the button to its original state (no border)?

+3


source to share


3 answers


For completeness (albeit partial, because the circle around the button is still holding until you inflate the view), I am posting the code I had to use to stop the counter without triggering the action .



@Override
public void onTimerSelected(View view) {
    if(mRunning) {
        mRunning = false;
        delayedConfirmationView.setTotalTimeMs(0);
    } else {
        view.setPressed(true);
        mRunning = true;
        delayedConfirmationView.start();
    }
}

@Override
public void onTimerFinished(View view) {
    view.setPressed(false);
    if (mRunning) {
        mRunning = false;
        performAction();
    } else {
        delayedConfirmationView.setTotalTimeMs(CONFIRMATION_TIME);
    }
}

      

+1


source


DelayedConfirmationView.reset()

performs the task.



You just need to keep track of the status of the work, similar to what was done in the other answer.

+1


source


Google in its example just uses

mDelayedView.setListener (null);

private DelayedConfirmationView mDelayedView;
...
mDelayedView = (DelayedConfirmationView) stub.findViewById(R.id.act_main__delayed_confirm);
...
private DelayedConfirmationView.DelayedConfirmationListener mDelayedViewListener =  new DelayedConfirmationView.DelayedConfirmationListener()
{
    @Override
    public void onTimerFinished(View view)
    {
        Log.d(LOG_TAG, "onTimerFinished() : Time out launching reboot");

        // User did not cancel, let go
        ...
    }

    @Override
    public void onTimerSelected(View parView)
    {
        // User canceled, abort the action

        // Prevent onTimerFinished from being heard.
        mDelayedView.setListener(null);
        ...
    }
};

      

0


source







All Articles