|
@@ -3,48 +3,22 @@ package com.miekir.newmvp.ui.home.article.presenter
|
|
|
import com.miekir.common.utils.LogTool
|
|
import com.miekir.common.utils.LogTool
|
|
|
import com.miekir.mvp.presenter.BasePresenterKt
|
|
import com.miekir.mvp.presenter.BasePresenterKt
|
|
|
import com.miekir.newmvp.ui.home.IArticleView
|
|
import com.miekir.newmvp.ui.home.IArticleView
|
|
|
-import com.rxjava.rxlife.life
|
|
|
|
|
-import io.reactivex.Observable
|
|
|
|
|
-import io.reactivex.ObservableEmitter
|
|
|
|
|
-import io.reactivex.ObservableOnSubscribe
|
|
|
|
|
-import io.reactivex.schedulers.Schedulers
|
|
|
|
|
|
|
+import kotlinx.coroutines.delay
|
|
|
|
|
|
|
|
class AutoPresenter<V : IArticleView> : BasePresenterKt<V>() {
|
|
class AutoPresenter<V : IArticleView> : BasePresenterKt<V>() {
|
|
|
-
|
|
|
|
|
- fun doWorkOld() {
|
|
|
|
|
- //showProgress();
|
|
|
|
|
- val disposable = Observable.create(ObservableOnSubscribe { emitter: ObservableEmitter<String?> ->
|
|
|
|
|
- try {
|
|
|
|
|
- Thread.sleep(5000)
|
|
|
|
|
- } catch (e: Exception) {
|
|
|
|
|
- e.printStackTrace()
|
|
|
|
|
- }
|
|
|
|
|
- emitter.onNext("")
|
|
|
|
|
- emitter.onComplete()
|
|
|
|
|
- } as ObservableOnSubscribe<String?>)
|
|
|
|
|
- .subscribeOn(Schedulers.io())
|
|
|
|
|
- .life(this)
|
|
|
|
|
- .subscribe({ next: String? ->
|
|
|
|
|
- LogTool.d("MainPresenter", "onNext thread is: " + Thread.currentThread().name)
|
|
|
|
|
- view?.onArticleResult("result from kotlin")
|
|
|
|
|
- //post(Consumer<IArticleView> { view: IArticleView -> view.onArticleResult("result") })
|
|
|
|
|
- }) { error: Throwable ->
|
|
|
|
|
- hideProgress()
|
|
|
|
|
- LogTool.d(javaClass.name, error.message)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- mBackDisposableList.add(disposable)
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
fun doWorkNew() {
|
|
fun doWorkNew() {
|
|
|
val job = launchProgressTask({
|
|
val job = launchProgressTask({
|
|
|
|
|
+ delay(10000)
|
|
|
//协程体
|
|
//协程体
|
|
|
|
|
+ LogTool.d("success")
|
|
|
|
|
+ view?.onArticleResult("success")
|
|
|
}, {
|
|
}, {
|
|
|
//异常回调
|
|
//异常回调
|
|
|
|
|
+ LogTool.d("exception")
|
|
|
})
|
|
})
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
override fun onInit() {
|
|
override fun onInit() {
|
|
|
-
|
|
|
|
|
|
|
+ LogTool.d("init")
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|