コード例 #1
0
  private void purchase() {
    if (isLoading) {
      BLog.v(TAG, "is Loading ...");
      return;
    }

    if (!MarketUtils.hasSDcard()) {
      Toast.makeText(mActivity, R.string.msg_no_sdcard, Toast.LENGTH_SHORT).show();
      return;
    }

    if (!DataConnectionUtils.testValidConnection(mActivity)) {
      Toast.makeText(mActivity, R.string.dlg_msg_no_active_connectivity, Toast.LENGTH_SHORT).show();
      //            showLoadMessage(R.string.dlg_msg_no_active_connectivity);
      return;
    }
    if (!AccountSession.isLogin() && !mData.isFree) {
      BasicActivity bac = (BasicActivity) getActivity();
      bac.login();
      return;
    }
    synchronized (mLocked) {
      isLoading = true;
    }

    if (mData.isFree || mData.purchased) {
      onPayed(null);
    } else {
      doPaying();
    }
  }
コード例 #2
0
  private void getProductDetail(boolean isVisbleLoadingUI) {
    if (isLoading) {
      BLog.v(TAG, "is Loading ...");
      return;
    }

    BLog.v(TAG, "begin getProductDetail");
    if (isVisbleLoadingUI) begin();
    if (!DataConnectionUtils.testValidConnection(mActivity)) {
      //            Toast.makeText(mActivity, R.string.dlg_msg_no_active_connectivity,
      //                    Toast.LENGTH_SHORT).show();
      mHandler.postDelayed(
          new Runnable() {
            @Override
            public void run() {
              showLoadMessage(
                  R.string.dlg_msg_no_active_connectivity, R.drawable.biz_pic_empty_view, true);
            }
          },
          500);
      return;
    }
    synchronized (mLocked) {
      isLoading = true;
    }

    mApiUtil = ApiUtil.getInstance();
    mApiUtil.getProductDetail(
        mActivity,
        product_id,
        version_code,
        supported_mod,
        new RequestListener() {

          @Override
          public void onIOException(IOException e) {
            BLog.v(TAG, "getProductDetail onIOException  " + e.getMessage());
            synchronized (mLocked) {
              isLoading = false;
            }

            Message mds = mHandler.obtainMessage(LOAD_END);
            mds.getData().putBoolean(RESULT, false);
            mHandler.sendMessage(mds);
          }

          @Override
          public void onError(WutongException e) {
            BLog.d(TAG, "onError  " + e.getMessage());
            synchronized (mLocked) {
              isLoading = false;
            }

            Message mds = mHandler.obtainMessage(LOAD_END);
            mds.getData().putBoolean(RESULT, false);
            mHandler.sendMessage(mds);
          }

          @Override
          public void onComplete(String response) {
            JSONObject obj;
            try {
              obj = new JSONObject(response);
              if (!obj.has("data")) return;
              jsonString = obj.optJSONObject("data").toString();
              mData = new ProductJSONImpl(obj.optJSONObject("data"));

            } catch (JSONException e) {
              e.printStackTrace();
            }

            synchronized (mLocked) {
              isLoading = false;
            }

            Message mds = mHandler.obtainMessage(LOAD_END);
            mds.getData().putBoolean(RESULT, true);
            mHandler.sendMessage(mds);
          }
        });
  }
コード例 #3
0
  private void editComment() {
    if (isLoading) {
      BLog.v(TAG, "is Loading ...");
      return;
    }

    if (!DataConnectionUtils.testValidConnection(mActivity)) {
      Toast.makeText(mActivity, R.string.dlg_msg_no_active_connectivity, Toast.LENGTH_SHORT).show();
      return;
    }

    if (sendDialog == null) {
      sendDialog = LightProgressDialog.create(getActivity(), R.string.label_comment_sending);
      sendDialog.setCanceledOnTouchOutside(false);
    }
    sendDialog.show();

    synchronized (mLocked) {
      isLoading = true;
    }

    if (mApiUtil == null) {
      mApiUtil = new ApiUtil();
    }
    mApiUtil.createComment(
        mActivity.getApplicationContext(),
        version,
        product_id,
        message,
        rating,
        new RequestListener() {

          @Override
          public void onIOException(IOException e) {
            BLog.e(TAG, "getCommentList onIOException  " + e.getMessage());
            synchronized (mLocked) {
              isLoading = false;
            }

            Message mds = mHandler.obtainMessage(SEND_END);
            mds.getData().putBoolean(RESULT, false);
            mHandler.sendMessage(mds);
          }

          @Override
          public void onError(WutongException e) {
            BLog.e(TAG, "onError  " + e.getMessage());
            synchronized (mLocked) {
              isLoading = false;
            }

            Message mds = mHandler.obtainMessage(SEND_END);
            mds.getData().putBoolean(RESULT, false);
            mHandler.sendMessage(mds);
          }

          @Override
          public void onComplete(String response) {
            JSONObject obj;
            try {
              obj = new JSONObject(response);
              if (!obj.has("data")) return;
              mData = new CommentJSONImpl(obj.optJSONObject("data"));
            } catch (JSONException e) {
              e.printStackTrace();
            }

            synchronized (mLocked) {
              isLoading = false;
            }

            Message mds = mHandler.obtainMessage(SEND_END);
            mds.getData().putBoolean(RESULT, true);
            mHandler.sendMessage(mds);
          }
        });
  }