예제 #1
0
 public static String getHash(VKResponse response) throws IllegalArgumentException {
   try {
     return response.getJsonObject().get("hash").getAsString();
   } catch (Exception e) {
     throw new IllegalArgumentException("Bad input params(" + e.getMessage() + "): " + response);
   }
 }
예제 #2
0
 public static int findInt(VKResponse response, String key) {
   try {
     return response.getJsonObject().get(key).getAsInt();
   } catch (Exception e) {
     throw new IllegalArgumentException("Bad input params(" + e.getMessage() + "): " + response);
   }
 }
  /**
   * Method used for response processing
   *
   * @param jsonResponse response from API
   * @param parsedModel model parsed from json
   */
  private void provideResponse(final JSONObject jsonResponse, Object parsedModel) {
    final VKResponse response = new VKResponse();
    response.request = this;
    response.json = jsonResponse;
    response.parsedModel = parsedModel;
    if (mLoadingOperation instanceof VKHttpOperation) {
      response.responseString = ((VKHttpOperation) mLoadingOperation).getResponseString();
    }

    if (mPostRequestsQueue != null && mPostRequestsQueue.size() > 0) {
      for (VKRequest request : mPostRequestsQueue) {
        request.start();
      }
    }

    if (requestListener != null) {
      requestListener.onComplete(response);
    }
  }
예제 #4
0
  public static String getPhoto(VKResponse response) throws IllegalArgumentException {
    try {
      String photo = response.getJsonObject().get("photo").getAsString();
      /*JsonElement jsonElement = new JsonParser().parse(photo);
      return jsonElement.getAsJsonArray().get(0).getAsJsonObject().get("photo").getAsString();*/
      return photo;

    } catch (Exception e) {
      throw new IllegalArgumentException("Bad input params(" + e.getMessage() + "): " + response);
    }
  }
예제 #5
0
 private static JsonArray getResponseArray(VKResponse response) {
   return response.getJsonObject().getAsJsonArray("response");
 }
예제 #6
0
 private static JsonObject getResponseObject(VKResponse response) {
   return response.getJsonObject().getAsJsonObject("response");
 }