Ejemplo n.º 1
0
  // 取消收藏
  private void readyToChanceFav(final String Id, final int Pos) {
    if (!NetworkUtil.getInstance().existNetwork(this)) {
      Toast.makeText(this, R.string.network_disable_error, Toast.LENGTH_SHORT).show();
      return;
    }
    lockScreen(this.getResources().getString(R.string.chance_fav_send_ing));
    final String currMethod = "readyToChanceFav:";
    GoodsService gs = new GoodsService();
    AjaxCallBack<Object> callBack =
        new AjaxCallBack<Object>() {
          @Override
          public void onSuccess(Object t) {

            releaseScreen();
            if (null != t) {
              String json = t.toString();
              Log.e(TAG, currMethod + ",Json->" + json);
              ServerResponseParser parser = new ServerResponseParser();
              Log.e(TAG, "do");
              BaseResponse br = parser.parseAddFav(json);
              Log.e(TAG, "do");
              if (null != br && ErrorCodeStant.getInstance().isSucceed(br.getErrorCode())) {
                ResponseFavPost response = (ResponseFavPost) br;
                String id = response.getId();
                if (Id.equals(id)) {
                  productList.get(Pos).setInFav(false);
                  //							productList.get(Pos).setFavNum(productList.get(Pos).getFavNum()-1);
                }
                refreshListForFav();
              } else {
                String message = getString(R.string.chance_fav_failed_rem);
                String msg = getString(R.string.chance_fav_failed_rem);
                if (null == br) {
                  msg = "parseChanceFav: Result:BaseResponse is null.";
                } else {
                  int errorCode = br.getErrorCode();
                  switch (errorCode) {
                    default:
                      msg = br.getMessage();
                      message = br.getMessage();
                      break;
                  }
                }
                Log.e(
                    TAG,
                    currMethod + "errorCode:" + br.getErrorCode() + "--Message:" + br.getMessage());
                if (BuildConfig.isDebug) {
                  ExceptionRemHelper.showExceptionReport(TagReviewListActivity.this, msg);
                } else {
                  Toast.makeText(TagReviewListActivity.this, message, Toast.LENGTH_SHORT).show();
                }
              }
            } else {
              if (BuildConfig.isDebug) {
                String msg = "result t is null.";
                ExceptionRemHelper.showExceptionReport(TagReviewListActivity.this, msg);
              } else {
                Toast.makeText(
                        TagReviewListActivity.this,
                        R.string.chance_fav_failed_rem,
                        Toast.LENGTH_SHORT)
                    .show();
              }
            }
            super.onSuccess(t);
          }

          @Override
          public void onFailure(Throwable t, String strMsg) {

            releaseScreen();
            Log.e(TAG, currMethod + "onFailure,Msg->" + strMsg, t);
            if (BuildConfig.isDebug) {
              String msg = strMsg;
              if (StringUtil.getInstance().IsEmpty(msg)) {
                msg = null == t ? "Exception t is null." : t.toString();
              }
              ExceptionRemHelper.showExceptionReport(TagReviewListActivity.this, msg);
            } else {
              Toast.makeText(
                      TagReviewListActivity.this,
                      R.string.chance_fav_failed_rem,
                      Toast.LENGTH_SHORT)
                  .show();
            }
            super.onFailure(t, strMsg);
          }
        };
    gs.ToCancelFav(this, Id, callBack);
  }
Ejemplo n.º 2
0
  private void readyToGetAllGoodsByTagID(final String Id, final Boolean isfirst) {

    if (!NetworkUtil.getInstance().existNetwork(this)) {
      Toast.makeText(this, R.string.network_disable_error, Toast.LENGTH_SHORT).show();
      return;
    }
    if (isfirst) {
      count = 20;
      offset = 0;
    }
    lockScreen(this.getResources().getString(R.string.get_category_ing));
    final String currMethod = "readyToGetAllGoodsByTagID:";
    GoodsService gs = new GoodsService();
    AjaxCallBack<Object> callBack =
        new AjaxCallBack<Object>() {
          @Override
          public void onFailure(Throwable t, String strMsg) {
            releaseScreen();
            Log.e(TAG, currMethod + "onFailure,Msg->" + strMsg, t);
            if (BuildConfig.isDebug) {
              String msg = strMsg;
              if (StringUtil.getInstance().IsEmpty(msg)) {
                msg = null == t ? "Exception t is null." : t.toString();
              }
              ExceptionRemHelper.showExceptionReport(TagReviewListActivity.this, msg);
            } else {
              Toast.makeText(
                      TagReviewListActivity.this,
                      R.string.get_category_failed_rem,
                      Toast.LENGTH_SHORT)
                  .show();
            }
            super.onFailure(t, strMsg);
          }

          @Override
          public void onSuccess(Object t) {
            releaseScreen();
            if (null != t) {
              String json = t.toString();
              Trace.d(TAG, currMethod + ",Json->" + json);
              ServerResponseParser parser = new ServerResponseParser();
              BaseResponse br = parser.parseGetAllGoodsByCatID(json);
              if (null != br && ErrorCodeStant.getInstance().isSucceed(br.getErrorCode())) {
                ResponseAllGoodsByCatID response = (ResponseAllGoodsByCatID) br;
                List<ProductRec> list = response.getProductRecs();
                if (list != null && list.size() > 0) {
                  if (!isfirst) {
                    productList.addAll(list);
                    offset += productList.size();
                    Boolean ishas = (list.size() < 20) ? false : true;
                    lvProduct.onScrollComplete(ishas);
                    refreshList();
                  } else {
                    productList.clear();
                    productList.addAll(list);
                    offset += list.size();
                    Boolean ishas = (list.size() < 20) ? false : true;
                    lvProduct.onScrollComplete(ishas);
                    refreshList();
                  }
                }
              } else {

                String message = getString(R.string.get_category_failed_rem);
                String msg = getString(R.string.get_category_failed_rem);
                if (null == br) {
                  msg = "parseGetAllGoodsByCatID: Result:BaseResponse is null.";
                } else {
                  int errorCode = br.getErrorCode();
                  switch (errorCode) {
                    default:
                      msg = br.getMessage();
                      message = br.getMessage();
                      break;
                  }
                }
                Log.e(
                    TAG,
                    currMethod + "errorCode:" + br.getErrorCode() + "--Message:" + br.getMessage());
                if (BuildConfig.isDebug) {
                  ExceptionRemHelper.showExceptionReport(TagReviewListActivity.this, msg);
                } else {
                  Toast.makeText(TagReviewListActivity.this, message, Toast.LENGTH_SHORT).show();
                }
              }
            } else {
              if (BuildConfig.isDebug) {
                String msg = "result t is null.";
                ExceptionRemHelper.showExceptionReport(TagReviewListActivity.this, msg);
              } else {
                Toast.makeText(
                        TagReviewListActivity.this,
                        R.string.get_category_failed_rem,
                        Toast.LENGTH_SHORT)
                    .show();
              }
            }
            super.onSuccess(t);
          }
        };
    String moffset = String.valueOf(offset);
    String mcount = String.valueOf(count);
    gs.GetAllGoodsByTagID(this, Id, moffset, mcount, callBack);
  }