Esempio n. 1
0
  private void initGoods(JSONArray jsonArray) {
    List<Goods> goodsList = new ArrayList<Goods>();
    for (int i = 0; i < jsonArray.size(); i++) {
      JSONObject jsonObject = jsonArray.getJSONObject(i);
      Goods goods = JSONObject.toJavaObject(jsonObject, Goods.class);
      goodsList.add(goods);
    }

    if (goodsList != null && goodsList.size() > 0) {
      homePageListAdapter.resetData(goodsList);
    }
  }
Esempio n. 2
0
 public static AreaDomain getUserAreaByIP(final String ip) {
   AreaDomain areaDomain = null;
   try {
     JSONObject jsonObject =
         HttpService.doHttpRequestGetJson(requestURL.replaceAll("USERIP", ip), "GET", null);
     if (jsonObject.getInteger("code") == 0) {
       jsonObject = jsonObject.getJSONObject("data");
       areaDomain = JSONObject.toJavaObject(jsonObject, AreaDomain.class);
     }
   } catch (Exception e) {
     logger.warn("通过淘宝API根据IP获取地址出错");
   }
   return areaDomain;
 }
Esempio n. 3
0
  private void initAllType(JSONArray jsonArray) {
    allCategorieList = new ArrayList<AllCategory>();
    ArrayList<String> groups = new ArrayList<String>();
    SparseArray<LinkedList<String>> children = new SparseArray<LinkedList<String>>();
    for (int i = 0; i < jsonArray.size(); i++) {
      JSONObject jsonObject = jsonArray.getJSONObject(i);
      AllCategory allCategory = JSONObject.toJavaObject(jsonObject, AllCategory.class);
      allCategorieList.add(allCategory);
      groups.add(allCategory.getTypename());
      LinkedList<String> tItem = new LinkedList<String>();
      if (allCategory.getListc() != null && allCategory.getListc().size() > 0) {
        for (int j = 0; j < allCategory.getListc().size(); j++) {
          tItem.add(allCategory.getListc().get(j).getCatName());
        }
      }
      children.put(i, tItem);
    }

    if (groups != null && groups.size() > 0) {
      viewMiddle.setAdapter(getActivity(), groups, children);
    }
  }
  @Override
  public void onGetChannelList(String response) {
    try {
      channelList.clear();

      JSONArray jsonArray =
          (JSONArray) JSONObject.parseObject(response).get("plcm-content-channel");

      for (int index = 0; index < jsonArray.size(); index++) {
        JSONObject jsonObject = (JSONObject) jsonArray.get(index);
        ChannelItemObject channelItem =
            JSONObject.toJavaObject(jsonObject, ChannelItemObject.class);

        channelList.add(channelItem);
      }

      channelListAdapter.notifyDataSetChanged();

      //            progressDialog.dismiss();
    } catch (Exception ex) {
      Log.e(">>> onGetChannelList: ", ex.getMessage());
    }
  }