Commit 5050b9cb authored by 王雪伟's avatar 王雪伟

[提交人]:王雪伟

[提交简述] :小象省钱
[实现方案] :加入指示器
parent 8da58e26
...@@ -264,10 +264,14 @@ public class NetConfig { ...@@ -264,10 +264,14 @@ public class NetConfig {
} }
//权益卡 //
public static class QY { public static class QY {
public static final String QY_JGQ_CARD_LIST = "app/v1/game/xiaoxiang/equitCardList";//金刚区权益列表 public static final String QY_JGQ_CARD_LIST = "app/v1/game/xiaoxiang/equitCardList";//金刚区权益列表
public static final String QY_JGQ_CARD_DETAIL = "app/v1/game/xiaoxiang/equitCardList/detail";//获取权益详情 public static final String QY_JGQ_CARD_DETAIL = "app/v1/game/xiaoxiang/equitCardList/detail";//获取权益详情
public static final String XX_GOODS_SEARCH = "app/v1/game/xiaoxiang/search";//搜索
public static final String XX_GOODS_GUESS_LIKE = "app/v1/game/xiaoxiang/guessLike";//猜你喜欢
public static final String XX_GOODS_CONVERT_LINK = "app/v1/game/xiaoxiang/convertLink";//转链
public static final String XX_GOODS_ITEM_DETAIL = "app/v1/game/xiaoxiang/itemDetail";//图文详情
} }
......
...@@ -7,6 +7,7 @@ import com.zxhl.cms.net.model.other.IsWeChatLoginEntity ...@@ -7,6 +7,7 @@ import com.zxhl.cms.net.model.other.IsWeChatLoginEntity
import com.zxhl.cms.net.model.other.WxBindEntity import com.zxhl.cms.net.model.other.WxBindEntity
import com.zxhl.cms.net.model.qy.JgqQyEntity import com.zxhl.cms.net.model.qy.JgqQyEntity
import com.zxhl.cms.net.model.qy.RightsDetailEntity import com.zxhl.cms.net.model.qy.RightsDetailEntity
import com.zxhl.cms.net.model.qy.TbGoodsEntity
import com.zxhl.cms.net.model.uc.UserInfo import com.zxhl.cms.net.model.uc.UserInfo
import com.zxhl.cms.net.model.uc.VersionEntity import com.zxhl.cms.net.model.uc.VersionEntity
import io.reactivex.Observable import io.reactivex.Observable
...@@ -338,5 +339,32 @@ interface IHomeApi { ...@@ -338,5 +339,32 @@ interface IHomeApi {
@Query("previewModel") previewModel: String @Query("previewModel") previewModel: String
): Observable<Response<List<RightsDetailEntity>>> ): Observable<Response<List<RightsDetailEntity>>>
//商品搜索
@GET(NetConfig.QY.XX_GOODS_SEARCH)
fun getGoodsListSearch(
@Query("cate") cate: String,
@Query("keyword") keyword: String,
@Query("page") page: Int,
@Query("size") size: Int
): Observable<Response<TbGoodsEntity>>
//猜你喜欢
@GET(NetConfig.QY.XX_GOODS_GUESS_LIKE)
fun getGoodsGuessLike(
@Query("page") page: Int,
@Query("size") size: Int
): Observable<Response<TbGoodsEntity>>
//转链
@GET(NetConfig.QY.XX_GOODS_CONVERT_LINK)
fun getGoodsConvertLink(
@Query("link") link: String
): Observable<Response<TbGoodsEntity>>
//图文详情
@GET(NetConfig.QY.XX_GOODS_ITEM_DETAIL)
fun getGoodsImgDetail(
@Query("productId") productId: String
): Observable<Response<TbGoodsEntity>>
} }
\ No newline at end of file
...@@ -10,42 +10,45 @@ class AppInEntity { ...@@ -10,42 +10,45 @@ class AppInEntity {
var depots_text: String? = "" var depots_text: String? = ""
var recover_type: String = "" var recover_type: String = ""
var login: String = ""//1开启 0 关闭 var login: String = ""//1开启 0 关闭
var pay_config:PayConfig?=null var pay_config: PayConfig? = null
var pay_config_v2:List<PayFun>?=null var pay_config_v2: List<PayFun>? = null
var box_price_config:List<BoxPriceConfig>?=null var box_price_config: List<BoxPriceConfig>? = null
var risk_text: String = ""// var risk_text: String = ""//
var risk_open: String = ""//1开启 0 关闭 var risk_open: String = ""//1开启 0 关闭
var kefu_url: String = ""//客服地址 var kefu_url: String = ""//客服地址
var card_desc: String = ""//权益说明 var card_desc: String = ""//权益说明
var tabs: List<TabEntity>? = null//tab
} }
class PayFun :Serializable{ class PayFun : Serializable {
var open:Int?=0 var open: Int? = 0
var type:Int?=0 var type: Int? = 0
var title:String?="" var title: String? = ""
var icon:String?="" var icon: String? = ""
} }
class PayConfig { class PayConfig {
var ali_ming:MinPay?=null var ali_ming: MinPay? = null
var ali:aliPay?=null var ali: aliPay? = null
class MinPay { class MinPay {
var type:Int?=0 var type: Int? = 0
var title:String?="" var title: String? = ""
var open:Int?=0 var open: Int? = 0
} }
class aliPay { class aliPay {
var type:Int?=0 var type: Int? = 0
var title:String?="" var title: String? = ""
var open:Int?=0 var open: Int? = 0
} }
} }
class BoxPriceConfig{ class BoxPriceConfig {
var boxNum:Int=0; var boxNum: Int = 0;
var boxDiscount:Double=0.0; var boxDiscount: Double = 0.0;
} }
package com.zxhl.cms.net.model.box package com.zxhl.cms.net.model.box
class TabEntity { class TabEntity {
var name: String? = "推荐" var name: String? = ""
var id: String? = "1" var id: String? = ""
var value: String? = ""
} }
\ No newline at end of file
package com.zxhl.cms.net.model.qy
import java.io.Serializable
/**
* @author (wangXuewei)
* @detail :
*/
class TbGoodsEntity : Serializable {
var msg: String? = ""
var is_similar: String? = ""
var result_list: List<TbGoodsItemEntity>? = null//普通tab
var data: List<TbGoodsItemEntity>? = null//猜你喜欢
var is_splitWord: String? = ""
var error: String? = ""
var search_type: String? = ""
var request_id: String? = ""
var force_index: String? = ""
var total_results: String? = ""
}
\ No newline at end of file
package com.zxhl.cms.net.model.qy
import java.io.Serializable
/**
* @author (wangXuewei)
* @detail :
*/
class TbGoodsItemEntity : Serializable {
var presale_end_time: String? = ""
var category_name: String? = ""
var zk_final_price: String? = ""
var coupon_remain_count: String? = ""
var num_iid: String? = ""
var shop_dsr: String? = ""
var title: String? = ""
var presale_tail_start_time: String? = ""
var nick: String? = ""
var level_one_category_id: String? = ""
var presale_tail_end_time: String? = ""
var presale_deposit: String? = ""
var short_title: String? = ""
var user_type: String? = ""
var category_id: String? = ""
var coupon_id: String? = ""
var shop_title: String? = ""
var small_images: List<String>? = null
var seller_id: String? = ""
var coupon_amount: String? = ""
var superior_brand: String? = ""
var item_id: String? = ""
var level_one_category_name: String? = ""
var presale_start_time: String? = ""
var coupon_total_count: String? = ""
var pict_url: String? = ""
var white_image: String? = ""
var coupon_info: String? = ""
var volume: String? = ""
var coupon_start_fee: String? = ""
var real_post_fee: String? = ""
var provcity: String? = ""
var tk_total_sales: String? = ""
var item_url: String? = ""
var commission_rate: String? = ""
var tk_total_commi: String? = ""
var item_description: String? = ""
var reserve_price: String? = ""
var coupon_start_time: String? = ""
var coupon_end_time: String? = ""
var viewType: Int = 3
}
\ No newline at end of file
...@@ -1220,5 +1220,30 @@ public class Utils { ...@@ -1220,5 +1220,30 @@ public class Utils {
BigDecimal p3 = new BigDecimal(Double.toString(m3)); BigDecimal p3 = new BigDecimal(Double.toString(m3));
return p1.multiply(p2).multiply(p3).setScale(2, RoundingMode.HALF_UP).doubleValue(); return p1.multiply(p2).multiply(p3).setScale(2, RoundingMode.HALF_UP).doubleValue();
} }
/**
* 提供精确的减法运算。
* @param v1 被减数
* @param v2 减数
* @return 两个参数的差
*/
public static double sub(double v1,double v2){
BigDecimal b1 = new BigDecimal(Double.toString(v1));
BigDecimal b2 = new BigDecimal(Double.toString(v2));
return b1.subtract(b2).doubleValue();
}
/**
* 对入参保留最多两位小数(舍弃末尾的0),如:
* 3.345->3.34
* 3.40->3.4
* 3.0->3
*/
public static String getNoMoreThanTwoDigits(double number) {
DecimalFormat format = new DecimalFormat("0.##");
//未保留小数的舍弃规则,RoundingMode.FLOOR表示直接舍弃。
format.setRoundingMode(RoundingMode.FLOOR);
return format.format(number);
}
} }
...@@ -45,4 +45,10 @@ dependencies { ...@@ -45,4 +45,10 @@ dependencies {
implementation 'com.contrarywind:Android-PickerView:4.1.9' implementation 'com.contrarywind:Android-PickerView:4.1.9'
implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4' implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
//banner
implementation 'com.github.zhpanvip:viewpagerindicator:1.2.1'
implementation 'com.github.zhpanvip:bannerviewpager:3.5.5'
//刷新 核心必须依赖
implementation 'io.github.scwang90:refresh-layout-kernel:2.0.5'
implementation 'io.github.scwang90:refresh-header-classics:2.0.5' //经典刷新头
} }
package com.zxbw.modulemain.activity package com.zxbw.modulemain.activity
import android.util.Log
import android.view.View import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.viewpager2.widget.ViewPager2
import com.zxbw.modulemain.R import com.zxbw.modulemain.R
import com.zxbw.modulemain.adapter.DetailBannerAdapter
import com.zxbw.modulemain.adapter.GoodsListAdapter import com.zxbw.modulemain.adapter.GoodsListAdapter
import com.zxbw.modulemain.contract.TbGoodsDetailContract
import com.zxbw.modulemain.presenter.TbGoodsDetailPresenter
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.TbGoodsItemEntity
import com.zxhl.cms.net.model.shop.ShopListEntity
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_tb_goods_detail.* import kotlinx.android.synthetic.main.activity_layout_tb_goods_detail.*
...@@ -16,9 +23,11 @@ import me.jessyan.autosize.utils.ScreenUtils ...@@ -16,9 +23,11 @@ import me.jessyan.autosize.utils.ScreenUtils
* @datetime 2022-05-24 17:12 GMT+8 * @datetime 2022-05-24 17:12 GMT+8
* @detail : 淘宝商品详情 * @detail : 淘宝商品详情
*/ */
class TbGoodsDetailActivity : BaseActivity() { class TbGoodsDetailActivity : BaseActivity(), TbGoodsDetailContract.View {
private var mGoodsAdapter: GoodsListAdapter? = null; private var mGoodsAdapter: GoodsListAdapter? = null;
private var mPresenter: TbGoodsDetailPresenter? = null;
private var goodsDetail: TbGoodsItemEntity? = null
override fun before() { override fun before() {
super.before() super.before()
...@@ -36,18 +45,52 @@ class TbGoodsDetailActivity : BaseActivity() { ...@@ -36,18 +45,52 @@ class TbGoodsDetailActivity : BaseActivity() {
} }
id_tb_goods_detail_title_sys_bar_view.layoutParams.height = statusBarHeight id_tb_goods_detail_title_sys_bar_view.layoutParams.height = statusBarHeight
goodsDetail = intent.getSerializableExtra("goods") as TbGoodsItemEntity
mPresenter = TbGoodsDetailPresenter(this)
mGoodsAdapter = GoodsListAdapter(this, mGoodsAdapter = GoodsListAdapter(this,
OnRecycleItemClickListener<Any> { view, position, data -> OnRecycleItemClickListener<TbGoodsItemEntity> { view, position, data ->
showToast("postion" + position)
JumpUtils.TbGoodsDetailJump() JumpUtils.TbGoodsDetailJump()
}) })
id_rcl_recommend_goods_list?.layoutManager = LinearLayoutManager(this) id_rcl_recommend_goods_list?.layoutManager = LinearLayoutManager(this)
id_rcl_recommend_goods_list.adapter = mGoodsAdapter id_rcl_recommend_goods_list.adapter = mGoodsAdapter
id_img_close_btn?.setOnClickListener(this) id_img_close_btn?.setOnClickListener(this)
initView()
var link = ""
if (!goodsDetail?.item_url.isNullOrEmpty()) {
link = goodsDetail?.item_url!!
} else if (!goodsDetail?.item_id.isNullOrEmpty()) {
link = goodsDetail?.item_id!!
}
mPresenter?.getConvertLink(link)
mPresenter?.getGoodsDetail(goodsDetail?.item_id ?: "")
}
private fun initView() {
if (goodsDetail == null) {
return
}
id_tv_goods_name?.text = goodsDetail?.title
var mList = listOf<String>("")
id_detail_top_banner.apply {
adapter = DetailBannerAdapter()
setLifecycleRegistry(lifecycle)
}.create((goodsDetail?.small_images ?:mList) as List<Nothing>?)
id_detail_top_banner.registerOnPageChangeCallback(object :
ViewPager2.OnPageChangeCallback() {
override fun onPageSelected(position: Int) {
Log.e("MXL", "" + position)
id_tv_vp_index.text = "${position + 1}/${goodsDetail?.small_images?.size ?: 0 + 1}"
}
})
} }
override fun onClick(v: View?) { override fun onClick(v: View?) {
...@@ -58,4 +101,12 @@ class TbGoodsDetailActivity : BaseActivity() { ...@@ -58,4 +101,12 @@ class TbGoodsDetailActivity : BaseActivity() {
} }
} }
override fun setConvertLink() {
}
override fun setGoodsDetail() {
}
} }
\ No newline at end of file
...@@ -8,6 +8,7 @@ import com.zxbw.modulemain.contract.ZeroBuyListContract ...@@ -8,6 +8,7 @@ import com.zxbw.modulemain.contract.ZeroBuyListContract
import com.zxbw.modulemain.presenter.ZeroBuyListPresenter import com.zxbw.modulemain.presenter.ZeroBuyListPresenter
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.TbGoodsItemEntity
import com.zxhl.cms.utils.OnRecycleItemClickListener import com.zxhl.cms.utils.OnRecycleItemClickListener
import kotlinx.android.synthetic.main.activity_layout_zero_buy_list.* import kotlinx.android.synthetic.main.activity_layout_zero_buy_list.*
...@@ -17,7 +18,7 @@ import kotlinx.android.synthetic.main.activity_layout_zero_buy_list.* ...@@ -17,7 +18,7 @@ import kotlinx.android.synthetic.main.activity_layout_zero_buy_list.*
* @detail :零元购列表 * @detail :零元购列表
*/ */
class ZeroBuyListActivity : BaseActivity(), ZeroBuyListContract.View, class ZeroBuyListActivity : BaseActivity(), ZeroBuyListContract.View,
OnRecycleItemClickListener<Any> { OnRecycleItemClickListener<TbGoodsItemEntity> {
private var mPresenter: ZeroBuyListPresenter? = null private var mPresenter: ZeroBuyListPresenter? = null
private var mAdapter: GoodsListAdapter? = null; private var mAdapter: GoodsListAdapter? = null;
...@@ -54,7 +55,7 @@ class ZeroBuyListActivity : BaseActivity(), ZeroBuyListContract.View, ...@@ -54,7 +55,7 @@ class ZeroBuyListActivity : BaseActivity(), ZeroBuyListContract.View,
mPresenter?.getZeroBuyList() mPresenter?.getZeroBuyList()
} }
override fun onItemClick(view: View?, position: Int, data: Any?) { override fun onItemClick(view: View?, position: Int, data: TbGoodsItemEntity?) {
} }
...@@ -62,4 +63,5 @@ class ZeroBuyListActivity : BaseActivity(), ZeroBuyListContract.View, ...@@ -62,4 +63,5 @@ class ZeroBuyListActivity : BaseActivity(), ZeroBuyListContract.View,
id_zero_buy_refreshLayout?.isRefreshing = false id_zero_buy_refreshLayout?.isRefreshing = false
} }
} }
\ No newline at end of file
package com.zxbw.modulemain.adapter
import android.widget.ImageView
import com.bumptech.glide.Glide
import com.zhpan.bannerview.BaseBannerAdapter
import com.zhpan.bannerview.BaseViewHolder
import com.zxbw.modulemain.R
/**
* @author (wangXuewei)
* @datetime 2022-05-26 22:30 GMT+8
* @detail :
*/
class DetailBannerAdapter() : BaseBannerAdapter<String>() {
override fun bindData(
holder: BaseViewHolder<String>?,
data: String?,
position: Int,
pageSize: Int
) {
var imageView = holder?.findViewById<ImageView>(R.id.id_img_detail_banner_bg) as ImageView
// if (mContext?.isFinishing==false){
// Glide.with(mContext!!)
// .load(data)
// .into(imageView)
// }
Glide.with(imageView)
.load(data)
.placeholder(R.drawable.beijing)
.into(imageView);
}
override fun getLayoutId(viewType: Int): Int {
return R.layout.item_layout_detail_banner
}
}
\ No newline at end of file
...@@ -17,33 +17,41 @@ import com.zxhl.cms.AppContext ...@@ -17,33 +17,41 @@ 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.box.AddressEntity import com.zxhl.cms.net.model.box.AddressEntity
import com.zxhl.cms.net.model.box.LotteryEntity import com.zxhl.cms.net.model.box.LotteryEntity
import com.zxhl.cms.net.model.qy.TbGoodsItemEntity
import com.zxhl.cms.utils.OnRecycleItemClickListener import com.zxhl.cms.utils.OnRecycleItemClickListener
import com.zxhl.cms.utils.Utils
import com.zxhl.cms.widget.RecycleImageView import com.zxhl.cms.widget.RecycleImageView
class GoodsListAdapter : BaseRecyclerAdapter<Any, GoodsListAdapter.ViewHolder> { class GoodsListAdapter : BaseRecyclerAdapter<TbGoodsItemEntity, GoodsListAdapter.ViewHolder> {
private var mContext: Activity? = null private var mContext: Activity? = null
private val listener: OnRecycleItemClickListener<Any> private val listener: OnRecycleItemClickListener<TbGoodsItemEntity>
constructor( constructor(
content: Activity?, content: Activity?,
listener: OnRecycleItemClickListener<Any> listener: OnRecycleItemClickListener<TbGoodsItemEntity>
) : 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) {
val bean = mList[position]
holder.id_tv_goods_name?.text = bean.title
if (mContext?.isFinishing == false) {
holder.id_item_goods_img?.setLoadImageUrl(bean.pict_url, 0, 5)
}
holder.id_tv_tb_price_value?.text = "淘宝商城价 : ¥${bean.reserve_price}"
holder.id_tv_yhq_value?.text = "${bean.coupon_start_fee}元券"
var r_price = bean.reserve_price?.toDoubleOrNull() ?: 0 as Double
var c_price = bean.coupon_start_fee?.toDoubleOrNull() ?: 0 as Double
holder.id_tv_goods_price?.text = Utils.getNoMoreThanTwoDigits(Utils.sub(r_price, c_price))
holder.id_rl_goods_item_view?.setOnClickListener { holder.id_rl_goods_item_view?.setOnClickListener {
listener.onItemClick(it, position, null) listener.onItemClick(it, position, bean)
} }
} }
override fun getItemCount(): Int {
return 23
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder( return ViewHolder(
LayoutInflater.from(AppContext.get()) LayoutInflater.from(AppContext.get())
......
...@@ -4,55 +4,58 @@ import android.app.Activity ...@@ -4,55 +4,58 @@ import android.app.Activity
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.widget.LinearLayout import android.widget.ImageView
import android.widget.TextView import androidx.viewpager.widget.PagerAdapter
import androidx.recyclerview.widget.RecyclerView import com.bumptech.glide.Glide
import com.zxbw.modulemain.R import com.zxbw.modulemain.R
import com.zxhl.cms.AppContext import com.zxhl.cms.utils.Utils
import com.zxhl.cms.common.base.BaseRecyclerAdapter import java.util.ArrayList
import com.zxhl.cms.utils.OnRecycleItemClickListener
import com.zxhl.cms.widget.RecycleImageView
class HomeBannerAdapter : BaseRecyclerAdapter<Any, HomeBannerAdapter.ViewHolder> { class HomeBannerAdapter : PagerAdapter {
private var mContext: Activity? = null
private val listener: OnRecycleItemClickListener<Any>
private var mActivity: Activity? = null
private var mViewList: List<String> = ArrayList()
constructor( constructor(
content: Activity?, mList: List<String>,
listener: OnRecycleItemClickListener<Any> context: Activity,
) : super() { ) : super() {
mContext = content mViewList = mList //构造方法,参数是我们的页卡,这样比较方便。
this.listener = listener mActivity = context
} }
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.id_ll_item?.setOnClickListener { override fun isViewFromObject(p0: View, p1: Any): Boolean {
listener.onItemClick(it, position, null) return p0 == p1
}
} }
override fun getItemCount(): Int {
return 3
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder { override fun instantiateItem(container: ViewGroup, position: Int): Any {
return ViewHolder( val data = mViewList[position]
LayoutInflater.from(AppContext.get()) val view = LayoutInflater.from(mActivity).inflate(R.layout.item_layout_home_banner, null)
.inflate(R.layout.item_layout_home_banner, parent, false) val bg = view.findViewById<ImageView>(R.id.id_img_banner_bg)
) if (mActivity?.isFinishing==false){
Glide.with(mActivity!!).load(data).placeholder(R.drawable.img_banner_ms_bg).into(bg)
}
bg.setOnClickListener {
Utils.showToast(mActivity,"postion$position")
}
container.addView(view)// 添加页卡
return view
} }
class ViewHolder : RecyclerView.ViewHolder { override fun getItemPosition(`object`: Any): Int {
var id_ll_item: LinearLayout? return super.getItemPosition(`object`)
}
override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
constructor( container.removeView(`object` as View)
itemView: View }
) : super(itemView) {
id_ll_item =
itemView.findViewById<LinearLayout>(R.id.id_ll_item)
} override fun getCount(): Int {
return mViewList.size
} }
} }
\ No newline at end of file
package com.zxbw.modulemain.adapter
import android.app.Activity
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageView
import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager.widget.PagerAdapter
import com.bumptech.glide.Glide
import com.zxbw.modulemain.R
import com.zxhl.cms.net.model.qy.JgqQyEntity
import com.zxhl.cms.utils.JumpUtils
import com.zxhl.cms.utils.OnRecycleItemClickListener
import com.zxhl.cms.utils.Utils
import java.util.ArrayList
class HomeQyBannerAdapter : PagerAdapter {
private var mActivity: Activity? = null
private var mViewList: List<List<JgqQyEntity>> = ArrayList()
constructor(
mList: List<List<JgqQyEntity>>,
context: Activity?,
) : super() {
mViewList = mList //构造方法,参数是我们的页卡,这样比较方便。
mActivity = context
}
override fun isViewFromObject(p0: View, p1: Any): Boolean {
return p0 == p1
}
override fun instantiateItem(container: ViewGroup, position: Int): Any {
val data = mViewList[position]
Log.d("wxw", "data${data.size}")
val view =
LayoutInflater.from(mActivity).inflate(R.layout.item_layout_home_qy_grid_view, null)
val grid_view = view.findViewById<RecyclerView>(R.id.id_rcl_home_jgq_qy_grid_list)
var mJgqQyAdapter = JgqQyAdapter(mActivity,
OnRecycleItemClickListener<JgqQyEntity> { view, position, data ->
JumpUtils.RightsDetailJump(data.brand, data.icon)
})
grid_view.layoutManager = GridLayoutManager(mActivity, 5)
grid_view.adapter = mJgqQyAdapter
mJgqQyAdapter.clear()
mJgqQyAdapter.appendToList(data)
container.addView(view)// 添加页卡
return view
}
override fun getItemPosition(`object`: Any): Int {
return super.getItemPosition(`object`)
}
override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
container.removeView(`object` as View)
}
override fun getCount(): Int {
return mViewList.size
}
}
\ No newline at end of file
package com.zxbw.modulemain.adapter
import android.app.Activity
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.RelativeLayout
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import androidx.viewpager.widget.ViewPager
import com.zhpan.indicator.IndicatorView
import com.zxbw.modulemain.R
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.base.BaseRecyclerAdapter
import com.zxhl.cms.net.model.qy.JgqQyEntity
import com.zxhl.cms.net.model.qy.TbGoodsItemEntity
import com.zxhl.cms.utils.OnRecycleItemClickListener
import com.zxhl.cms.utils.Utils
import com.zxhl.cms.widget.RecycleImageView
/**
* @author (wangXuewei)
* @datetime 2022-05-26 21:05 GMT+8
* @detail :
*/
class HomeRecommendAdapter : BaseRecyclerAdapter<TbGoodsItemEntity, RecyclerView.ViewHolder> {
private var mContext: Activity? = null
private val listener: OnRecycleItemClickListener<TbGoodsItemEntity>
private val VIEW_TYPE_QY_VIEW = 1
private val VIEW_TYPE_ZERO_VIEW = 2
private val VIEW_TYPE_GOODS_VIEW = 3
constructor(
content: Activity?,
listener: OnRecycleItemClickListener<TbGoodsItemEntity>
) : super() {
mContext = content
this.listener = listener
}
private var mIsShowQyView = false;
fun IsShowQyView(boolean: Boolean) {
mIsShowQyView = boolean
}
private var mQyDataList: List<JgqQyEntity>? = null
fun updateHomeQyData(qyDataList: List<JgqQyEntity>) {
mQyDataList = qyDataList
// notifyItemChanged(0)
}
override fun getItemViewType(position: Int): Int {
if (position == 0 && mIsShowQyView) {
return VIEW_TYPE_QY_VIEW
} else {
return VIEW_TYPE_GOODS_VIEW
}
}
override fun getItemCount(): Int {
if (mIsShowQyView) {
return mList.size + 1
} else {
return mList.size
}
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
if (holder is GoodsViewHolder) {
var viewNum = 0;
if (mIsShowQyView) {
viewNum = 1;
}
val bean = mList[position - viewNum]
holder.id_tv_goods_name?.text = bean.title
if (mContext?.isFinishing == false) {
holder.id_item_goods_img?.setLoadImageUrl(bean.pict_url, 0, 5)
}
holder.id_tv_tb_price_value?.text = "淘宝商城价 : ¥${bean.reserve_price}"
holder.id_tv_yhq_value?.text = "${bean.coupon_start_fee}元券"
var r_price = bean.reserve_price?.toDoubleOrNull() ?: 0 as Double
var c_price = bean.coupon_start_fee?.toDoubleOrNull() ?: 0 as Double
holder.id_tv_goods_price?.text = Utils.getNoMoreThanTwoDigits(
Utils.sub(
r_price,
c_price
)
)
holder.id_rl_goods_item_view?.setOnClickListener {
listener.onItemClick(it, position, bean)
}
} else if (holder is QyViewHolder) {
if (!mQyDataList.isNullOrEmpty()) {
holder.qy_item_view?.visibility = View.VISIBLE
var splitItemNum = 15;
val result = ArrayList<List<JgqQyEntity>>()
if (mQyDataList?.size!! <= splitItemNum) {
result.add(mQyDataList!!)
} else {
//
val splitNum = if (mQyDataList?.size!! % splitItemNum == 0) {
mQyDataList?.size!! / splitItemNum
} else {
mQyDataList?.size!! / splitItemNum + 1
}
var value: List<JgqQyEntity>? = null
for (i in 0 until splitNum) {
if (i < splitNum - 1) {
value = mQyDataList?.subList(i * splitItemNum, (i + 1) * splitItemNum)
} else {
// 最后一组
value = mQyDataList?.subList(i * splitItemNum, mQyDataList?.size!!)
}
if (value != null) {
result.add(value)
}
}
}
Log.d("wxw", "resultSize${result.size}")
var mQyBannerAdapter = HomeQyBannerAdapter(result, mContext)
holder.qy_vp?.adapter = mQyBannerAdapter;
holder.qy_vp?.postDelayed(Runnable {
holder.qy_vp?.requestLayout()
}, 100)
holder.id_qy_indicator_view?.setupWithViewPager(holder.qy_vp!!)
} else {
holder.qy_item_view?.visibility = View.GONE
}
} else if (holder is ZeroViewHolder) {
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
if (viewType == VIEW_TYPE_QY_VIEW) {
return QyViewHolder(
LayoutInflater.from(AppContext.get())
.inflate(R.layout.item_layout_home_qy_view, parent, false)
)
} else if (viewType == VIEW_TYPE_ZERO_VIEW) {
return ZeroViewHolder(
LayoutInflater.from(AppContext.get())
.inflate(R.layout.item_layout_home_zero_buy_view, parent, false)
)
} else {
return GoodsViewHolder(
LayoutInflater.from(AppContext.get())
.inflate(R.layout.item_layout_goods_view, parent, false)
)
}
}
class GoodsViewHolder : RecyclerView.ViewHolder {
var id_rl_goods_item_view: RelativeLayout?
var id_item_goods_img: RecycleImageView?
var id_tv_goods_name: TextView?
var id_tv_yhq_value: TextView?
var id_tv_manjian_value: TextView?
var id_tv_tb_price_value: TextView?
var id_tv_goods_price: TextView?
constructor(
itemView: View
) : super(itemView) {
id_rl_goods_item_view =
itemView.findViewById<RelativeLayout>(R.id.id_rl_goods_item_view)
id_item_goods_img = itemView.findViewById<RecycleImageView>(R.id.id_item_goods_img)
id_tv_goods_name = itemView.findViewById<TextView>(R.id.id_tv_goods_name)
id_tv_yhq_value = itemView.findViewById<TextView>(R.id.id_tv_yhq_value)
id_tv_manjian_value = itemView.findViewById<TextView>(R.id.id_tv_manjian_value)
id_tv_tb_price_value = itemView.findViewById<TextView>(R.id.id_tv_tb_price_value)
id_tv_goods_price = itemView.findViewById<TextView>(R.id.id_tv_goods_price)
}
}
class QyViewHolder : RecyclerView.ViewHolder {
var qy_item_view: RelativeLayout?
var qy_vp: ViewPager?
var id_qy_indicator_view: IndicatorView?
constructor(
itemView: View
) : super(itemView) {
qy_item_view = itemView.findViewById<RelativeLayout>(R.id.id_rl_home_qy_item_view)
qy_vp = itemView.findViewById<ViewPager>(R.id.id_vp_home_jgq_qy_list)
id_qy_indicator_view = itemView.findViewById<IndicatorView>(R.id.id_qy_indicator_view)
}
}
class ZeroViewHolder : RecyclerView.ViewHolder {
constructor(
itemView: View
) : super(itemView) {
}
}
}
\ No newline at end of file
package com.zxbw.modulemain.contract package com.zxbw.modulemain.contract
import com.zxhl.cms.net.model.qy.JgqQyEntity import com.zxhl.cms.net.model.qy.JgqQyEntity
import com.zxhl.cms.net.model.qy.TbGoodsItemEntity
/** /**
* 推荐 * 推荐
...@@ -8,10 +9,18 @@ import com.zxhl.cms.net.model.qy.JgqQyEntity ...@@ -8,10 +9,18 @@ import com.zxhl.cms.net.model.qy.JgqQyEntity
*/ */
class HomeRecommendContract { class HomeRecommendContract {
interface View { interface View {
fun setQyCardList(result: List<JgqQyEntity>) fun setQyCardList(result: List<JgqQyEntity>?)
fun setTbGoodsList(isRefresh: Boolean, result: List<TbGoodsItemEntity>?)
// fun setGuessLikeGoodsList(isRefresh: Boolean, result: List<TbGoodsItemEntity>?)
} }
interface Presenter { interface Presenter {
fun getQyCardList() fun getQyCardList(tabName: String)
fun getTbGoodsList(isRefresh: Boolean, cate: String)
fun getGuessLikeGoodsList(isRefresh: Boolean)
} }
} }
\ No newline at end of file
package com.zxbw.modulemain.contract
/**
*
*/
class TbGoodsDetailContract {
interface View {
fun setConvertLink()
fun setGoodsDetail()
}
interface Presenter {
fun getConvertLink(link: String)
fun getGoodsDetail(productId: String)
}
}
\ No newline at end of file
package com.zxbw.modulemain.fragment package com.zxbw.modulemain.fragment
import android.graphics.Color
import android.util.Log import android.util.Log
import android.view.View import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.PagerSnapHelper import androidx.recyclerview.widget.PagerSnapHelper
import com.flyco.tablayout.listener.OnTabSelectListener
import com.zxbw.modulemain.R import com.zxbw.modulemain.R
import com.zxbw.modulemain.adapter.DetailBannerAdapter
import com.zxbw.modulemain.adapter.HomeBannerAdapter import com.zxbw.modulemain.adapter.HomeBannerAdapter
import com.zxhl.cms.common.Constant
import com.zxhl.cms.common.FragmentAdapter import com.zxhl.cms.common.FragmentAdapter
import com.zxhl.cms.common.base.BaseFragment import com.zxhl.cms.common.base.BaseFragment
import com.zxhl.cms.net.ApiClient import com.zxhl.cms.net.ApiClient
import com.zxhl.cms.net.RxSchedulers import com.zxhl.cms.net.RxSchedulers
import com.zxhl.cms.net.SettingPreference
import com.zxhl.cms.net.callback.BaseObserver import com.zxhl.cms.net.callback.BaseObserver
import com.zxhl.cms.net.model.box.AppInEntity
import com.zxhl.cms.net.model.box.TabEntity import com.zxhl.cms.net.model.box.TabEntity
import com.zxhl.cms.utils.OnRecycleItemClickListener import com.zxhl.cms.utils.OnRecycleItemClickListener
import kotlinx.android.synthetic.main.activity_layout_tb_goods_detail.*
import kotlinx.android.synthetic.main.fragment_layout_home.* import kotlinx.android.synthetic.main.fragment_layout_home.*
import me.jessyan.autosize.utils.ScreenUtils import me.jessyan.autosize.utils.ScreenUtils
...@@ -21,7 +28,8 @@ import me.jessyan.autosize.utils.ScreenUtils ...@@ -21,7 +28,8 @@ import me.jessyan.autosize.utils.ScreenUtils
* Created by gaoleichao on 2021/10/25 * Created by gaoleichao on 2021/10/25
*/ */
class HomeFragment : BaseFragment() { class HomeFragment : BaseFragment() {
private var mBannerAdapter: HomeBannerAdapter? = null
private var mBannerAdapter: HomeBannerAdapter? = null//Banner
override fun layoutID(): Int { override fun layoutID(): Int {
return R.layout.fragment_layout_home return R.layout.fragment_layout_home
...@@ -41,18 +49,13 @@ class HomeFragment : BaseFragment() { ...@@ -41,18 +49,13 @@ class HomeFragment : BaseFragment() {
statusBarHeight = 40; statusBarHeight = 40;
} }
id_title_sys_bar_view.layoutParams.height = statusBarHeight id_title_sys_bar_view.layoutParams.height = statusBarHeight
var mList = listOf<String>("","","")
mBannerAdapter = HomeBannerAdapter( if (activity!=null){
activity mBannerAdapter = HomeBannerAdapter(mList,activity!!)
) { view, position, data -> id_home_top_banner.adapter = mBannerAdapter
showToast("pos" + position)
} }
indicator_view.setupWithViewPager(id_home_top_banner)
id_rcl_top_banner.layoutManager =
LinearLayoutManager(activity, LinearLayoutManager.HORIZONTAL, false)
id_rcl_top_banner.adapter = mBannerAdapter
val pagerSnapHelper = PagerSnapHelper()
pagerSnapHelper.attachToRecyclerView(id_rcl_top_banner)
getTabList() getTabList()
id_rl_search_view.setOnClickListener { id_rl_search_view.setOnClickListener {
showToast("搜索") showToast("搜索")
...@@ -65,34 +68,26 @@ class HomeFragment : BaseFragment() { ...@@ -65,34 +68,26 @@ class HomeFragment : BaseFragment() {
private fun getTabList() { private fun getTabList() {
ApiClient.homeApi.getBoxTab().compose(RxSchedulers.observableIO2Main()) ApiClient.homeApi.getAppInfo()
.subscribe(object : BaseObserver<List<TabEntity>>() { .compose(RxSchedulers.observableIO2Main())
override fun onSuccess(result: List<TabEntity>?) { .subscribe(object : BaseObserver<AppInEntity>() {
// if (result != null) { override fun onSuccess(result: AppInEntity?) {
// initViewPager(result) SettingPreference.saveConfig(result)
// } if (result != null && !result.tabs.isNullOrEmpty()) {
initViewPager(result.tabs!!)
}
} }
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) { override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
Log.e("wxw", "ERROR" + code + errorMsg) val config = SettingPreference.getConfig();
if (config != null && !config.tabs.isNullOrEmpty()) {
initViewPager(config.tabs!!)
}
} }
}) })
val createTitles = ArrayList<TabEntity>().apply {
add(TabEntity())
add(TabEntity())
add(TabEntity())
add(TabEntity())
add(TabEntity())
add(TabEntity())
add(TabEntity())
add(TabEntity())
}
initViewPager(createTitles)
} }
private fun initViewPager(result: List<TabEntity>) { private fun initViewPager(result: List<TabEntity>) {
Log.d("wxw", "result" + result.size)
val adapter = FragmentAdapter(childFragmentManager) val adapter = FragmentAdapter(childFragmentManager)
for (i in 0 until (result?.size ?: 0)) { for (i in 0 until (result?.size ?: 0)) {
val title = result[i].name ?: "" val title = result[i].name ?: ""
...@@ -101,6 +96,8 @@ class HomeFragment : BaseFragment() { ...@@ -101,6 +96,8 @@ class HomeFragment : BaseFragment() {
viewPager?.adapter = adapter viewPager?.adapter = adapter
id_fragment_home_tab?.setViewPager(viewPager) id_fragment_home_tab?.setViewPager(viewPager)
id_fragment_home_tab?.overScrollMode = View.OVER_SCROLL_NEVER id_fragment_home_tab?.overScrollMode = View.OVER_SCROLL_NEVER
id_fragment_home_tab?.notifyDataSetChanged()
} }
......
package com.zxbw.modulemain.fragment package com.zxbw.modulemain.fragment
import android.content.Intent
import android.view.View import android.view.View
import androidx.recyclerview.widget.GridLayoutManager import androidx.recyclerview.widget.GridLayoutManager
import androidx.recyclerview.widget.LinearLayoutManager import androidx.recyclerview.widget.LinearLayoutManager
import com.scwang.smart.refresh.footer.ClassicsFooter
import com.scwang.smart.refresh.header.ClassicsHeader
import com.zxbw.modulemain.R import com.zxbw.modulemain.R
import com.zxbw.modulemain.activity.TbGoodsDetailActivity
import com.zxbw.modulemain.adapter.GoodsListAdapter import com.zxbw.modulemain.adapter.GoodsListAdapter
import com.zxbw.modulemain.adapter.HomeRecommendAdapter
import com.zxbw.modulemain.adapter.JgqQyAdapter import com.zxbw.modulemain.adapter.JgqQyAdapter
import com.zxbw.modulemain.adapter.ZeroBuyGoodsListAdapter import com.zxbw.modulemain.adapter.ZeroBuyGoodsListAdapter
import com.zxbw.modulemain.contract.HomeRecommendContract import com.zxbw.modulemain.contract.HomeRecommendContract
import com.zxbw.modulemain.presenter.HomeRecommendPresenter import com.zxbw.modulemain.presenter.HomeRecommendPresenter
import com.zxhl.cms.common.base.BaseFragment import com.zxhl.cms.common.base.BaseFragment
import com.zxhl.cms.net.model.qy.JgqQyEntity import com.zxhl.cms.net.model.qy.JgqQyEntity
import com.zxhl.cms.net.model.qy.TbGoodsItemEntity
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.fragment_layout_recommend.* import kotlinx.android.synthetic.main.fragment_layout_recommend.*
...@@ -20,13 +26,12 @@ import kotlinx.android.synthetic.main.fragment_layout_recommend.* ...@@ -20,13 +26,12 @@ import kotlinx.android.synthetic.main.fragment_layout_recommend.*
* @datetime 2022-05-20 19:01 GMT+8 * @datetime 2022-05-20 19:01 GMT+8
* @detail : 首页推荐 * @detail : 首页推荐
*/ */
class RecommendFragment : BaseFragment, HomeRecommendContract.View { class RecommendFragment : BaseFragment, HomeRecommendContract.View,
OnRecycleItemClickListener<TbGoodsItemEntity> {
private val title: String private val title: String
private var mPresenter: HomeRecommendPresenter? = null private var mPresenter: HomeRecommendPresenter? = null
private var mJgqQyAdapter: JgqQyAdapter? = null; private var mGoodsAdapter: HomeRecommendAdapter? = null;
private var mZeroBuyAdapter: ZeroBuyGoodsListAdapter? = null;
private var mGoodsAdapter: GoodsListAdapter? = null;
override fun layoutID(): Int { override fun layoutID(): Int {
return R.layout.fragment_layout_recommend return R.layout.fragment_layout_recommend
...@@ -35,39 +40,38 @@ class RecommendFragment : BaseFragment, HomeRecommendContract.View { ...@@ -35,39 +40,38 @@ class RecommendFragment : BaseFragment, HomeRecommendContract.View {
override fun init(view: View?) { override fun init(view: View?) {
mPresenter = HomeRecommendPresenter(this) mPresenter = HomeRecommendPresenter(this)
mJgqQyAdapter = JgqQyAdapter(activity,
OnRecycleItemClickListener<JgqQyEntity> { view, position, data -> mGoodsAdapter = HomeRecommendAdapter(activity, this)
JumpUtils.RightsDetailJump(data.brand, data.icon) mGoodsAdapter?.IsShowQyView(title == "推荐")
})
mZeroBuyAdapter = ZeroBuyGoodsListAdapter(activity,
OnRecycleItemClickListener<Any> { view, position, data ->
JumpUtils.ZeroBuyJump()
})
mGoodsAdapter = GoodsListAdapter(activity,
OnRecycleItemClickListener<Any> { view, position, data ->
showToast("postion" + position)
JumpUtils.TbGoodsDetailJump()
})
//金刚区权益
val gridLayoutManager = GridLayoutManager(activity, 3)
gridLayoutManager.orientation = LinearLayoutManager.HORIZONTAL
id_rcl_jgq_qy_list?.layoutManager = gridLayoutManager
id_rcl_jgq_qy_list.adapter = mJgqQyAdapter
//零元购
id_rcl_zero_buy_goods?.layoutManager = GridLayoutManager(activity, 3)
id_rcl_zero_buy_goods.adapter = mZeroBuyAdapter
//底部商品列表 //底部商品列表
id_rcl_goods_list?.layoutManager = LinearLayoutManager(activity) id_rcl_goods_list?.layoutManager = LinearLayoutManager(activity)
id_rcl_goods_list.adapter = mGoodsAdapter id_rcl_goods_list.adapter = mGoodsAdapter
id_refresh_view.setRefreshHeader(ClassicsHeader(activity))
id_ll_zero_buy_view.setOnClickListener { id_refresh_view.setRefreshFooter(ClassicsFooter(activity))
JumpUtils.ZeroBuyJump() id_refresh_view.setOnRefreshListener {
// it.finishRefresh(2000/*,false*/);//传入false表示加载失败
if (title.equals("猜你喜欢")) {
mPresenter?.getGuessLikeGoodsList(true)
} else {
mPresenter?.getTbGoodsList(true, title)
}
}
id_refresh_view.setOnLoadMoreListener {
// it.finishLoadMore(2000/*,false*/);//传入false表示加载失败
if (title.equals("猜你喜欢")) {
mPresenter?.getGuessLikeGoodsList(false)
} else {
mPresenter?.getTbGoodsList(false, title)
}
} }
mPresenter?.getQyCardList() mPresenter?.getQyCardList(title)
if (title.equals("猜你喜欢")) {
mPresenter?.getGuessLikeGoodsList(true)
} else {
mPresenter?.getTbGoodsList(true, title)
}
} }
companion object { companion object {
...@@ -84,9 +88,34 @@ class RecommendFragment : BaseFragment, HomeRecommendContract.View { ...@@ -84,9 +88,34 @@ class RecommendFragment : BaseFragment, HomeRecommendContract.View {
this.title = "" this.title = ""
} }
override fun setQyCardList(result: List<JgqQyEntity>) { override fun setQyCardList(result: List<JgqQyEntity>?) {
mJgqQyAdapter?.clear() if (!result.isNullOrEmpty()) {
mJgqQyAdapter?.appendToList(result) mGoodsAdapter?.updateHomeQyData(result)
}
}
override fun setTbGoodsList(isRefresh: Boolean, result: List<TbGoodsItemEntity>?) {
if (isRefresh){
id_refresh_view.finishRefresh(!result.isNullOrEmpty());//传入false表示加载失败
}else{
id_refresh_view.finishLoadMore(!result.isNullOrEmpty());//传入false表示加载失败
}
if (isRefresh && !result.isNullOrEmpty()) {
mGoodsAdapter?.clear()
}
if (!result.isNullOrEmpty()) {
mGoodsAdapter?.appendToList(result)
}
}
override fun onItemClick(view: View?, position: Int, data: TbGoodsItemEntity?) {
// JumpUtils.TbGoodsDetailJump()
var intent = Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.putExtra("goods", data)
intent.setClass(activity!!, TbGoodsDetailActivity().javaClass)
activity?.startActivity(intent)
} }
} }
\ No newline at end of file
package com.zxbw.modulemain.presenter package com.zxbw.modulemain.presenter
import android.content.Context
import android.text.TextUtils
import android.util.Log import android.util.Log
import com.zxbw.modulemain.contract.HomeRecommendContract import com.zxbw.modulemain.contract.HomeRecommendContract
import com.zxbw.modulemain.contract.LoginContract
import com.zxhl.cms.net.ApiClient import com.zxhl.cms.net.ApiClient
import com.zxhl.cms.net.RxSchedulers import com.zxhl.cms.net.RxSchedulers
import com.zxhl.cms.net.SettingPreference
import com.zxhl.cms.net.callback.BaseObserver import com.zxhl.cms.net.callback.BaseObserver
import com.zxhl.cms.net.model.qy.JgqQyEntity import com.zxhl.cms.net.model.qy.JgqQyEntity
import com.zxhl.cms.net.model.uc.UserInfo import com.zxhl.cms.net.model.qy.TbGoodsEntity
import com.zxhl.cms.utils.EventUtils
import com.zxhl.cms.utils.UserDataUtils
/** /**
* 推荐 * 推荐
*/ */
class HomeRecommendPresenter:HomeRecommendContract.Presenter { class HomeRecommendPresenter : HomeRecommendContract.Presenter {
private val mView: HomeRecommendContract.View private val mView: HomeRecommendContract.View
...@@ -25,17 +19,67 @@ class HomeRecommendPresenter:HomeRecommendContract.Presenter { ...@@ -25,17 +19,67 @@ class HomeRecommendPresenter:HomeRecommendContract.Presenter {
this.mView = mView this.mView = mView
} }
override fun getQyCardList() { override fun getQyCardList(tabName: String) {
if (tabName != "推荐") {
mView.setQyCardList(null)
return
}
ApiClient.homeApi.getQyJgqCardList().compose(RxSchedulers.observableIO2Main()) ApiClient.homeApi.getQyJgqCardList().compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<List<JgqQyEntity>>() { .subscribe(object : BaseObserver<List<JgqQyEntity>>() {
override fun onSuccess(result: List<JgqQyEntity>?) { override fun onSuccess(result: List<JgqQyEntity>?) {
if(!result.isNullOrEmpty()){ mView.setQyCardList(result)
mView.setQyCardList(result) }
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
mView.setQyCardList(null)
}
})
}
private var searchPage = 1;
private var pageSize = 20;
override fun getTbGoodsList(isRefresh: Boolean, cate: String) {
if (isRefresh) {
searchPage = 1;
}
ApiClient.homeApi.getGoodsListSearch(cate, cate, searchPage, pageSize)
.compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<TbGoodsEntity>() {
override fun onSuccess(result: TbGoodsEntity?) {
if (result != null) {
searchPage++;
mView.setTbGoodsList(isRefresh, result.result_list)
} else {
mView.setTbGoodsList(isRefresh, null)
} }
} }
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) { override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
Log.d("wxw", "code$code")
mView.setTbGoodsList(isRefresh, null)
}
})
}
private var guessLikePage = 1;
override fun getGuessLikeGoodsList(isRefresh: Boolean) {
if (isRefresh) {
guessLikePage = 1;
}
ApiClient.homeApi.getGoodsGuessLike(guessLikePage, pageSize)
.compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<TbGoodsEntity>() {
override fun onSuccess(result: TbGoodsEntity?) {
if (result != null) {
guessLikePage++;
mView.setTbGoodsList(isRefresh, result.data)
} else {
mView.setTbGoodsList(isRefresh, null)
}
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
mView.setTbGoodsList(isRefresh, null)
} }
}) })
} }
......
package com.zxbw.modulemain.presenter
import android.app.Activity
import android.text.TextUtils
import android.util.Log
import com.zxbw.modulemain.contract.RightsPayContract
import com.zxbw.modulemain.contract.TbGoodsDetailContract
import com.zxhl.cms.AppContext
import com.zxhl.cms.net.ApiClient
import com.zxhl.cms.net.RxSchedulers
import com.zxhl.cms.net.SettingPreference
import com.zxhl.cms.net.callback.BaseObserver
import com.zxhl.cms.net.model.box.AppInEntity
import com.zxhl.cms.net.model.box.BoxInfoEntity
import com.zxhl.cms.net.model.box.VerifacationEntity
import com.zxhl.cms.net.model.qy.TbGoodsEntity
import com.zxhl.cms.net.model.uc.AliPayEntity
import com.zxhl.cms.net.model.uc.PayMinEntity
import com.zxhl.cms.net.model.uc.PayVerifyEntity
import com.zxhl.cms.net.model.uc.WeChatPayEntity
import com.zxhl.cms.net.model.video.MemberEntity
import com.zxhl.cms.pay.alipay.AlipayServer
import com.zxhl.cms.utils.EventUtils
import com.zxhl.cms.utils.JumpUtils
import com.zxhl.cms.utils.UserDataUtils
import com.zxhl.cms.utils.WeChatPay
import org.json.JSONObject
/**
*商品详情
*/
class TbGoodsDetailPresenter : TbGoodsDetailContract.Presenter {
private val mView: TbGoodsDetailContract.View
constructor(mView: TbGoodsDetailContract.View) {
this.mView = mView
}
override fun getConvertLink(link: String) {
ApiClient.homeApi.getGoodsConvertLink(link)
.compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<TbGoodsEntity>() {
override fun onSuccess(result: TbGoodsEntity?) {
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
}
})
}
override fun getGoodsDetail(productId: String) {
ApiClient.homeApi.getGoodsImgDetail(productId)
.compose(RxSchedulers.observableIO2Main())
.subscribe(object : BaseObserver<TbGoodsEntity>() {
override fun onSuccess(result: TbGoodsEntity?) {
}
override fun onFailure(e: Throwable?, code: String?, errorMsg: String?) {
}
})
}
}
\ No newline at end of file
package com.zxbw.modulemain.view;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import androidx.viewpager.widget.ViewPager;
/**
* @author (wangXuewei)
* @datetime 2022-05-27 03:20 GMT+8
* @detail :
*/
public class ViewPagerForRecyclerView extends ViewPager {
public ViewPagerForRecyclerView(Context context) {
super(context);
}
public ViewPagerForRecyclerView(Context context, AttributeSet attrs) {
super(context, attrs);
}
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int height = 0;
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
child.measure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
int h = child.getMeasuredHeight();
if (h > height)
height = h;
}
heightMeasureSpec = MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY);
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
}
}
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:background="#F6F6F6"> android:background="#F6F6F6">
<View <View
...@@ -22,14 +23,10 @@ ...@@ -22,14 +23,10 @@
<RelativeLayout <RelativeLayout
android:id="@+id/id_rl_top_view" android:id="@+id/id_rl_top_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:visibility="gone"
android:layout_height="360dp" android:layout_height="360dp"
android:background="@drawable/img_tb_goods_detail_title_bg"> android:background="@drawable/img_tb_goods_detail_title_bg">
<androidx.viewpager.widget.ViewPager
android:id="@+id/id_detail_top_viewpager"
android:layout_width="match_parent"
android:layout_height="match_parent" />
<TextView <TextView
android:id="@+id/id_tv_detail_title" android:id="@+id/id_tv_detail_title"
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -103,6 +100,22 @@ ...@@ -103,6 +100,22 @@
android:textSize="18sp" android:textSize="18sp"
android:textStyle="bold" /> android:textStyle="bold" />
</RelativeLayout>
<!-- 商品图片信息-->
<RelativeLayout
android:id="@+id/id_rl_top_view2"
android:layout_width="match_parent"
android:layout_height="360dp">
<com.zhpan.bannerview.BannerViewPager
android:id="@+id/id_detail_top_banner"
android:layout_width="match_parent"
app:bvp_can_loop="false"
app:bvp_indicator_visibility="gone"
app:bvp_auto_play="false"
android:layout_height="match_parent"/>
<TextView <TextView
android:id="@+id/id_tv_vp_index" android:id="@+id/id_tv_vp_index"
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -119,7 +132,6 @@ ...@@ -119,7 +132,6 @@
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="14sp" /> android:textSize="14sp" />
</RelativeLayout> </RelativeLayout>
<ImageView <ImageView
android:id="@+id/id_img_close_btn" android:id="@+id/id_img_close_btn"
android:layout_width="wrap_content" android:layout_width="wrap_content"
...@@ -132,7 +144,7 @@ ...@@ -132,7 +144,7 @@
android:id="@+id/id_rl_price_view" android:id="@+id/id_rl_price_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_below="@+id/id_rl_top_view" android:layout_below="@+id/id_rl_top_view2"
android:background="@color/white"> android:background="@color/white">
<LinearLayout <LinearLayout
......
...@@ -22,10 +22,32 @@ ...@@ -22,10 +22,32 @@
tl:layout_scrollFlags="scroll|exitUntilCollapsed" tl:layout_scrollFlags="scroll|exitUntilCollapsed"
tl:titleEnabled="false"> tl:titleEnabled="false">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="280dp">
<androidx.viewpager.widget.ViewPager
android:id="@+id/id_home_top_banner"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<com.zhpan.indicator.IndicatorView
android:id="@+id/indicator_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tl:vpi_slider_checked_color="@color/white"
tl:vpi_slider_normal_color="#80ffffff"
tl:vpi_slider_radius="3dp"
android:layout_marginBottom="50dp"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true" />
</RelativeLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/id_rcl_top_banner" android:id="@+id/id_rcl_top_banner"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content" />
<androidx.appcompat.widget.Toolbar <androidx.appcompat.widget.Toolbar
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -51,7 +73,8 @@ ...@@ -51,7 +73,8 @@
android:layout_below="@+id/id_title_sys_bar_view" android:layout_below="@+id/id_title_sys_bar_view"
android:layout_marginLeft="15dp" android:layout_marginLeft="15dp"
android:layout_marginRight="15dp" android:layout_marginRight="15dp"
android:background="@drawable/shape_ffffff_r20"> android:background="@drawable/shape_ffffff_r20"
android:visibility="gone">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
......
...@@ -6,97 +6,15 @@ ...@@ -6,97 +6,15 @@
android:background="#F8F8F8"> android:background="#F8F8F8">
<androidx.core.widget.NestedScrollView <com.scwang.smart.refresh.layout.SmartRefreshLayout
android:id="@+id/id_refresh_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent">
<LinearLayout <androidx.recyclerview.widget.RecyclerView
android:id="@+id/id_rcl_goods_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent" />
android:orientation="vertical"> </com.scwang.smart.refresh.layout.SmartRefreshLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/id_rcl_jgq_qy_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<LinearLayout
android:id="@+id/id_ll_zero_buy_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:background="@drawable/shape_f25e47_r15"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginTop="10dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="新人首单0元购"
android:textColor="@color/white"
android:textSize="16sp"
android:textStyle="bold" />
<View
android:layout_width="1dp"
android:layout_height="12dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#80ffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="限时限量抢好物"
android:textColor="@color/white"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="20dp"
android:background="@drawable/shape_ffffff_r10"
android:gravity="center"
android:paddingLeft="9dp"
android:paddingRight="8dp"
android:text="查看更多 >"
android:textColor="#F25E47"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/id_rcl_zero_buy_goods"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/id_rcl_goods_list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</RelativeLayout> </RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/id_ll_detail_item"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/id_img_detail_banner_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
</LinearLayout>
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp"
android:background="@drawable/shape_ffffff_r10" android:background="@drawable/shape_ffffff_r10"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="horizontal" android:orientation="horizontal"
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
<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:id="@+id/id_ll_item"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:orientation="horizontal"> android:orientation="horizontal">
<ImageView <ImageView
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/id_rcl_home_jgq_qy_grid_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/id_rl_home_qy_item_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="20dp"
android:background="@color/white"
android:gravity="center_horizontal"
android:orientation="horizontal">
<com.zxbw.modulemain.view.ViewPagerForRecyclerView
android:id="@+id/id_vp_home_jgq_qy_list"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
<com.zhpan.indicator.IndicatorView
android:id="@+id/id_qy_indicator_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignBottom="@+id/id_vp_home_jgq_qy_list"
app:vpi_slider_checked_color="#F1352C"
app:vpi_slider_normal_color="#E8DFDF"
app:vpi_slider_radius="3dp" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/id_rl_home_zero_buy_item_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginBottom="10dp"
android:background="@drawable/shape_ffffff_r10"
android:gravity="center_horizontal"
android:orientation="horizontal"
android:padding="10dp">
<LinearLayout
android:id="@+id/id_ll_zero_buy_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:background="@drawable/shape_f25e47_r15"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginTop="10dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="10dp"
android:gravity="center_vertical"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="新人首单0元购"
android:textColor="@color/white"
android:textSize="16sp"
android:textStyle="bold" />
<View
android:layout_width="1dp"
android:layout_height="12dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#80ffffff" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="限时限量抢好物"
android:textColor="@color/white"
android:textSize="12sp"
android:textStyle="bold" />
<TextView
android:layout_width="wrap_content"
android:layout_height="20dp"
android:background="@drawable/shape_ffffff_r10"
android:gravity="center"
android:paddingLeft="9dp"
android:paddingRight="8dp"
android:text="查看更多 >"
android:textColor="#F25E47"
android:textSize="12sp"
android:textStyle="bold" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/id_rcl_zero_buy_goods"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="12dp" />
</LinearLayout>
</RelativeLayout>
\ 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_qy_item_view" android:id="@+id/id_ll_qy_item_view"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginTop="10dp" android:layout_marginTop="10dp"
android:layout_marginRight="12dp"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
android:gravity="center_horizontal" android:gravity="center_horizontal"
android:orientation="vertical"> android:orientation="vertical">
......
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