|
|
@@ -2,13 +2,18 @@ package com.grkj.iscs.widget
|
|
|
|
|
|
import android.content.Context
|
|
|
import android.util.AttributeSet
|
|
|
+import android.view.LayoutInflater
|
|
|
import android.view.View
|
|
|
-import android.view.inputmethod.InputMethodManager
|
|
|
+import android.view.ViewGroup
|
|
|
import android.widget.LinearLayout
|
|
|
+import android.widget.PopupWindow
|
|
|
import com.grkj.iscs.R
|
|
|
+import com.grkj.iscs.databinding.ItemBleBinding
|
|
|
import com.grkj.iscs.databinding.LayoutSelectableInputBinding
|
|
|
+import com.grkj.iscs.util.ToastUtils
|
|
|
|
|
|
-class SelectableInput(ctx: Context, attrs: AttributeSet) : LinearLayout(ctx, attrs) {
|
|
|
+
|
|
|
+class SelectableInput(private val ctx: Context, attrs: AttributeSet) : LinearLayout(ctx, attrs) {
|
|
|
|
|
|
companion object {
|
|
|
const val MODE_INPUT = 0
|
|
|
@@ -38,15 +43,33 @@ class SelectableInput(ctx: Context, attrs: AttributeSet) : LinearLayout(ctx, att
|
|
|
private fun setMode(mode: Int) {
|
|
|
if (mode == MODE_SELECT) {
|
|
|
mBinding.et.isEnabled = false
|
|
|
- mBinding.spinner.visibility = View.VISIBLE
|
|
|
+
|
|
|
mBinding.et.visibility = View.GONE
|
|
|
+
|
|
|
+ mBinding.tvName.setOnClickListener {
|
|
|
+ val contentView = LayoutInflater.from(ctx).inflate(R.layout.item_ble, null)
|
|
|
+
|
|
|
+ val popWnd = PopupWindow(context)
|
|
|
+ popWnd.contentView = contentView
|
|
|
+// popWnd.width = ViewGroup.LayoutParams.MATCH_PARENT
|
|
|
+ popWnd.width = this.width
|
|
|
+ popWnd.height = ViewGroup.LayoutParams.WRAP_CONTENT
|
|
|
+ popWnd.isOutsideTouchable = true
|
|
|
+ popWnd.showAsDropDown(mBinding.tvName)
|
|
|
+
|
|
|
+ val popBinding = ItemBleBinding.bind(contentView)
|
|
|
+ popBinding.bleName.setOnClickListener {
|
|
|
+ ToastUtils.tip("ble name")
|
|
|
+ popWnd.dismiss()
|
|
|
+ }
|
|
|
+ }
|
|
|
// btnDropdown.visibility = View.VISIBLE
|
|
|
// if (!options.isNullOrEmpty()) {
|
|
|
// btnDropdown.setOnClickListener(onBtnDropdownClickListener)
|
|
|
// }
|
|
|
} else {
|
|
|
mBinding.et.isEnabled = true
|
|
|
- mBinding.spinner.visibility = View.GONE
|
|
|
+
|
|
|
mBinding.et.visibility = View.VISIBLE
|
|
|
// btnDropdown.visibility = View.GONE
|
|
|
// btnDropdown.setOnClickListener(null)
|