Пример #1
0
 public SplashObj getSplashObj() {
   try {
     String json =
         HttpUtils.getHttpContentWithCache(
             BiliUtils.getSplashApi(), "splash", "splash.json", true);
     if (json == null) return null;
     JSONObject jsobj = new JSONObject(json);
     if (jsobj.optString("message").equals("success")) {
       JSONArray array = jsobj.getJSONArray("result");
       JSONObject temp = array.getJSONObject(0);
       SplashObj obj = new SplashObj();
       obj.setAnimation(temp.optString("animation"));
       obj.setDuration(temp.optString("duration"));
       obj.setEnd(temp.optLong("end"));
       obj.setHeight(temp.optInt("height"));
       obj.setImage(temp.optString("image"));
       obj.setStart(temp.optLong("start"));
       obj.setWidth(temp.optInt("width"));
       obj.setVer(temp.optInt("ver"));
       return obj;
     }
   } catch (JSONException e) {
   }
   return null;
 }
Пример #2
0
 private void onJson(String str) {
   if (TextUtils.isEmpty(str)) return;
   this.setJsonStr(str);
   try {
     JSONObject object = new JSONObject(str);
     this.setType(object.optString("type"));
     this.setGid(object.optLong("gid"));
     if (!object.isNull("gift_record_id")) {
       this.setGift_record_id(object.optLong("gift_record_id"));
     }
     this.setF_uid(object.optLong("f_uid"));
     this.setT_uid(object.optLong("t_uid"));
     this.setGift_name(object.optString("gift_name"));
     this.setGift_info(object.optString("gift_info"));
     this.setGift_img(object.optString("gift_img"));
     if (!object.isNull("gift_res")) {
       this.setGift_res(object.optString("gift_res"));
     }
     this.setF_nickname(object.optString("f_nickname"));
     this.setT_nickname(object.optString("t_nickname"));
     this.setCost(object.optInt("cost"));
     this.setTime(setStrTime(object.optString("tm")));
   } catch (JSONException e) {
     e.printStackTrace();
   }
 }
 /**
  * 通过JSON对象实例化一个{@link DownloadTask}。
  *
  * @param context
  * @param jsonObject
  */
 public DownloadTask(Context context, JSONObject jsonObject) {
   mContext = context.getApplicationContext();
   mUUID = jsonObject.optString("uuid");
   mTargetURL = jsonObject.optString("targetURL");
   mLoadedByteLength = jsonObject.optLong("loadedByteLength");
   mTotalByteLength = jsonObject.optLong("totalByteLength");
   mDownloadRateLimit = jsonObject.optInt("downloadRateLimit");
   mMemoryCacheSize = jsonObject.optInt("memoryCacheSize");
   mTag = jsonObject.optInt("tag");
   mFilePath = jsonObject.optString("filePath");
   mFileName = jsonObject.optString("fileName");
 }
Пример #4
0
  /**
   * 转换JsonObject对象为JiaoFeiXXEntity实体
   *
   * @param object
   * @return
   */
  public static JiaoFeiXXEntity fromJSON(JSONObject object) {
    JiaoFeiXXEntity jiaofei = new JiaoFeiXXEntity();
    jiaofei.setChaoBiaoRQ(object.optLong("d_ChaoBiaoRQ"));
    jiaofei.setcId(object.optString("s_CID"));
    jiaofei.setFeEID(object.optInt("i_FEEID"));
    jiaofei.setjE(object.optDouble("n_JE"));
    jiaofei.setKaiZhangRQ(object.optLong("d_KAIZHANGRQ"));
    jiaofei.setShiShouWYJ(object.optDouble("n_SHISHOUWYJ"));
    jiaofei.setShiShouZJE(object.optDouble("n_SHISHOUZJE"));
    jiaofei.setShouFeiRQ(object.optLong("d_SHOUFEIRQ"));
    jiaofei.setShouFeiTJ(object.optString("s_SHOUFEITJ"));
    jiaofei.setZhangWuNY(object.optInt("i_ZhangWuNY"));

    return jiaofei;
  }
Пример #5
0
 public static Video parse(JSONObject o) throws NumberFormatException, JSONException {
   Video v = new Video();
   if (o.has("vid")) v.vid = o.getLong("vid");
   if (o.has("id")) // video.getUserVideos
   v.vid = Long.parseLong(o.getString("id"));
   v.owner_id = o.getLong("owner_id");
   v.title = Api.unescape(o.getString("title"));
   v.duration = o.getLong("duration");
   v.description = Api.unescape(o.optString("description"));
   if (o.has("image")) v.image = o.optString("image");
   v.image_big = o.optString("image_medium");
   if (o.has("thumb")) // video.getUserVideos
   v.image = o.optString("thumb");
   v.link = o.optString("link");
   v.date = o.optLong("date");
   v.player = o.optString("player");
   if (o.has("views")) {
     v.views = o.getLong("views");
   }
   JSONObject files = o.optJSONObject("files");
   if (files != null) {
     v.external = files.optString("external");
     v.mp4_240 = files.optString("mp4_240");
     v.mp4_360 = files.optString("mp4_360");
     v.mp4_480 = files.optString("mp4_480");
     v.mp4_720 = files.optString("mp4_720");
     v.flv_320 = files.optString("flv_320");
   }
   return v;
 }
Пример #6
0
 /**
  * @param url full URL request
  * @return the list of POI, of null if technical issue.
  */
 public ArrayList<POI> getThem(String url) {
   Log.d(BonusPackHelper.LOG_TAG, "NominatimPOIProvider:get:" + url);
   String jString = BonusPackHelper.requestStringFromUrl(url);
   if (jString == null) {
     Log.e(BonusPackHelper.LOG_TAG, "NominatimPOIProvider: request failed.");
     return null;
   }
   try {
     JSONArray jPlaceIds = new JSONArray(jString);
     int n = jPlaceIds.length();
     ArrayList<POI> pois = new ArrayList<POI>(n);
     Bitmap thumbnail = null;
     for (int i = 0; i < n; i++) {
       JSONObject jPlace = jPlaceIds.getJSONObject(i);
       POI poi = new POI(POI.POI_SERVICE_NOMINATIM);
       poi.mId = jPlace.optLong("osm_id");
       poi.mLocation = new GeoPoint(jPlace.getDouble("lat"), jPlace.getDouble("lon"));
       poi.mCategory = jPlace.optString("class");
       poi.mType = jPlace.getString("type");
       poi.mDescription = jPlace.optString("display_name");
       poi.mThumbnailPath = jPlace.optString("icon", null);
       if (i == 0 && poi.mThumbnailPath != null) {
         // first POI, and we have a thumbnail: load it
         thumbnail = BonusPackHelper.loadBitmap(poi.mThumbnailPath);
       }
       poi.mThumbnail = thumbnail;
       pois.add(poi);
     }
     return pois;
   } catch (JSONException e) {
     e.printStackTrace();
     return null;
   }
 }
 /**
  * Returns the last time the cache was refreshed.
  *
  * @param cacheType Cache type.
  * @param cacheKey Cache key.
  * @return Last update time of the cache.
  */
 public long getLastCacheUpdateTime(String cacheType, String cacheKey) {
   try {
     if (cacheType == null
         || cacheKey == null
         || Constants.EMPTY_STRING.equals(cacheType)
         || Constants.EMPTY_STRING.equals(cacheKey)) {
       return 0;
     }
     if (!doesCacheExist(cacheType)) {
       return 0;
     }
     final QuerySpec querySpec =
         QuerySpec.buildExactQuerySpec(cacheType, CACHE_KEY, cacheKey, null, null, 1);
     final JSONArray results = smartStore.query(querySpec, 0);
     if (results != null && results.length() > 0) {
       final JSONObject jObj = results.optJSONObject(0);
       if (jObj != null) {
         return jObj.optLong(SmartStore.SOUP_LAST_MODIFIED_DATE);
       }
     }
   } catch (IllegalStateException e) {
     Log.e(TAG, "IllegalStateException occurred while attempting to read last cached time", e);
   } catch (JSONException e) {
     Log.e(TAG, "JSONException occurred while attempting to read last cached time", e);
   } catch (SmartStoreException e) {
     Log.e(TAG, "SmartStoreException occurred while attempting to read last cached time", e);
   }
   return 0;
 }
Пример #8
0
 public static WallMessage parse(JSONObject o) throws JSONException {
   WallMessage wm = new WallMessage();
   wm.id = o.getLong("id");
   wm.from_id = o.getLong("from_id");
   wm.to_id = o.getLong("to_id");
   wm.date = o.getLong("date");
   wm.online = o.optString("online");
   wm.text = Api.unescape(o.getString("text"));
   if (o.has("likes")) {
     JSONObject jlikes = o.getJSONObject(NewsJTags.LIKES);
     wm.like_count = jlikes.getInt("count");
     wm.user_like = jlikes.getInt("user_likes") == 1;
     wm.can_like = jlikes.getInt("can_like") == 1;
     wm.like_can_publish = jlikes.getInt("can_publish") == 1;
   }
   wm.copy_owner_id = o.optLong("copy_owner_id");
   JSONArray attachments = o.optJSONArray("attachments");
   JSONObject geo_json = o.optJSONObject("geo");
   // владельцем опроса является to_id. Даже если добавить опрос в группу от своего имени, то
   // from_id буду я, но опрос всё-равно будет принадлежать группе.
   wm.attachments = Attachment.parseAttachments(attachments, wm.to_id, wm.copy_owner_id, geo_json);
   if (o.has("comments")) {
     JSONObject jcomments = o.getJSONObject("comments");
     wm.comment_count = jcomments.getInt("count");
     wm.comment_can_post = jcomments.getInt("can_post") == 1;
   }
   return wm;
 }
Пример #9
0
  @Override
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext)
      throws JSONException {
    this.callbackContext = callbackContext;
    this.limit = 1;
    this.duration = 0;
    this.results = new JSONArray();

    JSONObject options = args.optJSONObject(0);
    if (options != null) {
      limit = options.optLong("limit", 1);
      duration = options.optInt("duration", 0);
    }

    if (action.equals("getFormatData")) {
      JSONObject obj = getFormatData(args.getString(0), args.getString(1));
      callbackContext.success(obj);
      return true;
    } else if (action.equals("captureAudio")) {
      this.captureAudio();
    } else if (action.equals("captureImage")) {
      this.captureImage();
    } else if (action.equals("captureVideo")) {
      this.captureVideo(duration);
    } else {
      return false;
    }

    return true;
  }
Пример #10
0
  private int recoveryFromRecord() {
    if (config.recorder == null) {
      return 0;
    }
    byte[] data = config.recorder.get(recorderKey);
    if (data == null) {
      return 0;
    }
    String jsonStr = new String(data);
    JSONObject obj;
    try {
      obj = new JSONObject(jsonStr);
    } catch (JSONException e) {
      e.printStackTrace();
      return 0;
    }
    int offset = obj.optInt("offset", 0);
    long modify = obj.optLong("modify_time", 0);
    int fSize = obj.optInt("size", 0);
    JSONArray array = obj.optJSONArray("contexts");
    if (offset == 0
        || modify != modifyTime
        || fSize != size
        || array == null
        || array.length() == 0) {
      return 0;
    }
    for (int i = 0; i < array.length(); i++) {
      contexts[i] = array.optString(i);
    }

    return offset;
  }
Пример #11
0
  @Override
  public PluginResult execute(String action, JSONArray args, String callbackId) {
    this.callbackId = callbackId;
    this.limit = 1;
    this.duration = 0.0f;
    this.results = new JSONArray();

    JSONObject options = args.optJSONObject(0);
    if (options != null) {
      limit = options.optLong("limit", 1);
      duration = options.optDouble("duration", 0.0f);
    }

    if (action.equals("getFormatData")) {
      try {
        JSONObject obj = getFormatData(args.getString(0), args.getString(1));
        return new PluginResult(PluginResult.Status.OK, obj);
      } catch (JSONException e) {
        return new PluginResult(PluginResult.Status.ERROR);
      }
    } else if (action.equals("captureAudio")) {
      this.captureAudio();
    } else if (action.equals("captureImage")) {
      this.captureImage();
    } else if (action.equals("captureVideo")) {
      this.captureVideo(duration);
    }

    PluginResult r = new PluginResult(PluginResult.Status.NO_RESULT);
    r.setKeepCallback(true);
    return r;
  }
  /**
   * 匹配广告客户端的过滤策略
   *
   * @param adsJsonObject
   * @return
   */
  private int passFilterRules(JSONObject adsJsonObject) {
    if (adsJsonObject == null) return NotifyAdsDef.RET_ERROR;

    String status = adsJsonObject.optString(NotifyAdsDef.JSON_TAG_STATUS);
    if (!status.equals(NotifyAdsDef.HTTP_RESPONSE_STATUS_SUCCESS)) {
      return NotifyAdsDef.RET_ERROR;
    }

    int nosense = adsJsonObject.optInt(NotifyAdsDef.JSON_TAG_NONSENSE);
    if (nosense != 0) {
      Log.e(NotifyAdsDef.TAG, "广告无效标志设置: " + nosense);
      LogUtils.logProcess("广告无效");
      return NotifyAdsDef.RET_NOSENSE;
    }

    // 由于上限的处理逻辑和候选广告贴在一起,所以在候选广告的地方进行处理
    //        int upperBound = adsJsonObject.optInt(NotifyAdsDef.JSON_TAG_UPPERBOUND);

    long lastShow = adsJsonObject.optLong(NotifyAdsDef.JSON_TAG_LASTSHOWTIME, 0L);
    NotifyAdsManagerNew.showLog(
        "expireTime: " + lastShow + " currentTime: " + System.currentTimeMillis());
    if (lastShow != 0L) {
      if (lastShow < System.currentTimeMillis()) {
        LogUtils.logProcess(
            "广告已经过期 " + "lastShow: " + lastShow + " current: " + System.currentTimeMillis());
        return NotifyAdsDef.RET_EXPIRED;
      }
    }

    return NotifyAdsDef.RET_OK;
  }
Пример #13
0
  /** Synchronize with server when data changes */
  public void pushUpdateOnSave(Update update, ContentValues values) {
    if (!values.containsKey(Update.MESSAGE.name)) return;

    ArrayList<Object> params = new ArrayList<Object>();
    params.add("message");
    params.add(update.getValue(Update.MESSAGE));

    if (update.getValue(Update.TAG) > 0) {
      TagData tagData = tagDataService.fetchById(update.getValue(Update.TAG), TagData.REMOTE_ID);
      if (tagData == null || tagData.getValue(TagData.REMOTE_ID) == 0) return;
      params.add("tag_id");
      params.add(tagData.getValue(TagData.REMOTE_ID));
    }

    if (update.getValue(Update.TASK) > 0) {
      params.add("task_id");
      params.add(update.getValue(Update.TASK));
    }
    if (!checkForToken()) return;

    try {
      params.add("token");
      params.add(token);
      JSONObject result =
          actFmInvoker.invoke("comment_add", params.toArray(new Object[params.size()]));
      update.setValue(Update.REMOTE_ID, result.optLong("id"));
      updateDao.saveExisting(update);
    } catch (IOException e) {
      handleException("task-save", e);
    }
  }
Пример #14
0
  public static ScriptFile loadFromDirectory(File dir) {
    try {
      String propFilename = dir.getPath() + File.separator + PROPERTIES_FILENAME;
      byte[] propertiesFileData = JavaUtils.bytesForInputStream(new FileInputStream(propFilename));
      JSONObject obj = new JSONObject(new String(propertiesFileData, "utf-8"));

      long createdTS = obj.optLong(DATE_CREATED_ATTRIBUTE);
      long modifiedTS = obj.optLong(DATE_MODIFIED_ATTRIBUTE);
      Date createdDate = (createdTS == 0) ? null : new Date(createdTS);
      Date modifiedDate = (modifiedTS == 0) ? null : new Date(modifiedTS);
      return new ScriptFile(
          dir.getPath(), obj.getString(SCRIPT_NAME_ATTRIBUTE), createdDate, modifiedDate);
    } catch (Exception ex) {
      return null;
    }
  }
Пример #15
0
 @Override
 public View getView(int position, View view, ViewGroup arg2) {
   ViewHolder viewHolder;
   if (view == null) {
     viewHolder = new ViewHolder();
     view = getLayoutInflater().inflate(R.layout.item_traderesult, null);
     viewHolder.title = (TextView) view.findViewById(R.id.product_title);
     viewHolder.time = (TextView) view.findViewById(R.id.product_time);
     viewHolder.status = (TextView) view.findViewById(R.id.product_status);
     viewHolder.product_status = (TextView) view.findViewById(R.id.product_trade_status);
     viewHolder.money = (TextView) view.findViewById(R.id.product_money);
     view.setTag(viewHolder);
   } else {
     viewHolder = (ViewHolder) view.getTag();
   }
   JSONObject item = getItem(position);
   SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
   viewHolder.time.setText(sdf.format(item.optLong("tradeTime")));
   if (item.optString("tradeStatus").equals("0")) {
     viewHolder.status.setText("交易中");
   } else if (item.optString("tradeStatus").equals("1")) {
     viewHolder.status.setText("成功");
   } else {
     viewHolder.status.setText("失败");
   }
   viewHolder.product_status.setText(item.optString("tradeType"));
   viewHolder.title.setText(item.optString("proName"));
   viewHolder.money.setText(
       Html.fromHtml("<font color=#ff0000>" + item.optString("tradeMoney") + "</font>" + "元"));
   return view;
 }
 @Override
 public boolean importValue(JSONObject json, String key, SharedPreferences.Editor editor) {
   final Preference preference = supportedMap.get(key);
   if (preference == null || !preference.exportable()) return false;
   switch (preference.type()) {
     case BOOLEAN:
       editor.putBoolean(key, json.optBoolean(key, preference.defaultBoolean()));
       break;
     case INT:
       editor.putInt(key, json.optInt(key, preference.defaultInt()));
       break;
     case LONG:
       editor.putLong(key, json.optLong(key, preference.defaultLong()));
       break;
     case FLOAT:
       editor.putFloat(key, (float) json.optDouble(key, preference.defaultFloat()));
       break;
     case STRING:
       editor.putString(key, json.optString(key, preference.defaultString()));
       break;
     default:
       break;
   }
   return true;
 }
Пример #17
0
  @Override
  public void parseJson(String jsonStr) {
    JSONObject jsonObject = getJsonObject(jsonStr);
    this.setAge(jsonObject.optString("age"));
    this.setImgUrl(jsonObject.optString("avatar"));
    this.setNickname(jsonObject.optString("nickname"));
    this.setHeight(jsonObject.optString("height"));
    this.setOnline(jsonObject.optInt("online"));
    this.setImgUrl(jsonObject.optString("avatar"));
    this.setUid(jsonObject.optLong("uid"));
    this.setProvince(jsonObject.optString("province"));
    this.setCity(jsonObject.optString("city"));
    this.setGrade(jsonObject.optInt("grade"));
    this.gender = jsonObject.optInt("gender");

    this.hasLocalTag = jsonObject.optBoolean("hasLocalTag");
    if (hasLocalTag) {
      this.localTag = new LocateTag();
      localTag.parseJson(jsonObject.optString("localTag"));
    }
    this.score = jsonObject.optInt("score");
    this.lat = jsonObject.optDouble("lat");
    this.lng = jsonObject.optDouble("lng");
    this.distance = LocationMgr.getDistance(lng, lat);
    this.certify_level = jsonObject.optInt("certify_level");
    this.setFollowed(jsonObject.optBoolean("following"));
    this.setTm(jsonObject.optString("tm"));
    JSONObject JsonStatus = jsonObject.optJSONObject("status");
    if (JsonStatus != null) {
      this.setShow(JsonStatus.optString("show"));
    }
  }
 @Override
 public Trekpoint execute(Context ctx) throws Exception {
   Trekpoint point = new Trekpoint();
   if (NEW_API) {
     UserLoginRequest req =
         new UserLoginRequest(user.getId(), user.getUsername(), user.getPassword());
     req.invalidateCache(ctx);
     User user = req.execute(ctx);
     point.credit = user.getCredit();
   } else {
     String response = executeFetchRequest(getURL(), ctx);
     JSONObject json = new JSONArray(response).getJSONObject(0);
     point.credit = json.optLong("CREDIT");
     point.lifeTimeCredit = json.optLong("LIFETIMECREDIT");
   }
   return point;
 }
Пример #19
0
 public static ArrayList<Object> getCopies(JSONObject jfeedback) throws JSONException {
   ArrayList<Object> ids = new ArrayList<Object>();
   JSONArray items = jfeedback.optJSONArray("items");
   if (items == null) return ids;
   for (int i = 0; i < items.length(); i++) {
     JSONObject j_id = items.optJSONObject(i);
     if (j_id == null) continue;
     Long id = j_id.optLong("id");
     Long owner_id = j_id.optLong("from_id");
     if (id != null && owner_id != null) {
       IdsPair c = new IdsPair();
       c.id = id;
       c.owner_id = owner_id;
       ids.add(c);
     }
   }
   return ids;
 }
 public long getItemId(int position) {
   if (idField != null) {
     JSONObject o = data.optJSONObject(position);
     if (o != null) {
       return o.optLong(idField, 0);
     }
   }
   return internalAdapter.getItemId(position);
 }
 private static boolean verifyNonce(JSONObject data) {
   long nonce = data.optLong(JSON_NONCE);
   if (Security.isNonceKnown(nonce)) {
     Security.removeNonce(nonce);
     return true;
   } else {
     return false;
   }
 }
Пример #22
0
  /**
   * Gets the latest comments with the specified fetch size.
   *
   * <p>The returned comments content is plain text.
   *
   * @param fetchSize the specified fetch size
   * @return the latest comments, returns an empty list if not found
   * @throws ServiceException service exception
   */
  public List<JSONObject> getLatestComments(final int fetchSize) throws ServiceException {
    final Query query =
        new Query()
            .addSort(Comment.COMMENT_CREATE_TIME, SortDirection.DESCENDING)
            .setCurrentPageNum(1)
            .setPageSize(fetchSize)
            .setPageCount(1);
    try {
      final JSONObject result = commentRepository.get(query);
      final List<JSONObject> ret =
          CollectionUtils.<JSONObject>jsonArrayToList(result.optJSONArray(Keys.RESULTS));

      for (final JSONObject comment : ret) {
        comment.put(Comment.COMMENT_CREATE_TIME, comment.optLong(Comment.COMMENT_CREATE_TIME));
        final String articleId = comment.optString(Comment.COMMENT_ON_ARTICLE_ID);
        final JSONObject article = articleRepository.get(articleId);
        comment.put(
            Comment.COMMENT_T_ARTICLE_TITLE,
            Emotions.clear(article.optString(Article.ARTICLE_TITLE)));
        comment.put(
            Comment.COMMENT_T_ARTICLE_PERMALINK, article.optString(Article.ARTICLE_PERMALINK));

        final String commenterId = comment.optString(Comment.COMMENT_AUTHOR_ID);
        final JSONObject commenter = userRepository.get(commenterId);

        if (UserExt.USER_STATUS_C_INVALID == commenter.optInt(UserExt.USER_STATUS)
            || Comment.COMMENT_STATUS_C_INVALID == comment.optInt(Comment.COMMENT_STATUS)) {
          comment.put(Comment.COMMENT_CONTENT, langPropsService.get("commentContentBlockLabel"));
        }

        if (Article.ARTICLE_TYPE_C_DISCUSSION == article.optInt(Article.ARTICLE_TYPE)) {
          comment.put(Comment.COMMENT_CONTENT, "....");
        }

        String content = comment.optString(Comment.COMMENT_CONTENT);
        content = Emotions.clear(content);
        content = Jsoup.clean(content, Whitelist.none());
        if (StringUtils.isBlank(content)) {
          comment.put(Comment.COMMENT_CONTENT, "....");
        } else {
          comment.put(Comment.COMMENT_CONTENT, content);
        }

        final String commenterEmail = comment.optString(Comment.COMMENT_AUTHOR_EMAIL);
        final String avatarURL = avatarQueryService.getAvatarURL(commenterEmail);
        commenter.put(UserExt.USER_AVATAR_URL, avatarURL);

        comment.put(Comment.COMMENT_T_COMMENTER, commenter);
      }

      return ret;
    } catch (final RepositoryException e) {
      LOGGER.log(Level.ERROR, "Gets user comments failed", e);
      throw new ServiceException(e);
    }
  }
Пример #23
0
  /**
   * @param content
   * @return 评论
   */
  public static List<VideoBean> parse_pinlun(String content) {

    List<VideoBean> dates = new ArrayList<VideoBean>();
    try {
      JSONObject jsonobject = new JSONObject(content);
      JSONArray ja = new JSONArray(jsonobject.getString("data"));

      for (int i = 0; i < ja.length(); i++) {
        VideoBean vipRoomBean = new VideoBean();

        JSONObject jsonobject2 = ja.getJSONObject(i).getJSONObject("identityBase");
        vipRoomBean.identityTitle = jsonobject2.getString("identityTitle");
        vipRoomBean.myLogo = jsonobject2.optString("myLogo");
        vipRoomBean.aboutMe = jsonobject2.optString("aboutMe");
        vipRoomBean.verified = jsonobject2.optInt("verified");
        vipRoomBean.isDefault = jsonobject2.optBoolean("isDefault");
        vipRoomBean.userId = jsonobject2.optInt("userId");

        vipRoomBean.identityId = jsonobject2.optLong("identityId");
        vipRoomBean.followingNum = jsonobject2.optInt("followingNum");
        vipRoomBean.followedNum = jsonobject2.optInt("followedNum");
        vipRoomBean.speakCount = jsonobject2.optInt("speakCount");
        vipRoomBean.autoFollowing = jsonobject2.optInt("autoFollowing");
        vipRoomBean.autoFollowed = jsonobject2.optInt("autoFollowed");
        vipRoomBean.displayName = jsonobject2.optString("displayName");
        vipRoomBean.viewCount = jsonobject2.optInt("viewCount");

        JSONObject jsonobject3 = ja.getJSONObject(i).getJSONObject("onlineTeachComment");
        vipRoomBean.speakId = jsonobject3.optInt("speakId");
        vipRoomBean.commentId = jsonobject3.optInt("commentId");
        vipRoomBean.createTime = jsonobject3.optLong("createTime");
        vipRoomBean.content = jsonobject3.optString("content");
        vipRoomBean.annotations = jsonobject3.optString("annotations");
        vipRoomBean.audioId = jsonobject3.optString("audioUrl");

        dates.add(vipRoomBean);
      }
      return dates;
    } catch (JSONException e) {
      e.printStackTrace();
    }
    return dates;
  }
Пример #24
0
    public static HSInfo parse(JSONObject object) {

      if (object == null) {
        return null;
      }
      HSInfo hsInfo = new HSInfo();
      hsInfo.name = object.optString(KEY_NAME);
      hsInfo.gradYear = object.optLong(KEY_GRAD_YEAR);
      return hsInfo;
    }
Пример #25
0
 @Override
 public void parseData(JSONObject data) throws JSONException {
   this.country_id = data.optInt("country_id");
   this.iso_country_code = data.optString("iso_country_code");
   this.world_bank_country_code = data.optString("world_bank_country_code");
   this.name = data.optString("name");
   this.slug = data.optString("slug");
   this.lat = data.optLong("lat");
   this.lon = data.optLong("lon");
 }
Пример #26
0
 public void parseJson(JSONObject jsonObject) throws JSONException {
   if (jsonObject != null) {
     super.parseJson(jsonObject);
     playsCounts = jsonObject.optLong("playsCounts", 0);
     isFinished = jsonObject.optInt("isFinished", 0);
     serialState = jsonObject.optInt("serialState", 0);
     trackId = jsonObject.getLong("trackId");
     trackTitle = jsonObject.getString("trackTitle");
   }
 }
Пример #27
0
 public static ArrayList<Object> getProfiles(JSONObject jfeedback) throws JSONException {
   ArrayList<Object> ids = new ArrayList<Object>();
   JSONArray items = jfeedback.optJSONArray("items");
   if (items == null) return ids;
   for (int i = 0; i < items.length(); i++) {
     JSONObject j_id = items.optJSONObject(i);
     if (j_id != null) ids.add(j_id.optLong("from_id"));
   }
   return ids;
 }
Пример #28
0
  public static Note parse(JSONObject o) throws NumberFormatException, JSONException {
    Note note = new Note();
    note.nid = o.optLong("id");

    // в новости "добавил заметку" заметка приходит по-старому - баг в API
    if (!o.has("id") && o.has("nid")) note.nid = o.optLong("nid");

    note.owner_id = o.getLong("owner_id");
    note.title = Api.unescape(o.getString("title"));
    note.ncom = o.optLong("comments");

    // в новости "добавил заметку" заметка приходит по-старому - баг в API
    if (!o.has("comments") && o.has("ncom")) note.ncom = o.optLong("ncom");

    // note.read_ncom = o.optLong("read_comments");
    note.text = o.optString("text");
    note.date = o.optLong("date");
    return note;
  }
Пример #29
0
    public static UniversityInfo parse(JSONObject object) {
      if (object == null) {
        return null;
      }

      UniversityInfo universityInfo = new UniversityInfo();
      universityInfo.name = object.optString(KEY_NAME);
      universityInfo.year = object.optLong(KEY_YEAR);
      universityInfo.department = object.optString(KEY_DEPARTMENT);
      return universityInfo;
    }
Пример #30
0
  protected static long getLong(final JSONObject jo, final String key, final long d) {
    if (jo == null) {
      return d;
    }

    if (!jo.has(key)) {
      return d;
    }

    return jo.optLong(key);
  }