Skip to content

Commit

Permalink
fix data retrieval error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
wuan committed Jun 6, 2020
1 parent dda7576 commit a65cfb1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ android {
applicationId "org.blitzortung.android.app"
minSdkVersion 15
targetSdkVersion 29
versionCode 263
versionCode 264
versionName '2.1.0'
multiDexEnabled true
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/java/org/blitzortung/android/data/FetchDataTask.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package org.blitzortung.android.data

import android.util.Log
import kotlinx.coroutines.*
import org.blitzortung.android.app.Main
import org.blitzortung.android.app.R
import org.blitzortung.android.data.provider.data.DataProvider
import org.blitzortung.android.data.provider.result.ResultEvent
import java.net.SocketException
import java.net.SocketTimeoutException
import java.net.UnknownHostException
import kotlin.coroutines.CoroutineContext
import kotlin.reflect.KSuspendFunction1

Expand Down Expand Up @@ -47,8 +50,6 @@ internal open class FetchDataTask(
handleErrorUserFeedback(e)

ResultEvent(failed = true, referenceTime = System.currentTimeMillis(), parameters = parameters, flags = flags)

null
}
}

Expand All @@ -57,14 +58,16 @@ internal open class FetchDataTask(
is SocketTimeoutException ->
R.string.timeout_warning

is SocketException ->
is SocketException, is UnknownHostException->
R.string.connection_warning

else -> null
}

if (warningToastStringResource != null) {
toast.invoke(warningToastStringResource)
withContext(Dispatchers.Main) {
toast.invoke(warningToastStringResource)
}
}
}

Expand Down

0 comments on commit a65cfb1

Please sign in to comment.