Skip to content

Commit fd3acec

Browse files
committed
Update Spotless to 6.22.0
1 parent 78f95ec commit fd3acec

File tree

83 files changed

+1804
-1489
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

83 files changed

+1804
-1489
lines changed

Diff for: app/src/main/kotlin/dev/ricknout/rugbyranker/RugbyRankerApplication.kt

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import javax.inject.Inject
1111

1212
@HiltAndroidApp
1313
class RugbyRankerApplication : Application(), Configuration.Provider {
14-
1514
@Inject
1615
lateinit var workerFactory: HiltWorkerFactory
1716

@@ -25,9 +24,10 @@ class RugbyRankerApplication : Application(), Configuration.Provider {
2524
}
2625

2726
override val workManagerConfiguration: Configuration
28-
get() = Configuration.Builder()
29-
.setWorkerFactory(workerFactory)
30-
.build()
27+
get() =
28+
Configuration.Builder()
29+
.setWorkerFactory(workerFactory)
30+
.build()
3131

3232
@DelicateCoroutinesApi
3333
private fun setupTheme() {

Diff for: app/src/main/kotlin/dev/ricknout/rugbyranker/db/RugbyRankerDatabase.kt

-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ import dev.ricknout.rugbyranker.core.model.Ranking
1212
)
1313
@TypeConverters(RugbyRankerTypeConverters::class)
1414
abstract class RugbyRankerDatabase : RoomDatabase() {
15-
1615
abstract fun rankingDao(): RankingDao
1716

1817
companion object {

Diff for: app/src/main/kotlin/dev/ricknout/rugbyranker/db/RugbyRankerTypeConverters.kt

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import androidx.room.TypeConverter
44
import dev.ricknout.rugbyranker.core.model.Sport
55

66
class RugbyRankerTypeConverters {
7-
87
@TypeConverter
98
fun ordinalToSport(ordinal: Int): Sport = Sport.values()[ordinal]
109

Diff for: app/src/main/kotlin/dev/ricknout/rugbyranker/di/AppModule.kt

+15-6
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ import javax.inject.Singleton
3434
@InstallIn(SingletonComponent::class)
3535
@Module
3636
class AppModule {
37-
3837
@Provides
3938
@Singleton
4039
fun provideOkHttpClient(): OkHttpClient {
@@ -62,7 +61,9 @@ class AppModule {
6261

6362
@Provides
6463
@Singleton
65-
fun provideDatabase(@ApplicationContext context: Context): RugbyRankerDatabase {
64+
fun provideDatabase(
65+
@ApplicationContext context: Context,
66+
): RugbyRankerDatabase {
6667
return Room.databaseBuilder(
6768
context,
6869
RugbyRankerDatabase::class.java,
@@ -80,13 +81,17 @@ class AppModule {
8081

8182
@Provides
8283
@Singleton
83-
fun provideRankingDataStore(@ApplicationContext context: Context): RankingDataStore {
84+
fun provideRankingDataStore(
85+
@ApplicationContext context: Context,
86+
): RankingDataStore {
8487
return RankingDataStore(context.dataStore)
8588
}
8689

8790
@Provides
8891
@Singleton
89-
fun provideThemeDataStore(@ApplicationContext context: Context): ThemeDataStore {
92+
fun provideThemeDataStore(
93+
@ApplicationContext context: Context,
94+
): ThemeDataStore {
9095
return ThemeDataStore(context.dataStore)
9196
}
9297

@@ -129,7 +134,9 @@ class AppModule {
129134

130135
@Provides
131136
@Singleton
132-
fun provideWorkManager(@ApplicationContext context: Context): WorkManager {
137+
fun provideWorkManager(
138+
@ApplicationContext context: Context,
139+
): WorkManager {
133140
return WorkManager.getInstance(context)
134141
}
135142

@@ -147,7 +154,9 @@ class AppModule {
147154

148155
@Provides
149156
@Singleton
150-
fun provideNotificationManager(@ApplicationContext context: Context): NotificationManagerCompat {
157+
fun provideNotificationManager(
158+
@ApplicationContext context: Context,
159+
): NotificationManagerCompat {
151160
return NotificationManagerCompat.from(context)
152161
}
153162

Diff for: app/src/main/kotlin/dev/ricknout/rugbyranker/ui/MainActivity.kt

-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ import dev.ricknout.rugbyranker.info.ui.InfoViewModel
1919

2020
@AndroidEntryPoint
2121
class MainActivity : AppCompatActivity() {
22-
2322
private val infoViewModel: InfoViewModel by viewModels()
2423

2524
private lateinit var binding: ActivityMainBinding

Diff for: app/src/main/kotlin/dev/ricknout/rugbyranker/ui/SportFragment.kt

+41-37
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ import dev.ricknout.rugbyranker.ranking.ui.WomensRankingViewModel
5252

5353
@AndroidEntryPoint
5454
class SportFragment : Fragment() {
55-
5655
private val args: SportFragmentArgs by navArgs()
5756

5857
private val sport: Sport by lazy { args.sport }
@@ -99,11 +98,12 @@ class SportFragment : Fragment() {
9998
resources.getInteger(android.R.integer.config_mediumAnimTime).toLong()
10099
}
101100

102-
private val onBackPressedCallback = object : OnBackPressedCallback(false) {
103-
override fun handleOnBackPressed() {
104-
binding.viewPager.currentItem = POSITION_RANKINGS
101+
private val onBackPressedCallback =
102+
object : OnBackPressedCallback(false) {
103+
override fun handleOnBackPressed() {
104+
binding.viewPager.currentItem = POSITION_RANKINGS
105+
}
105106
}
106-
}
107107

108108
override fun onCreate(savedInstanceState: Bundle?) {
109109
super.onCreate(savedInstanceState)
@@ -120,7 +120,10 @@ class SportFragment : Fragment() {
120120
return binding.root
121121
}
122122

123-
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
123+
override fun onViewCreated(
124+
view: View,
125+
savedInstanceState: Bundle?,
126+
) {
124127
super.onViewCreated(view, savedInstanceState)
125128
postponeEnterTransition()
126129
view.doOnPreDraw { startPostponedEnterTransition() }
@@ -144,20 +147,22 @@ class SportFragment : Fragment() {
144147
rankingViewModel.setPredictions(predictions)
145148
val currentPredictions = binding.predictionBar.getPredictions()
146149
binding.predictionBar.setPredictions(predictions)
147-
val shouldTransition = when {
148-
currentPredictions.isEmpty() && !predictions.isNullOrEmpty() -> true
149-
currentPredictions.isNotEmpty() && predictions.isNullOrEmpty() -> true
150-
else -> false
151-
}
150+
val shouldTransition =
151+
when {
152+
currentPredictions.isEmpty() && !predictions.isNullOrEmpty() -> true
153+
currentPredictions.isNotEmpty() && predictions.isNullOrEmpty() -> true
154+
else -> false
155+
}
152156
val shouldShowRankings = currentPredictions != predictions
153157
if (shouldShowRankings) binding.viewPager.currentItem = POSITION_RANKINGS
154158
if (!shouldTransition) return@observe
155-
val transition = MaterialContainerTransform().apply {
156-
duration = transitionDuration
157-
interpolator = FastOutSlowInInterpolator()
158-
scrimColor = Color.TRANSPARENT
159-
fadeMode = MaterialContainerTransform.FADE_MODE_OUT
160-
}
159+
val transition =
160+
MaterialContainerTransform().apply {
161+
duration = transitionDuration
162+
interpolator = FastOutSlowInInterpolator()
163+
scrimColor = Color.TRANSPARENT
164+
fadeMode = MaterialContainerTransform.FADE_MODE_OUT
165+
}
161166
transition.addTarget(binding.fab)
162167
if (predictions.isNullOrEmpty()) {
163168
transition.startView = binding.predictionBar
@@ -233,7 +238,6 @@ class SportFragment : Fragment() {
233238
}.attach()
234239
binding.appBar.tabLayout.addOnTabSelectedListener(
235240
object : TabLayout.OnTabSelectedListener {
236-
237241
override fun onTabSelected(tab: TabLayout.Tab?) {
238242
onBackPressedCallback.isEnabled = tab?.position != POSITION_RANKINGS
239243
}
@@ -262,20 +266,20 @@ class SportFragment : Fragment() {
262266
}
263267

264268
private fun setupPredictionBar() {
265-
binding.predictionBar.listener = object : PredictionBar.PredictionBarListener {
266-
267-
override fun onAddPredictionClick() {
268-
findNavController().navigate(SportFragmentDirections.sportToPrediction(sport))
269-
}
269+
binding.predictionBar.listener =
270+
object : PredictionBar.PredictionBarListener {
271+
override fun onAddPredictionClick() {
272+
findNavController().navigate(SportFragmentDirections.sportToPrediction(sport))
273+
}
270274

271-
override fun onPredictionClick(prediction: Prediction) {
272-
findNavController().navigate(SportFragmentDirections.sportToPrediction(sport, prediction, edit = true))
273-
}
275+
override fun onPredictionClick(prediction: Prediction) {
276+
findNavController().navigate(SportFragmentDirections.sportToPrediction(sport, prediction, edit = true))
277+
}
274278

275-
override fun onRemovePredictionClick(prediction: Prediction) {
276-
predictionViewModel.removePrediction(prediction)
279+
override fun onRemovePredictionClick(prediction: Prediction) {
280+
predictionViewModel.removePrediction(prediction)
281+
}
277282
}
278-
}
279283
}
280284

281285
private fun toggleLiveMatchTabIcon(show: Boolean) {
@@ -312,14 +316,14 @@ class SportFragment : Fragment() {
312316
}
313317

314318
inner class SportAdapter(fragment: Fragment) : FragmentStateAdapter(fragment) {
315-
316-
override fun createFragment(position: Int) = when (position) {
317-
POSITION_RANKINGS -> RankingFragment.newInstance(sport)
318-
POSITION_MATCHES_UNPLAYED -> MatchFragment.newInstance(sport, Status.UNPLAYED)
319-
POSITION_MATCHES_COMPLETE -> MatchFragment.newInstance(sport, Status.COMPLETE)
320-
POSITION_MATCHES_LIVE -> LiveMatchFragment.newInstance(sport)
321-
else -> throw IllegalArgumentException("Position $position exceeds SportAdapter count")
322-
}
319+
override fun createFragment(position: Int) =
320+
when (position) {
321+
POSITION_RANKINGS -> RankingFragment.newInstance(sport)
322+
POSITION_MATCHES_UNPLAYED -> MatchFragment.newInstance(sport, Status.UNPLAYED)
323+
POSITION_MATCHES_COMPLETE -> MatchFragment.newInstance(sport, Status.COMPLETE)
324+
POSITION_MATCHES_LIVE -> LiveMatchFragment.newInstance(sport)
325+
else -> throw IllegalArgumentException("Position $position exceeds SportAdapter count")
326+
}
323327

324328
override fun getItemCount() = 4
325329
}

Diff for: core/src/main/kotlin/dev/ricknout/rugbyranker/core/api/WorldRugbyService.kt

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import retrofit2.http.Path
55
import retrofit2.http.Query
66

77
interface WorldRugbyService {
8-
98
@GET("rugby/v3/rankings/{sport}")
109
suspend fun getRankings(
1110
@Path("sport") sport: String,

Diff for: core/src/main/kotlin/dev/ricknout/rugbyranker/core/db/RankingDao.kt

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import kotlinx.coroutines.flow.Flow
1010

1111
@Dao
1212
interface RankingDao {
13-
1413
@Insert(onConflict = OnConflictStrategy.REPLACE)
1514
suspend fun insert(rankings: List<Ranking>)
1615

Diff for: core/src/main/kotlin/dev/ricknout/rugbyranker/core/lifecycle/ScrollableViewModel.kt

-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import androidx.lifecycle.asLiveData
66
import kotlinx.coroutines.flow.MutableStateFlow
77

88
open class ScrollableViewModel : ViewModel() {
9-
109
private val _scrollToTop = MutableStateFlow(false)
1110
val scrollToTop: LiveData<Boolean> = _scrollToTop.asLiveData()
1211

Diff for: core/src/main/kotlin/dev/ricknout/rugbyranker/core/model/Ranking.kt

-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ data class Ranking(
1616
val matches: Int,
1717
val sport: Sport,
1818
) {
19-
2019
fun resetPreviousPoints() = copy(previousPoints = this.points)
2120

2221
fun addPoints(points: Float) = copy(points = this.points + points)

Diff for: core/src/main/kotlin/dev/ricknout/rugbyranker/core/ui/MaterialListPopupWindow.kt

+19-17
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,24 @@ import com.google.android.material.color.MaterialColors
1111
import com.google.android.material.shape.MaterialShapeDrawable
1212
import dev.ricknout.rugbyranker.core.R
1313

14-
class MaterialListPopupWindow @JvmOverloads constructor(
15-
context: Context,
16-
attrs: AttributeSet? = null,
17-
@AttrRes defStyleAttr: Int = R.attr.listPopupWindowStyle,
18-
@StyleRes defStyleRes: Int = R.style.Widget_MaterialComponents_ListPopupWindow,
19-
) : ListPopupWindow(context, attrs, defStyleAttr, defStyleRes) {
20-
21-
init {
22-
val materialShapeDrawable = MaterialShapeDrawable(context, attrs, defStyleAttr, defStyleRes).apply {
23-
initializeElevationOverlay(context)
24-
val surfaceColor = MaterialColors.getColor(context, R.attr.colorSurface, javaClass.canonicalName)
25-
fillColor = ColorStateList.valueOf(surfaceColor)
26-
context.withStyledAttributes(attrs, R.styleable.MaterialListPopupWindow, defStyleAttr, defStyleRes) {
27-
elevation = getDimension(R.styleable.MaterialListPopupWindow_android_popupElevation, 0f)
28-
}
14+
class MaterialListPopupWindow
15+
@JvmOverloads
16+
constructor(
17+
context: Context,
18+
attrs: AttributeSet? = null,
19+
@AttrRes defStyleAttr: Int = R.attr.listPopupWindowStyle,
20+
@StyleRes defStyleRes: Int = R.style.Widget_MaterialComponents_ListPopupWindow,
21+
) : ListPopupWindow(context, attrs, defStyleAttr, defStyleRes) {
22+
init {
23+
val materialShapeDrawable =
24+
MaterialShapeDrawable(context, attrs, defStyleAttr, defStyleRes).apply {
25+
initializeElevationOverlay(context)
26+
val surfaceColor = MaterialColors.getColor(context, R.attr.colorSurface, javaClass.canonicalName)
27+
fillColor = ColorStateList.valueOf(surfaceColor)
28+
context.withStyledAttributes(attrs, R.styleable.MaterialListPopupWindow, defStyleAttr, defStyleRes) {
29+
elevation = getDimension(R.styleable.MaterialListPopupWindow_android_popupElevation, 0f)
30+
}
31+
}
32+
setBackgroundDrawable(materialShapeDrawable)
2933
}
30-
setBackgroundDrawable(materialShapeDrawable)
3134
}
32-
}

Diff for: core/src/main/kotlin/dev/ricknout/rugbyranker/core/util/CustomTabUtils.kt

+13-8
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,21 @@ import androidx.core.content.ContextCompat
88
import dev.ricknout.rugbyranker.core.R
99

1010
object CustomTabUtils {
11-
12-
fun launchCustomTab(context: Context, url: String, @CustomTabsIntent.ColorScheme colorScheme: Int) {
11+
fun launchCustomTab(
12+
context: Context,
13+
url: String,
14+
@CustomTabsIntent.ColorScheme colorScheme: Int,
15+
) {
1316
val lightToolbarColor = ContextCompat.getColor(context, R.color.white)
1417
val darkToolbarColor = ContextCompat.getColor(context, R.color.dark_grey)
15-
val lightParams = CustomTabColorSchemeParams.Builder()
16-
.setToolbarColor(lightToolbarColor)
17-
.build()
18-
val darkParams = CustomTabColorSchemeParams.Builder()
19-
.setToolbarColor(darkToolbarColor)
20-
.build()
18+
val lightParams =
19+
CustomTabColorSchemeParams.Builder()
20+
.setToolbarColor(lightToolbarColor)
21+
.build()
22+
val darkParams =
23+
CustomTabColorSchemeParams.Builder()
24+
.setToolbarColor(darkToolbarColor)
25+
.build()
2126
CustomTabsIntent.Builder()
2227
.setColorScheme(colorScheme)
2328
.setDefaultColorSchemeParams(lightParams)

Diff for: core/src/main/kotlin/dev/ricknout/rugbyranker/core/util/DateUtils.kt

+13-7
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,29 @@ import java.util.Calendar
55
import java.util.Locale
66

77
object DateUtils {
8-
98
fun getCurrentDate(format: String) = getDate(format, System.currentTimeMillis())
109

1110
fun getDayAfterCurrentDate(format: String) = getDayAfterDate(format, System.currentTimeMillis())
1211

13-
fun getDate(format: String, millis: Long): String {
12+
fun getDate(
13+
format: String,
14+
millis: Long,
15+
): String {
1416
val simpleDateFormat = SimpleDateFormat(format, Locale.getDefault())
1517
val time = Calendar.getInstance().apply { timeInMillis = millis }.time
1618
return simpleDateFormat.format(time)
1719
}
1820

19-
private fun getDayAfterDate(format: String, millis: Long): String {
21+
private fun getDayAfterDate(
22+
format: String,
23+
millis: Long,
24+
): String {
2025
val simpleDateFormat = SimpleDateFormat(format, Locale.getDefault())
21-
val time = Calendar.getInstance().apply {
22-
timeInMillis = millis
23-
add(Calendar.DATE, 1)
24-
}.time
26+
val time =
27+
Calendar.getInstance().apply {
28+
timeInMillis = millis
29+
add(Calendar.DATE, 1)
30+
}.time
2531
return simpleDateFormat.format(time)
2632
}
2733

0 commit comments

Comments
 (0)