|
@@ -2,9 +2,12 @@ package com.module.backstage.adapter
|
|
|
|
|
|
import ZtlApi.ZtlManager
|
|
|
import android.annotation.SuppressLint
|
|
|
+import android.app.XzjhSystemManager
|
|
|
import android.content.Context
|
|
|
import android.content.Intent
|
|
|
+import android.media.AudioManager
|
|
|
import android.provider.Settings
|
|
|
+import android.util.Log
|
|
|
import android.view.LayoutInflater
|
|
|
import android.view.View
|
|
|
import android.view.ViewGroup
|
|
@@ -12,6 +15,7 @@ import android.widget.AdapterView
|
|
|
import android.widget.AdapterView.OnItemSelectedListener
|
|
|
import android.widget.ArrayAdapter
|
|
|
import android.widget.SeekBar
|
|
|
+import androidx.core.content.ContextCompat.getSystemService
|
|
|
import androidx.core.content.ContextCompat.startActivity
|
|
|
import androidx.recyclerview.widget.RecyclerView
|
|
|
import com.chad.library.adapter4.BaseMultiItemAdapter
|
|
@@ -30,10 +34,13 @@ import com.quyunshuo.androidbaseframemvvm.common.util.ToastUtil
|
|
|
import com.quyunshuo.androidbaseframemvvm.common.util.UiUtil
|
|
|
import com.quyunshuo.androidbaseframemvvm.common.util.XLogUtil
|
|
|
|
|
|
+
|
|
|
class TestAdapter(var productList: MutableList<OtherEnum>) :
|
|
|
BaseMultiItemAdapter<OtherEnum>(productList) {
|
|
|
|
|
|
- // 类型 1 的 viewholder
|
|
|
+ private val TAG = "TestAdapter"
|
|
|
+
|
|
|
+ // 类型 1 的 viewholder 开关
|
|
|
class ItemVH(val viewBinding: BackstageItemSystemSettingsBinding) :
|
|
|
RecyclerView.ViewHolder(viewBinding.root)
|
|
|
|
|
@@ -41,7 +48,7 @@ class TestAdapter(var productList: MutableList<OtherEnum>) :
|
|
|
class HeaderVH(val viewBinding: BackstageItemInputBinding) :
|
|
|
RecyclerView.ViewHolder(viewBinding.root)
|
|
|
|
|
|
- // 类型 3 的 viewholder
|
|
|
+ // 类型 3 的 viewholder 下拉框
|
|
|
class SpinnerVH(val viewBinding: BackstageItemSpinnerBinding) :
|
|
|
RecyclerView.ViewHolder(viewBinding.root)
|
|
|
|
|
@@ -224,6 +231,9 @@ class TestAdapter(var productList: MutableList<OtherEnum>) :
|
|
|
|
|
|
override fun onBind(holder: SliderVH, position: Int, item: OtherEnum?) {
|
|
|
// 绑定 item 数据
|
|
|
+ val mManager = context.getSystemService("xzjh_server") as XzjhSystemManager?
|
|
|
+ val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager
|
|
|
+
|
|
|
itemListener?.onClickListener(holder.itemView, position, null)
|
|
|
holder.viewBinding.run {
|
|
|
tvName.text = UiUtil.getStringRes(item!!.nameId)
|
|
@@ -231,17 +241,19 @@ class TestAdapter(var productList: MutableList<OtherEnum>) :
|
|
|
MMKVName.VOLUME -> {
|
|
|
XLogUtil.d("音量:" + ZtlManager.GetInstance().systemMaxVolume + ":" + ZtlManager.GetInstance().systemCurrenVolume)
|
|
|
sbLight.max =
|
|
|
- ZtlManager.GetInstance().systemMaxVolume //maxVolume 为获取到的 Android 系统最大媒体音量值
|
|
|
+ audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
|
|
|
sbLight.progress =
|
|
|
- ZtlManager.GetInstance().systemCurrenVolume;//currenVolume 为获取到的 Android 系统当前媒体音量值
|
|
|
+ audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
|
|
|
}
|
|
|
|
|
|
MMKVName.LUMINANCE -> {
|
|
|
XLogUtil.d("亮度:" + ZtlManager.GetInstance().systemMaxBrightness + ":" + ZtlManager.GetInstance().systemBrightness)
|
|
|
+ Log.d(TAG, "onBind: "+mManager?.xzjhGetBacklight())
|
|
|
sbLight.max =
|
|
|
ZtlManager.GetInstance().systemMaxBrightness //maxBrightness 为 Android 系统最大亮度
|
|
|
- sbLight.progress =
|
|
|
- ZtlManager.GetInstance().systemBrightness; //systemBri 为 Android 系统当前亮度
|
|
|
+ if (mManager != null) {
|
|
|
+ sbLight.progress =mManager.xzjhGetBacklight()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -260,12 +272,12 @@ class TestAdapter(var productList: MutableList<OtherEnum>) :
|
|
|
when (item.mmkvName) {
|
|
|
MMKVName.VOLUME -> {
|
|
|
//设置 Android 系统媒体音量值为 10
|
|
|
- ZtlManager.GetInstance().setSystemVolumeIndex(progress);
|
|
|
+ audioManager.setStreamVolume(AudioManager.STREAM_MUSIC,progress,AudioManager.FLAG_SHOW_UI)
|
|
|
}
|
|
|
|
|
|
MMKVName.LUMINANCE -> {
|
|
|
//设置 Android 系统亮度为 200
|
|
|
- ZtlManager.GetInstance().setBrightness(progress);
|
|
|
+ mManager?.xzjhSetBacklight(progress);
|
|
|
}
|
|
|
}
|
|
|
|