Solved bug when the account dont have avatar

This commit is contained in:
ivan agosto 2018-10-10 10:13:35 -05:00
parent 72d1922d97
commit cd21704a49
3 changed files with 17 additions and 11 deletions

View File

@ -1,7 +1,8 @@
package org.libre.agosto.p2play.ajax package org.libre.agosto.p2play.ajax
import android.support.design.widget.Snackbar // import android.support.design.widget.Snackbar
import android.util.JsonReader import android.util.JsonReader
import android.util.JsonToken
import android.util.Log import android.util.Log
import org.libre.agosto.p2play.ManagerSingleton import org.libre.agosto.p2play.ManagerSingleton
import org.libre.agosto.p2play.models.TokenModel import org.libre.agosto.p2play.models.TokenModel
@ -133,15 +134,20 @@ class Auth: Client() {
when(l.toString()){ when(l.toString()){
"followersCount" -> user.followers = data.nextInt() "followersCount" -> user.followers = data.nextInt()
"avatar" -> { "avatar" -> {
data.beginObject() if(data.peek() == JsonToken.BEGIN_OBJECT) {
while (data.hasNext()){ data.beginObject()
val m = data.nextName() while (data.hasNext()) {
when (m.toString()){ val m = data.nextName()
"path" -> user.avatar = data.nextString() when (m.toString()) {
else -> data.skipValue() "path" -> user.avatar = data.nextString()
else -> data.skipValue()
}
} }
data.endObject()
}
else{
data.skipValue()
} }
data.endObject()
} }
else -> data.skipValue() else -> data.skipValue()
} }

View File

@ -7,7 +7,7 @@ buildscript {
jcenter() jcenter()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.1.4' classpath 'com.android.tools.build:gradle:3.2.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong // NOTE: Do not place your application dependencies here; they belong

View File

@ -1,6 +1,6 @@
#Wed Jul 11 18:31:20 CDT 2018 #Sun Sep 30 14:50:40 CDT 2018
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip