mirror of
https://github.com/pppscn/SmsForwarder
synced 2024-11-02 03:40:26 +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)
|
||||
@ -793,60 +793,20 @@ class SettingsFragment : BaseFragment<FragmentSettingsBinding?>(), View.OnClickL
|
||||
|
||||
//接口请求失败重试时间间隔
|
||||
private fun editRetryDelayTime(
|
||||
etRetryTimes: EditText, etDelayTime: EditText, etTimeout: EditText
|
||||
xsbRetryTimes: XSeekBar, xsbDelayTime: XSeekBar, xsbTimeout: XSeekBar
|
||||
) {
|
||||
etRetryTimes.setText(java.lang.String.valueOf(SettingUtils.requestRetryTimes))
|
||||
etRetryTimes.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 retryTimes = etRetryTimes.text.toString().trim()
|
||||
if (retryTimes.isNotEmpty()) {
|
||||
SettingUtils.requestRetryTimes = retryTimes.toInt()
|
||||
} else {
|
||||
etRetryTimes.setText("0")
|
||||
SettingUtils.requestRetryTimes = 0
|
||||
}
|
||||
}
|
||||
})
|
||||
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
|
||||
}
|
||||
}
|
||||
})
|
||||
xsbRetryTimes.setDefaultValue(SettingUtils.requestRetryTimes)
|
||||
xsbRetryTimes.setOnSeekBarListener { _: XSeekBar?, newValue: Int ->
|
||||
SettingUtils.requestRetryTimes = newValue
|
||||
}
|
||||
xsbDelayTime.setDefaultValue(SettingUtils.requestDelayTime)
|
||||
xsbDelayTime.setOnSeekBarListener { _: XSeekBar?, newValue: Int ->
|
||||
SettingUtils.requestDelayTime = newValue
|
||||
}
|
||||
xsbTimeout.setDefaultValue(SettingUtils.requestTimeout)
|
||||
xsbTimeout.setOnSeekBarListener { _: XSeekBar?, newValue: Int ->
|
||||
SettingUtils.requestTimeout = newValue
|
||||
}
|
||||
}
|
||||
|
||||
//设置设备名称
|
||||
|
@ -1145,6 +1145,7 @@
|
||||
style="@style/settingBarStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:baselineAligned="false"
|
||||
android:paddingEnd="15dp"
|
||||
tools:ignore="RtlSymmetry">
|
||||
|
||||
@ -1167,95 +1168,106 @@
|
||||
tools:ignore="SmallSp" />
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
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"
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:autofillHints=""
|
||||
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" />
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/times"
|
||||
android:textSize="12sp"
|
||||
android:textStyle="bold" />
|
||||
<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/interval"
|
||||
android:textSize="12sp"
|
||||
android:textStyle="bold" />
|
||||
<TextView
|
||||
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_delay_time"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:autofillHints=""
|
||||
android:digits="0123456789"
|
||||
android:inputType="number"
|
||||
android:maxLength="2"
|
||||
android:maxLines="1"
|
||||
android:text="@string/_1"
|
||||
android:textAlignment="center"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="LabelFor" />
|
||||
<com.xuexiang.xui.widget.picker.XSeekBar
|
||||
android:id="@+id/xsb_retry_times"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_weight="1"
|
||||
app:xsb_max="30"
|
||||
app:xsb_min="0" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/seconds"
|
||||
android:textSize="12sp"
|
||||
android:textStyle="bold" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:text="@string/times"
|
||||
android:textSize="12sp"
|
||||
android:textStyle="bold" />
|
||||
</LinearLayout>
|
||||
|
||||
<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" />
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/et_timeout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:autofillHints=""
|
||||
android:digits="0123456789"
|
||||
android:inputType="number"
|
||||
android:maxLength="2"
|
||||
android:maxLines="1"
|
||||
android:text="@string/_10"
|
||||
android:textAlignment="center"
|
||||
android:textSize="12sp"
|
||||
tools:ignore="LabelFor" />
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="5dp"
|
||||
android:text="@string/interval"
|
||||
android:textSize="12sp"
|
||||
android:textStyle="bold" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/seconds"
|
||||
android:textSize="12sp"
|
||||
android:textStyle="bold" />
|
||||
<com.xuexiang.xui.widget.picker.XSeekBar
|
||||
android:id="@+id/xsb_delay_time"
|
||||
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
|
||||
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>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user