/** Fills an user object from server response. */ public VKApiUser parse(JSONObject from) { super.parse(from); first_name = from.optString("first_name", first_name); last_name = from.optString("last_name", last_name); online = ParseUtils.parseBoolean(from, FIELD_ONLINE); online_mobile = ParseUtils.parseBoolean(from, FIELD_ONLINE_MOBILE); photo_50 = addSquarePhoto(from.optString(FIELD_PHOTO_50, photo_50), 50); photo_100 = addSquarePhoto(from.optString(FIELD_PHOTO_100, photo_100), 100); photo_200 = addSquarePhoto(from.optString(FIELD_PHOTO_200, photo_200), 200); photo_400_orig = from.optString(FIELD_PHOTO_400_ORIGIN, photo_400_orig); photo_max = from.optString(FIELD_PHOTO_MAX, photo_max); photo_max_orig = from.optString(FIELD_PHOTO_MAX_ORIGIN, photo_max_orig); photo_big = from.optString(FIELD_PHOTO_BIG, photo_big); photo.sort(); return this; }
protected String addSquarePhoto(String photoUrl, int size) { if (!TextUtils.isEmpty(photoUrl)) { photo.add(VKApiPhotoSize.create(photoUrl, size)); } return photoUrl; }