mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Fix java.lang.NullPointerException for username in ContributionBoundaryCallback (#5003)
This commit is contained in:
parent
d8e4c038e0
commit
5fe1ad84a0
1 changed files with 12 additions and 10 deletions
|
|
@ -21,7 +21,7 @@ class ContributionBoundaryCallback @Inject constructor(
|
|||
@param:Named(CommonsApplicationModule.IO_THREAD) private val ioThreadScheduler: Scheduler
|
||||
) : BoundaryCallback<Contribution>() {
|
||||
private val compositeDisposable: CompositeDisposable = CompositeDisposable()
|
||||
lateinit var userName: String
|
||||
var userName: String? = null
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -53,13 +53,13 @@ class ContributionBoundaryCallback @Inject constructor(
|
|||
/**
|
||||
* Fetches contributions using the MediaWiki API
|
||||
*/
|
||||
fun fetchContributions() {
|
||||
private fun fetchContributions() {
|
||||
if (sessionManager.userName != null) {
|
||||
compositeDisposable.add(
|
||||
mediaClient.getMediaListForUser(userName!!)
|
||||
userName?.let { userName ->
|
||||
mediaClient.getMediaListForUser(userName)
|
||||
.map { mediaList ->
|
||||
mediaList.map {
|
||||
Contribution(media = it, state = Contribution.STATE_COMPLETED)
|
||||
mediaList.map { media ->
|
||||
Contribution(media = media, state = Contribution.STATE_COMPLETED)
|
||||
}
|
||||
}
|
||||
.subscribeOn(ioThreadScheduler)
|
||||
|
|
@ -69,11 +69,13 @@ class ContributionBoundaryCallback @Inject constructor(
|
|||
error.message
|
||||
)
|
||||
}
|
||||
}?.let {
|
||||
compositeDisposable.add(
|
||||
it
|
||||
)
|
||||
}else {
|
||||
if (compositeDisposable != null){
|
||||
compositeDisposable.clear()
|
||||
}
|
||||
}else {
|
||||
compositeDisposable.clear()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue