[6.7.0][工具箱] feat: 增加工具箱Tab 及相关view ;
This commit is contained in:
@@ -14,6 +14,7 @@ import kotlinx.android.synthetic.main.view_bone_tab.view.tabSwitchCarInfo
|
||||
import kotlinx.android.synthetic.main.view_bone_tab.view.tabSwitchMore
|
||||
import kotlinx.android.synthetic.main.view_bone_tab.view.tabSwitchMsgBox
|
||||
import kotlinx.android.synthetic.main.view_bone_tab.view.tabSwitchReport
|
||||
import kotlinx.android.synthetic.main.view_bone_tab.view.toolKitTabView
|
||||
import kotlin.properties.Delegates
|
||||
|
||||
class BoneTabLayout @JvmOverloads constructor(
|
||||
@@ -129,11 +130,7 @@ class BoneTabLayout @JvmOverloads constructor(
|
||||
|
||||
TabType.MORE_INFO -> {
|
||||
tabSwitchMore.switchTab(check)
|
||||
if (check) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
toolKitTabView.visibility = if (check) VISIBLE else GONE
|
||||
}
|
||||
|
||||
else -> {}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.mogo.eagle.core.function.hmi.bone.tab
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.hmi.bone.toolkit.ToolKitBean
|
||||
import com.mogo.eagle.core.function.hmi.bone.toolkit.ToolKitDefaultItemView
|
||||
import com.mogo.eagle.core.function.hmi.bone.toolkit.ToolKitListAdapter
|
||||
import com.mogo.eagle.core.utilcode.mogo.view.GridSpacingItemDecoration
|
||||
import kotlinx.android.synthetic.main.view_tool_kit_tab.view.recyclerView
|
||||
import me.jessyan.autosize.utils.AutoSizeUtils
|
||||
import java.lang.ref.WeakReference
|
||||
|
||||
class ToolKitTabView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "ToolKitTabView"
|
||||
}
|
||||
|
||||
val toolKitList = ArrayList<ToolKitBean>()?.also {
|
||||
List(20) { index ->
|
||||
it += ToolKitBean(
|
||||
ToolKitDefaultItemView(context).apply {
|
||||
setData("标题标题标题标题标题$index", R.drawable.icon_toolkit_item_tiaoshi)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_tool_kit_tab, this, true)
|
||||
initView()
|
||||
}
|
||||
|
||||
override fun onAttachedToWindow() {
|
||||
super.onAttachedToWindow()
|
||||
}
|
||||
|
||||
override fun onDetachedFromWindow() {
|
||||
super.onDetachedFromWindow()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
// 设置布局管理器为GridLayoutManager,每行3列
|
||||
recyclerView.layoutManager = GridLayoutManager(context, 3)
|
||||
// 设置适配器
|
||||
recyclerView.adapter = ToolKitListAdapter(toolKitList)
|
||||
recyclerView.addItemDecoration(
|
||||
GridSpacingItemDecoration(
|
||||
3,
|
||||
AutoSizeUtils.dp2px(context, 10f),
|
||||
AutoSizeUtils.dp2px(context, 57f),
|
||||
false
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.mogo.eagle.core.function.hmi.bone.toolkit
|
||||
|
||||
import android.view.View
|
||||
|
||||
data class ToolKitBean(val itemView: View)
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.mogo.eagle.core.function.hmi.bone.toolkit
|
||||
|
||||
import android.content.Context
|
||||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
import com.mogo.eagle.core.function.main.MainMoGoApplication
|
||||
import kotlinx.android.synthetic.main.view_tool_kit_item_default.view.btnImageView
|
||||
import kotlinx.android.synthetic.main.view_tool_kit_item_default.view.tvTitleView
|
||||
|
||||
/**
|
||||
* 默认的item view, 上下机构,上面是按钮icon图片,下面是 title标题
|
||||
*/
|
||||
class ToolKitDefaultItemView @JvmOverloads constructor(
|
||||
context: Context,
|
||||
attrs: AttributeSet? = null,
|
||||
defStyleAttr: Int = 0
|
||||
) : ConstraintLayout(context, attrs, defStyleAttr) {
|
||||
|
||||
companion object {
|
||||
private const val TAG = "ToolKitDefaultItemView"
|
||||
}
|
||||
|
||||
init {
|
||||
LayoutInflater.from(context).inflate(R.layout.view_tool_kit_item_default, this, true)
|
||||
}
|
||||
|
||||
fun setData(title: String, iconDrawable: Int) {
|
||||
tvTitleView.text = title
|
||||
btnImageView.setImageDrawable(
|
||||
ContextCompat.getDrawable(
|
||||
MainMoGoApplication.getApp(),
|
||||
iconDrawable
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.mogo.eagle.core.function.hmi.bone.toolkit
|
||||
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.eagle.core.function.hmi.R
|
||||
|
||||
class ToolKitListAdapter(private val items: List<ToolKitBean>) :
|
||||
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
|
||||
|
||||
class ToolKitListViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
|
||||
var containerView: FrameLayout = itemView.findViewById(R.id.container)
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
|
||||
val itemView = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.view_tool_kit_item, parent, false)
|
||||
return ToolKitListViewHolder(itemView)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
|
||||
when (holder) {
|
||||
is ToolKitListViewHolder -> {
|
||||
holder.containerView.removeAllViews()
|
||||
val data = items[position] as ToolKitBean
|
||||
kotlin.runCatching {
|
||||
data?.itemView?.also {
|
||||
if (it.parent != null) {
|
||||
(it.parent as ViewGroup).removeView(it)
|
||||
}
|
||||
holder.containerView.addView(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun getItemCount() = items.size
|
||||
|
||||
override fun onViewRecycled(holder: RecyclerView.ViewHolder) {
|
||||
super.onViewRecycled(holder)
|
||||
}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 17 KiB |
@@ -21,6 +21,16 @@
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<com.mogo.eagle.core.function.hmi.bone.tab.ToolKitTabView
|
||||
android:id="@+id/toolKitTabView"
|
||||
android:layout_width="@dimen/dp_960"
|
||||
android:layout_height="@dimen/dp_1137"
|
||||
android:layout_marginStart="@dimen/dp_40"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/btnImageView"
|
||||
android:layout_width="@dimen/dp_160"
|
||||
android:layout_height="@dimen/dp_160"
|
||||
android:scaleType="fitXY"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:src="@drawable/icon_toolkit_item_tiaoshi" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tvTitleView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/dp_1"
|
||||
android:ellipsize="end"
|
||||
android:gravity="center"
|
||||
android:maxLines="2"
|
||||
android:text=""
|
||||
android:textColor="@color/color_FFFFFF"
|
||||
android:textSize="@dimen/sp_38"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/btnImageView"
|
||||
tools:text="调试面板" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout 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_height="match_parent"
|
||||
android:background="@drawable/bg_tab_item">
|
||||
|
||||
<View
|
||||
android:id="@+id/topViewPos"
|
||||
android:layout_width="@dimen/dp_856"
|
||||
android:layout_height="@dimen/dp_100"
|
||||
android:layout_marginTop="@dimen/dp_21"
|
||||
android:layout_marginEnd="@dimen/dp_40"
|
||||
android:background="@drawable/bg_tab_view_top"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="@dimen/dp_160"
|
||||
android:layout_height="@dimen/dp_56"
|
||||
android:layout_marginStart="@dimen/dp_104"
|
||||
android:layout_marginTop="@dimen/dp_55"
|
||||
android:text="@string/tab_tool_kit"
|
||||
android:textColor="@color/color_CC_FFFFFF"
|
||||
android:textSize="@dimen/dp_40"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="0dp"
|
||||
android:layout_marginLeft="@dimen/dp_56"
|
||||
android:layout_marginRight="@dimen/dp_56"
|
||||
android:clipToPadding="false"
|
||||
android:paddingTop="@dimen/dp_62"
|
||||
android:paddingBottom="@dimen/dp_200"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintLeft_toLeftOf="parent"
|
||||
app:layout_constraintRight_toRightOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@+id/topViewPos" />
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
@@ -3,6 +3,7 @@
|
||||
<string name="motice_push_check">查看</string>
|
||||
|
||||
<string name="tab_car_info">我的车辆</string>
|
||||
<string name="tab_tool_kit">更多内容</string>
|
||||
<string name="tab_car_login_info">登陆信息</string>
|
||||
<string name="tab_car_exit">退出</string>
|
||||
<string name="tab_car_no">车辆绑定</string>
|
||||
|
||||
Reference in New Issue
Block a user