Skip to content

Commit

Permalink
coding
Browse files Browse the repository at this point in the history
  • Loading branch information
HuanTanSheng committed Sep 19, 2018
1 parent fd77607 commit 03921b6
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 24 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package com.huantansheng.jandroid.sample.net


import com.huantansheng.jandroid.base.BaseApplication
import com.huantansheng.jandroid.dialog.SimpleLoadingDialog


object NetLoadingDialog {
private var dialog: SimpleLoadingDialog? = null


fun show() {
if (dialog == null)
dialog = SimpleLoadingDialog(BaseApplication.instance.applicationContext)

dialog?.show()

}

fun cancel() {
dialog?.dismiss()
}
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package com.huantansheng.jandroid.sample.net

import android.content.Context
import io.reactivex.FlowableSubscriber
import org.reactivestreams.Subscription
import java.net.ConnectException
import java.net.SocketTimeoutException
import java.net.UnknownHostException

abstract class RequestCallback<T>(private val context: Context) : FlowableSubscriber<ResponseWrapper<T>> {
abstract class RequestCallback<T> : FlowableSubscriber<ResponseWrapper<T>> {

abstract fun success(data: T)
abstract fun failure(statusCode: Int, message: String)
Expand All @@ -17,7 +16,7 @@ abstract class RequestCallback<T>(private val context: Context) : FlowableSubscr
}

override fun onSubscribe(s: Subscription) {
LoadingDialog.show(context)
NetLoadingDialog.show()
}

override fun onNext(t: ResponseWrapper<T>) {
Expand All @@ -30,11 +29,11 @@ abstract class RequestCallback<T>(private val context: Context) : FlowableSubscr
}

override fun onComplete() {
LoadingDialog.cancel()
NetLoadingDialog.cancel()
}

override fun onError(e: Throwable) {
LoadingDialog.cancel()
NetLoadingDialog.cancel()
val msg: String = when (e) {
is UnknownHostException -> "网络错误"
is ConnectException -> "网络错误"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.huantansheng.jandroid.dialog
import com.huantansheng.jandroid.R
import com.othershe.nicedialog.NiceDialog

object JDialog {
object JDialogFragment {
fun getLoadingDialog(): NiceDialog {

return NiceDialog.init()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package com.huantansheng.jandroid.dialog

import android.app.Dialog
import android.content.Context
import com.huantansheng.jandroid.R

class SimpleLoadingDialog(context: Context) : Dialog(context) {

init {
this.setContentView(R.layout.j_dialog_loading)
}


}

0 comments on commit 03921b6

Please sign in to comment.