Downloads von PDFs jetzt auch möglich :D

This commit is contained in:
Joshua
2018-10-11 15:14:18 +02:00
parent 11c65b6292
commit 59027b59fe
3 changed files with 19 additions and 12 deletions

View File

@@ -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) {

View File

@@ -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));
}

View File

@@ -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() {