// 返回获取的网络数据 public void onResultHandler(LMessage msg, int requestId) { super.onResultHandler(msg, requestId); if (msg != null) { if (requestId == 1) { getJsonSubmit(msg.getStr()); } else { T.ss("获取数据失败"); } } }
private void getJsonData(String data) { try { JSONObject jsonObject = new JSONObject(data); int code = jsonObject.getInt("status"); if (code == 1) { JSONObject obejc = jsonObject.getJSONObject("list"); if (obejc.getString("first_list").length() < 1) { // T.ss("您暂时没有下级分销商!"); } else { JSONArray array = obejc.getJSONArray("first_list"); for (int i = 0; i < array.length(); i++) { JSONObject o = array.getJSONObject(i); MyPartnerEntity.ChildList cl = new MyPartnerEntity.ChildList(); cl.setUsername(o.getString("username")); cl.setAmount(o.getString("total_amount")); list.add(cl); } } tv_money.setText(obejc.getString("first_total")); tv_nums.setText(obejc.getString("first_child")); adapter = new MyPartnerAdapter(getActivity(), list); listView.setAdapter(adapter); Scrollto(); } else { T.ss(jsonObject.getString("info")); String longs = jsonObject.getString("info"); if (longs.equals("请先登录")) { Intent intent = new Intent(getActivity(), LoginMain.class); startActivity(intent); } } } catch (JSONException e) { e.printStackTrace(); } }
private void getJsonSubmit(String data) { list.clear(); try { JSONObject jsonObject = new JSONObject(data); int code = jsonObject.getInt("status"); if (code == 1) { JSONObject o = jsonObject.getJSONObject("list"); if (o.equals("") || o.equals(null) || o.equals("null") || o.length() < 1) { rl_gssat.setVisibility(View.VISIBLE); listview.setVisibility(View.GONE); } else { rl_gssat.setVisibility(View.GONE); listview.setVisibility(View.VISIBLE); JSONArray jo = o.getJSONArray("orderlist"); for (int i = 0; i < jo.length(); i++) { JSONObject ob = jo.getJSONObject(i); AllOrderEntity ee = new AllOrderEntity(); ee.setState(ob.getString("state")); ee.setId(ob.getString("id")); ee.setTotal_price(ob.getString("total_price")); ee.setPay_price(ob.getString("pay_price")); ee.setFlgs(false); JSONArray ja = ob.getJSONArray("_child"); itemlist = new ArrayList<>(); for (int j = 0; j < ja.length(); j++) { JSONObject jt = ja.getJSONObject(j); AllOrderEntity.ChildEntity ce = new AllOrderEntity.ChildEntity(); ce.setOrderid(jt.getString("orderid")); ce.setTitle(jt.getString("title")); ce.setSpec_1(jt.getString("spec_1")); ce.setSpec_2(jt.getString("spec_2")); ce.setPrice(jt.getString("price")); ce.setNewprice(jt.getString("newprice")); ce.setNum(jt.getString("num")); ce.setPicurl(jt.getString("picurl")); itemlist.add(ce); } ee.set_child(itemlist); list.add(ee); } adapter = new AllOrderAdapter(Fragment_back_money.this, list); listview.setAdapter(adapter); } } else { T.ss(jsonObject.getString("info").toString()); // String longs=jsonObject.getString("info"); // if(longs.equals("请先登录")){ // LSharePreference.getInstance(getActivity()).setBoolean("login", // false); // Intent intent = new Intent(getActivity(), LoginMain.class); // startActivity(intent); // } } } catch (JSONException e) { e.printStackTrace(); rl_gssat.setVisibility(View.VISIBLE); listview.setVisibility(View.GONE); } }