Example #1
0
    @Override
    protected ArrayList<String> doInBackground(Void... params) {
      Request r = null;
      if (mIsHot) {
        r = new Request(HostManager.getHotSearch());
      } else {
        r = new Request(HostManager.getExpandSearch());
        r.addParam("word", mKeyword);
      }
      if (r.getStatus() == Request.STATUS_OK) {
        JSONObject json = r.requestJSON();
        ArrayList<String> result = new ArrayList<String>();
        try {
          if (mIsHot) {
            json = json.getJSONObject(JSON_TAG_DATA);
            ArrayList<HotWord> hotWords = new ArrayList<HotWord>();
            Iterator<String> keys = json.keys();
            while (keys.hasNext()) {
              HotWord hw = new HotWord();
              hw.word = keys.next();
              hw.weight = json.getInt(hw.word);
              hotWords.add(hw);
            }
            Collections.sort(
                hotWords,
                new Comparator<HotWord>() {

                  @Override
                  public int compare(HotWord lhs, HotWord rhs) {
                    return rhs.weight - lhs.weight;
                  }
                });
            for (HotWord hw : hotWords) {
              result.add(hw.word);
            }
          } else {
            JSONArray array = json.getJSONArray(JSON_TAG_DATA);
            int len = array.length();
            for (int i = 0; i < len; i++) {
              result.add(array.getString(i));
            }
          }
          return result;
        } catch (Exception e) {
        }
      }
      return null;
    }
Example #2
0
 @Override
 protected Request getRequest() {
   Request r = new Request(HostManager.getRegionPayment());
   r.addParam("pay_id", mPayId);
   r.addParam("region_id", mRegionId);
   if (!TextUtils.isEmpty(mMihomeBuyId)) {
     r.addParam(Tags.CheckoutSubmit.MIHOME_BUY_ID, mMihomeBuyId);
   }
   return r;
 }
 @Override
 protected Request getRequest() {
   Request request = new Request(HostManager.getSaleOutReg());
   request.addParam(Parameters.Keys.PRODUCT_ID, mProductId);
   return request;
 }