mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-05 02:39:23 +02:00
request parameters changed (according server's changes)
This commit is contained in:
parent
77247148b8
commit
dff1212c1e
1 changed files with 11 additions and 16 deletions
|
@ -68,7 +68,7 @@ public class SynchroniserService extends Service implements IBookCollection.List
|
|||
System.err.println("HELLO THREAD");
|
||||
myHashesFromServer.clear();
|
||||
try {
|
||||
myNetworkContext.perform(new JsonRequest("all.hashes", null) {
|
||||
myNetworkContext.perform(new PostRequest("all.hashes", null) {
|
||||
@Override
|
||||
public void processResponse(Object response) {
|
||||
myHashesFromServer.addAll((List)response);
|
||||
|
@ -110,22 +110,17 @@ public class SynchroniserService extends Service implements IBookCollection.List
|
|||
}
|
||||
}
|
||||
|
||||
private static String toJSON(Object object) {
|
||||
final StringWriter writer = new StringWriter();
|
||||
try {
|
||||
JSONValue.writeJSONString(object, writer);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("JSON serialization failed", e);
|
||||
}
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
private final static String DOMAIN = "demo.fbreader.org";
|
||||
private final static String BASE_URL = "https://" + DOMAIN + "/app/";
|
||||
|
||||
private static abstract class JsonRequest extends ZLNetworkRequest.PostWithBody {
|
||||
JsonRequest(String app, Object data) {
|
||||
super(BASE_URL + app, toJSON(data), false);
|
||||
private static abstract class PostRequest extends ZLNetworkRequest.PostWithMap {
|
||||
PostRequest(String app, Map<String,String> data) {
|
||||
super(BASE_URL + app, false);
|
||||
if (data != null) {
|
||||
for (Map.Entry<String, String> entry : data.entrySet()) {
|
||||
addPostParameter(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -190,8 +185,8 @@ public class SynchroniserService extends Service implements IBookCollection.List
|
|||
return;
|
||||
}
|
||||
final Map<String,Object> result = new HashMap<String,Object>();
|
||||
final JsonRequest verificationRequest =
|
||||
new JsonRequest("books.by.hash", Collections.singletonMap("sha1", uid.Id)) {
|
||||
final PostRequest verificationRequest =
|
||||
new PostRequest("books.by.hash", Collections.singletonMap("sha1", uid.Id)) {
|
||||
@Override
|
||||
public void processResponse(Object response) {
|
||||
result.put("result", response);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue