示例#1
0
 @Override
 public void onClick(View v) {
   switch (v.getId()) {
     case R.id.btnEndDate:
       dialogDate.show();
       break;
     case R.id.btnFav:
       if (cb.isFavorited()) {
         CouponBean favCoupon =
             RestClient.deleteFavCoupons(SessionUserBean.getId(), "" + cb.getId());
         if (favCoupon.getErrorId() == 0) {
           cb.setFavorited(false);
           imgFavOn.setVisibility(View.INVISIBLE);
           imgFavOff.setVisibility(View.VISIBLE);
         } else {
           Toast.makeText(
                   CouponActivity.this,
                   "Error!! " + favCoupon.getErrorMessage(),
                   Toast.LENGTH_LONG)
               .show();
         }
       } else {
         CouponBean favCoupon = RestClient.addMyFavorites(couponId, SessionUserBean.getId());
         if (favCoupon.getErrorId() == 0) {
           cb.setFavorited(true);
           imgFavOn.setVisibility(View.VISIBLE);
           imgFavOff.setVisibility(View.INVISIBLE);
         } else {
           Toast.makeText(
                   CouponActivity.this,
                   "Error!! " + favCoupon.getErrorMessage(),
                   Toast.LENGTH_LONG)
               .show();
         }
       }
       break;
     case R.id.btnLocation:
       dialogLocation.show();
       break;
     case R.id.btnUsage:
       dialogUsage.show();
       break;
     case R.id.btnInfo:
       dialogInfo.show();
       break;
     case R.id.btnTerms:
       dialogTerms.show();
       break;
   }
 }
示例#2
0
  @Override
  public void onStopTrackingTouch(SeekBar seekBar) {
    if (seekBarCheckIn.getProgress() > 80) {
      seekBarCheckIn.setProgress(100);
      CouponBean checkinCoupon =
          RestClient.getCouponCode(
              couponId,
              SessionUserBean.getId(),
              SessionUserBean.getLat(),
              SessionUserBean.getLng());
      txtDialogCouponCode = (TextView) dialogCheckIn.findViewById(R.id.txtCouponCode);
      if (checkinCoupon.getErrorId() == 0) {
        txtDialogCouponCode.setText(checkinCoupon.getCouponCode());
        seekBarCheckIn.setVisibility(View.INVISIBLE);
        linearLayoutCheckIn.setVisibility(View.GONE);
        txtCouponCodeTitle.setVisibility(View.VISIBLE);
        txtCouponCode.setVisibility(View.VISIBLE);
        txtCouponCode.setText(checkinCoupon.getCouponCode());
      } else if (checkinCoupon.getErrorId() == Errors.ERROR_ID_DUPLICATE_CHECKIN) {
        txtDialogCouponCode.setText("Error during checkin coupon");
        seekBarCheckIn.setProgress(0);
      } else if (checkinCoupon.getErrorId() == Errors.ERROR_ID_WRONG_LOCATION) {
        txtDialogCouponCode.setText(
            "You can not check in to this coupon in this location. For check in you have to be in "
                + brandName
                + " from "
                + branchAddress
                + " in latitude "
                + couponLat
                + " and longitude "
                + couponLng);
        seekBarCheckIn.setProgress(0);
      }

      dialogCheckIn.show();
    } else {
      seekBarCheckIn.setProgress(0);
    }
  }