getParsed NullPointerException / Version 7
This commit is contained in:
@@ -5,19 +5,24 @@ import com.android.volley.toolbox.HttpHeaderParser;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Map;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 24.10.17.
|
||||
*/
|
||||
public class Result {
|
||||
private final byte[] body;
|
||||
@Nullable private final byte[] body;
|
||||
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.headers = headers;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getParsed() {
|
||||
if (this.body == null)
|
||||
return null;
|
||||
try {
|
||||
return new String(this.body, HttpHeaderParser.parseCharset(headers));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
@@ -25,6 +30,7 @@ public class Result {
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public byte[] getBytes() {
|
||||
return body;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user