Downloads von PDFs jetzt auch möglich :D
This commit is contained in:
@@ -624,7 +624,7 @@ class KVVModuleList extends HTTPService {
|
||||
try {
|
||||
//todo eventuel prüfen ob genügend speicher noch vorhanden ist
|
||||
FileOutputStream out = new FileOutputStream(ordner.getPath()+"/"+filename);
|
||||
out.write(datei.getParsed().getBytes());
|
||||
out.write(datei.getBytes());
|
||||
out.close();
|
||||
pfad=ordner.getPath()+"/"+filename;
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -28,13 +28,7 @@ class HttpRequest extends Request<Result> {
|
||||
|
||||
@Override
|
||||
protected Response<Result> parseNetworkResponse(NetworkResponse response) {
|
||||
String parsed;
|
||||
try {
|
||||
parsed = new String(response.data, HttpHeaderParser.parseCharset(response.headers));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
parsed = new String(response.data);
|
||||
}
|
||||
Result result = new Result(parsed, response.headers);
|
||||
Result result = new Result(response.data, response.headers);
|
||||
|
||||
return Response.success(result, HttpHeaderParser.parseCacheHeaders(response));
|
||||
}
|
||||
|
||||
@@ -1,21 +1,34 @@
|
||||
package de.sebse.fuplanner.tools.network;
|
||||
|
||||
import com.android.volley.toolbox.HttpHeaderParser;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Map;
|
||||
|
||||
import de.sebse.fuplanner.tools.logging.Logger;
|
||||
|
||||
/**
|
||||
* Created by sebastian on 24.10.17.
|
||||
*/
|
||||
public class Result {
|
||||
private final String parsed;
|
||||
private final byte[] body;
|
||||
private final Map<String, String> headers;
|
||||
|
||||
public Result(String parsed, Map<String, String> headers) {
|
||||
this.parsed = parsed;
|
||||
public Result(byte[] body, Map<String, String> headers) {
|
||||
this.body = body;
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
public String getParsed() {
|
||||
return parsed;
|
||||
try {
|
||||
return new String(this.body, HttpHeaderParser.parseCharset(headers));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
return new String(this.body);
|
||||
}
|
||||
}
|
||||
|
||||
public byte[] getBytes() {
|
||||
return body;
|
||||
}
|
||||
|
||||
public Map<String, String> getHeaders() {
|
||||
|
||||
Reference in New Issue
Block a user