File tree Expand file tree Collapse file tree
FlowHttp/src/main/java/com/bhm/network/core/callback
app/src/main/java/com/bhm/sdk/demo/activity Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ package com.bhm.network.core.callback
77/* * 事件执行的回调
88 * Created by bhm on 2023/5/6.
99 */
10- open class CommonCallBack <T >(override var code : Int ) : SpecifiedTimeoutCallBack<T>() {
10+ open class CommonCallBack <T >() : SpecifiedTimeoutCallBack<T>() {
1111
1212 private var _start : (() -> Unit )? = null
1313
@@ -17,6 +17,8 @@ open class CommonCallBack<T>(override var code: Int) : SpecifiedTimeoutCallBack<
1717
1818 private var _complete : (() -> Unit )? = null
1919
20+ override var code: Int = 0
21+
2022 fun start (value : () -> Unit ) {
2123 _start = value
2224 }
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ package com.bhm.network.core.callback
77/* * 事件执行的回调
88 * Created by bhm on 2023/5/6.
99 */
10- open class DownloadCallBack (override var code : Int ) : ProgressCallBack<Any>() {
10+ open class DownloadCallBack () : ProgressCallBack<Any>() {
1111
1212 private var _start : (() -> Unit )? = null
1313
@@ -19,6 +19,8 @@ open class DownloadCallBack(override var code: Int) : ProgressCallBack<Any>() {
1919
2020 private var _complete : (() -> Unit )? = null
2121
22+ override var code: Int = 0
23+
2224 fun start (value : () -> Unit ) {
2325 _start = value
2426 }
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ package com.bhm.network.core.callback
44/* * 事件执行的回调
55 * Created by bhm on 2023/5/6.
66 */
7- open class UploadCallBack <T >(override var code : Int ) : ProgressCallBack<T>() {
7+ open class UploadCallBack <T >() : ProgressCallBack<T>() {
88
99 private var _start : (() -> Unit )? = null
1010
@@ -16,6 +16,8 @@ open class UploadCallBack<T>(override var code: Int) : ProgressCallBack<T>() {
1616
1717 private var _complete : (() -> Unit )? = null
1818
19+ override var code: Int = 0
20+
1921 fun start (value : () -> Unit ) {
2022 _start = value
2123 }
Original file line number Diff line number Diff line change @@ -174,10 +174,10 @@ open class MainActivity : FragmentActivity() {
174174 // 可以继承CommonCallBack,重写方法,比如在onFail中处理401,404等
175175 success { response ->
176176 Log .e(javaClass.name, response.date? : " " )
177- Toast .makeText(this @MainActivity, response.date, Toast .LENGTH_SHORT ).show()
177+ Toast .makeText(this @MainActivity, response.date + code , Toast .LENGTH_SHORT ).show()
178178 }
179179 fail { e ->
180- Toast .makeText(this @MainActivity, e?.message, Toast .LENGTH_SHORT ).show()
180+ Toast .makeText(this @MainActivity, e?.message + code , Toast .LENGTH_SHORT ).show()
181181 }
182182 }
183183 )
@@ -225,15 +225,15 @@ open class MainActivity : FragmentActivity() {
225225 {
226226 success { response ->
227227 Log .i(javaClass.name, response.toString())
228- Toast .makeText(this @MainActivity, response.data?.key, Toast .LENGTH_SHORT ).show()
228+ Toast .makeText(this @MainActivity, response.data?.key + code , Toast .LENGTH_SHORT ).show()
229229 }
230230 fail { e ->
231231 AlertDialog .Builder (this @MainActivity)
232232 .setMessage(e?.message)
233233 .setNegativeButton(" 确定" ) { dialog, _ -> dialog.dismiss() }.show()
234234 }
235235 specifiedTimeout {
236- Log .i(javaClass.name, " 请求超过0.5s还没有完成" )
236+ Log .i(javaClass.name, " 请求超过0.5s还没有完成${code} " )
237237 }
238238 }
239239 )
You can’t perform that action at this time.
0 commit comments