Skip to content

Commit 1855137

Browse files
bugfix/error_signing_redirect: Fixed code review comments
* Processed code review comments.
1 parent 11f508e commit 1855137

File tree

4 files changed

+9
-17
lines changed

4 files changed

+9
-17
lines changed

app/src/main/java/ro/code4/monitorizarevot/exceptions/RetrofitException.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import java.io.IOException
1010
/**
1111
* Exception that is retrieved from retrofit. It is of three types, http, network and unexpected.
1212
*/
13-
open class RetrofitException internal constructor(
13+
class RetrofitException internal constructor(
1414
message: String?,
1515
/**
1616
* RobResponse object containing status code, headers, body, etc.

app/src/main/java/ro/code4/monitorizarevot/repositories/Repository.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,13 +260,14 @@ class Repository : KoinComponent {
260260
.toObservable()
261261
.subscribeOn(Schedulers.io())
262262
.flatMap {
263-
return@flatMap syncAnswers(it)
263+
syncAnswers(it)
264264
}
265265
.map {
266266
return@map it.successOrThrow()
267267
}
268268
.flatMap {
269269
return@flatMap db.formDetailsDao()
270+
270271
.updateAnsweredQuestions(countyCode, pollingStationNumber, formId)
271272
.andThen(Observable.just(it))
272273
}

app/src/main/java/ro/code4/monitorizarevot/ui/guide/GuideFragment.kt

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@ class GuideFragment : BaseViewModelFragment<GuideViewModel>() {
7171
description: String?,
7272
failingUrl: String?
7373
) {
74-
var message: String? = description
75-
if (TextUtils.isEmpty(message)) {
76-
message = "Unknown Error"
77-
}
74+
val message = description.takeUnless { it.isNullOrEmpty() } ?: "Unknown Error"
7875
onError(
7976
WebViewException(
8077
message!!,
@@ -91,15 +88,11 @@ class GuideFragment : BaseViewModelFragment<GuideViewModel>() {
9188

9289
override fun onError(thr: Throwable) {
9390
logE(TAG, "Error loading the page:" + thr.message)
94-
var messageId: String = getString(R.string.error_generic_message)
95-
if (thr is WebViewException) {
96-
if (thr.message.contains("ERR_INTERNET_DISCONNECTED")) {
97-
messageId = getString(R.string.error_no_connection)
98-
}
99-
}
91+
val messageId =
92+
if (thr is WebViewException) R.string.error_no_connection else R.string.error_generic_message
10093

10194
progressDialog.dismiss()
102-
logE(TAG, messageId)
95+
logE(TAG, getString(messageId))
10396
//todo add action
10497
}
10598

app/src/main/java/ro/code4/monitorizarevot/ui/login/LoginActivity.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,8 @@ class LoginActivity : BaseAnalyticsActivity<LoginViewModel>() {
100100
processHttpException(exception, fallback)
101101
}
102102
RetrofitException.Kind.NETWORK -> {
103-
var messageId: String = getString(R.string.error_generic)
104-
if (!isOnline()) {
105-
messageId = getString(R.string.login_no_internet)
106-
}
103+
val messageId =
104+
if (!isOnline()) R.string.login_no_internet else R.string.error_generic
107105

108106
Snackbar.make(
109107
loginButton,

0 commit comments

Comments
 (0)