TextView stops updating after a while using hourglass tick function

67 views Asked by At

// After running for a few minutes the UI stop updating inside of the tick function. //This is update function of my text view in given below

private void timerGreen(final long time, long interval) {
        hourglassGreen = new Hourglass(time, interval) {
            @Override
            public void onTimerTick(long timeRemaining) {
                updateUIGreen(timeRemaining);
                if (soundrunning) {
                    soundTick = new SoundTick();
                    soundTick.playSound(MainActivity.this);
                }
               }

            @Override
            public void onTimerFinish() {

            }
        };

    }
// here it is my textview call in my function

private void updateUIGreen(long timeRemain) {
        greenTextView.setText(correctFormat(timeRemain));
    }

//here my correctFormat method public String correctFormat(long millisUntilFinished) {

    int minutes = (int) (millisUntilFinished / 1000) / 60;
    int secs = (int) (millisUntilFinished / 1000) % 60;
    return String.format(Locale.getDefault(), "%02d:%02d", minutes, secs);

    }
0

There are 0 answers