Browse Source

Remove redundant qualifier names'

Carles Sentis 1 year ago
parent
commit
70342c67e7

+ 8 - 8
feature/weather/src/main/java/com/trifork/feature/weather/data/mappers/WeatherMappers.kt

@@ -16,10 +16,10 @@ import java.time.format.DateTimeFormatter
 
 private data class IndexWeatherData(
     val index: Int,
-    val data: com.trifork.feature.weather.domain.model.WeatherData
+    val data: WeatherData
 )
 
-fun WeatherDataDto.toWeatherDataMap(sunData: com.trifork.feature.weather.domain.model.SunData): ImmutableMap<Int, ImmutableList<com.trifork.feature.weather.domain.model.WeatherData>> {
+fun WeatherDataDto.toWeatherDataMap(sunData: SunData): ImmutableMap<Int, ImmutableList<WeatherData>> {
     return time.mapIndexed { index, time ->
         val localDateTime = LocalDateTime.parse(time, DateTimeFormatter.ISO_DATE_TIME)
         val weatherCode = weatherCodes[index]
@@ -31,13 +31,13 @@ fun WeatherDataDto.toWeatherDataMap(sunData: com.trifork.feature.weather.domain.
 
         IndexWeatherData(
             index = index,
-            data = com.trifork.feature.weather.domain.model.WeatherData(
+            data = WeatherData(
                 time = localDateTime,
                 temperatureCelsius = temperature,
                 pressure = pressures[index],
                 windSpeed = windSpeeds[index],
                 humidity = humidities[index],
-                weatherType = com.trifork.feature.weather.domain.model.WeatherType.fromWMO(
+                weatherType = WeatherType.fromWMO(
                     weatherCode,
                     isDay,
                     isFreezing
@@ -61,21 +61,21 @@ private fun isFreezing(temperature: Double): Boolean {
     return temperature < 0
 }
 
-private fun SunDataDto.sunData(): com.trifork.feature.weather.domain.model.SunData {
-    return com.trifork.feature.weather.domain.model.SunData(
+private fun SunDataDto.sunData(): SunData {
+    return SunData(
         sunrise = sunrise.map { LocalDateTime.parse(it, DateTimeFormatter.ISO_DATE_TIME) },
         sunset = sunset.map { LocalDateTime.parse(it, DateTimeFormatter.ISO_DATE_TIME) },
     )
 }
 
-fun WeatherDto.toWeatherInfo(): com.trifork.feature.weather.domain.model.WeatherInfo {
+fun WeatherDto.toWeatherInfo(): WeatherInfo {
     val weatherDataMap = weatherData.toWeatherDataMap(sunData.sunData())
     val now = LocalDateTime.now()
     val currentWeatherData = weatherDataMap[0]?.find {
         val hour = if (now.minute < 30) now.hour else now.hour + 1
         it.time.hour == hour
     }
-    return com.trifork.feature.weather.domain.model.WeatherInfo(
+    return WeatherInfo(
         geoLocation = "",
         weatherDataPerDay = weatherDataMap,
         currentWeatherData = currentWeatherData

+ 6 - 3
feature/weather/src/main/java/com/trifork/feature/weather/data/repository/WeatherRepositoryImpl.kt

@@ -2,12 +2,15 @@ package com.trifork.feature.weather.data.repository
 
 import com.trifork.feature.common.util.Resource
 import com.trifork.feature.weather.data.mappers.toWeatherInfo
+import com.trifork.feature.weather.data.remote.WeatherApi
+import com.trifork.feature.weather.domain.model.WeatherInfo
+import com.trifork.feature.weather.domain.repository.WeatherRepository
 import javax.inject.Inject
 
 class WeatherRepositoryImpl @Inject constructor(
-    private val api: com.trifork.feature.weather.data.remote.WeatherApi
-) : com.trifork.feature.weather.domain.repository.WeatherRepository {
-    override suspend fun getWeatherData(lat: Double, long: Double): Resource<com.trifork.feature.weather.domain.model.WeatherInfo> {
+    private val api: WeatherApi
+) : WeatherRepository {
+    override suspend fun getWeatherData(lat: Double, long: Double): Resource<WeatherInfo> {
         return try {
             Resource.Success(
                 data = api.getWeatherData(

+ 2 - 1
feature/weather/src/main/java/com/trifork/feature/weather/di/LocationModule.kt

@@ -1,5 +1,6 @@
 package com.trifork.feature.weather.di
 
+import com.trifork.feature.weather.data.location.DefaultLocationTracker
 import com.trifork.feature.weather.domain.location.LocationTracker
 import dagger.Binds
 import dagger.Module
@@ -12,6 +13,6 @@ abstract class LocationModule {
 
     @Binds
     abstract fun bindsLocationTracker(
-        defaultLocationTracker: com.trifork.feature.weather.data.location.DefaultLocationTracker
+        defaultLocationTracker: DefaultLocationTracker
     ): LocationTracker
 }

+ 2 - 1
feature/weather/src/main/java/com/trifork/feature/weather/di/RepositoryModule.kt

@@ -1,6 +1,7 @@
 package com.trifork.feature.weather.di
 
 import com.trifork.feature.weather.data.repository.WeatherRepositoryImpl
+import com.trifork.feature.weather.domain.repository.WeatherRepository
 import dagger.Binds
 import dagger.Module
 import dagger.hilt.InstallIn
@@ -13,5 +14,5 @@ abstract class RepositoryModule {
     @Binds
     abstract fun bindsWeatherRepository(
         weatherRepositoryIml: WeatherRepositoryImpl
-    ): com.trifork.feature.weather.domain.repository.WeatherRepository
+    ): WeatherRepository
 }

+ 4 - 2
feature/weather/src/main/java/com/trifork/feature/weather/presentation/components/WeatherForecast.kt

@@ -18,7 +18,9 @@ import androidx.compose.ui.Alignment
 import androidx.compose.ui.Modifier
 import androidx.compose.ui.unit.dp
 import androidx.compose.ui.unit.sp
+import com.trifork.feature.weather.domain.model.WeatherData
 import com.trifork.feature.weather.domain.model.WeatherInfo
+import com.trifork.feature.weather.presentation.WeatherViewModel
 import com.trifork.feature.weather.presentation.mvi.WeatherEvent
 import kotlinx.collections.immutable.ImmutableList
 import java.time.LocalDateTime
@@ -27,8 +29,8 @@ import java.util.Locale
 @Composable
 fun WeatherForecast(
     weatherInfo: WeatherInfo,
-    perDay: ImmutableList<com.trifork.feature.weather.domain.model.WeatherData>,
-    viewModel: com.trifork.feature.weather.presentation.WeatherViewModel,
+    perDay: ImmutableList<WeatherData>,
+    viewModel: WeatherViewModel,
     modifier: Modifier = Modifier,
 ) {
     Column(

+ 8 - 5
feature/weather/src/main/java/com/trifork/feature/weather/presentation/components/WeatherScreen.kt

@@ -39,13 +39,16 @@ import androidx.compose.ui.text.style.TextAlign
 import androidx.compose.ui.unit.dp
 import androidx.navigation.NavController
 import com.trifork.feature.common.navigation.Screen
+import com.trifork.feature.weather.domain.model.WeatherLocation
+import com.trifork.feature.weather.presentation.WeatherViewModel
+import com.trifork.feature.weather.presentation.mvi.WeatherEvent
 
 @OptIn(ExperimentalMaterial3Api::class, ExperimentalMaterialApi::class)
 @Composable
 fun WeatherScreen(
     navController: NavController,
-    viewModel: com.trifork.feature.weather.presentation.WeatherViewModel,
-    geoLocation: com.trifork.feature.weather.domain.model.WeatherLocation
+    viewModel: WeatherViewModel,
+    geoLocation: WeatherLocation
 ) {
     val state by viewModel.state.collectAsState()
 
@@ -53,14 +56,14 @@ fun WeatherScreen(
         ActivityResultContracts.RequestMultiplePermissions()
     ) { map ->
         if (map.values.filter { it }.size > 1) {
-            viewModel.state.handleEvent(com.trifork.feature.weather.presentation.mvi.WeatherEvent.LoadWeatherInfo(geoLocation))
+            viewModel.state.handleEvent(WeatherEvent.LoadWeatherInfo(geoLocation))
         }
     }
 
     val isLoading = state.isLoading
     val pullRefreshState = rememberPullRefreshState(isLoading, {
         viewModel.state.handleEvent(
-            com.trifork.feature.weather.presentation.mvi.WeatherEvent.LoadWeatherInfo(
+            WeatherEvent.LoadWeatherInfo(
                 geoLocation
             )
         )
@@ -97,7 +100,7 @@ fun WeatherScreen(
                 actions = {
                     IconButton(onClick = {
                         viewModel.state.handleEvent(
-                            com.trifork.feature.weather.presentation.mvi.WeatherEvent.LoadWeatherInfo(com.trifork.feature.weather.domain.model.WeatherLocation())
+                            WeatherEvent.LoadWeatherInfo(WeatherLocation())
                         )
                     }) {
                         Icon(

+ 5 - 2
feature/weather/src/main/java/com/trifork/feature/weather/presentation/mvi/WeatherEvent.kt

@@ -1,9 +1,12 @@
 package com.trifork.feature.weather.presentation.mvi
 
+import com.trifork.feature.weather.domain.model.WeatherInfo
+import com.trifork.feature.weather.domain.model.WeatherLocation
+
 sealed interface WeatherEvent {
-    data class LoadWeatherInfo(val geoLocation: com.trifork.feature.weather.domain.model.WeatherLocation) :
+    data class LoadWeatherInfo(val geoLocation: WeatherLocation) :
         WeatherEvent
-    data class UpdateHourlyInfo(val weatherInfo: com.trifork.feature.weather.domain.model.WeatherInfo) :
+    data class UpdateHourlyInfo(val weatherInfo: WeatherInfo) :
         WeatherEvent
     data class Error(val message: String) : WeatherEvent
 }

+ 3 - 1
feature/weather/src/main/java/com/trifork/feature/weather/presentation/mvi/WeatherState.kt

@@ -1,9 +1,11 @@
 package com.trifork.feature.weather.presentation.mvi
 
+import com.trifork.feature.weather.domain.model.WeatherInfo
+
 data class WeatherState(
     val isLoading: Boolean,
     val error: String?,
-    val weatherInfo: com.trifork.feature.weather.domain.model.WeatherInfo?
+    val weatherInfo: WeatherInfo?
 ) {
     companion object {
         val initial = WeatherState(