Home » Android » java – the ticker is not starting again on finish of timer-Exceptionshub

java – the ticker is not starting again on finish of timer-Exceptionshub

Posted by: admin February 26, 2020 Leave a comment

Questions:

OnCreate Method

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_playing);



    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    circularViewWithTimer = findViewById(R.id.circular_view);
    CircularView.OptionsBuilder builderWithTimer =
            new CircularView.OptionsBuilder()
                    .shouldDisplayText(true)
                    .setCounterInSeconds(30)
                    .setCircularViewCallback(new CircularViewCallback() {
                        @Override
                        public void onTimerFinish() {


                            resetTimer();
                            showQuestion(++index);


                        }

                        @Override
                        public void onTimerCancelled() {



                        }
                    });
    circularViewWithTimer.setOptions(builderWithTimer);

    txtScore = findViewById(R.id.txtScore);
    txtQuestionNum = findViewById(R.id.txtTotalQuestion);
    question_text = findViewById(R.id.question_text);
    question_image = findViewById(R.id.question_image);

    progressBar = findViewById(R.id.progressBar);

    btnA = findViewById(R.id.btnAnswerA);
    btnB = findViewById(R.id.btnAnswerB);
    btnC = findViewById(R.id.btnAnswerC);
    btnD = findViewById(R.id.btnAnswerD);

    btnA.setOnClickListener(this);
    btnB.setOnClickListener(this);
    btnC.setOnClickListener(this);
    btnD.setOnClickListener(this);

}

ResetTimer Method

private void resetTimer() {
    CircularView.OptionsBuilder builderWithTimer =
            new CircularView.OptionsBuilder()
                    .shouldDisplayText(true)
                    .setCounterInSeconds(30)
                    .setCircularViewCallback(new CircularViewCallback() {
                        @Override
                        public void onTimerFinish() {

                        }

                        @Override
                        public void onTimerCancelled() {


                        }
                    });

    circularViewWithTimer.setOptions(builderWithTimer);
}    

The timer is not starting again on the finish
I have tried the above code

How to&Answers: