Skip to content

Instantly share code, notes, and snippets.

@aragaer
Created June 4, 2012 04:00
Show Gist options
  • Select an option

  • Save aragaer/2866249 to your computer and use it in GitHub Desktop.

Select an option

Save aragaer/2866249 to your computer and use it in GitHub Desktop.
long passed, next;
/* adjust the transition */
do {
passed = System.currentTimeMillis() - sync;
Log.d(TAG, "Adjust at "+l2s(passed+sync)+", sync was at "+l2s(sync)+" "+passed+"ms passed");
if (tr.isEmpty()) {
/* request more items */
exhausted();
if (tr.isEmpty()) {
Log.d(TAG, "no transitions");
return;
}
passed = System.currentTimeMillis() - sync;
}
next = tr.get(0);
Log.d(TAG, "next would be in "+next+"ms at "+l2s(sync+next));
if (passed > next) {
/* we can now ignore previous tick/sub values
* we will notify about transition anyway
* this allows us to simply move sync time
*/
sync += next;
tr0 = sync;
tr.remove();
tr_changed = true;
}
} while (passed > next);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment