Skip to content

Commit

Permalink
Merge pull request #8 from jxareas/bugfix/video-fragment-crash-on-unk…
Browse files Browse the repository at this point in the history
…nown-host-exception

Fix App Crash on UnknownHostException
  • Loading branch information
jxareas committed Dec 13, 2022
2 parents c02d569 + bd9dd8d commit 46b528d
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
12 changes: 6 additions & 6 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ dependencies {
implementation(Dependencies.Navigation.NAVIGATION_UI)

// OkHttp
implementation(Dependencies.Network.OKHTTP_CLIENT)
implementation(Dependencies.Network.LOGGING_INTERCEPTOR)
implementation(Dependencies.Square.OKHTTP_CLIENT)
implementation(Dependencies.Square.LOGGING_INTERCEPTOR)

// Retrofit
implementation(Dependencies.Network.RETROFIT)
implementation(Dependencies.Network.MOSHI_CONVERTER)
implementation(Dependencies.Square.RETROFIT)
implementation(Dependencies.Square.MOSHI_CONVERTER)

// Dagger Hilt
implementation(Dependencies.Dagger.HILT)
Expand All @@ -130,8 +130,8 @@ dependencies {
implementation(Dependencies.Android.SPLASH_SCREEN)

// Shimmer
implementation(Dependencies.Shimmer.SHIMMER)
implementation(Dependencies.Facebook.SHIMMER)

// Moshi
implementation(Dependencies.Moshi.MOSHI)
implementation(Dependencies.Square.MOSHI)
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import kotlinx.coroutines.flow.buffer
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.flowOn
import retrofit2.HttpException
import java.io.IOException
import javax.inject.Inject

class VideoClipsRepositoryImpl @Inject constructor(
Expand All @@ -29,7 +30,7 @@ class VideoClipsRepositoryImpl @Inject constructor(
} ?: run {
throw HttpException(response)
}
} catch (networkException: HttpException) {
} catch (networkException: IOException) {
emit(NetworkResult.Error(networkException))
}
}.buffer()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class VideoClipsFragment : Fragment() {
private val binding: FragmentVideoClipsBinding
get() = _binding!!

private val viewModel: VideosViewModel by viewModels()
private val viewModel: VideoClipsViewModel by viewModels()

private val videoClipsListAdapter = VideoClipsAdapter { videoDto ->
handleVideoClick(videoDto)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import kotlinx.coroutines.flow.onEach
import javax.inject.Inject

@HiltViewModel
class VideosViewModel @Inject constructor(
class VideoClipsViewModel @Inject constructor(
private val repository: VideoClipsRepository
) : ViewModel() {

Expand Down
7 changes: 2 additions & 5 deletions buildSrc/src/main/kotlin/com/jxareas/goalie/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ object Dependencies {
"org.jetbrains.kotlin:kotlin-serialization:$KOTLIN_SERIALIZATION_VERSION"
}

object Network {
object Square {
private const val OKHTTP_VERSION = "4.10.0"
const val OKHTTP_CLIENT = "com.squareup.okhttp3:okhttp:$OKHTTP_VERSION"
const val LOGGING_INTERCEPTOR = "com.squareup.okhttp3:logging-interceptor:$OKHTTP_VERSION"
Expand All @@ -91,15 +91,12 @@ object Dependencies {
const val RETROFIT = "com.squareup.retrofit2:retrofit:$RETROFIT_VERSION"
const val MOSHI_CONVERTER =
"com.squareup.retrofit2:converter-moshi:$RETROFIT_VERSION"
}

object Moshi {
private const val MOSHI_VERSION = "1.13.0"
const val MOSHI = "com.squareup.moshi:moshi-kotlin:$MOSHI_VERSION"

}

object Shimmer {
object Facebook {
private const val SHIMMER_VERSION = "0.5.0"

const val SHIMMER = "com.facebook.shimmer:shimmer:$SHIMMER_VERSION"
Expand Down

0 comments on commit 46b528d

Please sign in to comment.