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 { try {
//todo eventuel prüfen ob genügend speicher noch vorhanden ist //todo eventuel prüfen ob genügend speicher noch vorhanden ist
FileOutputStream out = new FileOutputStream(ordner.getPath()+"/"+filename); FileOutputStream out = new FileOutputStream(ordner.getPath()+"/"+filename);
out.write(datei.getParsed().getBytes()); out.write(datei.getBytes());
out.close(); out.close();
pfad=ordner.getPath()+"/"+filename; pfad=ordner.getPath()+"/"+filename;
} catch (Exception e) { } catch (Exception e) {

View File

@@ -28,13 +28,7 @@ class HttpRequest extends Request<Result> {
@Override @Override
protected Response<Result> parseNetworkResponse(NetworkResponse response) { protected Response<Result> parseNetworkResponse(NetworkResponse response) {
String parsed; Result result = new Result(response.data, response.headers);
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);
return Response.success(result, HttpHeaderParser.parseCacheHeaders(response)); return Response.success(result, HttpHeaderParser.parseCacheHeaders(response));
} }

View File

@@ -1,21 +1,34 @@
package de.sebse.fuplanner.tools.network; package de.sebse.fuplanner.tools.network;
import com.android.volley.toolbox.HttpHeaderParser;
import java.io.UnsupportedEncodingException;
import java.util.Map; import java.util.Map;
import de.sebse.fuplanner.tools.logging.Logger;
/** /**
* Created by sebastian on 24.10.17. * Created by sebastian on 24.10.17.
*/ */
public class Result { public class Result {
private final String parsed; private final byte[] body;
private final Map<String, String> headers; private final Map<String, String> headers;
public Result(String parsed, Map<String, String> headers) { public Result(byte[] body, Map<String, String> headers) {
this.parsed = parsed; this.body = body;
this.headers = headers; this.headers = headers;
} }
public String getParsed() { 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() { public Map<String, String> getHeaders() {