Search in sources :

Example 1 with EhClient

use of com.hippo.ehviewer.client.EhClient in project EhViewer by seven332.

the class CommonOperations method removeFromFavorites.

public static void removeFromFavorites(Activity activity, GalleryInfo galleryInfo, final EhClient.Callback<Void> listener) {
    EhDB.removeLocalFavorites(galleryInfo.gid);
    EhClient client = EhApplication.getEhClient(activity);
    EhRequest request = new EhRequest();
    request.setMethod(EhClient.METHOD_ADD_FAVORITES);
    request.setArgs(galleryInfo.gid, galleryInfo.token, -1, "");
    request.setCallback(new DelegateFavoriteCallback(listener, galleryInfo, null, -2));
    client.execute(request);
}
Also used : EhClient(com.hippo.ehviewer.client.EhClient) EhRequest(com.hippo.ehviewer.client.EhRequest)

Example 2 with EhClient

use of com.hippo.ehviewer.client.EhClient in project EhViewer by seven332.

the class CommonOperations method doAddToFavorites.

private static void doAddToFavorites(Activity activity, GalleryInfo galleryInfo, int slot, EhClient.Callback<Void> listener) {
    if (slot == -1) {
        EhDB.putLocalFavorites(galleryInfo);
        listener.onSuccess(null);
    } else if (slot >= 0 && slot <= 9) {
        EhClient client = EhApplication.getEhClient(activity);
        EhRequest request = new EhRequest();
        request.setMethod(EhClient.METHOD_ADD_FAVORITES);
        request.setArgs(galleryInfo.gid, galleryInfo.token, slot, "");
        request.setCallback(listener);
        client.execute(request);
    } else {
        // TODO Add text
        listener.onFailure(new Exception());
    }
}
Also used : JSONException(org.json.JSONException) IOException(java.io.IOException) EhClient(com.hippo.ehviewer.client.EhClient) EhRequest(com.hippo.ehviewer.client.EhRequest)

Aggregations

EhClient (com.hippo.ehviewer.client.EhClient)2 EhRequest (com.hippo.ehviewer.client.EhRequest)2 IOException (java.io.IOException)1 JSONException (org.json.JSONException)1