# DefaultPreloadManager.SimpleRankingDataComparator

Artifact: [androidx.media3:media3-exoplayer](https://developer.android.com/jetpack/androidx/releases/media3) [View Source](https://cs.android.com/search?q=file:androidx/media3/exoplayer/source/preload/DefaultPreloadManager.java+class:androidx.media3.exoplayer.source.preload.DefaultPreloadManager.SimpleRankingDataComparator)

*** ** * ** ***


```
class DefaultPreloadManager.SimpleRankingDataComparator : RankingDataComparator<Int!>
```

<br />

*** ** * ** ***

A `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/preload/RankingDataComparator` which compares the ranks of the media items based on their distances to the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/preload/DefaultPreloadManager.SimpleRankingDataComparator#setCurrentPlayingIndex(int)`.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/preload/DefaultPreloadManager.SimpleRankingDataComparator#SimpleRankingDataComparator()()` Creates a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/preload/DefaultPreloadManager.SimpleRankingDataComparator`. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/preload/DefaultPreloadManager.SimpleRankingDataComparator#compare(java.lang.Integer,java.lang.Integer)(o1: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!, o2: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!)` Compares the ranks of two media items based on their distances to the current playing index. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/preload/DefaultPreloadManager.SimpleRankingDataComparator#setInvalidationListener(androidx.media3.exoplayer.source.preload.RankingDataComparator.InvalidationListener)( invalidationListener: https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/preload/RankingDataComparator.InvalidationListener? )` Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/preload/RankingDataComparator.InvalidationListener`. |

| ### Protected properties |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/preload/DefaultPreloadManager.SimpleRankingDataComparator#currentPlayingIndex()` |

### Inherited functions

From [java.util.Comparator](https://developer.android.com/reference/java/util/Comparator.html) `java-static https://developer.android.com/reference/java/util/Comparator.html<T!>!` `<T, U : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-comparable/index.html<U!>?> https://developer.android.com/reference/java/util/Comparator.html#comparing(java.util.function.Function&lt;? super T,? extends U&gt;)(keyExtractor: https://developer.android.com/reference/java/util/function/Function.html<T!, U!>!)` `java-static https://developer.android.com/reference/java/util/Comparator.html<T!>!` `<T> https://developer.android.com/reference/java/util/Comparator.html#comparingDouble(java.util.function.ToDoubleFunction&lt;? super T&gt;)(keyExtractor: https://developer.android.com/reference/java/util/function/ToDoubleFunction.html<T!>!)` `java-static https://developer.android.com/reference/java/util/Comparator.html<T!>!` `<T> https://developer.android.com/reference/java/util/Comparator.html#comparingInt(java.util.function.ToIntFunction&lt;? super T&gt;)(keyExtractor: https://developer.android.com/reference/java/util/function/ToIntFunction.html<T!>!)` `java-static https://developer.android.com/reference/java/util/Comparator.html<T!>!` `<T> https://developer.android.com/reference/java/util/Comparator.html#comparingLong(java.util.function.ToLongFunction&lt;? super T&gt;)(keyExtractor: https://developer.android.com/reference/java/util/function/ToLongFunction.html<T!>!)` `java-static https://developer.android.com/reference/java/util/Comparator.html<T!>!` `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-comparable/index.html<T!>?> https://developer.android.com/reference/java/util/Comparator.html#naturalOrder()()` `java-static https://developer.android.com/reference/java/util/Comparator.html<T!>!` `<T> https://developer.android.com/reference/java/util/Comparator.html#nullsFirst(java.util.Comparator&lt;? super T&gt;)(comparator: https://developer.android.com/reference/java/util/Comparator.html<T!>!)` `java-static https://developer.android.com/reference/java/util/Comparator.html<T!>!` `<T> https://developer.android.com/reference/java/util/Comparator.html#nullsLast(java.util.Comparator&lt;? super T&gt;)(comparator: https://developer.android.com/reference/java/util/Comparator.html<T!>!)` `java-static https://developer.android.com/reference/java/util/Comparator.html<T!>!` `<T : https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-comparable/index.html<T!>?> https://developer.android.com/reference/java/util/Comparator.html#reverseOrder()()` `https://developer.android.com/reference/java/util/Comparator.html<T!>!` `https://developer.android.com/reference/java/util/Comparator.html#reversed()()` `https://developer.android.com/reference/java/util/Comparator.html<T!>!` `https://developer.android.com/reference/java/util/Comparator.html#thenComparing(java.util.Comparator&lt;? super T&gt;)(other: https://developer.android.com/reference/java/util/Comparator.html<T!>!)` `https://developer.android.com/reference/java/util/Comparator.html<T!>!` `https://developer.android.com/reference/java/util/Comparator.html#thenComparingDouble(java.util.function.ToDoubleFunction&lt;? super T&gt;)(keyExtractor: https://developer.android.com/reference/java/util/function/ToDoubleFunction.html<T!>!)` `https://developer.android.com/reference/java/util/Comparator.html<T!>!` `https://developer.android.com/reference/java/util/Comparator.html#thenComparingInt(java.util.function.ToIntFunction&lt;? super T&gt;)(keyExtractor: https://developer.android.com/reference/java/util/function/ToIntFunction.html<T!>!)` `https://developer.android.com/reference/java/util/Comparator.html<T!>!` `https://developer.android.com/reference/java/util/Comparator.html#thenComparingLong(java.util.function.ToLongFunction&lt;? super T&gt;)(keyExtractor: https://developer.android.com/reference/java/util/function/ToLongFunction.html<T!>!)`

## Public constructors

### SimpleRankingDataComparator

```
SimpleRankingDataComparator()
```

Creates a `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/preload/DefaultPreloadManager.SimpleRankingDataComparator`.

## Public functions

### compare

```
fun compare(o1: Int!, o2: Int!): Int
```

Compares the ranks of two media items based on their distances to the current playing index. The media item with lower rank will be preloaded earlier than the other. If the ranks of the two media items are equal, the relative preload order of them is arbitrary.

Apps can override this method if a more fine-tuned comparison logic is needed.

| Parameters |
|---|---|
| `o1: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!` | The index of the first media item to be compared. |
| `o2: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html!` | The index of the second media item to be compared. |

| Returns |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | A negative integer, zero, or a positive integer as the rank of the first media item is less than, equal to, or greater than the second. |

### setInvalidationListener

```
fun setInvalidationListener(
    invalidationListener: RankingDataComparator.InvalidationListener?
): Unit
```

Sets the `https://developer.android.com/reference/kotlin/androidx/media3/exoplayer/source/preload/RankingDataComparator.InvalidationListener`.

## Protected properties

### currentPlayingIndex

```
protected var currentPlayingIndex: Int
```