Advertisement
swqzz

Untitled

Apr 23rd, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. package me.zeero.clientbase.utils;
  2.  
  3. public class TimeHelper2 {
  4.  
  5. private long lastMS = 0L;
  6. private long prevMS;
  7.  
  8. public TimeHelper2() {
  9. this.prevMS = 0L;
  10. }
  11.  
  12. public boolean isDelayComplete(long delay) {
  13. if(System.currentTimeMillis() - lastMS >= delay)
  14. return true;
  15.  
  16. return false;
  17. }
  18.  
  19. public long getCurrentMS() {
  20. return System.nanoTime() / 1000000L;
  21. }
  22.  
  23. public void setLastMS(long lastMS) {
  24. this.lastMS = System.currentTimeMillis();
  25. }
  26.  
  27. public void setLastMS() {
  28. this.lastMS = System.currentTimeMillis();
  29. }
  30.  
  31. public int convertToMS(int i) {
  32. return 1000 / i;
  33. }
  34.  
  35. public boolean hasReached(float f) {
  36. return (float) (getCurrentMS() - this.lastMS) >= f;
  37. }
  38.  
  39. public void reset() {
  40. this.lastMS = getCurrentMS();
  41. }
  42.  
  43. public boolean delay(long milliSec) {
  44. return (float) (getTime() - this.prevMS) >= milliSec;
  45. }
  46.  
  47. private long getTime() {
  48. return System.nanoTime() / 1000000L;
  49. }
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement