Search in sources :

Example 6 with MediaRecord

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;
}
Also used : AudioSlide(org.thoughtcrime.securesms.mms.AudioSlide) Slide(org.thoughtcrime.securesms.mms.Slide) MediaRecord(org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord) MediaDatabase(org.thoughtcrime.securesms.database.MediaDatabase)

Example 7 with MediaRecord

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)));
}
Also used : MediaRecord(org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord) Media(org.thoughtcrime.securesms.mediasend.Media) LinkedList(java.util.LinkedList)

Example 8 with MediaRecord

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);
}
Also used : MediaRecord(org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord)

Example 9 with MediaRecord

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;
}
Also used : AudioSlide(org.thoughtcrime.securesms.mms.AudioSlide) Slide(org.thoughtcrime.securesms.mms.Slide) MediaRecord(org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord) MediaDatabase(org.thoughtcrime.securesms.database.MediaDatabase)

Example 10 with MediaRecord

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);
}
Also used : AudioSlide(org.thoughtcrime.securesms.mms.AudioSlide) Slide(org.thoughtcrime.securesms.mms.Slide) MediaRecord(org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord) MediaDatabase(org.thoughtcrime.securesms.database.MediaDatabase)

Aggregations

MediaRecord (org.thoughtcrime.securesms.database.MediaDatabase.MediaRecord)13 MediaDatabase (org.thoughtcrime.securesms.database.MediaDatabase)6 Slide (org.thoughtcrime.securesms.mms.Slide)6 AudioSlide (org.thoughtcrime.securesms.mms.AudioSlide)4 LinkedList (java.util.LinkedList)2 AttachmentId (org.thoughtcrime.securesms.attachments.AttachmentId)2 ThumbnailView (org.thoughtcrime.securesms.components.ThumbnailView)2 Media (org.thoughtcrime.securesms.mediasend.Media)2 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Cursor (android.database.Cursor)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 SaveAttachmentTask (org.thoughtcrime.securesms.util.SaveAttachmentTask)1 ProgressDialogAsyncTask (org.thoughtcrime.securesms.util.task.ProgressDialogAsyncTask)1