Fix service restart
This commit is contained in:
@@ -156,7 +156,7 @@ class BoxService(
|
||||
}
|
||||
|
||||
if (delayStart) {
|
||||
delay(200L)
|
||||
delay(1000L)
|
||||
}
|
||||
|
||||
newService.start()
|
||||
@@ -171,7 +171,7 @@ class BoxService(
|
||||
|
||||
override fun serviceReload() {
|
||||
status.postValue(Status.Starting)
|
||||
GlobalScope.launch(Dispatchers.IO) {
|
||||
runBlocking {
|
||||
val pfd = fileDescriptor
|
||||
if (pfd != null) {
|
||||
pfd.close()
|
||||
|
||||
@@ -98,11 +98,11 @@ class OverviewFragment : Fragment() {
|
||||
val status = Libbox.newStandaloneCommandClient().systemProxyStatus
|
||||
withContext(Dispatchers.Main) {
|
||||
binding.systemProxyCard.isVisible = status.available
|
||||
binding.systemProxyCard.isEnabled = true
|
||||
binding.systemProxySwitch.setOnClickListener(null)
|
||||
binding.systemProxySwitch.isChecked = status.enabled
|
||||
binding.systemProxySwitch.isEnabled = true
|
||||
binding.systemProxySwitch.setOnCheckedChangeListener { buttonView, isChecked ->
|
||||
binding.systemProxyCard.isEnabled = false
|
||||
binding.systemProxySwitch.isEnabled = false
|
||||
lifecycleScope.launch(Dispatchers.IO) {
|
||||
Settings.systemProxyEnabled = isChecked
|
||||
runCatching {
|
||||
@@ -247,7 +247,7 @@ class OverviewFragment : Fragment() {
|
||||
|
||||
class Adapter(
|
||||
internal val scope: CoroutineScope,
|
||||
private val parent: FragmentDashboardOverviewBinding
|
||||
internal val parent: FragmentDashboardOverviewBinding
|
||||
) :
|
||||
RecyclerView.Adapter<Holder>() {
|
||||
|
||||
@@ -312,6 +312,7 @@ class OverviewFragment : Fragment() {
|
||||
binding.profileSelected.isChecked = profile.id == adapter.selectedProfileID
|
||||
binding.profileSelected.setOnCheckedChangeListener { _, isChecked ->
|
||||
if (isChecked) {
|
||||
adapter.parent.profileList.isClickable = false
|
||||
adapter.selectedProfileID = profile.id
|
||||
adapter.lastSelectedIndex?.let { index ->
|
||||
adapter.notifyItemChanged(index)
|
||||
@@ -319,6 +320,9 @@ class OverviewFragment : Fragment() {
|
||||
adapter.lastSelectedIndex = adapterPosition
|
||||
adapter.scope.launch(Dispatchers.IO) {
|
||||
switchProfile(profile)
|
||||
withContext(Dispatchers.Main) {
|
||||
adapter.parent.profileList.isEnabled = true
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -338,7 +342,7 @@ class OverviewFragment : Fragment() {
|
||||
if (restart) {
|
||||
mainActivity.reconnect()
|
||||
BoxService.stop()
|
||||
delay(200L)
|
||||
delay(1000L)
|
||||
mainActivity.startService()
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user