public void getAllBrand(String category_id) { String url = ProtocolConst.BRAND; BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() { @Override public void callback(String url, JSONObject jo, AjaxStatus status) { AdvanceSearchModel.this.callback(url, jo, status); try { STATUS responseStatus = STATUS.fromJson(jo.optJSONObject("status")); if (responseStatus.succeed == 1) { JSONArray dataJsonArray = jo.optJSONArray("data"); if (null != dataJsonArray && dataJsonArray.length() > 0) { brandList.clear(); for (int i = 0; i < dataJsonArray.length(); i++) { JSONObject brandJsonObject = dataJsonArray.getJSONObject(i); BRAND brandItem = BRAND.fromJson(brandJsonObject); brandList.add(brandItem); } } AdvanceSearchModel.this.OnMessageResponse(url, jo, status); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; SESSION session = SESSION.getInstance(); JSONObject requestJsonObject = new JSONObject(); Map<String, String> params = new HashMap<String, String>(); try { requestJsonObject.put("session", session.toJson()); if (null != category_id) { requestJsonObject.put("category_id", category_id); } } catch (JSONException e) { // TODO: handle exception } params.put("json", requestJsonObject.toString()); cb.url(url).type(JSONObject.class).params(params); ProgressDialog pd = new ProgressDialog(mContext); pd.setMessage("请稍后..."); aq.progress(pd).ajax(cb); }
public void getCategory() { String url = ProtocolConst.CATEGORY; BeeCallback<JSONObject> cb = new BeeCallback<JSONObject>() { @Override public void callback(String url, JSONObject jo, AjaxStatus status) { AdvanceSearchModel.this.callback(url, jo, status); try { STATUS responseStatus = STATUS.fromJson(jo.optJSONObject("status")); categoryArrayList.clear(); if (responseStatus.succeed == 1) { JSONArray categoryJSONArray = jo.optJSONArray("data"); if (null != categoryJSONArray && categoryJSONArray.length() > 0) { for (int i = 0; i < categoryJSONArray.length(); i++) { JSONObject categoryObject = categoryJSONArray.getJSONObject(i); CATEGORY category = CATEGORY.fromJson(categoryObject); categoryArrayList.add(category); } } AdvanceSearchModel.this.OnMessageResponse(url, jo, status); } } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }; cb.url(url).type(JSONObject.class); aq.ajax(cb); }