Skip to content

Commit

Permalink
Fix warnings in Java/Kotlin code
Browse files Browse the repository at this point in the history
  • Loading branch information
MGaetan89 committed Aug 29, 2024
1 parent 9eddb12 commit 220ccb9
Show file tree
Hide file tree
Showing 32 changed files with 99 additions and 89 deletions.
4 changes: 1 addition & 3 deletions data/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
<manifest />
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import java.util.*
/**
* DateParser to convert Integration Layer String date to date (ISO_8601)
*
* DateParser isn't Thread Safe, each thread must use it own instance.
* DateParser isn't Thread Safe, each thread must use its own instance.
* Because SimpleDateFormat isn't Thread Safe @link(https://developer.android.com/reference/java/text/SimpleDateFormat)
*
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,21 @@ import kotlinx.serialization.Serializable
data class AspectRatio(val numerator: Int, val denominator: Int) {

override fun toString(): String {
return "$numerator$Separator$denominator"
return "$numerator$SEPARATOR$denominator"
}

companion object {
val Infinity = AspectRatio(1, 0)
val Zero = AspectRatio(0, 1)

private const val Separator = ":"
private const val SEPARATOR = ":"

/**
* Parse Aspect ratio writing with this numerator:denominator format.
* Example : 1:1, 16:9, 9:16
* Examples: 1:1, 16:9, 9:16
*/
fun parse(str: String): AspectRatio {
val numeratorDenominatorString = str.split(Separator)
val numeratorDenominatorString = str.split(SEPARATOR)
require(numeratorDenominatorString.size == 2) { "Expected rational as numerator:denominator but is $str" }
val numerator = numeratorDenominatorString[0].toInt()
val denominator = numeratorDenominatorString[1].toInt()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
@file:UseSerializers(DateSerializer::class)

package ch.srg.dataProvider.integrationlayer.data.remote

import ch.srg.dataProvider.integrationlayer.data.serializer.DateSerializer
import kotlinx.serialization.Serializable
import kotlinx.serialization.UseSerializers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ data class Chapter(
val postTrailerStart: Date? = null,
/**
* The reference date corresponding to the beginning of the stream, if any. You can use this date to map a time
* position relative to the stream (e.g. a segment mark in or mark out) to a date.
* position relative to the stream (e.g., a segment mark in or mark out) to a date.
*/
@SerialName("dvrReferenceDate")
val resourceReferenceDate: Date? = null,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@file:UseSerializers(DateSerializer::class)

package ch.srg.dataProvider.integrationlayer.data.remote

import ch.srg.dataProvider.integrationlayer.data.ImageUrl
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
@file:UseSerializers(DateSerializer::class)

package ch.srg.dataProvider.integrationlayer.data.remote

import ch.srg.dataProvider.integrationlayer.data.ImageUrl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ data class MediaComposition(
)

/**
* The chapter which should be initially played.
* The chapter that should be initially played.
*/
fun getMainChapter(): Chapter {
return checkNotNull(findChapter(chapterUrn)) { "The main chapter is missing from mediaComposition" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ch.srg.dataProvider.integrationlayer.data.remote

import kotlinx.serialization.Serializable

/**
* Copyright (c) SRG SSR. All rights reserved.
* <p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package ch.srg.dataProvider.integrationlayer.data.remote

import kotlinx.serialization.Serializable

/**
* Copyright (c) SRG SSR. All rights reserved.
* <p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ data class Resource @JvmOverloads constructor(
}

fun hasDrm(): Boolean {
return drmList != null && drmList.isNotEmpty()
return !drmList.isNullOrEmpty()
}

fun hasSubtitles(): Boolean {
return subtitleVariants != null && subtitleVariants.isNotEmpty()
return !subtitleVariants.isNullOrEmpty()
}

fun hasAudioTracks(): Boolean {
return audioVariants != null && audioVariants.isNotEmpty()
return !audioVariants.isNullOrEmpty()
}

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ interface SRGMediaMetadata : SRGIdentifierMetadata, SRGImageMetadata, SRGMetadat
}

/**
* isBlocked if it has a blockReason or blocked by TimeAvailability at given time
* isBlocked if it has a blockReason or blocked by TimeAvailability at a given time
*/
fun isBlocked(at: Date = Date()): Boolean {
return blockReason != null || getTimeAvailability(at) != TimeAvailability.AVAILABLE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ch.srg.dataProvider.integrationlayer.data

import ch.srg.dataProvider.integrationlayer.data.remote.AspectRatio
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import org.junit.Assert.assertEquals
import org.junit.Test

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package ch.srg.dataProvider.integrationlayer.data

import ch.srg.dataProvider.integrationlayer.data.remote.BlockReason
import kotlinx.serialization.encodeToString
import kotlinx.serialization.json.Json
import org.junit.Assert.assertEquals
import org.junit.Test

Expand Down
4 changes: 1 addition & 3 deletions dataprovider-paging/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

</manifest>
<manifest />
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,23 @@ class DataProviderPaging(
) {
private val searchProvider = SearchProvider(ilService)

fun getShowListFromUrns(tabUrns: List<String>, pageSize: Int = DefaultPageSize): Flow<PagingData<Show>> {
fun getShowListFromUrns(tabUrns: List<String>, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Show>> {
return Pager(config = pageSize.toPagingConfig(), pagingSourceFactory = {
UrnsPagingSource(urns = tabUrns, call = { urns ->
ilService.getShowListFromUrns(IlUrns(urns))
})
}).flow
}

fun getMediaListFromUrns(tabUrns: List<String>, pageSize: Int = DefaultPageSize): Flow<PagingData<Media>> {
fun getMediaListFromUrns(tabUrns: List<String>, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Media>> {
return Pager(config = pageSize.toPagingConfig(), pagingSourceFactory = {
UrnsPagingSource(urns = tabUrns, call = { urns ->
ilService.getMediaListFromUrns(IlUrns(urns))
})
}).flow
}

fun getLatestMediaByShowUrn(showUrn: String, pageSize: Int = DefaultPageSize): Flow<PagingData<Media>> {
fun getLatestMediaByShowUrn(showUrn: String, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize = pageSize, initialCall = { ilService.getLatestMediaByShowUrn(showUrn, it.toIlPaging()) },
nextCall = { ilService.getMediaListNextUrl(it) }
Expand All @@ -67,7 +67,7 @@ class DataProviderPaging(
maxPublishDate: Date? = null,
minPublishDate: Date? = null,
types: String? = null,
pageSize: Int = DefaultPageSize
pageSize: Int = DEFAULT_PAGE_SIZE
): Flow<PagingData<Media>> {
return Pager(config = pageSize.toPagingConfig(), pagingSourceFactory = {
UrnsPagingSource(
Expand All @@ -86,87 +86,87 @@ class DataProviderPaging(
}).flow
}

fun getMediaRecommendedByUrn(urn: String, pageSize: Int = DefaultPageSize): Flow<PagingData<Media>> {
fun getMediaRecommendedByUrn(urn: String, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getMediaRecommendedByUrn(urn, it.toIlPaging()) },
nextCall = { ilService.getMediaListNextUrl(it) }
)
}

fun getLatestMediaByTopicUrn(topicUrn: String, pageSize: Int = DefaultPageSize): Flow<PagingData<Media>> {
fun getLatestMediaByTopicUrn(topicUrn: String, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getLatestMediaByTopicUrn(topicUrn, it.toIlPaging()) },
nextCall = { ilService.getMediaListNextUrl(it) }
)
}

fun getMostClickedMediaByTopicUrn(topicUrn: String, pageSize: Int = DefaultPageSize): Flow<PagingData<Media>> {
fun getMostClickedMediaByTopicUrn(topicUrn: String, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getMostClickedMediaByTopicUrn(topicUrn, it.toIlPaging()) },
nextCall = { ilService.getMediaListNextUrl(it) }
)
}

fun getTvMostClickedMedias(bu: Bu, topicId: String? = null, pageSize: Int = DefaultPageSize): Flow<PagingData<Media>> {
fun getTvMostClickedMedias(bu: Bu, topicId: String? = null, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getTvMostClickedMedias(bu, topicId, it.toIlPaging()) },
nextCall = { ilService.getMediaListNextUrl(it) }
)
}

fun getTvSoonExpiringMedias(bu: Bu, topicId: String? = null, pageSize: Int = DefaultPageSize): Flow<PagingData<Media>> {
fun getTvSoonExpiringMedias(bu: Bu, topicId: String? = null, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getTvSoonExpiringMedias(bu, topicId, it.toIlPaging()) },
nextCall = { ilService.getMediaListNextUrl(it) }
)
}

fun getTvSoonExpiringMedias(bu: Bu, pageSize: Int = DefaultPageSize): Flow<PagingData<Media>> {
fun getTvSoonExpiringMedias(bu: Bu, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getTvWebFirstMedias(bu, it.toIlPaging()) },
nextCall = { ilService.getMediaListNextUrl(it) }
)
}

fun getTvLatestEpisodes(bu: Bu, pageSize: Int = DefaultPageSize): Flow<PagingData<Media>> {
fun getTvLatestEpisodes(bu: Bu, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getTvLatestEpisodes(bu, it.toIlPaging()) },
nextCall = { ilService.getMediaListNextUrl(it) }
)
}

fun getTrendingMedias(bu: Bu, type: IlMediaType, onlyEpisodes: Boolean = false, pageSize: Int = DefaultPageSize): Flow<PagingData<Media>> {
fun getTrendingMedias(bu: Bu, type: IlMediaType, onlyEpisodes: Boolean = false, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getTrendingMedias(bu, type, onlyEpisodes, it.toIlPaging()) },
nextCall = { ilService.getMediaListNextUrl(it) }
)
}

fun getLatestMediaByChannelId(bu: Bu, type: IlMediaType, channelId: String, pageSize: Int = DefaultPageSize): Flow<PagingData<Media>> {
fun getLatestMediaByChannelId(bu: Bu, type: IlMediaType, channelId: String, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getLatestMediaByChannelId(bu, type, channelId, it.toIlPaging()) },
nextCall = { ilService.getMediaListNextUrl(it) }
)
}

fun getTvEpisodesByDate(bu: Bu, date: IlDate, pageSize: Int = DefaultPageSize): Flow<PagingData<Media>> {
fun getTvEpisodesByDate(bu: Bu, date: IlDate, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getTvEpisodesByDate(bu, date, it.toIlPaging()) },
nextCall = { ilService.getMediaListNextUrl(it) }
)
}

fun getEpisodeCompositionByUrn(showUrn: String, pageSize: Int = DefaultPageSize): Flow<PagingData<Episode>> {
fun getEpisodeCompositionByUrn(showUrn: String, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Episode>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getEpisodeCompositionByUrn(showUrn, it.toIlPaging()) },
Expand All @@ -178,7 +178,7 @@ class DataProviderPaging(
bu: Bu,
type: LiveCenterType,
onlyEventsWithResult: Boolean = true,
pageSize: Int = DefaultPageSize
pageSize: Int = DEFAULT_PAGE_SIZE
): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize = pageSize,
Expand All @@ -187,15 +187,15 @@ class DataProviderPaging(
)
}

fun getScheduledLiveStreamVideos(bu: Bu, signLanguageOnly: Boolean = false, pageSize: Int = DefaultPageSize): Flow<PagingData<Media>> {
fun getScheduledLiveStreamVideos(bu: Bu, signLanguageOnly: Boolean = false, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getScheduledLiveStreamVideos(bu, signLanguageOnly, it.toIlPaging()) },
nextCall = { ilService.getMediaListNextUrl(it) }
)
}

fun getRadioEpisodesByDateByChannelId(bu: Bu, date: IlDate, channelId: String, pageSize: Int = DefaultPageSize): Flow<PagingData<Media>> {
fun getRadioEpisodesByDateByChannelId(bu: Bu, date: IlDate, channelId: String, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getRadioEpisodesByDateByChannelId(bu, date, channelId, it.toIlPaging()) },
Expand All @@ -207,7 +207,7 @@ class DataProviderPaging(
bu: Bu,
channelId: String,
onlyEpisodes: Boolean? = null,
pageSize: Int = DefaultPageSize
pageSize: Int = DEFAULT_PAGE_SIZE
): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize = pageSize,
Expand All @@ -217,15 +217,15 @@ class DataProviderPaging(
)
}

fun getRadioMostClickedMediasByChannelId(bu: Bu, onlyEpisodes: Boolean? = null, pageSize: Int = DefaultPageSize): Flow<PagingData<Media>> {
fun getRadioMostClickedMediasByChannelId(bu: Bu, onlyEpisodes: Boolean? = null, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getRadioMostClickedMedias(bu, onlyEpisodes, it.toIlPaging()) },
nextCall = { ilService.getMediaListNextUrl(it) }
)
}

fun getRadioSongListByChannelId(bu: Bu, channelId: String, pageSize: Int = DefaultPageSize): Flow<PagingData<Song>> {
fun getRadioSongListByChannelId(bu: Bu, channelId: String, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Song>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getRadioSongListByChannelId(bu = bu, channelId = channelId, pageSize = it.toIlPaging()) },
Expand All @@ -235,7 +235,7 @@ class DataProviderPaging(

fun getAllAlphabeticalShows(bu: Bu, transmission: Transmission, radioChannelId: String? = null): Flow<PagingData<Show>> {
return createNextUrlPagingData(
pageSize = DefaultPageSize,
pageSize = DEFAULT_PAGE_SIZE,
initialCall = {
ilService.getAllAlphabeticalShows(
bu = bu, transmission = IlTransmission(transmission),
Expand All @@ -245,15 +245,15 @@ class DataProviderPaging(
)
}

fun getTvAlphabeticalShows(bu: Bu, pageSize: Int = DefaultPageSize): Flow<PagingData<Show>> {
fun getTvAlphabeticalShows(bu: Bu, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Show>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getTvAlphabeticalShows(bu = bu, pageSize = it.toIlPaging()) },
nextCall = { ilService.getShowListNextUrl(it) }
)
}

fun getRadioAlphabeticalShowsByChannelId(bu: Bu, radioChannelId: String, pageSize: Int = DefaultPageSize): Flow<PagingData<Show>> {
fun getRadioAlphabeticalShowsByChannelId(bu: Bu, radioChannelId: String, pageSize: Int = DEFAULT_PAGE_SIZE): Flow<PagingData<Show>> {
return createNextUrlPagingData(
pageSize = pageSize,
initialCall = { ilService.getRadioAlphabeticalShowsByChannelId(bu = bu, channelId = radioChannelId, pageSize = it.toIlPaging()) },
Expand All @@ -275,7 +275,7 @@ class DataProviderPaging(
searchTerm: String,
queryParameters: SearchParams.MediaParams,
lastResult: MutableSharedFlow<SearchResultWithMediaList>? = null,
pageSize: Int = DefaultPageSize
pageSize: Int = DEFAULT_PAGE_SIZE
): Flow<PagingData<Media>> {
return createNextUrlPagingData(
pageSize,
Expand Down Expand Up @@ -303,7 +303,7 @@ class DataProviderPaging(
searchTerm: String,
queryParameters: SearchParams.ShowParams,
lastResult: MutableSharedFlow<SearchResultWithShowList>? = null,
pageSize: Int = DefaultPageSize
pageSize: Int = DEFAULT_PAGE_SIZE
): Flow<PagingData<Show>> {
return createNextUrlPagingData(
pageSize,
Expand All @@ -319,7 +319,7 @@ class DataProviderPaging(
}

companion object {
private const val DefaultPageSize = 10
private const val DEFAULT_PAGE_SIZE = 10

private fun Int.toPagingConfig() = PagingConfig(pageSize = this, prefetchDistance = 1)

Expand Down
1 change: 1 addition & 0 deletions dataprovider-retrofit/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />
</manifest>
Loading

0 comments on commit 220ccb9

Please sign in to comment.