Skip to content

Commit

Permalink
下载大文件崩溃
Browse files Browse the repository at this point in the history
  • Loading branch information
liangjingkanji committed Jul 2, 2023
1 parent 8856207 commit 98dac53
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.drake.net.sample.ui.fragment

import android.annotation.SuppressLint
import android.util.Log
import android.view.Menu
import android.view.MenuInflater
import android.view.MenuItem
Expand All @@ -25,7 +26,7 @@ class DownloadFileFragment :
setHasOptionsMenu(true)
downloadScope = scopeNetLife {
val file =
Get<File>("https://dl.coolapk.com/down?pn=com.coolapk.market&id=NDU5OQ&h=46bb9d98&from=from-web") {
Get<File>("https://r3---sn-i3b7knld.gvt1.com/edgedl/android/studio/install/2022.2.1.20/android-studio-2022.2.1.20-mac_arm.dmg?mh=fu&pl=22&shardbypass=sd&redirect_counter=1&cm2rm=sn-bavcx-hoael7s&req_id=6e6ac2d1c6f9032b&cms_redirect=yes&mip=180.190.115.150&mm=42&mn=sn-i3b7knld&ms=onc&mt=1685464123&mv=m&mvi=3&rmhost=r1---sn-i3b7knld.gvt1.com&smhost=r3---sn-i3b7kn6s.gvt1.com") {
setDownloadFileName("net.apk")
setDownloadDir(requireContext().filesDir)
setDownloadMd5Verify()
Expand All @@ -44,6 +45,8 @@ class DownloadFileFragment :
})
}.await()

Log.d("日志", "(DownloadFileFragment.kt:47) 下载完毕 = ${file.absoluteFile}")

// 下载完成才会执行此处(所有网络请求使用await都会等待请求完成), 只是监听文件下载完成请不要使用[addDownloadListener]
}
}
Expand Down
2 changes: 1 addition & 1 deletion sample/src/main/res/navigation/nav_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main"
app:startDestination="@id/request_method">
app:startDestination="@id/download_file">

<fragment
android:id="@+id/async_task"
Expand Down

0 comments on commit 98dac53

Please sign in to comment.