circle-time-view icon indicating copy to clipboard operation
circle-time-view copied to clipboard

Timer Values from Server

Open kaplanerkan opened this issue 8 years ago • 9 comments

Hi, first thanks for your super library. Is it possible, that the timer becomes his values from a broadcast-service?

Also an extern broadcast service send to your time the values (as long ) and your timer show the values.

Or can you programing your library with a broadcast service, Timer must run if user kill the app, timer must run always until onTimeStop or manuelly cancel the timer.

Thanks

kaplanerkan avatar Sep 22 '17 08:09 kaplanerkan

@kaplanerkan Thank you for your question.

I would strongly suggest you not to mix the Infrastructure layer with the Presentation layer. This library is intended to be used just a like a simple, dull view that can display time according provided settings.

In case you need to set values from a broadcast service. Personally I would follow the next way.

  1. You have a broadcast service defined somewhere. It is running in background.
  2. In your application you should probably define a listener for incoming events from the broadcast service. I would place this logic in the Infrastructure Layer and define an interface in the Domain layer.
  3. In case of a series of events, you could use RxJava to emit this event to subscribers,
  4. As for killing the app. This should not be a problem. You can just send sticky events using the
    https://developer.android.com/reference/android/content/Context.html#sendStickyBroadcast(android.content.Intent) method.
  5. Also do not run the timer internally defined in the CircleTimeView. Just set the time manually when you get it from the broadcast service.

I hope this will help you. If you have any other questions. Please comment belowe

CROSP avatar Sep 22 '17 09:09 CROSP

Hello Crosp,

i have a broadcast service for countdown in my app and show the results in a TEXTVIEW. If my user kill the app, timer run always until timer on stop....

I thought, i can send and set my values into your library.

PS: Your desing very very good, i like it.:-)

kaplanerkan avatar Sep 22 '17 09:09 kaplanerkan

https://i.imgur.com/TFQGXCq.png

kaplanerkan avatar Sep 22 '17 09:09 kaplanerkan

Crosp, how can i change your lib or how can i set a SETTEXT on the timer value? If you can say me, may be i can set the the timer values manuely?

kaplanerkan avatar Sep 22 '17 10:09 kaplanerkan

@kaplanerkan You can always use the setCurrentTime method that accepts time in seconds. Or you can call another method setCurrentTime(long time, @TimeFormat int timeFormat) that also accepts a time format Seconds/Minutes or Minutes/Hours.

CROSP avatar Sep 22 '17 11:09 CROSP

@kaplanerkan but time should be always provided in seconds.

CROSP avatar Sep 22 '17 11:09 CROSP

@kaplanerkan I have update my readme file. Thanks.

CROSP avatar Sep 22 '17 11:09 CROSP

super thanks ..:-)

=========== int count = 300; circleTimeView.setCurrentTime(300);

CountDownTimer timer; timer = new CountDownTimer(60000, 1000) { // Update value for 1min, every 1 sec @Override public void onTick(long millisUntilFinished) { circleTimeView.setCurrentTime(count - 1); count = count -1; }

        @Override
        public void onFinish() {

        }
    }.start();

kaplanerkan avatar Sep 22 '17 12:09 kaplanerkan

@kaplanerkan you are always welcome !!

CROSP avatar Sep 22 '17 13:09 CROSP