package com.lemenzo.gallery.model;

import android.net.Uri;

public final class MediaItem {
    public final long id; public final Uri uri; public final String displayName; public final String mimeType;
    public final long dateTaken; public final long dateAdded; public final int width; public final int height;
    public final long size; public final long bucketId; public final String bucketName; public final long duration;
    public final boolean favorite; public final boolean trashed; public final MediaType type; public final long inferredDate;

    public MediaItem(long id, Uri uri, String displayName, String mimeType, long dateTaken, long dateAdded,
            int width, int height, long size, long bucketId, String bucketName, long duration,
            boolean favorite, boolean trashed, MediaType type) {
        this(id, uri, displayName, mimeType, dateTaken, dateAdded, width, height, size, bucketId, bucketName,
                duration, favorite, trashed, type, dateTaken > 0 ? dateTaken : dateAdded * 1000L);
    }

    public MediaItem(long id, Uri uri, String displayName, String mimeType, long dateTaken, long dateAdded,
            int width, int height, long size, long bucketId, String bucketName, long duration,
            boolean favorite, boolean trashed, MediaType type, long inferredDate) {
        this.id=id; this.uri=uri; this.displayName=displayName; this.mimeType=mimeType; this.dateTaken=dateTaken;
        this.dateAdded=dateAdded; this.width=width; this.height=height; this.size=size; this.bucketId=bucketId;
        this.bucketName=bucketName; this.duration=duration; this.favorite=favorite; this.trashed=trashed; this.type=type;
        this.inferredDate=inferredDate > 0 ? inferredDate : (dateTaken > 0 ? dateTaken : dateAdded * 1000L);
    }

    public long sortDate() { return inferredDate; }
}
