Commit e7b0ce9f authored by mengcuiguang's avatar mengcuiguang

代码优化

parent fa2e1fd4
...@@ -82,7 +82,6 @@ class MyPresenter : BasePresenter<MyView>() { ...@@ -82,7 +82,6 @@ class MyPresenter : BasePresenter<MyView>() {
val code = baseResponse.status val code = baseResponse.status
when (code) { when (code) {
200 -> { 200 -> {
showTurn()
getMyInfo() getMyInfo()
} }
} }
...@@ -128,142 +127,4 @@ class MyPresenter : BasePresenter<MyView>() { ...@@ -128,142 +127,4 @@ class MyPresenter : BasePresenter<MyView>() {
} }
}) })
} }
fun showTurn() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.showTurn(),
object : BaseSubscriber<BaseResponse<NineShowBean>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<NineShowBean>) {
if (isLinkView) return
view.hideLoading()
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> view.showTurnSuc(baseResponse.data)
else -> {
view.showToast(message)
}
}
}
override fun onError(e: Throwable?) {
if (isLinkView) return
view.hideLoading()
view.showToast(e?.message)
}
})
}
fun getTurnIphoneMsg() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.getTurnConfig(),
object : BaseSubscriber<BaseResponse<NineListBean>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<NineListBean>) {
if (isLinkView) return
view.hideLoading()
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> view.getTurnIphoneMsgSuc(baseResponse.data)
else -> {
view.showToast(message)
}
}
}
override fun onError(e: Throwable?) {
if (isLinkView) return
view.hideLoading()
view.showToast(e?.message)
}
})
}
fun toTurn() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.toTurn(),
object : BaseSubscriber<BaseResponse<NineListBean.NineBean>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<NineListBean.NineBean>) {
if (isLinkView) return
view.hideLoading()
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> view.toTurnSuc(baseResponse.data)
else -> {
view.showToast(message)
}
}
}
override fun onError(e: Throwable?) {
if (isLinkView) return
view.hideLoading()
view.showToast(e?.message)
}
})
}
fun unlock(vo: java.util.HashMap<String, Any>) {
AppHttpManager.getInstance(loanApplication)
.call(
loanService.unlock(vo),
object : BaseSubscriber<BaseResponse<IndexList>>() {
override fun onCompleted() {
if (isLinkView) return
view.hideLoading()
}
override fun onNext(baseResponse: BaseResponse<IndexList>) {
if (isLinkView) return
view.hideLoading()
val code = baseResponse.status
val message = baseResponse.message
when (code) {
200 -> view.unlockSuc()
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.mints.helivideo.mvp.views package com.mints.helivideo.mvp.views
import com.mints.helivideo.mvp.model.NineListBean
import com.mints.helivideo.mvp.model.NineShowBean
import com.mints.helivideo.mvp.model.UserBean import com.mints.helivideo.mvp.model.UserBean
interface MyView : BaseView { interface MyView : BaseView {
fun getUserSuc(data:UserBean) fun getUserSuc(data:UserBean)
fun showTurnSuc(data: NineShowBean)
fun getTurnIphoneMsgSuc(data: NineListBean)
fun toTurnSuc(data: NineListBean.NineBean)
fun unlockSuc()
} }
package com.mints.helivideo.ui.adapter
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.FrameLayout
import android.widget.ProgressBar
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.mints.helivideo.R
import com.mints.helivideo.mvp.model.BannerBean
/**
* 任务中心-列表适配器
*/
class TasksAdapter(context: Context, var taskData: MutableList<BannerBean>? = null) :
RecyclerView.Adapter<TasksAdapter.ViewHolder>() {
private var mContext: Context = context
private var itemListener: ItemListener? = null
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
val inflater: LayoutInflater = LayoutInflater.from(mContext)
return ViewHolder(inflater.inflate(R.layout.item_fragment_adapter_task, parent, false))
}
override fun getItemCount(): Int {
return if (taskData == null) {
30
} else {
taskData!!.size
}
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
// taskData?.let {
// // 一级标题
// holder.itemTaskTitle.text = baseConfig.title
// // 二级内容
// holder.itemTaskContent.text = baseConfig.context
// // 按钮文字
// holder.itemTaskClick.text = baseConfig.buttonText
// // 金币
// holder.itemTaskMoney.text = baseConfig.coinText
// // 提现券
// holder.itemTaskCoupons.text = baseConfig.diText
//
// // 进度条 (文本)
// if (baseConfig.runingMax > 0) {
// holder.itemTaskPb.visibility = View.VISIBLE
// holder.itemTaskPb.max = baseConfig.runingMax
// holder.itemTaskPb.progress = baseConfig.runingComplete
//
// // 进度条文字
// holder.itemTaskProgress.visibility = View.VISIBLE
// holder.itemTaskProgress.text = baseConfig.runingText
// } else {
// holder.itemTaskPb.visibility = View.GONE
// holder.itemTaskProgress.visibility = View.GONE
// }
// }
}
inner class ViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
val itemTaskTitle: TextView = itemView.findViewById(R.id.item_task_title)
val itemTaskMoney: TextView = itemView.findViewById(R.id.item_task_money)
val itemTaskCoupons: TextView = itemView.findViewById(R.id.item_task_coupons)
val itemTaskProgress: TextView = itemView.findViewById(R.id.item_task_progress)
val itemTaskClick: TextView = itemView.findViewById(R.id.item_task)
val itemTaskContent: TextView = itemView.findViewById(R.id.item_task_content)
val itemTaskPb: ProgressBar = itemView.findViewById(R.id.item_task_pb)
val llTaskRoot: FrameLayout = itemView.findViewById(R.id.ll_task_root)
}
fun setItemListener(listener: ItemListener) {
itemListener = listener
}
interface ItemListener {
// fun onItemClick(bean: MyInfo.AutoListBean?)
}
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<solid android:color="@color/white" />
<corners android:radius="9dp" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!--3个层的顺序即为显示时的叠加顺序-->
<!--背景色-->
<item android:id="@android:id/background">
<shape>
<corners android:radius="5dip" />
<solid android:color="#FFE9E9" />
</shape>
</item>
<!--一级进度条的颜色,也可以直接替换成图片-->
<item android:id="@android:id/progress">
<clip>
<shape>
<corners android:radius="5dip" />
<solid android:color="#F13D3D" />
</shape>
</clip>
</item>
</layer-list>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="500dp" />
<gradient
android:angle="270"
android:endColor="#F13D3D"
android:startColor="#F13D3D" />
</shape>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/ll_task_root"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_task_list"
android:orientation="vertical"
android:padding="14dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/item_task_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/black"
android:textSize="16sp"
android:text="领金币" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:orientation="horizontal">
<ProgressBar
android:id="@+id/item_task_pb"
style="@android:style/Widget.ProgressBar.Horizontal"
android:layout_width="70dp"
android:layout_height="6dp"
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:progress="20"
android:progressDrawable="@drawable/progressbar_versus_changevedio_bg" />
<TextView
android:id="@+id/item_task_progress"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="2dp"
android:gravity="center_vertical|left"
android:textColor="#F13D3D"
android:textSize="11sp"
android:text="88/85" />
</LinearLayout>
</RelativeLayout>
<TextView
android:id="@+id/item_task_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="8dp"
android:textColor="#464646"
android:textSize="12sp"
android:text="观看福利视频赚金币" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:id="@+id/item_task_money"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:drawableLeft="@mipmap/ic_task_sign_coin"
android:gravity="center_vertical"
android:textColor="#F13D3D"
android:textSize="22sp"
android:text="+1500金币" />
<TextView
android:id="@+id/item_task_plus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:layout_toRightOf="@+id/item_task_money"
android:gravity="center_vertical"
android:text="+"
android:textColor="#FF9700"
android:textSize="20sp"
android:textStyle="bold" />
<TextView
android:id="@+id/item_task_coupons"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toRightOf="@+id/item_task_plus"
android:drawableLeft="@mipmap/ic_task_sign_coin"
android:gravity="center_vertical"
android:textColor="#F13D3D"
android:textSize="22sp"
android:text="*15" />
</RelativeLayout>
</LinearLayout>
<TextView
android:id="@+id/item_task"
android:layout_width="76dp"
android:layout_height="30dp"
android:layout_gravity="right|bottom"
android:layout_marginBottom="10dp"
android:background="@drawable/shape_task_btn"
android:gravity="center"
android:textColor="@color/white"
android:textSize="13dp"
android:text="去完成" />
</FrameLayout>
\ 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