2015-10-13 01:25:05 +00:00
|
|
|
package org.thoughtcrime.securesms.attachments;
|
|
|
|
|
|
|
|
import android.net.Uri;
|
2016-12-11 21:37:27 +00:00
|
|
|
import android.support.annotation.Nullable;
|
2015-10-13 01:25:05 +00:00
|
|
|
|
|
|
|
import org.thoughtcrime.securesms.mms.PartAuthority;
|
|
|
|
|
|
|
|
public class DatabaseAttachment extends Attachment {
|
|
|
|
|
|
|
|
private final AttachmentId attachmentId;
|
|
|
|
private final long mmsId;
|
|
|
|
private final boolean hasData;
|
2016-12-11 21:37:27 +00:00
|
|
|
private final boolean hasThumbnail;
|
2015-10-13 01:25:05 +00:00
|
|
|
|
2016-12-11 21:37:27 +00:00
|
|
|
public DatabaseAttachment(AttachmentId attachmentId, long mmsId,
|
|
|
|
boolean hasData, boolean hasThumbnail,
|
2015-10-13 01:25:05 +00:00
|
|
|
String contentType, int transferProgress, long size,
|
|
|
|
String location, String key, String relay)
|
|
|
|
{
|
|
|
|
super(contentType, transferProgress, size, location, key, relay);
|
|
|
|
this.attachmentId = attachmentId;
|
|
|
|
this.hasData = hasData;
|
2016-12-11 21:37:27 +00:00
|
|
|
this.hasThumbnail = hasThumbnail;
|
2015-10-13 01:25:05 +00:00
|
|
|
this.mmsId = mmsId;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-12-11 21:37:27 +00:00
|
|
|
@Nullable
|
2015-10-13 01:25:05 +00:00
|
|
|
public Uri getDataUri() {
|
2016-12-11 21:37:27 +00:00
|
|
|
if (hasData) {
|
|
|
|
return PartAuthority.getAttachmentDataUri(attachmentId);
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
2015-10-13 01:25:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-12-11 21:37:27 +00:00
|
|
|
@Nullable
|
2015-10-13 01:25:05 +00:00
|
|
|
public Uri getThumbnailUri() {
|
2016-12-11 21:37:27 +00:00
|
|
|
if (hasThumbnail) {
|
|
|
|
return PartAuthority.getAttachmentThumbnailUri(attachmentId);
|
|
|
|
} else {
|
|
|
|
return null;
|
|
|
|
}
|
2015-10-13 01:25:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public AttachmentId getAttachmentId() {
|
|
|
|
return attachmentId;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean equals(Object other) {
|
|
|
|
return other != null &&
|
|
|
|
other instanceof DatabaseAttachment &&
|
|
|
|
((DatabaseAttachment) other).attachmentId.equals(this.attachmentId);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int hashCode() {
|
|
|
|
return attachmentId.hashCode();
|
|
|
|
}
|
|
|
|
|
|
|
|
public long getMmsId() {
|
|
|
|
return mmsId;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasData() {
|
|
|
|
return hasData;
|
|
|
|
}
|
2016-12-11 21:37:27 +00:00
|
|
|
|
|
|
|
public boolean hasThumbnail() {
|
|
|
|
return hasThumbnail;
|
|
|
|
}
|
2015-10-13 01:25:05 +00:00
|
|
|
}
|