예제 #1
0
  /** 初始化数据--获得优惠券信息(登录后) */
  @Override
  public void initData() {
    SharedPreferences sp = BaseApplication.getSharedPreferences();
    if (sp.getBoolean("isLogin", false)) {
      String userId = sp.getString("id", null);
      HttpUtils httpUtils = new HttpUtils();
      httpUtils.send(
          HttpMethod.GET,
          AppConstant.GETCOUPON + userId,
          new RequestCallBack<String>() {

            private CenterCouponAdapter adapter;

            @Override
            public void onFailure(HttpException arg0, String arg1) {
              BaseApplication.getApplication().showToast("网络出了问题!");
            }

            @Override
            public void onSuccess(ResponseInfo<String> arg0) {
              try {
                JSONObject object = new JSONObject(arg0.result);
                if (object.getString("message").equals("OK")) {
                  JSONObject object2 = object.getJSONObject("data");
                  List<CouponBean> list =
                      JSON.parseArray(object2.getString("infos"), CouponBean.class);
                  adapter = new CenterCouponAdapter(list, CouponAcitivity.this);
                  lv_center_coupon.setAdapter(adapter);
                }
              } catch (JSONException e) {
                e.printStackTrace();
              }
            }
          });

    } else {
      BaseApplication.getApplication().showToast("请登录!");
    }
  }
예제 #2
0
 public void handleMessage(android.os.Message msg) {
   BaseApplication.getApplication().showToast(context.getString(R.string.deleted));
 };