-
Notifications
You must be signed in to change notification settings - Fork 612
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d4ce3f0
commit 926c7d7
Showing
19 changed files
with
231 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
rxdownload3/src/main/java/zlc/season/rxdownload3/core/DownloadConfig.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package zlc.season.rxdownload3.core | ||
|
||
import android.os.Environment | ||
|
||
|
||
object DownloadConfig { | ||
var defaultSavePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).path | ||
var retryCount = 3 | ||
var threadCount = 3 | ||
var perSize: Int = 5 * 1024 //KB | ||
|
||
} |
8 changes: 0 additions & 8 deletions
8
rxdownload3/src/main/java/zlc/season/rxdownload3/core/DownloadCore.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
rxdownload3/src/main/java/zlc/season/rxdownload3/core/DownloadType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package zlc.season.rxdownload3.core | ||
|
||
import io.reactivex.Flowable | ||
|
||
|
||
interface DownloadType { | ||
fun download(): Flowable<DownloadStatus> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 26 additions & 6 deletions
32
rxdownload3/src/main/java/zlc/season/rxdownload3/core/MissionWrapper.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
rxdownload3/src/main/java/zlc/season/rxdownload3/core/NormalDownload.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package zlc.season.rxdownload3.core | ||
|
||
import io.reactivex.BackpressureStrategy | ||
import io.reactivex.Flowable | ||
import io.reactivex.FlowableEmitter | ||
import okhttp3.ResponseBody | ||
import retrofit2.Response | ||
import zlc.season.rxdownload3.http.HttpProcessor | ||
|
||
|
||
class NormalDownload(val missionWrapper: MissionWrapper) : DownloadType { | ||
|
||
override fun download(): Flowable<DownloadStatus> { | ||
return HttpProcessor.download(missionWrapper) | ||
.flatMap { resp -> | ||
|
||
Flowable.just(DownloadStatus(1)) | ||
} | ||
} | ||
|
||
fun saveFile(resp: Response<ResponseBody>): Flowable<DownloadStatus> { | ||
return Flowable.create({ emitter -> | ||
|
||
}, BackpressureStrategy.LATEST) | ||
} | ||
|
||
fun realSave(emitter: FlowableEmitter<DownloadStatus>, resp: Response<ResponseBody>) { | ||
|
||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
rxdownload3/src/main/java/zlc/season/rxdownload3/core/RangeDownload.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package zlc.season.rxdownload3.core | ||
|
||
import io.reactivex.Flowable | ||
|
||
|
||
class RangeDownload:DownloadType { | ||
override fun download(): Flowable<DownloadStatus> { | ||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
rxdownload3/src/main/java/zlc/season/rxdownload3/core/TargetFile.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,30 @@ | ||
package zlc.season.rxdownload3.core | ||
|
||
import io.reactivex.FlowableEmitter | ||
import okhttp3.ResponseBody | ||
import retrofit2.Response | ||
import java.io.File | ||
import java.io.InputStream | ||
import java.io.OutputStream | ||
|
||
|
||
class TargetFile { | ||
lateinit var file: File | ||
|
||
fun save(emitter: FlowableEmitter<DownloadStatus>, response: Response<ResponseBody>) { | ||
var fileInStream: InputStream | ||
var fileOutSteam: OutputStream | ||
|
||
val buffer: ByteArray = kotlin.ByteArray(8) | ||
|
||
|
||
val respBody = response.body() | ||
if (respBody == null) { | ||
emitter.onError(RuntimeException("body is null")) | ||
return | ||
} | ||
|
||
fileInStream = respBody.byteStream() | ||
|
||
} | ||
} |
Oops, something went wrong.