private void requestFavouriteList() { HashMap<String, String> params = new HashMap<>(); params.put("roleId", String.valueOf(User.getInstance().getRoleId())); params.put("role", String.valueOf(User.getInstance().getUserType().toRole())); HttpHelper.getInstance() .get( AppURL.GetFavouriteList, params, new JsonCallback() { @Override public void onSuccess(String msg, String result) { //// TODO: 2016-3-10 收藏对象初始化 还有登录的返回 ResponseFavorites response = ParseJson_Object(result, ResponseFavorites.class); if (response == null) return; // 更新收藏信息 if (response.getFavorites() != null && !response.getFavorites().isEmpty()) { User.getInstance().setJsonFavorites(response); } if (response.getCompanies() != null && !response.getCompanies().isEmpty()) { ArrayList<Product> list = new ArrayList<Product>(); Product p; for (JsonCompany company : response.getCompanies()) { p = Product.ParseJson(company); if (p != null) { list.add(p); } } adapter.setData(list); runOnUiThread( new Runnable() { @Override public void run() { adapter.notifyDataSetChanged(); } }); } } @Override public void onFailed(String str) { showToast("收藏列表获取失败"); } }); }
public void init() { if (listView == null) listView = (ListView) findViewById(R.id.collect_list); listView.setOnItemClickListener(this); adapter = new CollectListAdapter(true, null); listView.setAdapter(adapter); adapter.setData(User.getInstance().getCollectionList()); }