getParsed NullPointerException / Version 7
This commit is contained in:
@@ -7,8 +7,8 @@ android {
|
|||||||
applicationId "de.sebse.fuplanner"
|
applicationId "de.sebse.fuplanner"
|
||||||
minSdkVersion 15
|
minSdkVersion 15
|
||||||
targetSdkVersion 28
|
targetSdkVersion 28
|
||||||
versionCode 6
|
versionCode 7
|
||||||
versionName "1.1.4"
|
versionName "1.1.5"
|
||||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
|||||||
@@ -5,19 +5,24 @@ import com.android.volley.toolbox.HttpHeaderParser;
|
|||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by sebastian on 24.10.17.
|
* Created by sebastian on 24.10.17.
|
||||||
*/
|
*/
|
||||||
public class Result {
|
public class Result {
|
||||||
private final byte[] body;
|
@Nullable private final byte[] body;
|
||||||
private final Map<String, String> headers;
|
private final Map<String, String> headers;
|
||||||
|
|
||||||
public Result(byte[] body, Map<String, String> headers) {
|
Result(@Nullable byte[] body, Map<String, String> headers) {
|
||||||
this.body = body;
|
this.body = body;
|
||||||
this.headers = headers;
|
this.headers = headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public String getParsed() {
|
public String getParsed() {
|
||||||
|
if (this.body == null)
|
||||||
|
return null;
|
||||||
try {
|
try {
|
||||||
return new String(this.body, HttpHeaderParser.parseCharset(headers));
|
return new String(this.body, HttpHeaderParser.parseCharset(headers));
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
@@ -25,6 +30,7 @@ public class Result {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
public byte[] getBytes() {
|
public byte[] getBytes() {
|
||||||
return body;
|
return body;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user