Skip to content

Commit

Permalink
Merge pull request #545 from mysteriumnetwork/bugfix/wifi_network_error
Browse files Browse the repository at this point in the history
Fixed wi-fi network error
  • Loading branch information
IrynaTsymbaliukGeniusee authored Mar 22, 2022
2 parents 9cdbe8f + caf09ac commit 22a5767
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,17 +198,17 @@ abstract class BaseActivity : AppCompatActivity() {
}

private fun subscribeViewModel() {
baseViewModel.balance.observe(this, {
baseViewModel.balance.observe(this) {
if (it < BaseViewModel.BALANCE_LIMIT) {
pushyNotifications.subscribe(PushyTopic.LESS_THEN_HALF_MYST)
} else {
pushyNotifications.unsubscribe(PushyTopic.LESS_THEN_HALF_MYST)
}
})
baseViewModel.balanceRunningOut.observe(this, {
}
baseViewModel.balanceRunningOut.observe(this) {
balanceRunningOutPopUp()
})
baseViewModel.connectionState.observe(this, {
}
baseViewModel.connectionState.observe(this) {
connectionState = it
if (
it == ConnectionState.CONNECTED ||
Expand All @@ -220,11 +220,11 @@ abstract class BaseActivity : AppCompatActivity() {
} else {
unprotectedConnection()
}
})
baseViewModel.insufficientFunds.observe(this, {
}
baseViewModel.insufficientFunds.observe(this) {
insufficientFundsPopUp()
})
baseViewModel.isInternetNotAvailable.observe(this, { isAvailable ->
}
baseViewModel.isInternetAvailable.observe(this) { isAvailable ->
isInternetAvailable = isAvailable
if (!isAvailable) {
wifiNetworkErrorPopUp()
Expand All @@ -233,7 +233,7 @@ abstract class BaseActivity : AppCompatActivity() {
wifiErrorDialog = null
retryLoading()
}
})
}
}

private fun isHintAlreadyShown() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ class BaseViewModel(useCaseProvider: UseCaseProvider) : ViewModel() {
val insufficientFunds: LiveData<Unit>
get() = _insufficientFunds

val isInternetNotAvailable: LiveData<Boolean>
get() = _isInternetNotAvailable
val isInternetAvailable: LiveData<Boolean>
get() = _isInternetAvailable

val balance: LiveData<Double>
get() = _balance
Expand All @@ -39,7 +39,7 @@ class BaseViewModel(useCaseProvider: UseCaseProvider) : ViewModel() {
private val _balanceRunningOut = SingleLiveEvent<Boolean>()
private val _connectionState = MutableLiveData<ConnectionState>()
private val _insufficientFunds = MutableLiveData<Unit>()
private val _isInternetNotAvailable = SingleLiveEvent<Boolean>()
private val _isInternetAvailable = SingleLiveEvent<Boolean>()
private val balanceUseCase = useCaseProvider.balance()
private val connectionUseCase = useCaseProvider.connection()
private val settingsUseCase = useCaseProvider.settings()
Expand Down Expand Up @@ -68,7 +68,7 @@ class BaseViewModel(useCaseProvider: UseCaseProvider) : ViewModel() {
checkInternetConnection()
} else {
numberOfInternetCheck = 0
_isInternetNotAvailable.postValue(false)
_isInternetAvailable.postValue(false)
}
}
viewModelScope.launch(handler) {
Expand All @@ -78,13 +78,14 @@ class BaseViewModel(useCaseProvider: UseCaseProvider) : ViewModel() {
}
isInternetChecking = false
if (exitValue == 0) {
_isInternetNotAvailable.postValue(true)
numberOfInternetCheck = 0
_isInternetAvailable.postValue(true)
} else {
if (numberOfInternetCheck <= 3) {
checkInternetConnection()
} else {
numberOfInternetCheck = 0
_isInternetNotAvailable.postValue(false)
_isInternetAvailable.postValue(false)
}
}
}
Expand Down

0 comments on commit 22a5767

Please sign in to comment.