|
@@ -1,16 +1,12 @@
|
|
package jx.cn.escort.adapter
|
|
package jx.cn.escort.adapter
|
|
|
|
|
|
|
|
+
|
|
import android.content.Context
|
|
import android.content.Context
|
|
import android.graphics.Bitmap
|
|
import android.graphics.Bitmap
|
|
import android.graphics.Canvas
|
|
import android.graphics.Canvas
|
|
import android.graphics.Color
|
|
import android.graphics.Color
|
|
-import android.graphics.drawable.Drawable
|
|
|
|
-import android.view.Gravity
|
|
|
|
-import android.view.LayoutInflater
|
|
|
|
-import android.view.View
|
|
|
|
-import android.view.ViewGroup
|
|
|
|
-import androidx.appcompat.widget.AppCompatTextView
|
|
|
|
-import androidx.cardview.widget.CardView
|
|
|
|
|
|
+import android.view.*
|
|
|
|
+import android.view.ViewGroup.MarginLayoutParams
|
|
import androidx.core.graphics.drawable.toBitmap
|
|
import androidx.core.graphics.drawable.toBitmap
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
import com.google.android.material.divider.MaterialDivider
|
|
import com.google.android.material.divider.MaterialDivider
|
|
@@ -19,27 +15,36 @@ import com.xuexiang.xui.utils.DensityUtils
|
|
import com.xuexiang.xui.utils.ResUtils
|
|
import com.xuexiang.xui.utils.ResUtils
|
|
import com.xuexiang.xui.widget.alpha.XUIAlphaTextView
|
|
import com.xuexiang.xui.widget.alpha.XUIAlphaTextView
|
|
import jx.cn.escort.R
|
|
import jx.cn.escort.R
|
|
|
|
+import jx.cn.escort.beans.TaskData
|
|
import jx.cn.escort.ui.widget.TaskCardView
|
|
import jx.cn.escort.ui.widget.TaskCardView
|
|
|
|
|
|
|
|
|
|
-class IndexRecycleAdapter(): RecyclerView.Adapter<IndexRecycleAdapter.IndexRecycleViewHolder>() {
|
|
|
|
|
|
+open class IndexRecycleAdapter(): RecyclerView.Adapter<IndexRecycleAdapter.IndexRecycleViewHolder>() {
|
|
|
|
|
|
|
|
|
|
- private var context: Context? =null
|
|
|
|
- constructor(context:Context?):this(){
|
|
|
|
|
|
+ private var context: Context?=null
|
|
|
|
+ private var mData = mutableListOf<TaskData>()
|
|
|
|
+ constructor(context: Context?):this(){
|
|
this.context=context
|
|
this.context=context
|
|
}
|
|
}
|
|
|
|
+ constructor(context: Context?, source:Collection<TaskData>):this(context){
|
|
|
|
+ if (source.isNotEmpty()) {
|
|
|
|
+ source.forEach{
|
|
|
|
+ mData.add(it)
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- class IndexRecycleViewHolder:RecyclerView.ViewHolder{
|
|
|
|
- var item: View?=null
|
|
|
|
- constructor(itemView: View):super(itemView){
|
|
|
|
- this.item=itemView
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ class IndexRecycleViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
|
|
|
+ var item: View?= itemView
|
|
}
|
|
}
|
|
|
|
|
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): IndexRecycleViewHolder {
|
|
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): IndexRecycleViewHolder {
|
|
@@ -49,10 +54,22 @@ class IndexRecycleAdapter(): RecyclerView.Adapter<IndexRecycleAdapter.IndexRecyc
|
|
}
|
|
}
|
|
|
|
|
|
override fun onBindViewHolder(holder: IndexRecycleViewHolder, position: Int) {
|
|
override fun onBindViewHolder(holder: IndexRecycleViewHolder, position: Int) {
|
|
- val cardView= holder.item?.findViewById<TaskCardView>(R.id.card_content)
|
|
|
|
- val divideTop= holder.item?.findViewById<MaterialDivider>(R.id.card_divide_top)
|
|
|
|
- val leftText = XUIAlphaTextView(context)
|
|
|
|
- leftText.text="线路${position+1}"
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ val cardView= holder.item?.findViewById<TaskCardView>(jx.cn.escort.R.id.card_content)
|
|
|
|
+ val divideTop= holder.item?.findViewById<MaterialDivider>(jx.cn.escort.R.id.card_divide_top)
|
|
|
|
+
|
|
|
|
+ val contextThemeWrapper: ContextThemeWrapper = ContextThemeWrapper(context, jx.cn.escort.R.style.Cus_Theme_AppCompat)
|
|
|
|
+ var leftText = XUIAlphaTextView(contextThemeWrapper)
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ var leftP=ViewGroup.MarginLayoutParams(DensityUtils.px2dp(context,300f),DensityUtils.px2dp(context,120f)) as MarginLayoutParams
|
|
|
|
+ leftP.topMargin=30
|
|
|
|
+ leftText.layoutParams=leftP
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ val layoutPosition = holder.layoutPosition
|
|
|
|
+ leftText.text=mData.get(layoutPosition).name
|
|
leftText.setTextColor(Color.BLACK)
|
|
leftText.setTextColor(Color.BLACK)
|
|
leftText.setSingleLine()
|
|
leftText.setSingleLine()
|
|
var mLeftImageResource = ResUtils.getDrawable(context, R.drawable.ic_task_title);
|
|
var mLeftImageResource = ResUtils.getDrawable(context, R.drawable.ic_task_title);
|
|
@@ -75,9 +92,11 @@ class IndexRecycleAdapter(): RecyclerView.Adapter<IndexRecycleAdapter.IndexRecyc
|
|
cardView?.setDivideTop(divideTop)
|
|
cardView?.setDivideTop(divideTop)
|
|
cardView?.addView(leftText)
|
|
cardView?.addView(leftText)
|
|
|
|
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
override fun getItemCount(): Int {
|
|
override fun getItemCount(): Int {
|
|
- return 10
|
|
|
|
|
|
+ return mData.size
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|