Commit 93821478 authored by maxiaoliang's avatar maxiaoliang

修改1

parent 6314c153
...@@ -9,4 +9,5 @@ class JgqQyEntity { ...@@ -9,4 +9,5 @@ class JgqQyEntity {
var brand: String? = "" var brand: String? = ""
var sort: String? = "" var sort: String? = ""
var icon: String? = "" var icon: String? = ""
var maxDiscount: String? = ""
} }
\ No newline at end of file
...@@ -8,11 +8,12 @@ import com.zxbw.modulemain.contract.CardVoucherContract ...@@ -8,11 +8,12 @@ import com.zxbw.modulemain.contract.CardVoucherContract
import com.zxbw.modulemain.presenter.CardVoucherPresenter import com.zxbw.modulemain.presenter.CardVoucherPresenter
import com.zxhl.cms.AppContext import com.zxhl.cms.AppContext
import com.zxhl.cms.common.base.BaseActivity import com.zxhl.cms.common.base.BaseActivity
import com.zxhl.cms.net.model.qy.JgqQyEntity
import com.zxhl.cms.utils.JumpUtils import com.zxhl.cms.utils.JumpUtils
import com.zxhl.cms.utils.OnRecycleItemClickListener import com.zxhl.cms.utils.OnRecycleItemClickListener
import kotlinx.android.synthetic.main.activity_layout_card_voucher.* import kotlinx.android.synthetic.main.activity_layout_card_voucher.*
class CardVoucherActivity:BaseActivity(),CardVoucherContract.View ,OnRecycleItemClickListener<Any>{ class CardVoucherActivity:BaseActivity(),CardVoucherContract.View ,OnRecycleItemClickListener<JgqQyEntity>{
private var mPresenter:CardVoucherPresenter?=null private var mPresenter:CardVoucherPresenter?=null
private var mAdapter:CardAdapter?=null private var mAdapter:CardAdapter?=null
override fun onClick(v: View?) { override fun onClick(v: View?) {
...@@ -37,13 +38,20 @@ class CardVoucherActivity:BaseActivity(),CardVoucherContract.View ,OnRecycleItem ...@@ -37,13 +38,20 @@ class CardVoucherActivity:BaseActivity(),CardVoucherContract.View ,OnRecycleItem
id_refresh_layout?.setOnRefreshListener { id_refresh_layout?.setOnRefreshListener {
mPresenter?.getCardList() mPresenter?.getCardList()
} }
mPresenter?.getCardList()
} }
override fun setData() {
override fun setData(result: List<JgqQyEntity>?) {
id_refresh_layout?.isRefreshing = false
mAdapter?.clear()
mAdapter?.appendToList(result)
mAdapter?.notifyDataSetChanged()
} }
override fun onItemClick(view: View?, position: Int, data: Any?) { override fun onItemClick(view: View?, position: Int, data: JgqQyEntity?) {
showToast(""+position) showToast(""+position)
JumpUtils.CardDetailJump() JumpUtils.CardDetailJump()
} }
......
package com.zxbw.modulemain.adapter package com.zxbw.modulemain.adapter
import android.app.Activity import android.app.Activity
import android.graphics.Paint
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
...@@ -10,30 +11,35 @@ import androidx.recyclerview.widget.RecyclerView ...@@ -10,30 +11,35 @@ import androidx.recyclerview.widget.RecyclerView
import com.zxbw.modulemain.R import com.zxbw.modulemain.R
import com.zxhl.cms.AppContext import com.zxhl.cms.AppContext
import com.zxhl.cms.common.base.BaseRecyclerAdapter import com.zxhl.cms.common.base.BaseRecyclerAdapter
import com.zxhl.cms.net.model.qy.JgqQyEntity
import com.zxhl.cms.utils.OnRecycleItemClickListener import com.zxhl.cms.utils.OnRecycleItemClickListener
import com.zxhl.cms.widget.RecycleImageView import com.zxhl.cms.widget.RecycleImageView
class CardAdapter : BaseRecyclerAdapter<Any, CardAdapter.ViewHolder> { class CardAdapter : BaseRecyclerAdapter<JgqQyEntity, CardAdapter.ViewHolder> {
private var mContext: Activity? = null private var mContext: Activity? = null
private val listener: OnRecycleItemClickListener<Any> private val listener: OnRecycleItemClickListener<JgqQyEntity>
constructor( constructor(
content: Activity?, content: Activity?,
listener: OnRecycleItemClickListener<Any> listener: OnRecycleItemClickListener<JgqQyEntity>
) : super() { ) : super() {
mContext = content mContext = content
this.listener = listener this.listener = listener
} }
override fun onBindViewHolder(holder: ViewHolder, position: Int) { override fun onBindViewHolder(holder: ViewHolder, position: Int) {
var bean = mList[position]
holder.id_tv_cards_name?.text="${bean.brand}"
holder.id_goods_icon?.setLoadImageUrl(bean.icon,false)
holder.id_goods_yuan_jia?.text=""
holder.id_tv_guanfang_price?.getPaint()?.setFlags(Paint.STRIKE_THRU_TEXT_FLAG) //中划线
holder.id_ll_item?.setOnClickListener { holder.id_ll_item?.setOnClickListener {
listener.onItemClick(it, position, null) listener.onItemClick(it, position, null)
} }
} }
override fun getItemCount(): Int { override fun getItemCount(): Int {
return 23 return mList.size
} }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
...@@ -46,7 +52,9 @@ class CardAdapter : BaseRecyclerAdapter<Any, CardAdapter.ViewHolder> { ...@@ -46,7 +52,9 @@ class CardAdapter : BaseRecyclerAdapter<Any, CardAdapter.ViewHolder> {
class ViewHolder : RecyclerView.ViewHolder { class ViewHolder : RecyclerView.ViewHolder {
var id_ll_item: LinearLayout? var id_ll_item: LinearLayout?
var id_img_cards: RecycleImageView? var id_img_cards: RecycleImageView?
var id_goods_icon: RecycleImageView?
var id_tv_cards_name: TextView? var id_tv_cards_name: TextView?
var id_goods_yuan_jia: TextView?
var id_tv_card_discount: TextView? var id_tv_card_discount: TextView?
var id_tv_card_price: TextView? var id_tv_card_price: TextView?
var id_tv_guanfang_price: TextView? var id_tv_guanfang_price: TextView?
...@@ -58,7 +66,9 @@ class CardAdapter : BaseRecyclerAdapter<Any, CardAdapter.ViewHolder> { ...@@ -58,7 +66,9 @@ class CardAdapter : BaseRecyclerAdapter<Any, CardAdapter.ViewHolder> {
id_ll_item = id_ll_item =
itemView.findViewById<LinearLayout>(R.id.id_ll_item) itemView.findViewById<LinearLayout>(R.id.id_ll_item)
id_img_cards = itemView.findViewById<RecycleImageView>(R.id.id_img_cards) id_img_cards = itemView.findViewById<RecycleImageView>(R.id.id_img_cards)
id_goods_icon = itemView.findViewById<RecycleImageView>(R.id.id_goods_icon)
id_tv_cards_name = itemView.findViewById<TextView>(R.id.id_tv_cards_name) id_tv_cards_name = itemView.findViewById<TextView>(R.id.id_tv_cards_name)
id_goods_yuan_jia = itemView.findViewById<TextView>(R.id.id_goods_yuan_jia)
id_tv_card_discount = itemView.findViewById<TextView>(R.id.id_tv_card_discount) id_tv_card_discount = itemView.findViewById<TextView>(R.id.id_tv_card_discount)
id_tv_card_price = itemView.findViewById<TextView>(R.id.id_tv_card_price) id_tv_card_price = itemView.findViewById<TextView>(R.id.id_tv_card_price)
id_tv_guanfang_price = itemView.findViewById<TextView>(R.id.id_tv_guanfang_price) id_tv_guanfang_price = itemView.findViewById<TextView>(R.id.id_tv_guanfang_price)
......
package com.zxbw.modulemain.contract package com.zxbw.modulemain.contract
import com.zxhl.cms.net.model.qy.JgqQyEntity
class CardVoucherContract { class CardVoucherContract {
interface View { interface View {
fun setData() fun setData(result: List<JgqQyEntity>?)
} }
interface Presenter { interface Presenter {
......
package com.zxbw.modulemain.presenter package com.zxbw.modulemain.presenter
import com.zxbw.modulemain.contract.CardVoucherContract import com.zxbw.modulemain.contract.CardVoucherContract
import com.zxhl.cms.net.ApiClient
import com.zxhl.cms.net.RxSchedulers
import com.zxhl.cms.net.callback.BaseObserver
import com.zxhl.cms.net.model.qy.JgqQyEntity
class CardVoucherPresenter : CardVoucherContract.Presenter { class CardVoucherPresenter : CardVoucherContract.Presenter {
private val mView: CardVoucherContract.View private val mView: CardVoucherContract.View
...@@ -10,6 +14,17 @@ class CardVoucherPresenter : CardVoucherContract.Presenter { ...@@ -10,6 +14,17 @@ class CardVoucherPresenter : CardVoucherContract.Presenter {
} }
override fun getCardList() { override fun getCardList() {
ApiClient.homeApi.getQyJgqCardList().compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<List<JgqQyEntity>>() {
override fun onSuccess(result: List<JgqQyEntity>?) {
if(!result.isNullOrEmpty()){
mView.setData(result)
}
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
}
})
} }
} }
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/id_ll_item"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="16dp" android:layout_marginLeft="16dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginRight="16dp" android:layout_marginRight="16dp"
android:background="@drawable/shape_ffffff_r10" android:background="@drawable/shape_ffffff_r10"
android:id="@+id/id_ll_item"
android:orientation="horizontal"> android:orientation="horizontal">
<com.zxhl.cms.widget.RecycleImageView <RelativeLayout
android:id="@+id/id_img_cards" android:id="@+id/id_rl_bg"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="10dp" android:padding="10dp">
android:background="@drawable/img_daijinquan" />
<com.zxhl.cms.widget.RecycleImageView
android:id="@+id/id_img_cards"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/img_daijinquan" />
<com.zxhl.cms.widget.RecycleImageView
android:id="@+id/id_goods_icon"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_margin="8dp"
android:src="@drawable/icon_huangse" />
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/id_img_cards"
android:layout_marginLeft="50dp"
android:layout_marginBottom="8dp"
android:orientation="horizontal">
<TextView
android:id="@+id/id_goods_yuan_jia"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:textColor="@color/white"
android:textSize="16sp"
android:textStyle="bold"/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="元"
android:textColor="@color/white"
android:textSize="10sp"
android:textStyle="bold"/>
</LinearLayout>
</RelativeLayout>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -26,8 +64,8 @@ ...@@ -26,8 +64,8 @@
android:id="@+id/id_tv_cards_name" android:id="@+id/id_tv_cards_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="猫眼电影5元代金券"
android:layout_marginTop="9dp" android:layout_marginTop="9dp"
android:text="猫眼电影5元代金券"
android:textColor="@color/color_333333" android:textColor="@color/color_333333"
android:textSize="14sp" /> android:textSize="14sp" />
...@@ -35,9 +73,9 @@ ...@@ -35,9 +73,9 @@
android:id="@+id/id_tv_card_discount" android:id="@+id/id_tv_card_discount"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/shape_edd49d_r4"
android:layout_marginBottom="8dp"
android:layout_marginTop="4dp" android:layout_marginTop="4dp"
android:layout_marginBottom="8dp"
android:background="@drawable/shape_edd49d_r4"
android:paddingLeft="6dp" android:paddingLeft="6dp"
android:paddingTop="2dp" android:paddingTop="2dp"
android:paddingRight="6dp" android:paddingRight="6dp"
...@@ -73,8 +111,8 @@ ...@@ -73,8 +111,8 @@
android:id="@+id/id_tv_guanfang_price" android:id="@+id/id_tv_guanfang_price"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="官方价 ¥5元"
android:layout_marginLeft="10dp" android:layout_marginLeft="10dp"
android:text="官方价 ¥5元"
android:textColor="@color/color_999999" android:textColor="@color/color_999999"
android:textSize="10sp" /> android:textSize="10sp" />
</LinearLayout> </LinearLayout>
......
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