Commit 0c424149 authored by 王雪伟's avatar 王雪伟

[提交人]:王雪伟

[提交简述] :小象省钱
[实现方案] :修改banner
parent fe9628ae
package com.zxbw.modulemain.adapter
import android.app.Activity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.zxbw.modulemain.R
import com.zxhl.cms.AppContext
import com.zxhl.cms.common.base.BaseRecyclerAdapter
import com.zxhl.cms.utils.OnRecycleItemClickListener
import com.zxhl.cms.widget.RecycleImageView
class HomeBannerAdapter : BaseRecyclerAdapter<Any, HomeBannerAdapter.ViewHolder> {
private var mContext: Activity? = null
private val listener: OnRecycleItemClickListener<Any>
constructor(
content: Activity?,
listener: OnRecycleItemClickListener<Any>
) : super() {
mContext = content
this.listener = listener
}
override fun onBindViewHolder(holder: ViewHolder, position: Int) {
holder.id_ll_item?.setOnClickListener {
listener.onItemClick(it, position, null)
}
}
override fun getItemCount(): Int {
return 3
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ViewHolder {
return ViewHolder(
LayoutInflater.from(AppContext.get())
.inflate(R.layout.item_layout_home_banner, parent, false)
)
}
class ViewHolder : RecyclerView.ViewHolder {
var id_ll_item: LinearLayout?
constructor(
itemView: View
) : super(itemView) {
id_ll_item =
itemView.findViewById<LinearLayout>(R.id.id_ll_item)
}
}
}
\ No newline at end of file
......@@ -2,13 +2,17 @@ package com.zxbw.modulemain.fragment
import android.util.Log
import android.view.View
import androidx.recyclerview.widget.LinearLayoutManager
import androidx.recyclerview.widget.PagerSnapHelper
import com.zxbw.modulemain.R
import com.zxbw.modulemain.adapter.HomeBannerAdapter
import com.zxhl.cms.common.FragmentAdapter
import com.zxhl.cms.common.base.BaseFragment
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.box.TabEntity
import com.zxhl.cms.utils.OnRecycleItemClickListener
import kotlinx.android.synthetic.main.fragment_layout_home.*
import me.jessyan.autosize.utils.ScreenUtils
......@@ -17,7 +21,7 @@ import me.jessyan.autosize.utils.ScreenUtils
* Created by gaoleichao on 2021/10/25
*/
class HomeFragment : BaseFragment() {
private var mBannerAdapter: HomeBannerAdapter? = null
override fun layoutID(): Int {
return R.layout.fragment_layout_home
......@@ -33,10 +37,22 @@ class HomeFragment : BaseFragment() {
override fun init(view: View?) {
var statusBarHeight = ScreenUtils.getStatusBarHeight()
if (statusBarHeight<=0){
if (statusBarHeight <= 0) {
statusBarHeight = 40;
}
id_title_sys_bar_view.layoutParams.height = statusBarHeight
mBannerAdapter = HomeBannerAdapter(
activity
) { view, position, data ->
showToast("pos" + position)
}
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()
id_rl_search_view.setOnClickListener {
showToast("搜索")
......
......@@ -22,14 +22,10 @@
tl:layout_scrollFlags="scroll|exitUntilCollapsed"
tl:titleEnabled="false">
<ImageView
android:id="@+id/id_img_banner"
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/id_rcl_top_banner"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/img_banner_ms_bg" />
android:layout_height="wrap_content"/>
<androidx.appcompat.widget.Toolbar
android:layout_width="match_parent"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/id_ll_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="@+id/id_img_banner_bg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:scaleType="fitXY"
android:src="@drawable/img_banner_ms_bg" />
</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