desc:增加联动开关
parent
b57348ad15
commit
322c14db1a
@ -0,0 +1,63 @@
|
||||
package com.yinuo.safetywatcher.watcher.ui
|
||||
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import com.yinuo.safetywatcher.databinding.ActivityLinkSettingBinding
|
||||
import com.yinuo.safetywatcher.watcher.base.NoOptionsActivity
|
||||
import com.yinuo.safetywatcher.watcher.utils.LztekUtil
|
||||
import com.yinuo.safetywatcher.watcher.utils.showIme
|
||||
import com.yinuo.safetywatcher.watcher.utils.showToast
|
||||
|
||||
class LinkSettingActivity : NoOptionsActivity() {
|
||||
|
||||
private val mBinding by lazy {
|
||||
ActivityLinkSettingBinding.inflate(layoutInflater)
|
||||
}
|
||||
|
||||
override fun generateContentView(): View {
|
||||
return mBinding.root
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
mBinding.linkDelay.setText(LztekUtil.getLinkDelay().toString())
|
||||
setListener()
|
||||
}
|
||||
|
||||
private fun setListener() {
|
||||
mBinding.linkDelay.setOnKeyListener { _, keyCode, event ->
|
||||
if (keyCode == KeyEvent.KEYCODE_DPAD_UP) {
|
||||
if (event.action == KeyEvent.ACTION_DOWN) {
|
||||
tryFocusBackArea()
|
||||
return@setOnKeyListener true
|
||||
}
|
||||
} else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) {
|
||||
if (event.action == KeyEvent.ACTION_DOWN) {
|
||||
mBinding.tvSave.requestFocus()
|
||||
return@setOnKeyListener true
|
||||
}
|
||||
} else if (keyCode == KeyEvent.KEYCODE_DPAD_CENTER || keyCode == KeyEvent.KEYCODE_ENTER) {
|
||||
if (event.action == KeyEvent.ACTION_DOWN) {
|
||||
mBinding.linkDelay.showIme()
|
||||
return@setOnKeyListener true
|
||||
}
|
||||
}
|
||||
return@setOnKeyListener false
|
||||
}
|
||||
|
||||
mBinding.tvSave.setOnClickListener {
|
||||
saveData()
|
||||
}
|
||||
}
|
||||
|
||||
private fun saveData() {
|
||||
val toString = mBinding.linkDelay.text.toString()
|
||||
if (toString.isEmpty()) {
|
||||
showToast("请输入具体数值!")
|
||||
return
|
||||
}
|
||||
val toInt = toString.toInt()
|
||||
LztekUtil.setLinkDelay(toInt)
|
||||
showToast("保存成功")
|
||||
finish()
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical"
|
||||
android:paddingStart="@dimen/_121dp"
|
||||
android:paddingTop="@dimen/_61dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_max"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/_40dp"
|
||||
android:text="@string/link_delay_setting"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/_30dp" />
|
||||
|
||||
<EditText
|
||||
android:id="@+id/link_delay"
|
||||
android:layout_width="@dimen/_600dp"
|
||||
android:layout_height="@dimen/_100dp"
|
||||
android:layout_marginTop="@dimen/_20dp"
|
||||
android:background="@drawable/cloud_sync_btn_bg"
|
||||
android:paddingStart="@dimen/_12dp"
|
||||
android:focusable="true"
|
||||
android:nextFocusDown="@id/link_delay"
|
||||
android:inputType="number"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/_30dp" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_save"
|
||||
android:layout_width="@dimen/_160dp"
|
||||
android:layout_height="@dimen/_80dp"
|
||||
android:layout_marginTop="@dimen/_40dp"
|
||||
android:background="@drawable/save_btn_bg"
|
||||
android:focusable="true"
|
||||
android:gravity="center"
|
||||
android:text="@string/save"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="@dimen/_30dp" />
|
||||
</LinearLayout>
|
Binary file not shown.
After Width: | Height: | Size: 6.0 KiB |
Loading…
Reference in New Issue