@@ -174,7 +174,7 @@ class WildcardFragment : Fragment(), AddressUpdateFragment.ICDCheckInMessageCall
174
174
setVisibilityEachView(radioBtnId)
175
175
}
176
176
177
- binding.sendBtn.setOnClickListener { showDialog() }
177
+ binding.sendBtn.setOnClickListener { showDialog(isICDQueueBtn = false ) }
178
178
179
179
binding.shutdownSubscriptionBtn.setOnClickListener { showShutdownSubscriptionDialog() }
180
180
@@ -183,6 +183,16 @@ class WildcardFragment : Fragment(), AddressUpdateFragment.ICDCheckInMessageCall
183
183
binding.addListBtn.setOnClickListener { addRequest() }
184
184
binding.resetBtn.setOnClickListener { resetPath() }
185
185
binding.writeInvokeresetBtn.setOnClickListener { resetPath() }
186
+ binding.icdQueueBtn.setOnCheckedChangeListener { _, isChecked ->
187
+ if (isChecked) {
188
+ val isSetting = showDialog(isICDQueueBtn = true )
189
+ if (! isSetting) {
190
+ binding.icdQueueBtn.isChecked = false
191
+ }
192
+ } else {
193
+ resetICDConfig()
194
+ }
195
+ }
186
196
187
197
addressUpdateFragment =
188
198
childFragmentManager.findFragmentById(R .id.addressUpdateFragment) as AddressUpdateFragment
@@ -202,11 +212,11 @@ class WildcardFragment : Fragment(), AddressUpdateFragment.ICDCheckInMessageCall
202
212
203
213
override fun notifyCheckInMessage () {
204
214
Log .d(TAG , " notifyCheckInMessage" )
205
- if (attributePath.isNotEmpty() || eventPath.isNotEmpty()) {
206
- if (binding.readRadioBtn.isChecked && readICDConfig != null ) {
207
- scope.launch { read(readICDConfig !! .isFabricFiltered, readICDConfig!! .eventMin) }
208
- } else if (binding.subscribeRadioBtn.isChecked && subscribeICDConfig != null ) {
209
- scope.launch {
215
+ scope.launch {
216
+ if (attributePath.isNotEmpty() || eventPath.isNotEmpty() ) {
217
+ if (binding.readRadioBtn.isChecked && readICDConfig != null ) {
218
+ read(readICDConfig !! .isFabricFiltered, readICDConfig !! .eventMin)
219
+ } else if (binding.subscribeRadioBtn.isChecked && subscribeICDConfig != null ) {
210
220
subscribe(
211
221
subscribeICDConfig!! .minInterval,
212
222
subscribeICDConfig!! .maxInterval,
@@ -215,20 +225,27 @@ class WildcardFragment : Fragment(), AddressUpdateFragment.ICDCheckInMessageCall
215
225
subscribeICDConfig!! .eventMin
216
226
)
217
227
}
218
- }
219
- } else if (
220
- binding.writeRadioBtn.isChecked && writePath.isNotEmpty() && writeICDConfig != null
221
- ) {
222
- scope.launch { write(writeICDConfig!! .timedRequestTimeoutMs, writeICDConfig!! .imTimeoutMs) }
223
- } else if (
224
- binding.invokeRadioBtn.isChecked && invokePath.isNotEmpty() && invokeICDConfig != null
225
- ) {
226
- scope.launch {
228
+ } else if (
229
+ binding.writeRadioBtn.isChecked && writePath.isNotEmpty() && writeICDConfig != null
230
+ ) {
231
+ write(writeICDConfig!! .timedRequestTimeoutMs, writeICDConfig!! .imTimeoutMs)
232
+ } else if (
233
+ binding.invokeRadioBtn.isChecked && invokePath.isNotEmpty() && invokeICDConfig != null
234
+ ) {
227
235
invoke(invokeICDConfig!! .timedRequestTimeoutMs, invokeICDConfig!! .imTimeoutMs)
228
236
}
237
+ requireActivity().runOnUiThread { binding.icdQueueBtn.isChecked = false }
238
+ resetICDConfig()
229
239
}
230
240
}
231
241
242
+ private fun resetICDConfig () {
243
+ readICDConfig = null
244
+ subscribeICDConfig = null
245
+ writeICDConfig = null
246
+ invokeICDConfig = null
247
+ }
248
+
232
249
private fun setVisibilityEachView (radioBtnId : Int ) {
233
250
val readBtnOn = (radioBtnId == R .id.readRadioBtn)
234
251
val subscribeBtnOn = (radioBtnId == R .id.subscribeRadioBtn)
@@ -261,16 +278,20 @@ class WildcardFragment : Fragment(), AddressUpdateFragment.ICDCheckInMessageCall
261
278
resetPath()
262
279
}
263
280
264
- private fun showDialog () {
281
+ private fun showDialog (isICDQueueBtn : Boolean ): Boolean {
282
+ var ret = false
265
283
if (binding.readRadioBtn.isChecked) {
266
- showReadDialog()
284
+ ret = showReadDialog(isICDQueueBtn )
267
285
} else if (binding.subscribeRadioBtn.isChecked) {
268
- showSubscribeDialog()
286
+ ret = showSubscribeDialog(isICDQueueBtn )
269
287
} else if (binding.writeRadioBtn.isChecked) {
270
- showWriteDialog()
288
+ showWriteDialog(isICDQueueBtn)
289
+ ret = true
271
290
} else if (binding.invokeRadioBtn.isChecked) {
272
- showInvokeDialog()
291
+ showInvokeDialog(isICDQueueBtn)
292
+ ret = true
273
293
}
294
+ return ret
274
295
}
275
296
276
297
private fun addRequest () {
@@ -547,7 +568,7 @@ class WildcardFragment : Fragment(), AddressUpdateFragment.ICDCheckInMessageCall
547
568
)
548
569
}
549
570
550
- private fun showReadDialog () {
571
+ private fun showReadDialog (isICDQueueBtn : Boolean ): Boolean {
551
572
if (attributePath.isEmpty() && eventPath.isEmpty()) {
552
573
requireActivity().runOnUiThread {
553
574
Toast .makeText(
@@ -557,7 +578,7 @@ class WildcardFragment : Fragment(), AddressUpdateFragment.ICDCheckInMessageCall
557
578
)
558
579
.show()
559
580
}
560
- return
581
+ return false
561
582
}
562
583
val dialogView = requireActivity().layoutInflater.inflate(R .layout.read_dialog, null )
563
584
val eventMinEd = dialogView.findViewById<EditText >(R .id.eventMinEd)
@@ -576,7 +597,7 @@ class WildcardFragment : Fragment(), AddressUpdateFragment.ICDCheckInMessageCall
576
597
if (eventPath.isNotEmpty() && eventMinEd.text.isNotBlank()) {
577
598
eventMin = eventMinEd.text.toString().toULong().toLong()
578
599
}
579
- if (addressUpdateFragment.isICDDevice() ) {
600
+ if (isICDQueueBtn ) {
580
601
readICDConfig =
581
602
ReadICDConfig (isFabricFilteredEd.selectedItem.toString().toBoolean(), eventMin)
582
603
} else {
@@ -586,9 +607,10 @@ class WildcardFragment : Fragment(), AddressUpdateFragment.ICDCheckInMessageCall
586
607
}
587
608
}
588
609
dialog.show()
610
+ return true
589
611
}
590
612
591
- private fun showWriteDialog () {
613
+ private fun showWriteDialog (isICDQueueBtn : Boolean ) {
592
614
binding.outputTv.text = " "
593
615
val dialogView = requireActivity().layoutInflater.inflate(R .layout.write_dialog, null )
594
616
val dialog = AlertDialog .Builder (requireContext()).apply { setView(dialogView) }.create()
@@ -610,7 +632,7 @@ class WildcardFragment : Fragment(), AddressUpdateFragment.ICDCheckInMessageCall
610
632
} else {
611
633
imTimeout.toInt()
612
634
}
613
- if (addressUpdateFragment.isICDDevice() ) {
635
+ if (isICDQueueBtn ) {
614
636
writeICDConfig = WriteInvokeICDConfig (timedRequestTimeoutInt, imTimeoutInt)
615
637
} else {
616
638
write(timedRequestTimeoutInt, imTimeoutInt)
@@ -621,7 +643,7 @@ class WildcardFragment : Fragment(), AddressUpdateFragment.ICDCheckInMessageCall
621
643
dialog.show()
622
644
}
623
645
624
- private fun showSubscribeDialog () {
646
+ private fun showSubscribeDialog (isICDQueueBtn : Boolean ): Boolean {
625
647
if (attributePath.isEmpty() && eventPath.isEmpty()) {
626
648
requireActivity().runOnUiThread {
627
649
Toast .makeText(
@@ -631,7 +653,7 @@ class WildcardFragment : Fragment(), AddressUpdateFragment.ICDCheckInMessageCall
631
653
)
632
654
.show()
633
655
}
634
- return
656
+ return false
635
657
}
636
658
val dialogView = requireActivity().layoutInflater.inflate(R .layout.subscribe_dialog, null )
637
659
val eventMinEd = dialogView.findViewById<EditText >(R .id.eventMinEd)
@@ -654,7 +676,7 @@ class WildcardFragment : Fragment(), AddressUpdateFragment.ICDCheckInMessageCall
654
676
if (eventPath.isNotEmpty() && eventMinEd.text.isNotBlank()) {
655
677
eventMin = eventMinEd.text.toString().toULong().toLong()
656
678
}
657
- if (addressUpdateFragment.isICDDevice() ) {
679
+ if (isICDQueueBtn ) {
658
680
subscribeICDConfig =
659
681
SubscribeICDConfig (
660
682
minIntervalEd.text.toString().toInt(),
@@ -679,9 +701,10 @@ class WildcardFragment : Fragment(), AddressUpdateFragment.ICDCheckInMessageCall
679
701
}
680
702
}
681
703
dialog.show()
704
+ return true
682
705
}
683
706
684
- private fun showInvokeDialog () {
707
+ private fun showInvokeDialog (isICDQueueBtn : Boolean ) {
685
708
binding.outputTv.text = " "
686
709
val dialogView = requireActivity().layoutInflater.inflate(R .layout.invoke_dialog, null )
687
710
val dialog = AlertDialog .Builder (requireContext()).apply { setView(dialogView) }.create()
@@ -703,7 +726,7 @@ class WildcardFragment : Fragment(), AddressUpdateFragment.ICDCheckInMessageCall
703
726
} else {
704
727
imTimeout.toInt()
705
728
}
706
- if (addressUpdateFragment.isICDDevice() ) {
729
+ if (isICDQueueBtn ) {
707
730
invokeICDConfig = WriteInvokeICDConfig (timedRequestTimeoutInt, imTimeoutInt)
708
731
} else {
709
732
invoke(timedRequestTimeoutInt, imTimeoutInt)
0 commit comments