Downloads von PDFs jetzt auch möglich :D
This commit is contained in:
@@ -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) {
|
||||||
|
|||||||
@@ -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));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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() {
|
||||||
|
|||||||
Reference in New Issue
Block a user