mirror of
https://github.com/pppscn/SmsForwarder
synced 2024-11-04 06:00:11 +00:00
优化:接口请求失败重试时间间隔输入方式 #285
This commit is contained in:
parent
1d5f538fd7
commit
c7ead43a29
@ -145,7 +145,7 @@ class SettingsFragment : BaseFragment<FragmentSettingsBinding?>(), View.OnClickL
|
|||||||
)
|
)
|
||||||
|
|
||||||
//接口请求失败重试时间间隔
|
//接口请求失败重试时间间隔
|
||||||
editRetryDelayTime(binding!!.etRetryTimes, binding!!.etDelayTime, binding!!.etTimeout)
|
editRetryDelayTime(binding!!.xsbRetryTimes, binding!!.xsbDelayTime, binding!!.xsbTimeout)
|
||||||
|
|
||||||
//设备备注
|
//设备备注
|
||||||
editAddExtraDeviceMark(binding!!.etExtraDeviceMark)
|
editAddExtraDeviceMark(binding!!.etExtraDeviceMark)
|
||||||
@ -793,60 +793,20 @@ class SettingsFragment : BaseFragment<FragmentSettingsBinding?>(), View.OnClickL
|
|||||||
|
|
||||||
//接口请求失败重试时间间隔
|
//接口请求失败重试时间间隔
|
||||||
private fun editRetryDelayTime(
|
private fun editRetryDelayTime(
|
||||||
etRetryTimes: EditText, etDelayTime: EditText, etTimeout: EditText
|
xsbRetryTimes: XSeekBar, xsbDelayTime: XSeekBar, xsbTimeout: XSeekBar
|
||||||
) {
|
) {
|
||||||
etRetryTimes.setText(java.lang.String.valueOf(SettingUtils.requestRetryTimes))
|
xsbRetryTimes.setDefaultValue(SettingUtils.requestRetryTimes)
|
||||||
etRetryTimes.addTextChangedListener(object : TextWatcher {
|
xsbRetryTimes.setOnSeekBarListener { _: XSeekBar?, newValue: Int ->
|
||||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
SettingUtils.requestRetryTimes = newValue
|
||||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
|
}
|
||||||
override fun afterTextChanged(s: Editable) {
|
xsbDelayTime.setDefaultValue(SettingUtils.requestDelayTime)
|
||||||
val retryTimes = etRetryTimes.text.toString().trim()
|
xsbDelayTime.setOnSeekBarListener { _: XSeekBar?, newValue: Int ->
|
||||||
if (retryTimes.isNotEmpty()) {
|
SettingUtils.requestDelayTime = newValue
|
||||||
SettingUtils.requestRetryTimes = retryTimes.toInt()
|
}
|
||||||
} else {
|
xsbTimeout.setDefaultValue(SettingUtils.requestTimeout)
|
||||||
etRetryTimes.setText("0")
|
xsbTimeout.setOnSeekBarListener { _: XSeekBar?, newValue: Int ->
|
||||||
SettingUtils.requestRetryTimes = 0
|
SettingUtils.requestTimeout = newValue
|
||||||
}
|
}
|
||||||
}
|
|
||||||
})
|
|
||||||
etDelayTime.setText(java.lang.String.valueOf(SettingUtils.requestDelayTime))
|
|
||||||
etDelayTime.addTextChangedListener(object : TextWatcher {
|
|
||||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
|
||||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
|
|
||||||
override fun afterTextChanged(s: Editable) {
|
|
||||||
val delayTime = etDelayTime.text.toString().trim()
|
|
||||||
if (delayTime.isNotEmpty()) {
|
|
||||||
SettingUtils.requestDelayTime = delayTime.toInt()
|
|
||||||
if (SettingUtils.requestDelayTime < 1) {
|
|
||||||
etDelayTime.setText("1")
|
|
||||||
XToastUtils.error(R.string.invalid_delay_time)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
XToastUtils.warning(R.string.invalid_delay_time)
|
|
||||||
etDelayTime.setText("1")
|
|
||||||
SettingUtils.requestDelayTime = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
etTimeout.setText(java.lang.String.valueOf(SettingUtils.requestTimeout))
|
|
||||||
etTimeout.addTextChangedListener(object : TextWatcher {
|
|
||||||
override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {}
|
|
||||||
override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {}
|
|
||||||
override fun afterTextChanged(s: Editable) {
|
|
||||||
val timeout = etTimeout.text.toString().trim()
|
|
||||||
if (timeout.isNotEmpty()) {
|
|
||||||
SettingUtils.requestTimeout = timeout.toInt()
|
|
||||||
if (SettingUtils.requestTimeout < 1) {
|
|
||||||
etTimeout.setText("1")
|
|
||||||
XToastUtils.error(R.string.invalid_timeout)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
XToastUtils.warning(R.string.invalid_timeout)
|
|
||||||
etTimeout.setText("1")
|
|
||||||
SettingUtils.requestTimeout = 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//设置设备名称
|
//设置设备名称
|
||||||
|
@ -1145,6 +1145,7 @@
|
|||||||
style="@style/settingBarStyle"
|
style="@style/settingBarStyle"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:baselineAligned="false"
|
||||||
android:paddingEnd="15dp"
|
android:paddingEnd="15dp"
|
||||||
tools:ignore="RtlSymmetry">
|
tools:ignore="RtlSymmetry">
|
||||||
|
|
||||||
@ -1167,95 +1168,106 @@
|
|||||||
tools:ignore="SmallSp" />
|
tools:ignore="SmallSp" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginStart="5dp"
|
|
||||||
android:text="@string/retry"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<EditText
|
|
||||||
android:id="@+id/et_retry_times"
|
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1"
|
||||||
android:autofillHints=""
|
android:orientation="vertical">
|
||||||
android:digits="0123456789"
|
|
||||||
android:inputType="number"
|
|
||||||
android:maxLength="2"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:text="@string/_0"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:textSize="12sp"
|
|
||||||
tools:ignore="LabelFor" />
|
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/times"
|
android:orientation="horizontal">
|
||||||
android:textSize="12sp"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="5dp"
|
android:layout_marginStart="5dp"
|
||||||
android:text="@string/interval"
|
android:text="@string/retry"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
android:textStyle="bold" />
|
android:textStyle="bold" />
|
||||||
|
|
||||||
<EditText
|
<com.xuexiang.xui.widget.picker.XSeekBar
|
||||||
android:id="@+id/et_delay_time"
|
android:id="@+id/xsb_retry_times"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_weight="1"
|
android:layout_marginStart="5dp"
|
||||||
android:autofillHints=""
|
android:layout_weight="1"
|
||||||
android:digits="0123456789"
|
app:xsb_max="30"
|
||||||
android:inputType="number"
|
app:xsb_min="0" />
|
||||||
android:maxLength="2"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:text="@string/_1"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:textSize="12sp"
|
|
||||||
tools:ignore="LabelFor" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="@string/seconds"
|
android:layout_marginStart="5dp"
|
||||||
android:textSize="12sp"
|
android:text="@string/times"
|
||||||
android:textStyle="bold" />
|
android:textSize="12sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="5dp"
|
android:orientation="horizontal">
|
||||||
android:text="@string/timeout"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:textStyle="bold" />
|
|
||||||
|
|
||||||
<EditText
|
<TextView
|
||||||
android:id="@+id/et_timeout"
|
android:layout_width="wrap_content"
|
||||||
android:layout_width="0dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_marginStart="5dp"
|
||||||
android:layout_weight="1"
|
android:text="@string/interval"
|
||||||
android:autofillHints=""
|
android:textSize="12sp"
|
||||||
android:digits="0123456789"
|
android:textStyle="bold" />
|
||||||
android:inputType="number"
|
|
||||||
android:maxLength="2"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:text="@string/_10"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:textSize="12sp"
|
|
||||||
tools:ignore="LabelFor" />
|
|
||||||
|
|
||||||
<TextView
|
<com.xuexiang.xui.widget.picker.XSeekBar
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/xsb_delay_time"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:text="@string/seconds"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="12sp"
|
android:layout_marginStart="5dp"
|
||||||
android:textStyle="bold" />
|
android:layout_weight="1"
|
||||||
|
app:xsb_max="99"
|
||||||
|
app:xsb_min="1" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:text="@string/seconds"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:text="@string/timeout"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
|
||||||
|
<com.xuexiang.xui.widget.picker.XSeekBar
|
||||||
|
android:id="@+id/xsb_timeout"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
app:xsb_max="99"
|
||||||
|
app:xsb_min="1" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="5dp"
|
||||||
|
android:text="@string/seconds"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textStyle="bold" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user