Bez popisu

RNFetchBlobProgressConfig.java 1007B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package com.RNFetchBlob;
  2. /**
  3. * Created by wkh237 on 2016/9/24.
  4. */
  5. public class RNFetchBlobProgressConfig {
  6. public boolean shouldReport() {
  7. boolean checkCount = true;
  8. if(count > 0)
  9. checkCount = Math.floor(progress*100/count)> tick;
  10. return (lastTick - System.currentTimeMillis() > interval) && enable && checkCount;
  11. }
  12. public void tick(float progress) {
  13. this.progress = progress;
  14. this.tick ++;
  15. this.lastTick = System.currentTimeMillis();
  16. }
  17. public enum ReportType {
  18. Upload,
  19. Download
  20. };
  21. long lastTick = 0;
  22. float progress = 0;
  23. int tick = 0;
  24. int count = -1;
  25. public int interval = -1;
  26. public boolean enable = false;
  27. public ReportType type = ReportType.Download;
  28. RNFetchBlobProgressConfig(boolean report, int interval, int count, ReportType type) {
  29. this.enable = report;
  30. this.interval = interval;
  31. this.type = type;
  32. this.count = count;
  33. }
  34. }