Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

some function update #102

Merged
merged 43 commits into from
Aug 22, 2023
Merged
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
a2ec375
exo+netspeed
watson1982 Aug 21, 2023
b0482f8
define netspeed
watson1982 Aug 21, 2023
452457f
AndroidMediaPlayer+netspeed
watson1982 Aug 21, 2023
59f6785
VodController+lock
watson1982 Aug 21, 2023
589c651
icon_lock.xml
watson1982 Aug 21, 2023
2381fa0
Update player_vod_control_view.xml
watson1982 Aug 21, 2023
a131e7a
RoomDataManger.java+del all
watson1982 Aug 21, 2023
59ded04
VodCollectDao.java+del all
watson1982 Aug 21, 2023
ac67c21
Update VodRecordDao.java+del all
watson1982 Aug 21, 2023
b2a10d8
CollectActivity+del all
watson1982 Aug 21, 2023
203e9c1
HistoryActivity+del all
watson1982 Aug 21, 2023
6c06a4d
ConfirmClearDialog.java
watson1982 Aug 21, 2023
8ff3d96
Update HawkConfig.java
watson1982 Aug 21, 2023
cd089bf
button_dialog_vod.xml
watson1982 Aug 21, 2023
6496025
icon_clear.xml
watson1982 Aug 21, 2023
1604ccb
Update activity_collect.xml
watson1982 Aug 21, 2023
e611418
Update activity_history.xml
watson1982 Aug 21, 2023
31d46f5
dialog_confirm.xml
watson1982 Aug 21, 2023
691f178
Update colors.xml
watson1982 Aug 21, 2023
722bad7
dialog_confirm.xml
watson1982 Aug 21, 2023
d09e459
HistoryAdapter
watson1982 Aug 21, 2023
4b5c5dd
HomeHotVodAdapter
watson1982 Aug 21, 2023
acc4b8e
item_grid.xml
watson1982 Aug 21, 2023
11203b0
item_user_hot_vod
watson1982 Aug 21, 2023
eb910de
shape_user_delete.xml
watson1982 Aug 21, 2023
835b682
Update colors.xml
watson1982 Aug 21, 2023
4bcd1b2
HomeActivity+del mode
watson1982 Aug 21, 2023
e379fda
Merge branch 'q215613905:main' into main
watson1982 Aug 21, 2023
5e62124
UserFragment+check del mode
watson1982 Aug 21, 2023
231af14
UserFragment.java
watson1982 Aug 21, 2023
61c486c
Merge branch 'q215613905:main' into main
watson1982 Aug 21, 2023
d4e034f
Update button_dialog_vod.xml
watson1982 Aug 21, 2023
c6c1499
Update dialog_confirm.xml
watson1982 Aug 21, 2023
5b7e302
Update colors.xml
watson1982 Aug 21, 2023
0b1acc6
UserFragment.java
watson1982 Aug 21, 2023
0027338
VodController.java
watson1982 Aug 21, 2023
c5fd9ce
ScreenUtils.java
watson1982 Aug 21, 2023
a7a5c46
HomeActivity.java
watson1982 Aug 21, 2023
0189e8e
Update HomeActivity.java
watson1982 Aug 21, 2023
583678b
VodController.java
watson1982 Aug 21, 2023
617a822
UserFragment.java
watson1982 Aug 21, 2023
746864c
icon_lock.xml
watson1982 Aug 21, 2023
6750427
icon_unlock.xml
watson1982 Aug 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
define netspeed
  • Loading branch information
watson1982 committed Aug 21, 2023
commit b0482f8aaeae38649d95533df413acbb406510bc
32 changes: 30 additions & 2 deletions player/src/main/java/xyz/doikki/videoplayer/util/PlayerUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import android.graphics.Point;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.net.TrafficStats;
import android.os.Build;
import android.telephony.TelephonyManager;
import android.util.TypedValue;
Expand All @@ -34,7 +35,8 @@
*/

public final class PlayerUtils {

private static long lastTotalRxBytes;
private static long lastTimeStamp;
private PlayerUtils() {
}

Expand Down Expand Up @@ -286,4 +288,30 @@ public static <T> List<T> getSnapshot(@NonNull Collection<T> other) {
}
return result;
}
}

public static long getNetSpeed(Context context) {
//这里的context是获取getApplicationContext的
if (context == null) {
return 0;
}
//先使用getUidRxBytes方法获取该进程总接收量,如果没获取到就把当前接收数据总量设置为0,否则就获取接收的总流量并转为kb
long nowTotalRxBytes = TrafficStats.getUidRxBytes(context.getApplicationInfo().uid) == TrafficStats.UNSUPPORTED ? 0 : (TrafficStats.getTotalRxBytes());//转为KB
//记录当前的时间
long nowTimeStamp = System.currentTimeMillis();
//上一次记录的时间-当前记录时间算出两次记录的时间差
long calculationTime = (nowTimeStamp - lastTimeStamp);
//如果时间差不变,直接返回0
if (calculationTime == 0) {
return calculationTime;
}

//两次的数据接收量的差除以两次数据接收的时间,就计算网速了。这边的时间差是毫秒,咱们需要转换成秒。
long speed = ((nowTotalRxBytes - lastTotalRxBytes) * 1000 / calculationTime);
//当前时间存到上次时间这个变量,供下次计算用
lastTimeStamp = nowTimeStamp;
//当前总接收量存到上次接收总量这个变量,供下次计算用
lastTotalRxBytes = nowTotalRxBytes;
return speed;
}

}