Commit 4aaa457d authored by mengcuiguang's avatar mengcuiguang

首页添加接口、业务逻辑

parent 3f929fbe
......@@ -7,29 +7,10 @@ import java.io.Serializable
@SuppressLint("ParcelCreator")
@Parcelize
data class HotStyleListBean(
val list: List<HotStyleBean>
) : Parcelable
@SuppressLint("ParcelCreator")
@Parcelize
data class HotStyleTypesListBean(
data class HotStyleTypesList(
val list: List<HotStyleTypesBean>
) : Parcelable
@SuppressLint("ParcelCreator")
@Parcelize
data class HotStyleBean(
var effectUrl: String? = null,
var imageUrl: String? = null,
var topUrl: String? = null,
var imageid: Int? = 0,
var lock: Boolean? = false,
var name: String? = null,
var isChecked: Boolean = false,
var remark: String? = null,
var typeId: Int = 0,
) : Parcelable
@SuppressLint("ParcelCreator")
......@@ -39,9 +20,3 @@ data class HotStyleTypesBean(
var torder: Int = 0
) : Parcelable
@SuppressLint("ParcelCreator")
@Parcelize
data class HotStyleMsgBean(
val images: List<HotStyleBean>,
val types: List<HotStyleTypesBean>
) : Parcelable
package com.mints.wisdomclean.mvp.model;
import java.io.Serializable;
import java.util.ArrayList;
public class VedioBean implements Serializable {
......@@ -9,7 +10,7 @@ public class VedioBean implements Serializable {
private String title;
private String type;
private String topTabsReamrk;
private Object orderTags;
private ArrayList<String> orderTags;//标签
private int vedioTotal;//同穿山甲 total
private String vedioDesc;
private String coverImage;
......@@ -58,11 +59,11 @@ public class VedioBean implements Serializable {
this.topTabsReamrk = topTabsReamrk;
}
public Object getOrderTags() {
public ArrayList<String> getOrderTags() {
return orderTags;
}
public void setOrderTags(Object orderTags) {
public void setOrderTags(ArrayList<String> orderTags) {
this.orderTags = orderTags;
}
......
......@@ -16,7 +16,7 @@ class HomePresenter : BasePresenter<HomeView>() {
fun getHomeV1Types() {
AppHttpManager.getInstance(loanApplication)
.call(loanService.homeV1Types,
object : BaseSubscriber<BaseResponse<HotStyleTypesListBean>>() {
object : BaseSubscriber<BaseResponse<HotStyleTypesList>>() {
override fun onCompleted() {
if (isLinkView) return
}
......@@ -26,7 +26,7 @@ class HomePresenter : BasePresenter<HomeView>() {
view.showToast(e.message)
}
override fun onNext(baseResponse: BaseResponse<HotStyleTypesListBean>) {
override fun onNext(baseResponse: BaseResponse<HotStyleTypesList>) {
if (isLinkView) return
val code = baseResponse.status
......@@ -176,9 +176,9 @@ class HomePresenter : BasePresenter<HomeView>() {
val code = baseResponse.status
when (code) {
200 -> {
getHomeV1Types()
topTabs()
orders()
getHomeV1Types()
}
}
}
......
package com.mints.wisdomclean.mvp.presenters
import com.mints.wisdomclean.common.AppConfig
import com.mints.wisdomclean.manager.AppHttpManager
import com.mints.wisdomclean.mvp.model.BaseResponse
import com.mints.wisdomclean.mvp.model.HotStyleListBean
import com.mints.wisdomclean.mvp.views.PicContentView
import com.mints.library.net.neterror.BaseSubscriber
import com.mints.library.net.neterror.Throwable
import com.mints.wisdomclean.mvp.model.BannerList
class PicContentPresenter : BasePresenter<PicContentView>() {
fun getHomePageImageList(typeId: Int, page: Int, pageCount: Int) {
fun getHomePageImageList(type: String, page: Int, pageCount: Int) {
val vo = hashMapOf<String, Any>()
vo["typeId"] = typeId
vo["type"] = type
vo["page"] = page
vo["size"] = pageCount
AppHttpManager.getInstance(loanApplication)
.call(loanService.getHomeV1List(vo),
object : BaseSubscriber<BaseResponse<HotStyleListBean>>() {
object : BaseSubscriber<BaseResponse<BannerList>>() {
override fun onCompleted() {
if (isLinkView) return
}
......@@ -29,7 +28,7 @@ class PicContentPresenter : BasePresenter<PicContentView>() {
view.getHomePageImageListFail()
}
override fun onNext(baseResponse: BaseResponse<HotStyleListBean>) {
override fun onNext(baseResponse: BaseResponse<BannerList>) {
if (isLinkView) return
val code = baseResponse.status
......
package com.mints.wisdomclean.mvp.views
import com.mints.wisdomclean.mvp.model.BannerList
import com.mints.wisdomclean.mvp.model.HotStyleTypesListBean
import com.mints.wisdomclean.mvp.model.HotStyleTypesList
interface HomeView : BaseView {
fun getHomeV1MsgSuc(data: HotStyleTypesListBean)
fun topTabsSuc(data: BannerList)
fun ordersSuc(data: BannerList)
fun getHomeV1MsgSuc(data: HotStyleTypesList)
fun topTabsSuc(data: BannerList?)
fun ordersSuc(data: BannerList?)
}
......@@ -3,6 +3,6 @@ package com.mints.wisdomclean.mvp.views
import com.mints.wisdomclean.mvp.model.*
interface PicContentView : BaseView {
fun getHomePageImageListSuc(data: HotStyleListBean)
fun getHomePageImageListSuc(data: BannerList)
fun getHomePageImageListFail()
}
......@@ -7,8 +7,8 @@ import com.google.gson.JsonObject;
import com.mints.wisdomclean.BuildConfig;
import com.mints.wisdomclean.mvp.model.BannerList;
import com.mints.wisdomclean.mvp.model.BaseResponse;
import com.mints.wisdomclean.mvp.model.HotStyleListBean;
import com.mints.wisdomclean.mvp.model.HotStyleTypesListBean;
import com.mints.wisdomclean.mvp.model.BannerList;
import com.mints.wisdomclean.mvp.model.HotStyleTypesList;
import com.mints.wisdomclean.mvp.model.OrderRecordBean;
import com.mints.wisdomclean.mvp.model.UserBean;
import com.mints.wisdomclean.mvp.model.Version;
......@@ -166,15 +166,15 @@ public interface LoanService {
* @return
*/
@POST("api/vedio/types")
Observable<BaseResponse<HotStyleTypesListBean>> getHomeV1Types();
Observable<BaseResponse<HotStyleTypesList>> getHomeV1Types();
/**
* 首页列表
*
* @return
*/
@POST("api/ai/homeV1List")
Observable<BaseResponse<HotStyleListBean>> getHomeV1List(@Body Map<String, Object> vo);
@POST("api/vedio/listByType")
Observable<BaseResponse<BannerList>> getHomeV1List(@Body Map<String, Object> vo);
/**
* 用户反馈
......
......@@ -23,7 +23,7 @@ class HomeVideoPageAdapter(
val fragment = fragments[position]
if (fragment != null) return fragment
val newFragment = MovieFragment.newInstance(data[position].torder,position)
val newFragment = MovieFragment.newInstance(data[position].type,position)
fragments[position] = newFragment
return newFragment
}
......
......@@ -10,11 +10,11 @@ import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.mints.library.utils.GlideUtils
import com.mints.wisdomclean.R
import com.mints.wisdomclean.mvp.model.HotStyleBean
import com.mints.wisdomclean.mvp.model.VedioBean
import com.mints.wisdomclean.ui.adapter.base.OnItemClickListener
class HotStyleAdapter(val context: Context, val dataList: ArrayList<HotStyleBean>) :
class HotStyleAdapter(val context: Context, val dataList: ArrayList<VedioBean>) :
RecyclerView.Adapter<HotStyleAdapter.ViewHolder>() {
lateinit var mOnItemClickListener: OnItemClickListener
......@@ -32,44 +32,19 @@ class HotStyleAdapter(val context: Context, val dataList: ArrayList<HotStyleBean
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
// if (dataList.size > 0) {
// val data = dataList[position]
// if (position == 0 && showAnim) {
// val lottieDrawable = LottieDrawable()
// LottieCompositionFactory.fromAsset(context, "guide_template_category.json")
// .addListener { result: LottieComposition? ->
// lottieDrawable.setImagesAssetsFolder("guild_template_category/")
// lottieDrawable.composition = result
// lottieDrawable.loop(true)
// lottieDrawable.playAnimation()
// }
// holder.ivXmlyPage.setImageDrawable(lottieDrawable)
// holder.ivXmlyPage.visibility = View.VISIBLE
// holder.tvHotBtn.visibility = View.VISIBLE
// holder.rivXmlyPage.visibility = View.GONE
// holder.tvHotBtn.postDelayed({
// YoYo.with(Techniques.Pulse).duration(500).repeat(-1).playOn(holder.tvHotBtn)
// }, 300)
// } else {
//// GlideUtils.loadRoundImageViewGif(
//// holder.itemView.context,
//// data.imageUrl!!,
//// holder.rivXmlyPage
//// )
// holder.ivXmlyPage.visibility = View.GONE
// holder.tvHotBtn.visibility = View.GONE
// holder.rivXmlyPage.visibility = View.VISIBLE
// }
// viewHolder.tvTitle.text = data.name
//
// }
// GlideUtils.loadImageViewGifForFitCenter(
// context,
// "https://mints-pkg.oss-cn-beijing.aliyuncs.com/pkg-bcurd/img/bg_vip_top3.png",
// holder.ivVedioItem
// )
val topBean = dataList?.get(position)
if (topBean != null) {
holder.tvVedioItemCount.text =
"${if (topBean.completeStatus == 0) "已完结" else "更新至${topBean.vedioTotal}"}"
holder.tvVedioItemTitle.text = "${topBean.title}"
holder.tvVedioItemText.text = "${topBean.topTabsReamrk}"
GlideUtils.loadImageViewGifForFitCenter(
context,
topBean.coverImage,
holder.ivVedioItem
)
}
holder.itemView.setOnClickListener {
mOnItemClickListener.onItemClick(holder.itemView, position)
......
......@@ -36,13 +36,24 @@ class TopAdapter(val topList: MutableList<VedioBean>?) :
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
// val topBean = topList[position]
val topBean = topList?.get(position)
if (topBean != null) {
holder.tvTopItemLable.text = "${position + 1}"
holder.tvTopItemTitle.text = "${topBean.title}"
if (topBean.orderTags != null && topBean.orderTags.size > 0) {
val sb = StringBuilder()
for (i in 0 until topBean.orderTags.size) {
sb.append(topBean.orderTags.get(i) + " ")
}
holder.tvTopItemText.text = "${sb}"
}
GlideUtils.loadImageViewGifForFitCenter(
context,
"https://mints-pkg.oss-cn-beijing.aliyuncs.com/pkg-bcurd/img/bg_vip_top1.png",
topBean.coverImage,
holder.ivTopItem
)
}
when (position) {
......
......@@ -104,7 +104,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
R.id.tv_main_watching_goto -> {
val cacheVedio = LocalVedioManager.getCacheVedio()
if (cacheVedio != null) {
LocalVedioManager.startVedioDetailActivityForType(requireActivity(), null)
LocalVedioManager.startVedioDetailActivityForType(requireActivity(), cacheVedio)
}
}
}
......@@ -120,9 +120,9 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
//获取游客登录数据
homePresenter.userLogin()
} else {
homePresenter.getHomeV1Types()
homePresenter.topTabs()
homePresenter.orders()
homePresenter.getHomeV1Types()
}
}
}
......@@ -136,7 +136,12 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
rv_main_list.adapter = topAdapter
topAdapter?.setOnItemClickListener(object : TopAdapter.OnItemClickListener {
override fun onItemClick(position: Int) {
LocalVedioManager.startVedioDetailActivityForType(requireActivity(), null)
if (topList.size > 0) {
LocalVedioManager.startVedioDetailActivityForType(
requireActivity(),
topList.get(position)
)
}
}
})
......@@ -216,7 +221,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
// }
}
override fun getHomeV1MsgSuc(data: HotStyleTypesListBean) {
override fun getHomeV1MsgSuc(data: HotStyleTypesList) {
tabsData.clear()
tabsData.addAll(data.list)
if (tabsData.isNotEmpty()) {
......@@ -225,7 +230,7 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
}
}
override fun topTabsSuc(data: BannerList) {
override fun topTabsSuc(data: BannerList?) {
if (data != null && data.list != null && data.list.size > 0) {
bannerList.clear()
for (i in 0 until data.list.size) {
......@@ -237,15 +242,20 @@ class MainFragment : LazyLoadBaseFragment(), HomeView, View.OnClickListener, OnR
banner.addBannerLifecycleObserver(this)
.setAdapter(ImageTitleAdapter(bannerList))
.setOnBannerListener { data, position ->
LocalVedioManager.startVedioDetailActivityForType(requireActivity(), null)
.setOnBannerListener { data2, position ->
LocalVedioManager.startVedioDetailActivityForType(
requireActivity(),
data.list.get(position)
)
}
}
}
override fun ordersSuc(data: BannerList) {
override fun ordersSuc(data: BannerList?) {
topList.clear()
if (data != null) {
topList.addAll(data.list)
}
topAdapter?.notifyDataSetChanged()
}
}
\ No newline at end of file
......@@ -20,16 +20,16 @@ import java.util.*
class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener {
private var mType = 0
private var mType = ""
private var mPosition = 0 // 首页-第一个tab-第一个recyclerview Item
companion object {
private const val VIDEO_TYPE = "VIDEO_TYPE"
private const val VIDEO_POSITION = "VIDEO_POSITION"
fun newInstance(type: Int, position: Int): Fragment {
fun newInstance(type: String, position: Int): Fragment {
val args = Bundle()
args.putInt(VIDEO_TYPE, type)
args.putString(VIDEO_TYPE, type)
args.putInt(VIDEO_POSITION, position)
val fragment = MovieFragment()
fragment.arguments = args
......@@ -40,7 +40,7 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
private val picContentPresenter by lazy { PicContentPresenter() }
private var hotPage = 1 // 分页
private val hotList: ArrayList<HotStyleBean> = arrayListOf()
private val hotList: ArrayList<VedioBean> = arrayListOf()
private lateinit var hotStyleAdapter: HotStyleAdapter
private var mCurrentPosition = 0
......@@ -48,7 +48,7 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
override fun initViewsAndEvents() {
arguments?.let {
mType = it.getInt(VIDEO_TYPE, mType)
mType = it.getString(VIDEO_TYPE, mType)
mPosition = it.getInt(VIDEO_POSITION, mPosition)
}
}
......@@ -89,7 +89,7 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
picContentPresenter.getHomePageImageList(mType, hotPage, Constant.PAGE_SIZE)
}
override fun getHomePageImageListSuc(data: HotStyleListBean) {
override fun getHomePageImageListSuc(data: BannerList) {
if (activity == null || requireActivity().isFinishing) {
srlMainPage?.finishRefresh(true)
return
......@@ -121,11 +121,12 @@ class MovieFragment : LazyLoadBaseFragment(), PicContentView, OnLoadMoreListener
rv_pic_list.adapter = hotStyleAdapter
hotStyleAdapter.setOnItemClickListener(object : OnItemClickListener {
override fun onItemClick(view: View?, position: Int) {
// if (hotList.size > 0) {
//
// }
LocalVedioManager.startVedioDetailActivityForType(requireActivity(),null)
// showToast(position.toString())
if (hotList.size > 0) {
LocalVedioManager.startVedioDetailActivityForType(
requireActivity(),
hotList.get(position)
)
}
}
})
}
......
......@@ -19,8 +19,7 @@
android:id="@+id/ivVedioItem"
android:layout_width="110dp"
android:layout_height="150dp"
android:scaleType="fitXY"
android:background="#0ff" />
android:scaleType="fitXY" />
<TextView
android:id="@+id/tvVedioItemCount"
......
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