DefaultPreloadManager.SimpleRankingDataComparator


class DefaultPreloadManager.SimpleRankingDataComparator : RankingDataComparator


A RankingDataComparator which compares the ranks of the media items based on their distances to the index of current playing media item.

Summary

Public constructors

Creates a SimpleRankingDataComparator.

Public functions

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

Compares the ranks of two media items based on their distances to the current playing index.

Unit

Sets the InvalidationListener.

Protected properties

Int

Inherited functions

From java.util.Comparator
java-static Comparator<T!>!
<T, U> comparing(
    keyExtractor: Function<T!, U!>!,
    keyComparator: Comparator<U!>!
)
java-static Comparator<T!>!
<T> comparingDouble(keyExtractor: ToDoubleFunction<T!>!)
java-static Comparator<T!>!
<T> comparingInt(keyExtractor: ToIntFunction<T!>!)
java-static Comparator<T!>!
<T> comparingLong(keyExtractor: ToLongFunction<T!>!)
java-static Comparator<T!>!
<T : Comparable<T!>?> naturalOrder()
java-static Comparator<T!>!
<T> nullsFirst(comparator: Comparator<T!>!)
java-static Comparator<T!>!
<T> nullsLast(comparator: Comparator<T!>!)
java-static Comparator<T!>!
<T : Comparable<T!>?> reverseOrder()
Comparator<T!>!
Comparator<T!>!
Comparator<T!>!
Comparator<T!>!
thenComparingInt(keyExtractor: ToIntFunction<T!>!)
Comparator<T!>!
thenComparingLong(keyExtractor: ToLongFunction<T!>!)

Public constructors

SimpleRankingDataComparator

SimpleRankingDataComparator()

Creates a 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: Int!

The index of the first media item to be compared.

o2: Int!

The index of the second media item to be compared.

Returns
Int

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 InvalidationListener.

Protected properties

currentPlayingIndex

protected var currentPlayingIndexInt