Commit 28cd9e39 authored by wanglei's avatar wanglei

aaa

parent b2ee4c82
Pipeline #1048 failed with stages
package com.test.mydemo3.adapter package com.test.mydemo3.adapter
import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import com.test.mydemo3.R
import com.test.mydemo3.databinding.CleanListItemLayoutBinding
import com.test.mydemo3.databinding.FilesItemLayoutBinding
import com.test.mydemo3.model.CleanBean
import com.test.mydemo3.model.FileBean
class CleanAdapter2 : RecyclerView.Adapter<CleanAdapter2.AAA>() { class CleanAdapter2 : RecyclerView.Adapter<CleanAdapter2.AAA>() {
class AAA(view: View) : RecyclerView.ViewHolder(view) {
private val list = ArrayList<CleanBean>()
fun Int.inflate(parent: ViewGroup, attachToRoot: Boolean = false): View {
return LayoutInflater.from(parent.context).inflate(this, parent, attachToRoot)
}
class AAA(view: View) : RecyclerView.ViewHolder(view) {
val binding = CleanListItemLayoutBinding.bind(view)
} }
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AAA { override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AAA {
TODO("Not yet implemented") return AAA(R.layout.clean_list_item_layout.inflate(parent))
} }
override fun getItemCount(): Int { override fun getItemCount(): Int {
TODO("Not yet implemented") return list.size
} }
override fun onBindViewHolder(holder: AAA, position: Int) { override fun onBindViewHolder(holder: AAA, position: Int) {
TODO("Not yet implemented") val data = list[position]
holder.binding.cleanItemName.text = data.typeName
///展开逻辑
if (data.isListViewShow) {
holder.binding.cleanItemList.visibility = View.VISIBLE
val subAdapter = SubAdapter()
holder.binding.cleanItemList.adapter = subAdapter
subAdapter.setData(data.fileBeans)
} else {
holder.binding.cleanItemList.visibility = View.GONE
}
holder.binding.cleanItemUnfold.setOnClickListener {
data.isListViewShow = !data.isListViewShow
notifyItemChanged(position)
}
//选中的逻辑,先外层通过data的属性值是否选中,点击事假更新子类表选中状态下
} }
fun setData(datas: List<CleanBean>) {
list.clear()
list.addAll(datas)
notifyDataSetChanged()
}
inner Sub inner class SubAdapter : RecyclerView.Adapter<SubAdapter.BBB>() {
private val sibList = ArrayList<FileBean>()
inner class BBB(view: View) : RecyclerView.ViewHolder(view) {
val binding = FilesItemLayoutBinding.bind(view)
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): BBB {
return BBB(R.layout.files_item_layout.inflate(parent))
}
override fun getItemCount(): Int {
return sibList.size
}
override fun onBindViewHolder(holder: BBB, position: Int) {
val data = sibList[position]
holder.binding.fileItemName.text = data.fileName
//todo data通过状态值显示选中状态
// holder.binding.fileJoinToImg.isSelected=data.
}
fun setData(datas: List<FileBean>) {
sibList.clear()
sibList.addAll(datas)
notifyDataSetChanged()
}
}
} }
\ 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"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent" android:layout_width="match_parent"
android:orientation="vertical" android:layout_height="wrap_content"
android:layout_height="wrap_content"> android:orientation="vertical">
<RelativeLayout <RelativeLayout
android:id="@+id/clean_item_bar" android:id="@+id/clean_item_bar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="50dp"> android:layout_height="50dp">
<TextView <TextView
android:id="@+id/clean_item_name" android:id="@+id/clean_item_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:textSize="16dp" android:text="Uninstall remains"
android:textColor="@color/black" android:textColor="@color/black"
android:text="Uninstall remains"/> android:textSize="16dp" />
<ImageView <ImageView
android:id="@+id/clean_item_unfold" android:id="@+id/clean_item_unfold"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginStart="12dp"
android:layout_toEndOf="@+id/clean_item_name" android:layout_toEndOf="@+id/clean_item_name"
android:src="@mipmap/unfold"/> android:src="@mipmap/unfold" />
<CheckBox <CheckBox
android:id="@+id/clean_item_check_box" android:id="@+id/clean_item_check_box"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:button="@null"
android:layout_centerVertical="true"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:drawableEnd="@drawable/bg_item_switch_selector"/> android:layout_centerVertical="true"
android:button="@null"
android:drawableEnd="@drawable/bg_item_switch_selector" />
<ImageView <ImageView
android:id="@+id/clean_item_more" android:id="@+id/clean_item_more"
...@@ -40,25 +43,26 @@ ...@@ -40,25 +43,26 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:src="@mipmap/more"/> android:src="@mipmap/more" />
<TextView <TextView
android:id="@+id/file_item_size" android:id="@+id/file_item_size"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="23MB"
android:layout_alignParentEnd="true" android:layout_alignParentEnd="true"
android:layout_marginEnd="46dp"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:textColor="#DBDBDB"/> android:layout_marginEnd="46dp"
android:text="23MB"
android:textColor="#DBDBDB" />
</RelativeLayout> </RelativeLayout>
<ListView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/clean_item_list" android:id="@+id/clean_item_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"/> android:layout_height="wrap_content"
android:orientation="vertical"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" />
</LinearLayout> </LinearLayout>
\ 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