Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mopsalarm committed Nov 22, 2020
1 parent 4e51610 commit dd177f2
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -229,5 +229,6 @@ dependencies {
configurations {
implementation {
exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib-jdk7"
exclude group: "org.jetbrains.kotlin", module: "kotlin-stdlib-jdk8"
}
}
4 changes: 2 additions & 2 deletions app/src/main/java/com/pr0gramm/app/services/Graph.kt
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ data class Graph(val firstX: Double, val lastX: Double, val points: List<Graph.P

val maxValue: Double
get() {
return points.maxBy { it.y }!!.y
return points.maxOf { it.y }
}

val minValue: Double
get() {
return points.minBy { it.y }!!.y
return points.minOf { it.y }
}

operator fun get(idx: Int): Point {
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/com/pr0gramm/app/services/InboxService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class InboxService(private val api: Api, private val preferences: SharedPreferen

if (markAsRead) {
// mark the most recent item/message as read.
converted.maxBy { it.creationTime }?.let { markAsRead(it) }
converted.maxByOrNull { it.creationTime }?.let { creationTime -> markAsRead(creationTime) }
}

return converted
Expand Down Expand Up @@ -181,7 +181,7 @@ class InboxService(private val api: Api, private val preferences: SharedPreferen
val result = api.messagesWith(name, olderThan?.epochSeconds)

// mark the latest message in the conversation as read
result.messages.maxBy { it.creationTime }?.let { markAsRead(name, it.creationTime) }
result.messages.maxOfOrNull { msg -> msg.creationTime }?.let { creationTime -> markAsRead(name, creationTime) }

return result
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class StatisticsService(private val feedService: FeedService) {

private fun streamStats(cache: ConcurrentMap<Long, Stats>, filter: FeedFilter): Flow<Stats> {

val startAt = cache.keys.max() ?: 0L
val startAt = cache.keys.maxOrNull() ?: 0L
val initialState = cache[startAt] ?: Stats(counts = emptyMap())

return feedService.stream(FeedService.FeedQuery(filter, ContentType.AllSet, newer = startAt)).scan(initialState) { state, feed ->
Expand All @@ -38,8 +38,8 @@ class StatisticsService(private val feedService: FeedService) {
if (!feed.isAtEnd && !feed.isAtStart) {
// this is a complete page, just cache the state at
// it's most recent item
feed.items.maxBy { it.id }?.let { item ->
cache[item.id] = newState
feed.items.maxOfOrNull { it.id }?.let { itemId ->
cache[itemId] = newState
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ fun isMoreRestrictiveContentTypeTag(tags: List<String>, tag: String): Boolean {
return false
}

val maxExistingTagIndex = tags.map { sorted.indexOf(it.toLowerCase(Locale.ROOT)) }.max()
val maxExistingTagIndex = tags.map { sorted.indexOf(it.toLowerCase(Locale.ROOT)) }.maxOrNull()
return maxExistingTagIndex == null || maxExistingTagIndex < newTagIndex
}

4 changes: 2 additions & 2 deletions app/src/main/java/com/pr0gramm/app/ui/StatisticsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ class StatisticsActivity : BaseAppCompatActivity("StatisticsActivity") {

private fun updateTimeRange() {
if (benisValues.size > 2) {
val min = benisValues.minBy { it.time }!!.time
val max = benisValues.maxBy { it.time }!!.time
val min = benisValues.minOf { v -> v.time }
val max = benisValues.maxOf { v -> v.time }

benisGraphTimeSelector.maxRangeInMillis = (max - min)
}
Expand Down

0 comments on commit dd177f2

Please sign in to comment.