app/src/main/java/com/mensa/zhmensa/services/PollApi.java
/**
     *  Adds a new Poll and returns the ID given by the server to the callback function
     * @param poll
     * @param callback
     * @param ctx
     */
Adds a new Poll and returns the ID given by the server to the callback function
@param poll
@param callback
@param ctx
Adds a new Poll and returns the ID given by the server to the callback function @param poll @param callback @param ctx
public static void addNewPollToApi(Poll poll, final Function1<JsonElement, Void> callback, Context ctx) {
          JsonObject payload = convertPollToJsonObj(poll);
          Log.d("addNewPollToAPi", "json: "+ payload.toString());
          try {
              HttpUtils.post(BASE_URL + CREATE, payload, ctx,  new AsyncHttpResponseHandler() {
                  @Override
                  public void onSuccess(int statusCode, Header[] headers, byte[] responseBody) {
                      String jsonString = new String(responseBody);
                      callback.invoke(new JsonParser().parse(jsonString));
                  }
                  @Override
                  public void onFailure(int statusCode, Header[] headers, byte[] responseBody, Throwable error) {
                      callback.invoke(null);
                  }
              });
          } catch (UnsupportedEncodingException e) {
             Log.e("addNewPollToApi", "UnsupportedEncodingException", e);
          }
      }
public static void addNewPollToApi ( Poll poll , final Function1 < JsonElement , Void > callback , Context ctx ) { JsonObject payload = convertPollToJsonObj ( poll ) ; Log . d ( "addNewPollToAPi" , "json: " + payload . toString ( ) ) ; try { HttpUtils . post ( BASE_URL + CREATE , payload , ctx , new AsyncHttpResponseHandler ( ) { @ Override public void onSuccess ( int statusCode , Header [ ] headers , byte [ ] responseBody ) { String jsonString = new String ( responseBody ) ; callback . invoke ( new JsonParser ( ) . parse ( jsonString ) ) ; } @ Override public void onFailure ( int statusCode , Header [ ] headers , byte [ ] responseBody , Throwable error ) { callback . invoke ( null ) ; } } ) ; } catch ( UnsupportedEncodingException e ) { Log . e ( "addNewPollToApi" , "UnsupportedEncodingException" , e ) ; } }
Adds a new Poll and returns the ID given by the server to the callback function
 @param poll
 @param callback
 @param ctx
Adds a new Poll and returns the ID given by the server to the callback function @param poll @param callback @param ctx