Example #1
0
        @Override
        public void needCharge(
            String oid, String currency, String couponId, final CtFetchCallback<Boolean> callback) {
          LogHelper.e(TAG, TextUtils.join("|", new String[] {oid, currency, couponId}));
          OrderBusiness.getFinalPrice(
              ((PayOrderAcivity) iPayOrderView),
              mClient,
              new LabAsyncHttpResponseHandler() {
                @Override
                public void onSuccess(LabResponse response, Object data) {
                  LogHelper.e(TAG, " need char " + String.valueOf(response.result));
                  JSONObject jsonObject = JSONObject.parseObject(String.valueOf(data));
                  double value = 0;

                  try {
                    value = Double.valueOf(jsonObject.getString("finalPrice"));
                  } catch (NumberFormatException e) {
                    value = 1;
                  }
                  callback.onSuc(value > 0);
                }

                @Override
                public void onFailure(LabResponse response, Object data) {
                  String msg = response.msg;
                  if (TextUtils.isEmpty(msg)) {
                    msg = PlatformUtil.getInstance().getString(R.string.ct_pay_failed);
                  }
                  callback.onFailed(new CtException(msg));
                }
              },
              oid,
              currency,
              couponId);
        }
Example #2
0
        @Override
        public void getChar(
            String oid,
            String type,
            String ip,
            String currency,
            String couponId,
            final CtFetchCallback<String> callback) {
          LogHelper.e(TAG, TextUtils.join("|", new String[] {oid, type, ip, currency, couponId}));
          OrderBusiness.getCharge(
              ((PayOrderAcivity) iPayOrderView),
              mClient,
              new LabAsyncHttpResponseHandler() {
                @Override
                public void onSuccess(LabResponse response, Object data) {
                  callback.onSuc(String.valueOf(data));
                }

                @Override
                public void onFailure(LabResponse response, Object data) {
                  String msg = response.msg;
                  if (TextUtils.isEmpty(msg)) {
                    msg = PlatformUtil.getInstance().getString(R.string.ct_pay_failed);
                  }
                  callback.onFailed(new CtException(msg));
                }
              },
              oid,
              type,
              ip,
              currency,
              couponId);
        }
Example #3
0
 /**
  * * Get the Drawable from URL
  *
  * @param urlString
  * @return
  */
 public Drawable fetchDrawable(String urlString) {
   try {
     Bitmap bitmap =
         ImageLoader.getInstance()
             .loadImageSync(urlString, ImageHelper.getDefaultDisplayImageOptions());
     //                InputStream is = fetch(urlString);
     //                Drawable drawable = Drawable.createFromStream(is, "src");
     Drawable drawable = new BitmapDrawable(bitmap);
     int tempWidth =
         bitmap.getScaledWidth(MainApplication.getInstance().getResources().getDisplayMetrics());
     int height =
         bitmap.getScaledHeight(MainApplication.getInstance().getResources().getDisplayMetrics())
             * 2
             / 3;
     //                drawable.setBounds(0,0,tempWidth,height);
     LogHelper.e("omg", "normal  " + tempWidth + " -" + height);
     LogHelper.e(
         "omg",
         "page  "
             + MainApplication.getInstance().getPageWidth()
             + " -"
             + MainApplication.getInstance().getPageHeight());
     int width = MainApplication.getInstance().getPageWidth();
     float leftPadding =
         MainApplication.getInstance()
             .getResources()
             .getDimension(R.dimen.ct_personal_desc_left_padding);
     float topPadding =
         MainApplication.getInstance()
             .getResources()
             .getDimension(R.dimen.ct_personal_desc_top_padding);
     //                height =  width * height /tempWidth ;
     drawable.setBounds(
         (int) leftPadding,
         0,
         (width > 0 ? width : 0) - (int) leftPadding * 2,
         (height > 0 ? height : 0));
     LogHelper.e(
         "omg", "bound " + drawable.getBounds().width() + " - " + drawable.getBounds().height());
     return drawable;
   } catch (Exception e) {
     return null;
   }
 }
Example #4
0
    @Override
    protected void onPostExecute(Drawable result) {
      // set the correct bound according to the result from HTTP call
      LogHelper.e(
          TAG,
          "w/h "
              + result.getIntrinsicWidth()
              + "/"
              + result.getIntrinsicHeight()
              + "  "
              + result.getBounds());
      // change the reference of the current drawable to the result
      // from the HTTP call
      urlMap.put(source, result);

      // redraw the image by invalidating the container
      container.setText(Html.fromHtml(html, URLImageParser.this, null));
    }
 @Override
 protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setContentView(R.layout.ct_service_desc_detail);
   ButterKnife.inject(this);
   if (getIntent().hasExtra(SERVIDE_ID)
       && getIntent().getSerializableExtra(SERVIDE_ID) instanceof ServiceInfo) {
     serviceInfo = (ServiceInfo) getIntent().getSerializableExtra(SERVIDE_ID);
   } else {
     MessageUtils.showToast(R.string.data_error);
     finish();
     return;
   }
   showActionBar(getString(R.string.ct_detail_desc));
   ceServiceName.setText(serviceInfo.getName());
   ceServiceLocation.setText(serviceInfo.getAddress());
   serviceScore.setRating(NumberUtils.paserFloat(serviceInfo.getScore()));
   String introduce = URLImageParser.replae(serviceInfo.getDescpt());
   introduce = URLImageParser.replaeWidth(introduce);
   //        URLImageParser p = new URLImageParser(ctContentV, ServideDetailDescActivity.this,
   // introduce);
   //        ctContentV.setText(Html.fromHtml(introduce, p, null));
   //        ctBook.setOnClickListener(new View.OnClickListener() {
   //            @Override
   //            public void onClick(View v) {
   //                CreateOrderActivity.start(ServideDetailDescActivity.this, serviceInfo);
   //            }
   //        });
   while (!TextUtils.isEmpty(introduce) && introduce.indexOf("<div>") >= 0) {
     if (introduce.indexOf("<div>") >= 0) {
       String temp = introduce.substring(0, introduce.indexOf("<div>"));
       introduce = introduce.substring(introduce.indexOf("<div>") + 5);
       LogHelper.e("now ", introduce);
       buildTextView(temp);
       temp = introduce.substring(0, introduce.indexOf("</div>"));
       buildImage(temp);
       introduce = introduce.substring(introduce.indexOf("</div>") + 6);
     }
   }
   buildTextView(introduce);
 }