mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 12:23:58 +01:00
Fixed NPE caused by not initializing the resultStatus field of UploadResult when on the happy-path.
This commit is contained in:
parent
883419844d
commit
6f86b1871f
2 changed files with 7 additions and 2 deletions
|
|
@ -4,6 +4,7 @@ import android.os.Build;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.conn.ClientConnectionManager;
|
||||
|
|
@ -356,6 +357,9 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
|
|||
progressListener.onProgress(transferred, total);
|
||||
}
|
||||
});
|
||||
|
||||
Log.e("WTF", "Result: "+result.toString());
|
||||
|
||||
String resultStatus = result.getString("/api/upload/@result");
|
||||
if (!resultStatus.equals("Success")) {
|
||||
String errorCode = result.getString("/api/error/@code");
|
||||
|
|
@ -364,7 +368,7 @@ public class ApacheHttpClientMediaWikiApi implements MediaWikiApi {
|
|||
Date dateUploaded = Utils.parseMWDate(result.getString("/api/upload/imageinfo/@timestamp"));
|
||||
String canonicalFilename = "File:" + result.getString("/api/upload/@filename").replace("_", " "); // Title vs Filename
|
||||
String imageUrl = result.getString("/api/upload/imageinfo/@url");
|
||||
return new UploadResult(dateUploaded, canonicalFilename, imageUrl);
|
||||
return new UploadResult(resultStatus, dateUploaded, canonicalFilename, imageUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@ public class UploadResult {
|
|||
this.errorCode = errorCode;
|
||||
}
|
||||
|
||||
UploadResult(Date dateUploaded, String canonicalFilename, String imageUrl) {
|
||||
UploadResult(String resultStatus, Date dateUploaded, String canonicalFilename, String imageUrl) {
|
||||
this.resultStatus = resultStatus;
|
||||
this.dateUploaded = dateUploaded;
|
||||
this.canonicalFilename = canonicalFilename;
|
||||
this.imageUrl = imageUrl;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue