use of org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord in project Signal-Android by signalapp.
the class MediaGalleryAllAdapter method getSectionItemViewType.
@Override
public int getSectionItemViewType(int section, int offset) {
MediaDatabase.MediaRecord mediaRecord = media.get(section, offset);
Slide slide = MediaUtil.getSlideForAttachment(context, mediaRecord.getAttachment());
if (slide.hasAudio())
return AUDIO_DETAIL;
if (slide.hasImage() || slide.hasVideo())
return detailView ? GALLERY_DETAIL : GALLERY;
if (slide.hasDocument())
return DOCUMENT_DETAIL;
return 0;
}
use of org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord in project Signal-Android by signalapp.
the class MediaPreviewViewModel method setActiveAlbumRailItem.
public void setActiveAlbumRailItem(@NonNull Context context, int activePosition) {
if (cursor == null) {
previewData.postValue(new PreviewData(Collections.emptyList(), null, 0));
return;
}
activePosition = getCursorPosition(activePosition);
cursor.moveToPosition(activePosition);
MediaRecord activeRecord = MediaRecord.from(context, cursor);
LinkedList<Media> rail = new LinkedList<>();
Media activeMedia = toMedia(activeRecord);
if (activeMedia != null)
rail.add(activeMedia);
while (cursor.moveToPrevious()) {
MediaRecord record = MediaRecord.from(context, cursor);
if (record.getAttachment().getMmsId() == activeRecord.getAttachment().getMmsId()) {
Media media = toMedia(record);
if (media != null)
rail.addFirst(media);
} else {
break;
}
}
cursor.moveToPosition(activePosition);
while (cursor.moveToNext()) {
MediaRecord record = MediaRecord.from(context, cursor);
if (record.getAttachment().getMmsId() == activeRecord.getAttachment().getMmsId()) {
Media media = toMedia(record);
if (media != null)
rail.addLast(media);
} else {
break;
}
}
if (!leftIsRecent) {
Collections.reverse(rail);
}
previewData.postValue(new PreviewData(rail.size() > 1 ? rail : Collections.emptyList(), activeRecord.getAttachment().getCaption(), rail.indexOf(activeMedia)));
}
use of org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord in project Signal-Android by WhisperSystems.
the class MediaGalleryAllAdapter method selectAllMedia.
void selectAllMedia() {
int sectionCount = media.getSectionCount();
for (int section = 0; section < sectionCount; section++) {
int sectionItemCount = media.getSectionItemCount(section);
for (int item = 0; item < sectionItemCount; item++) {
MediaRecord mediaRecord = media.get(section, item);
selected.put(mediaRecord.getAttachment().getAttachmentId(), mediaRecord);
}
}
this.notifyItemRangeChanged(0, getItemCount(), PAYLOAD_SELECTED);
}
use of org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord in project Signal-Android by WhisperSystems.
the class MediaGalleryAllAdapter method getSectionItemViewType.
@Override
public int getSectionItemViewType(int section, int offset) {
MediaDatabase.MediaRecord mediaRecord = media.get(section, offset);
Slide slide = MediaUtil.getSlideForAttachment(context, mediaRecord.getAttachment());
if (slide.hasAudio())
return AUDIO_DETAIL;
if (slide.hasImage() || slide.hasVideo())
return detailView ? GALLERY_DETAIL : GALLERY;
if (slide.hasDocument())
return DOCUMENT_DETAIL;
return 0;
}
use of org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord in project Signal-Android by WhisperSystems.
the class MediaGalleryAllAdapter method onBindItemViewHolder.
@Override
public void onBindItemViewHolder(ItemViewHolder viewHolder, int section, int offset) {
MediaDatabase.MediaRecord mediaRecord = media.get(section, offset);
Slide slide = MediaUtil.getSlideForAttachment(context, mediaRecord.getAttachment());
((SelectableViewHolder) viewHolder).bind(context, mediaRecord, slide);
}
Aggregations