tanoDxyz / GDownload

Light Weight, Fast 🚀 , Easy to Use, Reliable Download client for android.
Apache License 2.0
39 stars 2 forks source link

please help me。Group Download dont work #27

Open HeQuanLi opened 1 week ago

HeQuanLi commented 1 week ago

In Fragment :


GDownload.init(lifecycle)

 val ctx = context ?: return
        val downloadList = mutableListOf<Download>()
        downloadList.add(
            Download(
                System.nanoTime(),
                "https://cdn.llscdn.com/yy/files/xs8qmxn8-lls-LLS-5.8-800-20171207-111607.apk",
                "15.jpg"
            )
        )
        downloadList.add(
            Download(
                System.nanoTime(),
                "https://cdn.llscdn.com/yy/files/xs8qmxn8-lls-LLS-5.8-800-20171207-111607.apk",
                "151.jpg"
            )
        )
        downloadList.add(
            Download(
                System.nanoTime(),
                "https://cdn.llscdn.com/yy/files/xs8qmxn8-lls-LLS-5.8-800-20171207-111607.apk",
                "152.jpg"
            )
        )
        downloadList.add(
            Download(
                System.nanoTime(),
                "https://cdn.llscdn.com/yy/files/xs8qmxn8-lls-LLS-5.8-800-20171207-111607.apk",
                "5MB.mp4"
            )
        )

        GDownload.freeGroup(ctx) {
            groupLoopTimeMilliSecs = 5_00
            getGroup()?.apply {
                start() // start group thread. as group has it's dedicated thread
                addAll(downloadList) { // enqueue downloads in the group but don't issue the start command
                    startDownloads(it) // start group downloads
                }
                addGroupProgressListener(object : GroupListener {
                    override fun onAdded(
                        groupId: Long,
                        download: DownloadInfo,
                        groupState: GroupState
                    ) {
                        super.onAdded(groupId, download, groupState)
                        Log.d("TAG_HQL", "onAdded: ")
                    }

                    override fun onDownloading(
                        groupId: Long,
                        download: DownloadInfo,
                        groupState: GroupState
                    ) {
                        super.onDownloading(groupId, download, groupState)
                        Log.d("TAG_HQL", "onDownloading: ")
                    }

                    override fun onEnqueued(
                        groupId: Long,
                        download: DownloadInfo,
                        groupState: GroupState
                    ) {
                        super.onEnqueued(groupId, download, groupState)
                        Log.d("TAG_HQL", "onEnqueued: ")
                    }

                    override fun onFailure(
                        groupId: Long,
                        errorMessage: String?,
                        download: DownloadInfo,
                        groupState: GroupState
                    ) {
                        super.onFailure(groupId, errorMessage, download, groupState)
                        Log.d("TAG_HQL", "onFailure: ")
                    }

                    override fun onPaused(
                        groupId: Long,
                        download: DownloadInfo,
                        groupState: GroupState
                    ) {
                        super.onPaused(groupId, download, groupState)
                        Log.d("TAG_HQL", "onPaused: ")
                    }

                    override fun onStarting(
                        groupId: Long,
                        download: DownloadInfo,
                        groupState: GroupState
                    ) {
                        super.onStarting(groupId, download, groupState)
                        Log.d("TAG_HQL", "onStarting: ")
                    }

                    override fun onStopped(
                        groupId: Long,
                        download: DownloadInfo,
                        groupState: GroupState
                    ) {
                        super.onStopped(groupId, download, groupState)
                        Log.d("TAG_HQL", "onStopped: ")
                    }

                    override fun onSuccess(
                        groupId: Long,
                        download: DownloadInfo,
                        groupState: GroupState
                    ) {
                        super.onSuccess(groupId, download, groupState)
                        Log.d("TAG_HQL", "onSuccess: ")
                    }

                    override fun onWaitingForTurn(
                        groupId: Long,
                        download: DownloadInfo,
                        groupState: GroupState
                    ) {
                        super.onWaitingForTurn(groupId, download, groupState)
                        Log.d("TAG_HQL", "onWaitingForTurn: ")
                    }
                })
            }

this code dont work.

tanoDxyz commented 23 hours ago

Will look into it shortly