Пример #1
0
 /**
  * 被选择的Label字符串表示,e.g. "1,2,3".
  *
  * @param selectedLabels
  */
 public void updateLabels(String selectedLabels) {
   if (selectedLabels == null || selectedLabels.equals("")) return;
   String[] labelIDs = selectedLabels.split(",");
   HashMap<String, Float> map =
       JSONUtils.gson.fromJson(this.labels, new TypeToken<HashMap<String, Float>>() {}.getType());
   for (String labelID : labelIDs) {
     try {
       float currentScore = map.get(labelID);
       map.put(labelID, currentScore + 0.01f);
     } catch (Exception e) {
       e.printStackTrace();
       return;
     }
   }
   this.labels = JSONUtils.toJSON(map);
 }
Пример #2
0
 /**
  * 从现有的Label组合中删除一个key.
  *
  * @param labelID
  */
 public void removeLabel(String labelID) {
   HashMap<String, Float> map =
       JSONUtils.gson.fromJson(this.labels, new TypeToken<HashMap<String, Float>>() {}.getType());
   map.remove(labelID);
   this.labels = JSONUtils.toJSON(map);
 }
Пример #3
0
 public static JSONObject parse(int code, String... params)
     throws ClientProtocolException, IOException, JSONException {
   String setting = "response_type:json";
   ArrayList<NameValuePair> param = new ArrayList<NameValuePair>();
   param.add(new BasicNameValuePair("setting", setting));
   param.add(new BasicNameValuePair("SET_DEVICE", "android(APP)"));
   String movieProduct_seq, member_seq, ad_seq, num;
   String type, msg, state_info, memo, bug_title;
   String bookmark_time, is_public, bookmark_seq;
   String text_banner_seq, posturl;
   // String bug_image;
   // String bookmark_image;
   switch (code) {
     case REQ_GET_CONTENTS:
       posturl = URL_GET_CONTENTS;
       movieProduct_seq = params[0];
       member_seq = params[1];
       param.add(new BasicNameValuePair(KEY_MOVIE_NUM, movieProduct_seq));
       param.add(new BasicNameValuePair(KEY_MEMBER_NUM, member_seq));
       break;
     case REQ_AD_VIEW_CHECK:
       posturl = params[0];
       movieProduct_seq = params[1];
       member_seq = params[2];
       ad_seq = params[3];
       param.add(new BasicNameValuePair(KEY_AD_NUM, ad_seq));
       param.add(new BasicNameValuePair(KEY_MOVIE_NUM, movieProduct_seq));
       param.add(new BasicNameValuePair(KEY_MEMBER_NUM, member_seq));
       break;
     case REQ_GET_AD_LIST:
       posturl = params[0];
       movieProduct_seq = params[1];
       num = params[2];
       param.add(new BasicNameValuePair(KEY_MOVIE_NUM, movieProduct_seq));
       param.add(new BasicNameValuePair(KEY_NUM, num));
       break;
     case REQ_AD_CLICK_CHECK:
       posturl = params[0];
       ad_seq = params[1];
       movieProduct_seq = params[2];
       member_seq = params[3];
       param.add(new BasicNameValuePair(KEY_AD_NUM, ad_seq));
       param.add(new BasicNameValuePair(KEY_MOVIE_NUM, movieProduct_seq));
       param.add(new BasicNameValuePair(KEY_MEMBER_NUM, member_seq));
       break;
     case REQ_SEND_LOG:
       posturl = params[0];
       type = params[1];
       msg = params[2];
       param.add(new BasicNameValuePair(KEY_TYPE, type));
       param.add(new BasicNameValuePair(KEY_LOG_MSG, msg));
       break;
     case REQ_REPORT_BUG:
       posturl = params[0];
       movieProduct_seq = params[1];
       member_seq = params[2];
       state_info = params[3];
       memo = params[4];
       bug_title = params[5];
       // bug_image = params[5];
       param.add(new BasicNameValuePair(KEY_MOVIE_NUM, movieProduct_seq));
       param.add(new BasicNameValuePair(KEY_MEMBER_NUM, member_seq));
       param.add(new BasicNameValuePair(KEY_BUG_STATE_INFO, state_info));
       param.add(new BasicNameValuePair(KEY_BUG_MEMO, memo));
       param.add(new BasicNameValuePair(KEY_BUG_TITLE, bug_title));
       break;
     case REQ_SEND_BOOKMARK:
       posturl = params[0];
       movieProduct_seq = params[1];
       member_seq = params[2];
       is_public = params[3];
       memo = params[4];
       bookmark_time = params[5];
       // bookmark_image = params[5];
       param.add(new BasicNameValuePair(KEY_MOVIE_NUM, movieProduct_seq));
       param.add(new BasicNameValuePair(KEY_MEMBER_NUM, member_seq));
       param.add(new BasicNameValuePair(KEY_BOOKMARK_PUBLIC, is_public));
       param.add(new BasicNameValuePair(KEY_BUG_MEMO, memo));
       param.add(new BasicNameValuePair(KEY_BOOKMARK_TIME, bookmark_time));
       break;
     case REQ_DELETE_BOOKMARK:
       posturl = params[0];
       bookmark_seq = params[1];
       param.add(new BasicNameValuePair(KEY_BOOKMARK_NUM, bookmark_seq));
       break;
     case REQ_GET_BOOKMARK:
       posturl = params[0];
       movieProduct_seq = params[1];
       member_seq = params[2];
       param.add(new BasicNameValuePair(KEY_MOVIE_NUM, movieProduct_seq));
       param.add(new BasicNameValuePair(KEY_MEMBER_NUM, member_seq));
       break;
     case REQ_TEXT_AD_VIEW_CHECK:
       posturl = params[0];
       text_banner_seq = params[1];
       movieProduct_seq = params[2];
       member_seq = params[3];
       param.add(new BasicNameValuePair(KEY_TEXT_AD_NUM, text_banner_seq));
       param.add(new BasicNameValuePair(KEY_MOVIE_NUM, movieProduct_seq));
       param.add(new BasicNameValuePair(KEY_MEMBER_NUM, member_seq));
       break;
     case REQ_GET_TEXT_AD_LIST:
       posturl = params[0];
       break;
     case REQ_TEXT_AD_CLICK_CHECK:
       posturl = params[0];
       text_banner_seq = params[1];
       movieProduct_seq = params[2];
       member_seq = params[3];
       param.add(new BasicNameValuePair(KEY_TEXT_AD_NUM, text_banner_seq));
       param.add(new BasicNameValuePair(KEY_MOVIE_NUM, movieProduct_seq));
       param.add(new BasicNameValuePair(KEY_MEMBER_NUM, member_seq));
       break;
     default:
       throw new IllegalArgumentException("not defined action");
   }
   return JSONUtils.jsonFromURL(posturl, param);
 }