コード例 #1
0
 @Override
 public void onClick(View view) {
   switch (view.getId()) {
     case R.id.btn_back:
       finish();
       break;
     case R.id.btn_answer:
       String txt = mEditAnswer.getText().toString().trim();
       if (TextUtils.isEmpty(txt)) return;
       answerQuestion(Utils.getUTF8String(txt));
       break;
     case R.id.btn_prev:
       mQid = mQuestionStack.pop();
       initData(mQid);
       break;
   }
 }
コード例 #2
0
  private void initData(int id) {
    String url = MyConfig.QUESTION_DETAILS_URL + Utils.getTokenString(this) + "&id=" + id;
    NetComTools netComTools = NetComTools.getInstance(this);
    mContentView.setVisibility(View.GONE);
    mProgBar.setVisibility(View.VISIBLE);
    if (mQuestionStack.isEmpty()) mPrevBtn.setVisibility(View.GONE);
    else mPrevBtn.setVisibility(View.VISIBLE);
    netComTools.getNetJson(
        url,
        new JsonDataListener() {
          @Override
          public void OnReceive(JSONObject jsonObject) {
            Log.d(TAG, "Question Details data:" + jsonObject.toString());
            try {
              int ret = jsonObject.getInt("code");
              if (ret == 0) {
                JSONObject jsonObject1 = jsonObject.getJSONObject("data");
                mAnswerArray = jsonObject1.optJSONArray("answer");
                mOtherArray = jsonObject1.optJSONArray("other_question");
                JSONObject question = jsonObject1.optJSONObject("question");
                JSONArray topic = jsonObject1.optJSONArray("topic_list");
                mContent.setText(question.optString("question_content"));
                mUser.setText(question.optString("user_name"));
                mTime.setText(question.optString("time"));
                mType.setText("癌症种类:" + question.optString("category"));
                if (topic != null) {
                  setTopList(mTopicLayout, topic);
                }
                mAuid = question.optInt("uid");
                mProgBar.setVisibility(View.GONE);
                mContentView.setVisibility(View.VISIBLE);
                initListView();
              }
            } catch (Exception e) {
              e.printStackTrace();
            }
          }

          @Override
          public void OnError(String error) {
            Log.d(TAG, "Get Question details error, " + error);
          }
        });
  }
コード例 #3
0
  private void answerQuestion(String txt) {
    String url =
        MyConfig.QUESTION_ANSWER_URL
            + Utils.getTokenString(this)
            + "&qid="
            + mQid
            + "&auid="
            + mAuid
            + "&content="
            + txt;
    NetComTools netComTools = NetComTools.getInstance(this);
    netComTools.getNetJson(
        url,
        new JsonDataListener() {
          @Override
          public void OnReceive(JSONObject jsonObject) {
            Log.d(TAG, "Question answer data:" + jsonObject.toString());
            try {
              int ret = jsonObject.getInt("code");
              if (ret == 0) {
                Utils.showToast(QuestionDetailsActivity.this, "回答成功!");
                mEditAnswer.setText("");
                initData(mQid);
              } else {
                String txt = jsonObject.optString("message");
                if (!TextUtils.isEmpty(txt)) Utils.showToast(QuestionDetailsActivity.this, txt);
              }
            } catch (Exception e) {
              e.printStackTrace();
            }
          }

          @Override
          public void OnError(String error) {
            Log.d(TAG, "Get Question answer error, " + error);
          }
        });
    SociaxUIUtils.hideSoftKeyboard(this, mEditAnswer);
  }
コード例 #4
0
  // 设置最佳
  private void setBestQuestion(final View view, int qid, int aid, int set) {
    String url =
        MyConfig.QUESTION_BAST_URL
            + Utils.getTokenString(this)
            + "&qid="
            + qid
            + "&aid="
            + aid
            + "&type="
            + set;
    NetComTools netComTools = NetComTools.getInstance(this);
    netComTools.getNetJson(
        url,
        new JsonDataListener() {
          @Override
          public void OnReceive(JSONObject jsonObject) {
            Log.d(TAG, "Set bast question data:" + jsonObject.toString());
            try {
              int ret = jsonObject.getInt("code");
              if (ret == 0) {
                view.setBackgroundResource(R.drawable.zuijiadaan);
                Utils.showToast(QuestionDetailsActivity.this, "设置成功!");
              } else {
                String txt = jsonObject.optString("message");
                if (!TextUtils.isEmpty(txt)) Utils.showToast(QuestionDetailsActivity.this, txt);
              }
            } catch (Exception e) {
              Utils.showToast(QuestionDetailsActivity.this, "网络错误!");
              e.printStackTrace();
            }
          }

          @Override
          public void OnError(String error) {
            Log.d(TAG, "Set best question error, " + error);
          }
        });
  }