Skip to content

Commit 5af8ad3

Browse files
committed
[#101] Minor name changes
1 parent 8a173a8 commit 5af8ad3

File tree

7 files changed

+16
-16
lines changed

7 files changed

+16
-16
lines changed

app/src/main/java/co/nimblehq/compose/crypto/ui/screens/home/HomeScreen.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,10 @@ fun HomeScreen(
5757
}
5858

5959
// TODO remove in integration ticket
60-
val hasConnection by viewModel.hasConnection.collectAsState()
61-
LaunchedEffect(key1 = hasConnection) {
62-
if (hasConnection != null) {
63-
Toast.makeText(context,"Connection: $hasConnection", Toast.LENGTH_SHORT).show()
60+
val isNetworkConnected by viewModel.hasConnection.collectAsState()
61+
LaunchedEffect(isNetworkConnected) {
62+
if (isNetworkConnected != null) {
63+
Toast.makeText(context,"Connection: $isNetworkConnected", Toast.LENGTH_SHORT).show()
6464
}
6565
}
6666

app/src/main/java/co/nimblehq/compose/crypto/ui/screens/home/HomeViewModel.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class HomeViewModel @Inject constructor(
5252
dispatchers: DispatchersProvider,
5353
private val getMyCoinsUseCase: GetMyCoinsUseCase,
5454
private val getTrendingCoinsUseCase: GetTrendingCoinsUseCase,
55-
private val getConnectionStatusUseCase: GetConnectionStatusUseCase,
55+
private val isNetworkConnectedUseCase: IsNetworkConnectedUseCase,
5656
) : BaseViewModel(dispatchers), Input, Output {
5757

5858
override val input = this
@@ -92,7 +92,7 @@ class HomeViewModel @Inject constructor(
9292
loadData()
9393
// TODO remove in integration ticket
9494
execute {
95-
getConnectionStatusUseCase()
95+
isNetworkConnectedUseCase()
9696
.collect {
9797
_hasConnection.emit(it)
9898
}

app/src/test/java/co/nimblehq/compose/crypto/ui/screens/home/HomeScreenTest.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ class HomeScreenTest : BaseViewModelTest() {
5555
private val mockGetTrendingCoinsUseCase = mockk<GetTrendingCoinsUseCase>()
5656

5757
// TODO remove in integration ticket
58-
private val mockGetConnectionStatusUseCase = mockk<GetConnectionStatusUseCase>()
58+
private val mockIsNetworkConnectedUseCase = mockk<IsNetworkConnectedUseCase>()
5959

6060
private lateinit var viewModel: HomeViewModel
6161

6262
private var appDestination: AppDestination? = null
6363

6464
@Before
6565
fun setUp() {
66-
every { mockGetConnectionStatusUseCase() } returns flowOf(null)
66+
every { mockIsNetworkConnectedUseCase() } returns flowOf(null)
6767
composeAndroidTestRule.activity.setContent {
6868
HomeScreen(
6969
viewModel = viewModel,
@@ -220,7 +220,7 @@ class HomeScreenTest : BaseViewModelTest() {
220220
dispatchers = testDispatcherProvider,
221221
getMyCoinsUseCase = mockGetMyCoinsUseCase,
222222
getTrendingCoinsUseCase = mockGetTrendingCoinsUseCase,
223-
getConnectionStatusUseCase = mockGetConnectionStatusUseCase
223+
isNetworkConnectedUseCase = mockIsNetworkConnectedUseCase
224224
)
225225
}
226226
}

app/src/test/java/co/nimblehq/compose/crypto/ui/screens/home/HomeViewModelTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class HomeViewModelTest : BaseViewModelTest() {
2525
private lateinit var viewModel: HomeViewModel
2626

2727
// TODO remove in integration ticket
28-
private val mockGetConnectionStatusUseCase = mockk<GetConnectionStatusUseCase>()
28+
private val mockIsNetworkConnectedUseCase = mockk<IsNetworkConnectedUseCase>()
2929

3030
@Before
3131
fun setUp() {
@@ -146,7 +146,7 @@ class HomeViewModelTest : BaseViewModelTest() {
146146
testDispatcherProvider,
147147
mockGetMyCoinsUseCase,
148148
mockGetTrendingCoinsUseCase,
149-
mockGetConnectionStatusUseCase
149+
mockIsNetworkConnectedUseCase
150150
)
151151
}
152152
}

data/src/main/java/co/nimblehq/compose/crypto/data/repository/GlobalRepositoryImpl.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class GlobalRepositoryImpl(
1010
context: Context
1111
) : GlobalRepository {
1212

13-
private var isNetworkConnected: MutableStateFlow<Boolean?> = MutableStateFlow(null)
13+
private val isNetworkConnected: MutableStateFlow<Boolean?> = MutableStateFlow(null)
1414

1515
private val networkRequest = NetworkRequest.Builder()
1616
.addCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET)
@@ -49,5 +49,5 @@ class GlobalRepositoryImpl(
4949
connectivityManager.requestNetwork(networkRequest, networkCallback)
5050
}
5151

52-
override fun getConnectionStatus(): Flow<Boolean?> = isNetworkConnected
52+
override fun isNetworkConnected(): Flow<Boolean?> = isNetworkConnected
5353
}

domain/src/main/java/co/nimblehq/compose/crypto/domain/repository/GlobalRepository.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@ package co.nimblehq.compose.crypto.domain.repository
33
import kotlinx.coroutines.flow.Flow
44

55
interface GlobalRepository {
6-
fun getConnectionStatus(): Flow<Boolean?>
6+
fun isNetworkConnected(): Flow<Boolean?>
77
}

domain/src/main/java/co/nimblehq/compose/crypto/domain/usecase/GetConnectionStatusUseCase.kt renamed to domain/src/main/java/co/nimblehq/compose/crypto/domain/usecase/IsNetworkConnectedUseCase.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ import co.nimblehq.compose.crypto.domain.repository.GlobalRepository
44
import kotlinx.coroutines.flow.Flow
55
import javax.inject.Inject
66

7-
class GetConnectionStatusUseCase @Inject constructor(private val repository: GlobalRepository) {
8-
operator fun invoke(): Flow<Boolean?> = repository.getConnectionStatus()
7+
class IsNetworkConnectedUseCase @Inject constructor(private val repository: GlobalRepository) {
8+
operator fun invoke(): Flow<Boolean?> = repository.isNetworkConnected()
99
}

0 commit comments

Comments
 (0)