BadCase自定义录包
This commit is contained in:
@@ -8,6 +8,7 @@ import android.view.LayoutInflater
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import com.mogo.eagle.core.data.badcase.RecordTypeEntity
|
||||
import com.mogo.eagle.core.data.badcase.TopicEntity
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotRecordListener
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager
|
||||
@@ -156,6 +157,20 @@ internal class BadCaseConfigView @JvmOverloads constructor(
|
||||
val gridLayoutManager = GridLayoutManager(context,2)
|
||||
rvTemplate.layoutManager = gridLayoutManager
|
||||
rvTemplate.adapter = recordTemplateAdapter
|
||||
// val list = ArrayList<TopicEntity>()
|
||||
// list.add(TopicEntity("/v2n/aicloud/rsm_info",false,false))
|
||||
// list.add(TopicEntity("/autopilot_info/report_msg_error",false,false))
|
||||
// list.add(TopicEntity("/v2n/aicloud/rsi_info",false,false))
|
||||
// list.add(TopicEntity("/record_cache/task",false,true))
|
||||
// list.add(TopicEntity("/sensor/rainmode",false,true))
|
||||
// list.add(TopicEntity("/record_cache/master/task",false,true))
|
||||
// list.add(TopicEntity("/telematics/trip_info_event",false,true))
|
||||
// list.add(TopicEntity("/telematics/light",false,true))
|
||||
// list.add(TopicEntity("/guardian/aicloud_state",false,true))
|
||||
// recordTypesList.add(RecordTypeEntity(1,"红路灯",list))
|
||||
// recordTemplateAdapter?.setData(recordTypesList)
|
||||
// recordTemplateAdapter?.notifyDataSetChanged()
|
||||
|
||||
}
|
||||
|
||||
fun setClickListener(clickListener: ClickListener) {
|
||||
@@ -163,9 +178,7 @@ internal class BadCaseConfigView @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
private fun showCaseTopicListDialog(recordTypeEntity: RecordTypeEntity){
|
||||
if(caseTopicListDialog == null){
|
||||
caseTopicListDialog = CaseTopicListDialog(context)
|
||||
}
|
||||
caseTopicListDialog = CaseTopicListDialog(context)
|
||||
caseTopicListDialog?.setData(recordTypeEntity)
|
||||
caseTopicListDialog?.show()
|
||||
}
|
||||
@@ -175,9 +188,9 @@ internal class BadCaseConfigView @JvmOverloads constructor(
|
||||
ThreadUtils.runOnUiThread {
|
||||
config.recordTypesList.iterator().forEach {
|
||||
if (it.id != 99){
|
||||
val topicList = ArrayList<String>()
|
||||
val topicList = ArrayList<TopicEntity>()
|
||||
it.topicsList.iterator().forEach {
|
||||
topicList.add(it)
|
||||
topicList.add(TopicEntity(it,true,false))
|
||||
}
|
||||
recordTypesList.add(RecordTypeEntity(it.id,it.desc,topicList))
|
||||
}
|
||||
|
||||
@@ -17,10 +17,12 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.mogo.eagle.core.data.badcase.RecordTypeEntity;
|
||||
import com.mogo.eagle.core.data.badcase.TopicEntity;
|
||||
import com.mogo.eagle.core.function.api.autopilot.IMoGoAutopilotRecordListener;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutoPilotManager;
|
||||
import com.mogo.eagle.core.function.call.autopilot.CallerAutopilotRecordListenerManager;
|
||||
import com.mogo.eagle.core.utilcode.util.ThreadUtils;
|
||||
import com.mogo.eagle.core.utilcode.util.ToastUtils;
|
||||
import com.zhjt.mogo_core_function_devatools.R;
|
||||
import com.zhjt.mogo_core_function_devatools.badcase.biz.adapter.TopicListAdapter;
|
||||
|
||||
@@ -46,8 +48,10 @@ public class CaseTopicListDialog extends Dialog implements IMoGoAutopilotRecordL
|
||||
private RecyclerView rvTopicList;
|
||||
private TopicListAdapter topicListAdapter;
|
||||
private String searchStr;
|
||||
private List<String> allTopicList = new ArrayList<>();
|
||||
|
||||
private List<TopicEntity> allTopicList = new ArrayList<>();
|
||||
private RecordTypeEntity recordType;
|
||||
private List<String> addTopicList = new ArrayList<>();
|
||||
private List<TopicEntity> searchTopicList = new ArrayList<>();
|
||||
|
||||
public CaseTopicListDialog(@NonNull Context context) {
|
||||
super(context, R.style.bad_case_dialog);
|
||||
@@ -61,6 +65,20 @@ public class CaseTopicListDialog extends Dialog implements IMoGoAutopilotRecordL
|
||||
CallerAutopilotRecordListenerManager.INSTANCE.addListener(TAG, this);
|
||||
init();
|
||||
initEvent();
|
||||
//获取所有Topic
|
||||
CallerAutoPilotManager.INSTANCE.getBadCaseConfig(1, 0, new ArrayList<>());
|
||||
if(recordType!=null){
|
||||
tvCaseName.setText(recordType.getDesc());
|
||||
if(recordType.getTopicsList().size()>0){
|
||||
topicListAdapter.setData(recordType.getTopicsList());
|
||||
topicListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAttachedToWindow() {
|
||||
super.onAttachedToWindow();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -70,12 +88,8 @@ public class CaseTopicListDialog extends Dialog implements IMoGoAutopilotRecordL
|
||||
}
|
||||
|
||||
public void setData(RecordTypeEntity recordTypeEntity){
|
||||
tvCaseName.setText(recordTypeEntity.getDesc());
|
||||
//获取所有Topic
|
||||
CallerAutoPilotManager.INSTANCE.getBadCaseConfig(1, 0, new ArrayList<>());
|
||||
if(recordTypeEntity.getTopicsList().size()>0){
|
||||
topicListAdapter.setData(recordTypeEntity.getTopicsList());
|
||||
topicListAdapter.notifyDataSetChanged();
|
||||
if(recordTypeEntity!=null){
|
||||
recordType = recordTypeEntity;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,6 +104,13 @@ public class CaseTopicListDialog extends Dialog implements IMoGoAutopilotRecordL
|
||||
linearLayoutManager.setOrientation(LinearLayoutManager.VERTICAL);
|
||||
rvTopicList.setLayoutManager(linearLayoutManager);
|
||||
topicListAdapter = new TopicListAdapter();
|
||||
topicListAdapter.setListener((topicName, clicked) -> {
|
||||
if(clicked){
|
||||
addTopicList.add(topicName);
|
||||
}else{
|
||||
addTopicList.remove(topicName);
|
||||
}
|
||||
});
|
||||
rvTopicList.setAdapter(topicListAdapter);
|
||||
}
|
||||
|
||||
@@ -113,7 +134,16 @@ public class CaseTopicListDialog extends Dialog implements IMoGoAutopilotRecordL
|
||||
} else {
|
||||
ivSearch.setImageDrawable(getContext().getDrawable(R.drawable.icon_bad_case_search));
|
||||
}
|
||||
//TODO
|
||||
if(searchStr!=null && searchStr.length()>0){
|
||||
searchTopicList.clear();
|
||||
for(int index=0;index<recordType.getTopicsList().size();index++){
|
||||
if(recordType.getTopicsList().get(index).getTopicName().contains(searchStr)){
|
||||
searchTopicList.add(recordType.getTopicsList().get(index));
|
||||
}
|
||||
}
|
||||
topicListAdapter.setData(searchTopicList);
|
||||
topicListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -121,6 +151,24 @@ public class CaseTopicListDialog extends Dialog implements IMoGoAutopilotRecordL
|
||||
if(searchStr!=null && searchStr.length()>0){
|
||||
etSearch.setText("");
|
||||
ivSearch.setImageDrawable(getContext().getDrawable(R.drawable.icon_bad_case_search));
|
||||
topicListAdapter.setData(recordType.getTopicsList());
|
||||
topicListAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
tvSave.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(recordType!=null){
|
||||
Boolean success=CallerAutoPilotManager.INSTANCE.getBadCaseConfig(2,recordType.getId(),addTopicList);
|
||||
if(Boolean.TRUE.equals(success)){
|
||||
ToastUtils.showShort("Topic设置成功");
|
||||
dismiss();
|
||||
}else{
|
||||
ToastUtils.showShort("Topic设置失败");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
@@ -135,8 +183,9 @@ public class CaseTopicListDialog extends Dialog implements IMoGoAutopilotRecordL
|
||||
ThreadUtils.runOnUiThread(() -> {
|
||||
if(config.getAllTopicsCount()>0){
|
||||
for(int index=0;index<config.getAllTopicsCount();index++){
|
||||
allTopicList.add(config.getAllTopics(index));
|
||||
allTopicList.add(new TopicEntity(config.getAllTopics(index),false,true));
|
||||
}
|
||||
recordType.getTopicsList().addAll(allTopicList);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.CheckBox
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.mogo.eagle.core.data.badcase.TopicEntity
|
||||
import com.zhjt.mogo_core_function_devatools.R
|
||||
|
||||
/**
|
||||
@@ -14,12 +15,17 @@ import com.zhjt.mogo_core_function_devatools.R
|
||||
*/
|
||||
class TopicListAdapter: RecyclerView.Adapter<TopicListAdapter.TopicListHolder>() {
|
||||
|
||||
private var data:List<String>? = null
|
||||
private var data:List<TopicEntity>? = null
|
||||
private var topicClickListener: TopicClickListener? = null
|
||||
|
||||
fun setData( data: List<String>?){
|
||||
fun setData( data: List<TopicEntity>?){
|
||||
this.data = data
|
||||
}
|
||||
|
||||
fun setListener(listener: TopicClickListener){
|
||||
topicClickListener = listener
|
||||
}
|
||||
|
||||
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TopicListHolder {
|
||||
val view = LayoutInflater.from(parent.context)
|
||||
.inflate(R.layout.item_topic_list, parent, false)
|
||||
@@ -27,8 +33,16 @@ class TopicListAdapter: RecyclerView.Adapter<TopicListAdapter.TopicListHolder>()
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: TopicListHolder, position: Int) {
|
||||
data?.let{
|
||||
holder.topic_check_box.text = it[position]
|
||||
data?.let{topicList->
|
||||
holder.topic_check_box.text = topicList[position].topicName
|
||||
holder.topic_check_box.setOnCheckedChangeListener(null)
|
||||
holder.topic_check_box.isChecked = topicList[position].topicStatus
|
||||
holder.topic_check_box.tag = topicList
|
||||
holder.topic_check_box.isClickable = topicList[position].topicCanClick
|
||||
holder.topic_check_box.setOnCheckedChangeListener { _, b ->
|
||||
topicList[position].topicStatus = b
|
||||
topicClickListener?.onClick(topicList[position].topicName,b)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -38,4 +52,8 @@ class TopicListAdapter: RecyclerView.Adapter<TopicListAdapter.TopicListHolder>()
|
||||
var topic_check_box: CheckBox = itemView.findViewById(R.id.topic_check_box);
|
||||
}
|
||||
|
||||
interface TopicClickListener{
|
||||
fun onClick(topicName: String,clicked: Boolean)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -317,6 +317,7 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/tvRecordTemplate"
|
||||
android:background="@drawable/template_list_bg"
|
||||
android:layout_marginTop="@dimen/dp_50"
|
||||
android:paddingBottom="20dp"
|
||||
/>
|
||||
|
||||
<RadioGroup
|
||||
|
||||
Reference in New Issue
Block a user