File tree Expand file tree Collapse file tree 2 files changed +14
-4
lines changed
app/src/main/java/tech/akpmakes/android/taskkeeper Expand file tree Collapse file tree 2 files changed +14
-4
lines changed Original file line number Diff line number Diff line change 44import android .content .Intent ;
55import android .os .Bundle ;
66import android .os .Handler ;
7+ import android .os .SystemClock ;
78import android .support .v7 .app .AppCompatActivity ;
89import android .view .Menu ;
910import android .view .MenuInflater ;
@@ -51,9 +52,9 @@ public void run() {
5152 if (useCurrentTime .isChecked ()) {
5253 updateTime ();
5354 }
54- handler .postDelayed ( this , 250 );
55+ handler .postDelayed ( this , delay () );
5556 }
56- }, 0 );
57+ }, delay () );
5758
5859 Intent i = getIntent ();
5960 if (i .hasExtra ("whenName" )) {
@@ -109,6 +110,10 @@ public void onClick(View view) {
109110 getWindow ().setSoftInputMode (WindowManager .LayoutParams .SOFT_INPUT_STATE_VISIBLE );
110111 }
111112
113+ private long delay () {
114+ return 1000 - (SystemClock .uptimeMillis () % 1000 );
115+ }
116+
112117 private void saveTask () {
113118 if (useCurrentTime .isChecked ()) {
114119 updateTime ();
Original file line number Diff line number Diff line change 11package tech .akpmakes .android .taskkeeper ;
22
33import android .os .Handler ;
4+ import android .os .SystemClock ;
45import android .support .v7 .widget .RecyclerView ;
56import android .view .View ;
67import android .widget .TextView ;
@@ -22,9 +23,9 @@ public WhenEventViewHolder(View v) {
2223 @ Override
2324 public void run () {
2425 draw ();
25- handler .postDelayed ( this , 1000 );
26+ handler .postDelayed ( this , delay () );
2627 }
27- }, 1000 );
28+ }, delay () );
2829 v .setOnClickListener (new View .OnClickListener () {
2930 @ Override
3031 public void onClick (View view ) {
@@ -40,6 +41,10 @@ public boolean onLongClick(View view) {
4041 });
4142 }
4243
44+ private long delay () {
45+ return 1000 - (SystemClock .uptimeMillis () % 1000 );
46+ }
47+
4348 private void draw () {
4449 String extra = "" ;
4550 if (this .when > new Date ().getTime ()) {
You can’t perform that action at this time.
0 commit comments