Skip to content

Commit 440eaec

Browse files
committed
Convert the LeaderboardFragment to kotlin
1 parent 755d2c6 commit 440eaec

File tree

5 files changed

+338
-380
lines changed

5 files changed

+338
-380
lines changed

app/src/main/java/fr/free/nrw/commons/profile/leaderboard/DataSourceClass.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import androidx.lifecycle.MutableLiveData
55
import androidx.paging.PageKeyedDataSource
66
import fr.free.nrw.commons.auth.SessionManager
77
import fr.free.nrw.commons.mwapi.OkHttpJsonApiClient
8-
import fr.free.nrw.commons.profile.leaderboard.LeaderboardConstants.LOADED
9-
import fr.free.nrw.commons.profile.leaderboard.LeaderboardConstants.LOADING
8+
import fr.free.nrw.commons.profile.leaderboard.LeaderboardConstants.LoadingStatus.LOADING
9+
import fr.free.nrw.commons.profile.leaderboard.LeaderboardConstants.LoadingStatus.LOADED
1010
import io.reactivex.disposables.CompositeDisposable
1111
import io.reactivex.disposables.Disposable
1212
import timber.log.Timber
@@ -23,7 +23,7 @@ class DataSourceClass(
2323
private val limit: Int,
2424
private val offset: Int
2525
) : PageKeyedDataSource<Int, LeaderboardList>() {
26-
val progressLiveStatus: MutableLiveData<String> = MutableLiveData()
26+
val progressLiveStatus: MutableLiveData<LeaderboardConstants.LoadingStatus> = MutableLiveData()
2727
private val compositeDisposable = CompositeDisposable()
2828

2929

app/src/main/java/fr/free/nrw/commons/profile/leaderboard/LeaderboardConstants.kt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,18 @@ object LeaderboardConstants {
1919
*/
2020
const val USER_LINK_PREFIX: String = "https://commons.wikimedia.org/wiki/User:"
2121

22-
/**
23-
* This is the a constant string for the state loading, when the pages are getting loaded we can
24-
* use this constant to identify if we need to show the progress bar or not
25-
*/
26-
const val LOADING: String = "Loading"
27-
28-
/**
29-
* This is the a constant string for the state loaded, when the pages are loaded we can
30-
* use this constant to identify if we need to show the progress bar or not
31-
*/
32-
const val LOADED: String = "Loaded"
22+
sealed class LoadingStatus {
23+
/**
24+
* This is the state loading, when the pages are getting loaded we can
25+
* use this constant to identify if we need to show the progress bar or not
26+
*/
27+
data object LOADING: LoadingStatus()
28+
/**
29+
* This is the state loaded, when the pages are loaded we can
30+
* use this constant to identify if we need to show the progress bar or not
31+
*/
32+
data object LOADED: LoadingStatus()
33+
}
3334

3435
/**
3536
* This API endpoint is to update the leaderboard avatar

0 commit comments

Comments
 (0)