/** 请求服务器数据---首页 */ private void requestData() { // 获取轮播图 HttpUtils.getSpecialList( new EntityHandler<Gift>(Gift.class) { @Override public void onReadSuccess(List<Gift> list) { specialList = list; for (int i = 0; i < list.size(); i++) { imageList.add(list.get(i).getGoods_image()); } // 设置轮播 viewPager.setAdapter(adapter); // 设置选中的标识 LinearLayout pointLinear = (LinearLayout) findViewById(R.id.gallery_point_linear); for (int i = 0; i < imageList.size(); i++) { ImageView pointView = new ImageView(IndexActivity.this); if (i == 0) { pointView.setBackgroundResource(R.drawable.feature_point_cur); } else { pointView.setBackgroundResource(R.drawable.feature_point); } pointLinear.addView(pointView); } } }); // 获取首页新闻资讯列表 RequestParams params = new RequestParams(); params.put("page", page); // 当前第几页 params.put("per_page", NUM); // 每页条数 HttpUtils.getnewslist(rel_getnewslist, params); }
@Override protected void onResume() { super.onResume(); if (viewPager != null) { viewPager.startAutoScroll(); } if (container != null) { container.smoothScrollTo(0, 0); } HttpUtils.getpertemcount( new HttpErrorHandler() { @Override public void onRecevieSuccess(JSONObject json) { String jishi = json.getJSONObject(UrlContants.jsonData).getString("jishi"); String yongjiu = json.getJSONObject(UrlContants.jsonData).getString("yongjiu"); if (CommonUtils.CheckLogin() && Integer.valueOf(StringUtil.toString(jishi, "0")) > 0) { badgeView1.show(); badgeView1.setText(jishi); } else { badgeView1.hide(); } if (CommonUtils.CheckLogin() && Integer.valueOf(StringUtil.toString(yongjiu, "0")) > 0) { badgeView2.show(); badgeView2.setText(yongjiu); } else { badgeView2.hide(); } } }); }
/** @param viewId 获取用户选择的兴趣标签 */ private void getmemberinterests(final int type) { HttpUtils.getmemberinterests( new HttpErrorHandler() { @Override public void onRecevieSuccess(JSONObject json) { JSONArray jsonArray = json.getJSONArray("list"); interestIds = ""; for (int i = 0; i < jsonArray.size(); i++) { interestIds += jsonArray.getJSONObject(i).getString("interest_id") + ","; } interestIds = interestIds.length() > 0 ? interestIds.substring(0, interestIds.length() - 1) : ""; if (type == 0) { startActivity( new Intent(IndexActivity.this, GiftForthwithActivity.class) .putExtra("interestIds", interestIds)); // 即时红包 } else if (type == 1) { startActivity( new Intent(IndexActivity.this, GiftPerpetualActivity.class) .putExtra("interestIds", interestIds)); // 永久红包 } else { startActivity( new Intent(IndexActivity.this, UserLableActivity.class) .putExtra("interestIds", interestIds)); // 兴趣标签 } } }); }