circle-time-view
circle-time-view copied to clipboard
Timer Values from Server
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 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.
- You have a broadcast service defined somewhere. It is running in background.
- 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.
- In case of a series of events, you could use RxJava to emit this event to subscribers,
- 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. - 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
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.:-)
https://i.imgur.com/TFQGXCq.png
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 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.
@kaplanerkan but time should be always provided in seconds.
@kaplanerkan I have update my readme file. Thanks.
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 you are always welcome !!