/* package */ JSONObject encode() throws JSONException { JSONObject json = new JSONObject(); json.put("__type", "File"); json.put("name", getName()); String url = getUrl(); if (url == null) { throw new IllegalStateException("Unable to encode an unsaved ParseFile."); } json.put("url", getUrl()); return json; }
void writeToParcel(Parcel dest, ParseParcelEncoder encoder) { if (isDirty()) { throw new RuntimeException("Unable to parcel an unsaved ParseFile."); } dest.writeString(getUrl()); // Not null dest.writeString(getName()); // Not null String type = state.mimeType(); // Nullable dest.writeByte(type != null ? (byte) 1 : 0); if (type != null) { dest.writeString(type); } }
if (file.getUrl() == null) { dirtyFiles.add(file);
assertArrayEquals(data, dataCaptor.getValue()); assertEquals(url, parseFile.getUrl());
assertEquals(file, fileCaptor.getValue()); assertEquals(url, parseFile.getUrl());
@Test public void testGetParseFileKeyExist() { final ParseFile file = new ParseFile( new ParseFile.State.Builder().name("image.png").url("http://yarr.com/image.png").build()); ParseFile fileAgain = new ParseFile( new ParseFile.State.Builder().name("file.txt").url("http://yarr.com/file.txt").build()); final Map<String, Object> params = new HashMap<>(); params.put("key", file); ParseConfig config = new ParseConfig(params); ParseFile fileConfig = config.getParseFile("key"); assertEquals(file.getName(), fileConfig.getName()); assertEquals(file.getUrl(), fileConfig.getUrl()); assertSame(fileConfig, config.getParseFile("key", fileAgain)); }
@Test public void testGetters() { ParseFile file = new ParseFile(new ParseFile.State.Builder().url("http://example.com").build()); assertEquals("http://example.com", file.getUrl()); assertFalse(file.isDirty()); // Note: rest of the getters are tested in `testConstructor` }
assertEquals(date, decodedDiskConfigParameters.get("date")); ParseFile fileAgain = (ParseFile) decodedDiskConfigParameters.get("file"); assertEquals(file.getUrl(), fileAgain.getUrl()); assertEquals(file.getName(), fileAgain.getName()); ParseGeoPoint geoPointAgain = (ParseGeoPoint) decodedDiskConfigParameters.get("geoPoint");
private void configureViewHolderNotification(ViewHolderNotification holder, int position) { UserNotification un = (UserNotification) items.get(position); ImageView ivNotificationImage = holder.ivNotificationImage; TextView tvNotificationMessage = holder.tvNotificationMessage; Context context = ivNotificationImage.getContext(); Glide.with(context) .load(un.getNotification().getPhotoFile().getUrl()) .asGif() .into(ivNotificationImage); tvNotificationMessage.setText(un.getNotification().getMessage()); }
private void setFeatureData() { String title = feature.getTitle(); String description = feature.getDescription(); int color = Color.parseColor(String.valueOf(feature.getHexColor())); rlFeatures.setBackgroundColor(color); String imageUrl = feature.getImageUrl(); if (feature.getPhotoFile() != null) { imageUrl = feature.getPhotoFile().getUrl(); } Picasso.with(this) .load(imageUrl) .resize(40, 40) .centerCrop() .placeholder(R.mipmap.ic_launcher) .into(ivFeatureImage); tvFeatureTitle.setText(title); tvToolbarTitle.setText(title); tvFeatureDescription.setText(description); }
@Test public void testParcelable() { String mime = "mime"; String name = "name"; String url = "url"; ParseFile file = new ParseFile(new ParseFile.State.Builder() .name(name) .mimeType(mime) .url(url) .build()); Parcel parcel = Parcel.obtain(); file.writeToParcel(parcel, 0); parcel.setDataPosition(0); file = ParseFile.CREATOR.createFromParcel(parcel); assertEquals(file.getName(), name); assertEquals(file.getUrl(), url); assertEquals(file.getState().mimeType(), mime); assertFalse(file.isDirty()); }
@Override public void done(Profile p, ParseException e) { if (e == null) { if (p != null) { profile = p; if (p.getPhotoFile() != null) { Picasso.with(getApplicationContext()) .load(p.getPhotoFile().getUrl()) .resize(48, 48) .centerCrop() .placeholder(R.mipmap.ic_launcher) .into(ivHeaderPhoto); } tvFullName.setText(p.getFullName()); tvJobTitle.setText(p.getJobTitle()); } } } });
assertEquals(newRel.getKnownObjects().size(), rel.getKnownObjects().size()); newRel.hasKnownObject(related); assertEquals(newObject.getParseFile("file").getUrl(), object.getParseFile("file").getUrl()); assertEquals(newObject.getParseGeoPoint("point").getLatitude(), object.getParseGeoPoint("point").getLatitude(), 0);
private void configureViewHolderTopic(ViewHolderTopic viewHolderTopic, int position) { Feature feature = (Feature) items.get(position); TextView tvFeatureTitle = viewHolderTopic.tvEventTopicTitle; RoundedImageView ivFeatureImage = viewHolderTopic.ivEventTopicPhoto; CardView cvFeature = viewHolderTopic.cvFeature; // Insert the model data into each of the view items String title = feature.getTitle(); String imageUrl = feature.getImageUrl(); // set color! int color = Color.parseColor(String.valueOf(feature.getHexColor())); cvFeature.setCardBackgroundColor(color); // set title tvFeatureTitle.setText(title); // set image Context context = ivFeatureImage.getContext(); ivFeatureImage.setImageDrawable(null); // clear image, to avoid memory leak if (title.contains("Recommend")) { // this may not be accurate - only for the recommended piece ivFeatureImage.setImageResource(R.drawable.ic_add_post); } else { if (feature.getPhotoFile() != null) { imageUrl = feature.getPhotoFile().getUrl(); } Picasso.with(context) .load(imageUrl) .resize(48, 48) .centerCrop() .placeholder(R.mipmap.ic_launcher) .into(ivFeatureImage); } }
holder.tvCreatedAt.setText(date); if (profile != null) { if (profile.getPhotoFile() != null && !TextUtils.isEmpty(profile.getPhotoFile().getUrl())) { Picasso.with(getContext()) .load(profile.getPhotoFile().getUrl()) .transform(new CircleTransform()) .resize(40, 40) holder.tvOtherCreatedAt.setText(date); if (profile != null) { if (profile.getPhotoFile() != null && !TextUtils.isEmpty(profile.getPhotoFile().getUrl())) { Picasso.with(getContext()) .load(profile.getPhotoFile().getUrl()) .transform(new CircleTransform()) .resize(40, 40)