I have implemented function to get the restaurant area minimum order. In check_minimum_order() function, I have got desired result from the response. The value is rest_area_min_order = 10. Now, I want to pass the value which I received through JSON to the next function So that I can do calculation part.
Here is the code of check_minimum_order()
private void check_minimum_order(String restaurant_id)
{
try
{
String url;
if(appPrefs.getLanguage().equalsIgnoreCase("ar"))
url = LinksConstants.BASE_URL
+ LinksConstants.CHECK_MINIMUM_ORDER;
else
url = LinksConstants.BASE_URL
+ LinksConstants.CHECK_MINIMUM_ORDER;
RequestParams params = new RequestParams();
params.put("restaurant_id", restaurant_id);
params.put("area_id", city_id);
NetworkRestClient.post(url, params, new JsonHttpResponseHandler() {
@Override
public void onStart() {
super.onStart();
progressActivity.showLoading();
}
@Override
public void onSuccess(int statusCode, Header[] headers, JSONObject response) {
super.onSuccess(statusCode, headers, response);
try
{
if (response != null)
{
rest_area_min_order = response.getString("restaurant_area_min_order");
}
}
catch (Exception ex)
{
GSLogger.e(ex);
showError();
}
}
@Override
public void onFailure(int statusCode, Header[] headers, String errorResponse, Throwable throwable) {
super.onFailure(statusCode, headers, errorResponse, throwable);
showError();
if(AppConstants.DEBUG_MODE)
showToast(errorResponse);
}
@Override
public void onFailure(int statusCode, Header[] headers, Throwable throwable, JSONObject errorResponse) {
super.onFailure(statusCode, headers, throwable, errorResponse);
showError();
}
});
}
catch (Exception ex)
{
GSLogger.e(ex);
showError();
}
}
Now, the above check_minimum_order() function gave me the value of rest_area_min_order as 10. Now, I want to use this rest_area_min_order in another function. Here is the code: `
check_minimum_order(restaurant_id);
HashMap<String, Object> items_hash = (HashMap<String, Object>) rest_cart_hash.get(restaurant.getId());
items_hash.put("delivery_pickup_time", time);
items_hash.put("pickup_address_id", pickup_id);
items_hash.put("payment_method_id", payment_id);
items_hash.put("delivery_pickup", delivery_pickup);
items_hash.put("selected_user_address_id", user_address_id);
items_hash.put("rest_area_min_order", rest_area_min_order);
restaurantList.add(items_hash);
String rest_min_order = (String) items_hash.get("rest_min_order");
String rest_subtotal = (String) items_hash.get("rest_subtotal");
String rest_area_min_order = (String) items_hash.get("rest_area_min_order");
boolean isError = isValidMinOrderAmount(rest_min_order, rest_subtotal, rest_area_min_order);`