carlosmuvi / SegmentedProgressBar

Instagram like segmented progress bar for Android, written in Kotlin!
132 stars 24 forks source link

call event on complete segment #5

Closed meghaandroidwmt closed 4 years ago

meghaandroidwmt commented 7 years ago

hello...

actually i want to perfom action after complete 1 segment and also get event for all complete segment from one screen

private void initDrawingTimer() {
    drawingTimer = new DrawingTimer();

    drawingTimer.setListener(new DrawingTimer.Listener() {
        @Override
        public void onTick(int currentTicks, int totalTicks) {

            int segmentWidth = getSegmentWidth();
            currentSegmentProgressInPx = currentTicks * segmentWidth / totalTicks;
            if (totalTicks <= currentTicks) {
                lastCompletedSegment++;
                currentSegmentProgressInPx = 0;

            }
            invalidate();
        }
    });

I see in this condition i can write code for start next segment. for this i use eventbus and post event for start next segment in this condition. and also check if last completed segment and segment count equal that it means all segment of one screen are completed and in this condition post event for start next fragment .

if (totalTicks <= currentTicks) { lastCompletedSegment++; currentSegmentProgressInPx = 0; } but i found issue that this condition call not only one time but 2- 3 time .so my question is why its happen this condition becomes true means segment completed.but because 2-3 time this condition call - event also post for not one time and multiple time so any suggestion for manage it?

}