@Override
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext)
      throws JSONException {
    try {
      if (ACTION_ADD_CALENDAR_ENTRY.equals(action)) {
        JSONObject arg_object = args.getJSONObject(0);
        Intent calIntent =
            new Intent(Intent.ACTION_EDIT)
                .setType("vnd.android.cursor.item/event")
                .putExtra("beginTime", arg_object.getLong("startTimeMillis"))
                .putExtra("endTime", arg_object.getLong("endTimeMillis"))
                .putExtra("title", arg_object.getString("title"))
                .putExtra("description", arg_object.getString("description"))
                .putExtra("eventLocation", arg_object.getString("eventLocation"));

        this.cordova.getActivity().startActivity(calIntent);
        callbackContext.success();
        return true;
      }
      callbackContext.error("Invalid action");
      return false;
    } catch (Exception e) {
      System.err.println("Exception: " + e.getMessage());
      callbackContext.error(e.getMessage());
      return false;
    }
  }
  @Override
  protected void initializeContent(final JSONObject json) throws JSONException {
    super.initializeContent(json);

    if (json.has(JSON_TEXT) && !json.isNull(JSON_TEXT)) {
      selectedEntityValue = json.getString(JSON_TEXT);
    }
    if (json.has(JSON_CODE) && !json.isNull(JSON_CODE)) {
      selectedEntityCode = json.getString(JSON_CODE);
    }
    if (json.has(JSON_BELONGS_TO_ENTITY_ID) && !json.isNull(JSON_BELONGS_TO_ENTITY_ID)) {
      belongsToEntityId = json.getLong(JSON_BELONGS_TO_ENTITY_ID);
    }
    if (json.has(JSON_OLD_SELECTED_ENTITY_ID) && !json.isNull(JSON_OLD_SELECTED_ENTITY_ID)) {
      oldSelectedEntityId = json.getLong(JSON_OLD_SELECTED_ENTITY_ID);
    }

    if (json.has(JSON_CURRENT_CODE) && !json.isNull(JSON_CURRENT_CODE)) {
      currentCode = json.getString(JSON_CURRENT_CODE);
    }

    if (json.has(JSON_AUTOCOMPLETE_CODE) && !json.isNull(JSON_AUTOCOMPLETE_CODE)) {
      autocompleteCode = json.getString(JSON_AUTOCOMPLETE_CODE);
    }

    if (json.has(JSON_CRITERIA_MODIFIER_PARAMETER)
        && !json.isNull(JSON_CRITERIA_MODIFIER_PARAMETER)) {
      criteriaModifierParameter.initialize(json.getJSONObject(JSON_CRITERIA_MODIFIER_PARAMETER));
    }

    if (belongsToFieldDefinition != null && belongsToEntityId == null) {
      setEnabled(false);
    }
  }
Example #3
0
  private void parseJSONArray(JSONArray checkIns) {

    if (checkIns == null) return;

    try {
      for (int i = 0; i < checkIns.length(); i++) {
        JSONObject checkIn = checkIns.getJSONObject(i);

        NotUsedCheckInPostItem postItem = new NotUsedCheckInPostItem();

        postItem.setCheckInId(checkIn.getLong(TAG_CHECKIN));
        Log.d(LOGTAG, "TEST ::: checkin post item id : " + checkIn.getLong(TAG_CHECKIN));
        postItem.setAuthorId(checkIn.getInt(TAG_AUTHOR));
        postItem.setPageId(checkIn.getInt(TAG_PAGE));
        postItem.setAppId(checkIn.getInt(TAG_APP));
        postItem.setPostId(checkIn.getString(TAG_POST));
        postItem.setTaggedIds(checkIn.getJSONArray(TAG_TAGGED_IDS));

        JSONObject coordObject = checkIn.getJSONObject(TAG_COORDS);
        postItem.setCoords(
            coordObject.getDouble(TAG_COORDS_LONG), coordObject.getDouble(TAG_COORDS_LAT));

        postItem.setTimeStamp(checkIn.getInt(TAG_TIMESTAMP));
        postItem.setMessage(checkIn.getString(TAG_MESSAGE));
      }
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
  @Override
  public NetResult onResponseSuccess(JSONObject jsonObject) {
    try {
      if (jsonObject != null
          && jsonObject.getInt("ajax_optinfo") == NET_RETURN_SUCCESS
          && jsonObject.getInt("hasdata") == HAS_DATA) {
        Batch btch = new Batch();
        btch.setBatch_id(jsonObject.getLong("id"));
        btch.setCode(jsonObject.getString("batch_code"));
        btch.setProducecount(jsonObject.getInt("producecount"));
        btch.setVariety(jsonObject.getString("variety_name"));
        btch.setVariety_id(jsonObject.getLong("variety_id"));
        btch.setVilleage_id(jsonObject.getInt("farm_id"));
        btch.setStatus(jsonObject.getInt("status"));
        btch.setStage(jsonObject.getInt("stage"));
        btch.setBuylink(jsonObject.getString("buy_link"));
        btch.setConsumercount(jsonObject.getInt("consumercount"));
        btch.setCreate_time(jsonObject.getString("create_time"));
        btch.setVilleage_name(jsonObject.getString("farm_name"));
        btch.setIsdel(jsonObject.getInt("isdel"));
        btch.setLastoptime(jsonObject.getString("lastoptime"));
        btch.setCategoryid(jsonObject.getInt("categoryid"));
        btch.setUserid(jsonObject.getInt("user_id"));
        btch.setOrder_index(0);
        btch.setOrder_date(btch.getBatch_id());
        return new NetResult(NetResult.RESULT_OF_SUCCESS, "获取数据成功!", btch);

      } else {
        return new NetResult(NetResult.RESULT_OF_ERROR, "获取数据失败!");
      }
    } catch (JSONException e) {
      e.printStackTrace();
      return new NetResult(NetResult.RESULT_OF_ERROR, "操作失败!");
    }
  }
  private void insertActivityEntryTableRows(JSONArray jArray) {
    for (int i = 0; i < jArray.length(); i++) {
      try {
        JSONObject row = jArray.optJSONObject(i);
        ActivityEntry activityEntry = new ActivityEntry();
        activityEntry.setActivity_entry_id(row.getLong(ActivityEntry.column_activityEntryID));
        activityEntry.setActivity_id(row.getLong(ActivityEntry.column_activityID));
        activityEntry.setImage(row.getString(ActivityEntry.column_image));
        activityEntry.setTimestamp(row.getString(ActivityEntry.column_timestamp));
        activityEntry.setDate(row.getString(ActivityEntry.column_date));
        activityEntry.setNotes(row.getString(ActivityEntry.column_notes));
        activityEntry.setActivity_length(row.getString(ActivityEntry.column_activitylength));
        activityEntry.setCount_towards_goal(row.getInt(ActivityEntry.column_counttowardsgoal));
        activityEntry.setGoal_id(row.getLong(ActivityEntry.column_goalID));
        activityEntry.setRpe(row.getInt(ActivityEntry.column_rpe));
        activityEntry.setIs_sync(1);
        long id = dbOperations.insertRow(activityEntry);

        Log.i(
            "ActivityEntryTableRows",
            "A row with an ID "
                + String.valueOf(id)
                + " has been inserted into activity_entry table");

      } catch (JSONException e) {
        e.printStackTrace();
      }
    }
  }
Example #6
0
  public void Update(JSONObject jsonObject) {
    try {
      name = jsonObject.getString("username");
      cooldown = jsonObject.getLong("cooldown");

      if (!local) {
        JSONObject location = jsonObject.getJSONObject("location");
        latitude = Double.parseDouble(location.getString("y"));
        longitude = Double.parseDouble(location.getString("x"));
        accuracy = Double.parseDouble(location.getString("Acc"));
      } else if (prevCooldown != cooldown && prevCooldown != -1) {

        EventBus.NOTIFICATION_EVENTBUS.broadcast(
            new NotificationEvent.NotificationInfo(type, "You've been eaten!"));
      }

      score = jsonObject.getInt("points");
      invulnerable = jsonObject.getLong("invulnerable");

      type = Integer.parseInt(jsonObject.getString("type"));

      if (marker != null && accuracyCircle != null) {
        UpdateMarker();
      }

      prevType = type;
      prevCooldown = cooldown;
    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
  public sp_GetUnnotifieds_Result(JSONObject obj) {
    try {

      if (!obj.isNull("message")) message = obj.getString("message");

      if (!obj.isNull("device_id")) device_id = obj.getString("device_id");

      if (!obj.isNull("device_type")) device_type = obj.getInt("device_type");

      if (!obj.isNull("id")) id = obj.getString("id");

      if (!obj.isNull("user_id")) user_id = obj.getLong("user_id");

      if (!obj.isNull("is_sent")) is_sent = obj.getBoolean("is_sent");

      if (!obj.isNull("sent_time")) sent_time = obj.getString("sent_time");

      if (!obj.isNull("priority")) priority = obj.getInt("priority");

      if (!obj.isNull("type")) type = obj.getInt("type");

      if (!obj.isNull("bidding_id")) bidding_id = obj.getLong("bidding_id");

      if (!obj.isNull("provide_id")) provide_id = obj.getLong("provide_id");

      if (!obj.isNull("request_id")) request_id = obj.getLong("request_id");

    } catch (JSONException e) {
      e.printStackTrace();
    }
  }
 public static List<ChatMsg> parseChatList(JSONArray jsonArr) {
   List<ChatMsg> chats = null;
   if (jsonArr == null || jsonArr.length() == 0) return chats;
   int length = jsonArr.length();
   chats = new ArrayList<ChatMsg>();
   for (int i = 0; i < length; i++) {
     JSONObject json;
     try {
       json = (JSONObject) jsonArr.get(i);
       ChatMsg chat = new ChatMsg();
       chat.setAvatar(json.getString("avatar"));
       chat.setNickName(json.getString("nickName"));
       chat.setDstUserId(json.getLong("dstUserId"));
       chat.setSrcUserId(json.getLong("srcUserId"));
       chat.setChatId(json.getLong("chatId"));
       chat.setChatSrcType(json.getString("chatSrcType"));
       chat.setChatType(json.getString("chatType"));
       chat.setChatImage(json.getString("chatImage"));
       chat.setChatContent(json.getString("chatContent"));
       chat.setChatTips(json.getString("chatTips"));
       chat.setChatCreateTime(json.getString("chatCreateTime"));
       chats.add(chat);
     } catch (JSONException e) {
       e.printStackTrace();
     }
   }
   return chats;
 }
Example #9
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;
 }
Example #10
0
    /**
     * Read task from json
     *
     * @param json
     * @param model
     * @param metadata
     * @throws JSONException
     */
    public static void taskFromJson(JSONObject json, Task model, ArrayList<Metadata> metadata)
        throws JSONException {
      metadata.clear();
      model.clearValue(Task.REMOTE_ID);
      model.setValue(Task.REMOTE_ID, json.getLong("id"));
      model.setValue(Task.FLAGS, 0);
      readUser(json.getJSONObject("user"), model, Task.USER_ID, Task.USER);
      readUser(json.getJSONObject("creator"), model, Task.CREATOR_ID, null);
      model.setValue(Task.COMMENT_COUNT, json.getInt("comment_count"));
      model.setValue(Task.TITLE, json.getString("title"));
      model.setValue(Task.IMPORTANCE, json.getInt("importance"));
      model.setValue(
          Task.DUE_DATE, model.createDueDate(Task.URGENCY_SPECIFIC_DAY, readDate(json, "due")));
      model.setValue(Task.COMPLETION_DATE, readDate(json, "completed_at"));
      model.setValue(Task.CREATION_DATE, readDate(json, "created_at"));
      model.setValue(Task.DELETION_DATE, readDate(json, "deleted_at"));
      model.setValue(Task.RECURRENCE, json.optString("repeat", ""));
      model.setValue(Task.NOTES, json.optString("notes", ""));
      model.setValue(Task.DETAILS_DATE, 0L);

      JSONArray tags = json.getJSONArray("tags");
      for (int i = 0; i < tags.length(); i++) {
        JSONObject tag = tags.getJSONObject(i);
        String name = tag.getString("name");
        Metadata tagMetadata = new Metadata();
        tagMetadata.setValue(Metadata.KEY, TagService.KEY);
        tagMetadata.setValue(TagService.TAG, name);
        tagMetadata.setValue(TagService.REMOTE_ID, tag.getLong("id"));
        metadata.add(tagMetadata);
      }
    }
Example #11
0
 public static Reply parse(JSONObject o) throws JSONException {
   Reply r = new Reply();
   r.id = o.getLong("id");
   r.date = o.getLong("date");
   r.text = o.getString("text");
   return r;
 }
Example #12
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;
 }
Example #13
0
  private ArrayList<TorrentFile> parseJsonShowFilesTorrent(JSONArray response)
      throws JSONException {
    ArrayList<TorrentFile> files = new ArrayList<TorrentFile>();

    if (response != null) {
      for (int i = 0; i < response.length(); i++) {
        JSONObject finfo = response.getJSONObject(i);

        long done_bytes = finfo.getLong("done") * finfo.getLong("chunksize");
        long file_size = finfo.getLong("size");

        if (done_bytes > file_size) {
          /* Shared chunk */
          done_bytes = file_size;
        }

        // @formatter:off
        files.add(
            new TorrentFile(
                "" + i,
                finfo.getString("name"),
                finfo.getString("path"),
                null, // hmm.. can we have something without file:// ?!
                file_size,
                done_bytes,
                Priority.Normal));
        // @formatter:on
      }
    }

    return files;
  }
Example #14
0
  /**
   * { "type": 5, "display_time": 1411878658, "online_time": 1411878658, "ad": {
   * "display_image_height": 400, "ad_id": 3561092485, "display_image_width": 600, "source": "",
   * "package": "", "title": "霜霜和阿伟都爱玩的游戏,还有iphone6等你拿哦!", "open_url": "", "download_url":
   * "http://yihua.b0.upaiyun.com/neihan.apk", "is_ad": 1, "display_info":
   * "霜霜和阿伟都爱玩的游戏,还有iphone6等你拿哦!", "web_url": "http://yihua.b0.upaiyun.com/neihan.apk",
   * "display_type": 3, "button_text": "立即下载", "appleid": "", "track_url": "", "label": "推广",
   * "type": "app", "id": 3561092485, "ipa_url": "", "display_image":
   * "http://p2.pstatp.com/large/1362/1075506622" } },
   */
  public void parseJson(JSONObject jsonObject) throws JSONException {
    if (jsonObject != null) {
      type = jsonObject.getInt("type");
      displayTime = jsonObject.getLong("display_time");
      onlineTime = jsonObject.getLong("online_time");

      JSONObject ad = jsonObject.getJSONObject("ad");
      displayImageHeight = ad.getInt("display_image_height");
      displayImageWidth = ad.getInt("display_image_width");
      adId = ad.getLong("ad_id");
      source = ad.getString("source");
      mPackage = ad.getString("package");
      title = ad.getString("title");
      openUrl = ad.getString("open_url");
      downloadUrl = ad.getString("download_url");
      isAd = ad.getInt("is_ad");
      displayInfo = ad.getString("display_info");
      webUrl = ad.getString("web_url");
      displayType = ad.getInt("display_type");
      buttonText = ad.getString("button_text");
      appleid = ad.getString("appleid");
      trackUrl = ad.getString("track_url");
      label = ad.getString("label");
      typeId = ad.getString("type");
      id = ad.getLong("id");
      ipaUrl = ad.getString("ipa_url");
      displayImage = ad.getString("display_image");
    }
  }
Example #15
0
  /**
   * @param content
   * @return 赞
   */
  public static List<VideoBean> parse_zan(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++) {
        JSONObject jsonobject2 = ja.getJSONObject(i).getJSONObject("identityBase");
        VideoBean vipRoomBean = new VideoBean();
        vipRoomBean.identityTitle = jsonobject2.getString("identityTitle");
        vipRoomBean.myLogo = jsonobject2.getString("myLogo");
        vipRoomBean.aboutMe = jsonobject2.getString("aboutMe");
        vipRoomBean.verified = jsonobject2.getInt("verified");
        vipRoomBean.isDefault = jsonobject2.getBoolean("isDefault");
        vipRoomBean.userId = jsonobject2.getInt("userId");

        vipRoomBean.identityId = jsonobject2.getLong("identityId");
        vipRoomBean.followingNum = jsonobject2.getInt("followingNum");
        vipRoomBean.followedNum = jsonobject2.getInt("followedNum");
        vipRoomBean.speakCount = jsonobject2.getInt("speakCount");
        vipRoomBean.autoFollowing = jsonobject2.getInt("autoFollowing");
        vipRoomBean.autoFollowed = jsonobject2.getInt("autoFollowed");
        vipRoomBean.displayName = jsonobject2.getString("displayName");
        vipRoomBean.viewCount = jsonobject2.getInt("viewCount");

        JSONObject jsonobject3 = ja.getJSONObject(i).getJSONObject("onlineTeachLiked");
        vipRoomBean.createTime = jsonobject3.getLong("createTime");
        dates.add(vipRoomBean);
      }
      return dates;
    } catch (JSONException e) {
      e.printStackTrace();
    }
    return dates;
  }
  void remove_single_item(Long itemid) {
    String Query = "SELECT type,data FROM playlist WHERE playorder=" + itemid;
    JSONArray jArray = activity.ld.runQuery("lyricDb", Query);
    if (jArray == null) {
      return;
    }
    try {
      JSONObject results = jArray.getJSONObject(0);
      if ((results.getString("type").equals("play")) || (results.getString("type").equals("sub"))) {
        Query = "SELECT playorder FROM playlist WHERE playlist=" + results.getLong("data");
        JSONArray pArray = activity.ld.runQuery("lyricDb", Query);
        if (pArray != null) {
          for (int i = 0; i < pArray.length(); i++) {
            JSONObject item = pArray.getJSONObject(i);
            remove_single_item(item.getLong("playorder"));
          }
        }
        Query = "DELETE FROM playlist WHERE playlist=" + results.getLong("data");
        activity.ld.runQuery("lyricDb", Query);
        Query = "DELETE FROM playlists WHERE id=" + results.getLong("data");
        activity.ld.runQuery("lyricDb", Query);
      }
      Query = "DELETE FROM playlist WHERE playorder=" + itemid;
      activity.ld.runQuery("lyricDb", Query);
      Query = "DELETE FROM associations WHERE playlist=" + itemid;
      activity.ld.runQuery("lyricDb", Query);

    } catch (JSONException e) {
      activity.logError("Error parsing data " + e.toString());
    }
  }
  /**
   * Creates a new instance of a GameItem with the given data
   *
   * @param inventory The inventory this item is contained in
   * @param itemData The data specifying this item
   * @throws WebApiException on Web API errors
   */
  public GameItem(GameInventory inventory, JSONObject itemData) throws SteamCondenserException {
    this.inventory = inventory;

    try {
      this.defindex = itemData.getInt("defindex");
      this.backpackPosition = (int) itemData.getLong("inventory") & 0xffff;
      this.count = itemData.getInt("quantity");
      this.craftable = !itemData.optBoolean("flag_cannot_craft");
      this.id = itemData.getInt("id");
      this.itemClass = this.getSchemaData().getString("item_class");
      this.itemSet =
          this.inventory
              .getItemSchema()
              .getItemSets()
              .get(this.getSchemaData().optString("item_set"));
      this.level = itemData.getInt("level");
      this.name = this.getSchemaData().getString("item_name");
      this.preliminary = (itemData.getLong("inventory") & 0x40000000) != 0;
      this.originalId = itemData.getInt("original_id");
      this.quality = this.inventory.getItemSchema().getQualities().get(itemData.getInt("quality"));
      this.tradeable = !itemData.optBoolean("flag_cannot_trade");
      this.type = this.getSchemaData().getString("item_type_name");

      if (itemData.has("origin")) {
        this.origin = this.inventory.getItemSchema().getOrigins().get(itemData.getInt("origin"));
      }

      JSONArray attributesData = this.getSchemaData().optJSONArray("attributes");
      if (attributesData == null) {
        attributesData = new JSONArray();
      }
      if (itemData.has("attributes")) {
        JSONArray itemAttributes = itemData.getJSONArray("attributes");
        for (int i = 0; i < itemAttributes.length(); i++) {
          attributesData.put(itemAttributes.get(i));
        }
      }

      this.attributes = new ArrayList<JSONObject>();
      for (int i = 0; i < attributesData.length(); i++) {
        JSONObject attributeData = attributesData.getJSONObject(i);
        Object attributeKey = attributeData.opt("defindex");
        if (attributeKey == null) {
          attributeKey = attributeData.opt("name");
        }

        if (attributeKey != null) {
          JSONObject schemaAttributeData =
              inventory.getItemSchema().getAttributes().get(attributeKey);
          for (String key : JSONObject.getNames(schemaAttributeData)) {
            attributeData.put(key, schemaAttributeData.get(key));
          }
          this.attributes.add(attributeData);
        }
      }
    } catch (JSONException e) {
      throw new WebApiException("Could not parse JSON data.", e);
    }
  }
 public PartieData(JSONObject partie) throws Exception {
   this(
       partie.getLong("idPartie"),
       partie.getString("nomPartie"),
       partie.getLong("idCreateur"),
       partie.getInt("nbJoueursMax"),
       getJoueursFromJSON(partie.getJSONArray("joueurs")));
 }
Example #19
0
  private TorrentStatus convertBitfluStatus(JSONObject obj) throws JSONException {

    if (obj.getInt("paused") != 0) {
      return TorrentStatus.Paused;
    } else if (obj.getLong("done_bytes") == obj.getLong("total_bytes")) {
      return TorrentStatus.Seeding;
    }
    return TorrentStatus.Downloading;
  }
Example #20
0
 public Note(JSONObject json) throws JSONException {
   mId = UUID.fromString(json.getString(JSON_ID));
   mTitle = json.getString(JSON_TITLE);
   mDate = new Date(json.getLong(JSON_DATE));
   mTime = new Date(json.getLong(JSON_TIME));
   mDone = json.getBoolean(JSON_DONE);
   mLastChangeDate = new Date(json.getLong(JSON_LASTCHANGE));
   if (json.has(JSON_PHOTO)) mPhoto = new Photo(json.getJSONObject(JSON_PHOTO));
 }
Example #21
0
 public Track(JSONObject json) throws JSONException {
   mId = UUID.fromString(json.getString(JSON_ID));
   mStartTime = new Date(json.getLong(JSON_START_TIME));
   mStopTime = new Date(json.getLong(JSON_STOP_TIME));
   mElapsedTime = json.getDouble(JSON_ELAPSED_TIME);
   mDistanceTravelled = json.getDouble(JSON_DIST);
   mModeOfTransport = json.getInt(JSON_MODE);
   mInsult = json.getString(JSON_INSULT);
   mCarbonFootprint = json.getDouble(JSON_CARBON_FOOTPRINT);
 }
Example #22
0
  /**
   * Create next round object from part of json object response to placing a bet or initiating a
   * game round
   *
   * @see <a href="https://www.satoshidice.com/api/#place-bet">satoshidice.com/api/#place-bet</a>
   * @param nextRound Json object containing all Round data
   * @throws JSONException On parse error
   */
  public Round(JSONObject nextRound) throws JSONException {

    id = nextRound.getLong("id");
    hash = nextRound.getString("hash");
    welcomeMessage = nextRound.getString("welcomeMessage");

    if (nextRound.has("maxProfitInSatoshis")) {
      maxProfitInSatoshis = nextRound.getLong("maxProfitInSatoshis");
    }
  }
Example #23
0
 public static Movie fromJson(JSONObject jsonObject) throws JSONException {
   return new Movie(
       jsonObject.getLong(KEY_ID),
       jsonObject.getString(KEY_TITLE),
       jsonObject.getString(KEY_OVERVIEW),
       jsonObject.getString(KEY_POSTER_PATH),
       jsonObject.getDouble(KEY_VOTE_AVERAGE),
       jsonObject.getLong(KEY_VOTE_COUNT),
       jsonObject.getString(KEY_RELEASE_DATE));
 }
 public WorkTime(JSONObject json) throws JSONException {
   id = json.getLong(JSON_ID);
   clockInTime = new Date(json.getLong(JSON_CLOCK_IN));
   clockOutTime = new Date(json.getLong(JSON_CLOCK_OUT));
   active = json.getBoolean(JSON_ACTIVE);
   working = json.getBoolean(JSON_WORKING);
   breakTime = json.getLong(JSON_BREAK_TIME);
   breakTimeStart = json.getLong(JSON_LAST_SAVED_BREAK_TIME);
   initOtherVars();
 }
Example #25
0
 public Notification(final JSONObject json) throws JSONException {
   if (json.has(Columns.TIME)) time = json.getLong(Columns.TIME);
   if (json.has(Columns.PERMANENT)) permanent = 1 == json.getLong(Columns.PERMANENT);
   if (json.has(Columns.TASKID)) taskID = json.getLong(Columns.TASKID);
   if (json.has(Columns.REPEATS)) repeats = json.getLong(Columns.REPEATS);
   if (json.has(Columns.LOCATIONNAME)) locationName = json.getString(Columns.LOCATIONNAME);
   if (json.has(Columns.LATITUDE)) latitude = json.getDouble(Columns.LATITUDE);
   if (json.has(Columns.LONGITUDE)) longitude = json.getDouble(Columns.LONGITUDE);
   if (json.has(Columns.RADIUS)) radius = json.getDouble(Columns.RADIUS);
 }
    @Override
    protected Boolean doInBackground(String... params) {
      OAuth OAuth = new OAuth(context);
      Utils Utils = new Utils();

      Map<String, String> postParams = new HashMap<String, String>(1);
      postParams.put("client_id", Config.OAUTHCLIENTID);
      postParams.put("client_secret", Config.OAUTHCLIENTSECRET);
      JSONObject result = OAuth.call("StaticData", "", postParams);

      if (Config.DEBUG) Log.d("SyncStaticData", result.toString());

      try {
        // Save sync data
        JSONObject data = result.getJSONObject("data");

        JSONObject currentData;
        ActiveAndroid.beginTransaction();
        try {
          // Save countries
          new Delete().from(Country.class).execute();
          JSONArray countries = data.getJSONObject("country").getJSONArray("data");

          for (int i = 0; i < countries.length(); i++) {
            currentData = countries.getJSONObject(i);
            Country country = new Country();
            country.name = currentData.getString("name");
            country.countryId = currentData.getLong("id");
            country.save();
          }

          // Save cities
          new Delete().from(City.class).execute();
          JSONArray cities = data.getJSONObject("city").getJSONArray("data");

          for (int i = 0; i < cities.length(); i++) {
            currentData = cities.getJSONObject(i);
            City city = new City();
            city.name = currentData.getString("name");
            city.cityId = currentData.getLong("id");
            city.country_id = currentData.getLong("country_id");
            city.save();
          }

          ActiveAndroid.setTransactionSuccessful();
        } finally {
          ActiveAndroid.endTransaction();
        }
        return true;
      } catch (Exception e) {
        if (Config.DEBUG) Log.d("Sync", "Sync failed. Cause: " + e.toString());
        e.printStackTrace();
        return false;
      }
    }
 public static ApplicationInfo parse(JSONObject json) throws JSONException {
   ApplicationInfo app = new ApplicationInfo();
   app.setId(json.getString("_id"));
   app.setName(json.getString("name"));
   app.setSubdomain(json.getString("subdomain"));
   app.setState(json.getString("state"));
   app.setActiveSnapshot(SnapshotInfo.parse(json.getJSONObject("active")));
   app.setCreationDate(new Date(json.getLong("ctime")));
   app.setChangedDate(new Date(json.getLong("mtime")));
   return app;
 }
Example #28
0
 public void fromJson(JSONObject json) {
   try {
     if (json.has("uuid")) this.uuid = json.getString("uuid");
     if (json.has("localUpdated")) this.localUpdated = json.getLong("localUpdated");
     if (json.has("globalUpdated")) this.globalUpdated = json.getLong("globalUpdated");
     if (json.has("title")) this.title = json.getString("title");
   } catch (JSONException e) {
     Log.e(TAG, "Bad JSON object " + e.toString() + " - '" + json.toString() + "'");
     e.printStackTrace();
   }
 }
Example #29
0
 public AbstractFenceRecord(JSONObject j) throws JSONException {
   mID = j.getLong("id");
   mInstallationID = j.getLong("InstallationID");
   mGuid = j.getString("Guid");
   mDisplayName = j.getString("DisplayName");
   mLatitude = j.getDouble("Latitude");
   mLongitude = j.getDouble("Longitude");
   mRadius = j.getDouble("Radius");
   mEvents = j.getInt("Events");
   mURI = j.getString("URI");
 }
 public static Comment getFromJson(JSONObject commentJson) throws JSONException {
   Comment comment = new Comment();
   comment.setId(commentJson.getLong(ID));
   comment.setSpotId(commentJson.getLong(SPOT_ID));
   comment.setUserId(commentJson.getLong(USER_ID));
   comment.setComment(commentJson.getString(COMMENT));
   comment.setCreatedAt(commentJson.getLong(CREATED_AT));
   comment.setUserName(commentJson.getString(USER_NAME));
   comment.setUserDp(commentJson.getString(USER_DP));
   return comment;
 }