Commit 331223d6 authored by jyx's avatar jyx

代码优化

parent 9c1ee8d2
...@@ -3,25 +3,24 @@ package com.duben.roseplaylet.mvp.presenters ...@@ -3,25 +3,24 @@ package com.duben.roseplaylet.mvp.presenters
import com.duben.library.net.neterror.BaseSubscriber import com.duben.library.net.neterror.BaseSubscriber
import com.duben.library.net.neterror.Throwable import com.duben.library.net.neterror.Throwable
import com.duben.roseplaylet.manager.AppHttpManager import com.duben.roseplaylet.manager.AppHttpManager
import com.duben.roseplaylet.mvp.model.BaseResponse import com.duben.roseplaylet.mvp.model.*
import com.duben.roseplaylet.mvp.model.NineListBean import com.duben.roseplaylet.mvp.views.UserProfileView
import com.duben.roseplaylet.mvp.model.UserProfileDataBean import com.google.gson.JsonObject
import com.duben.roseplaylet.mvp.views.UserInfoView
class UserInfoPresenter : BasePresenter<UserInfoView>() { class UserProfilePresenter : BasePresenter<UserProfileView>() {
fun getMorePage(toUid: String) { fun getMorePage(toUid: String) {
val vo = hashMapOf<String, Any>() val vo = hashMapOf<String, Any>()
vo["toUid"] = toUid vo["toUid"] = toUid
AppHttpManager.getInstance(loanApplication) AppHttpManager.getInstance(loanApplication)
.call(loanService.getMorePage(vo), .call(loanService.getMorePage(vo),
object : BaseSubscriber<BaseResponse<UserProfileDataBean>>() { object : BaseSubscriber<BaseResponse<UserProfileData>>() {
override fun onCompleted() { override fun onCompleted() {
if (isLinkView) return if (isLinkView) return
view.hideLoading() view.hideLoading()
} }
override fun onNext(baseResponse: BaseResponse<UserProfileDataBean>) { override fun onNext(baseResponse: BaseResponse<UserProfileData>) {
if (isLinkView) return if (isLinkView) return
view.hideLoading() view.hideLoading()
...@@ -50,14 +49,14 @@ class UserInfoPresenter : BasePresenter<UserInfoView>() { ...@@ -50,14 +49,14 @@ class UserInfoPresenter : BasePresenter<UserInfoView>() {
val vo = hashMapOf<String, Any>() val vo = hashMapOf<String, Any>()
vo["toUid"] = toUid vo["toUid"] = toUid
AppHttpManager.getInstance(loanApplication) AppHttpManager.getInstance(loanApplication)
.call(loanService.getMorePage(vo), .call(loanService.seeWechat(vo),
object : BaseSubscriber<BaseResponse<NineListBean>>() { object : BaseSubscriber<BaseResponse<SeeWechat>>() {
override fun onCompleted() { override fun onCompleted() {
if (isLinkView) return if (isLinkView) return
view.hideLoading() view.hideLoading()
} }
override fun onNext(baseResponse: BaseResponse<NineListBean>) { override fun onNext(baseResponse: BaseResponse<SeeWechat>) {
if (isLinkView) return if (isLinkView) return
view.hideLoading() view.hideLoading()
...@@ -65,7 +64,7 @@ class UserInfoPresenter : BasePresenter<UserInfoView>() { ...@@ -65,7 +64,7 @@ class UserInfoPresenter : BasePresenter<UserInfoView>() {
val message = baseResponse.message val message = baseResponse.message
when (code) { when (code) {
200 -> view.seeWechatSuc() 200 -> view.seeWechatSuc(baseResponse.data)
else -> { else -> {
view.showToast(message) view.showToast(message)
view.getMorePageFail() view.getMorePageFail()
...@@ -119,4 +118,76 @@ class UserInfoPresenter : BasePresenter<UserInfoView>() { ...@@ -119,4 +118,76 @@ class UserInfoPresenter : BasePresenter<UserInfoView>() {
}) })
} }
fun toBlack(toUid: String) {
val vo = hashMapOf<String, Any>()
vo["toUid"] = toUid
AppHttpManager.getInstance(loanApplication)
.call(loanService.setBlack(vo),
object : BaseSubscriber<BaseResponse<JsonObject>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<JsonObject>) {
if (isLinkView) return
view.hideLoading()
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> {
view.toBlackSuc()
}
else -> {
view.showToast(message)
}
}
}
override fun onError(e: Throwable?) {
if (isLinkView) return
view.hideLoading()
view.showToast(e?.message)
}
})
}
fun toWhite(toUid: String) {
val vo = hashMapOf<String, Any>()
vo["toUid"] = toUid
AppHttpManager.getInstance(loanApplication)
.call(loanService.setWhite(vo),
object : BaseSubscriber<BaseResponse<JsonObject>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<JsonObject>) {
if (isLinkView) return
view.hideLoading()
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> {
view.toWhiteSuc()
}
else -> {
view.showToast(message)
}
}
}
override fun onError(e: Throwable?) {
if (isLinkView) return
view.hideLoading()
view.showToast(e?.message)
}
})
}
} }
\ No newline at end of file
package com.duben.roseplaylet.mvp.views
import com.duben.roseplaylet.mvp.model.UserProfileDataBean
interface UserInfoView : BaseView {
fun getMorePageSuc(data: UserProfileDataBean)
fun getMorePageFail()
fun seeWechatSuc()
fun seeWechatFail()
fun unlockWechatSuc()
fun unlockWechatFail()
}
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<!-- 填充的颜色 -->
<solid android:color="#4bbdd5" />
<!-- 设置按钮的四个角为弧形 -->
<!-- android:radius 弧形的半径 -->
<corners android:radius="5dip" />
</shape>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment