pull/586/head
FongMi 1 year ago
parent 032d006262
commit 5319731c3d
  1. 2
      app/src/main/java/com/fongmi/android/tv/Constant.java
  2. 6
      app/src/main/java/com/fongmi/android/tv/utils/Traffic.java

@ -6,7 +6,7 @@ public class Constant {
//控件隱藏時間
public static final int INTERVAL_HIDE = 5 * 1000;
//網路偵測間隔
public static final int INTERVAL_TRAFFIC = 1000;
public static final int INTERVAL_TRAFFIC = 500;
//點播爬蟲時間
public static final int TIMEOUT_VOD = 30 * 1000;
//直播爬蟲時間

@ -13,8 +13,8 @@ public class Traffic {
private static final DecimalFormat format = new DecimalFormat("#.0");
private static final String UNIT_KB = " KB/s";
private static final String UNIT_MB = " MB/s";
private static long lastTotalRxBytes = 0;
private static long lastTimeStamp = 0;
private static long lastTotalRxBytes;
private static long lastTimeStamp;
public static void setSpeed(TextView view) {
if (unsupported()) return;
@ -27,8 +27,8 @@ public class Traffic {
}
private static String getSpeed() {
long nowTotalRxBytes = TrafficStats.getTotalRxBytes() / 1024;
long nowTimeStamp = System.currentTimeMillis();
long nowTotalRxBytes = TrafficStats.getTotalRxBytes() / 1024;
long speed = (nowTotalRxBytes - lastTotalRxBytes) * 1000 / Math.max(nowTimeStamp - lastTimeStamp, 1);
lastTimeStamp = nowTimeStamp;
lastTotalRxBytes = nowTotalRxBytes;

Loading…
Cancel
Save