package epson.print.imgsel;

import java.util.ArrayList;
import java.util.Comparator;

class ImageFolderInfo {
    public static final int IMAGE_ID_MAX = 4;
    public String mCanonicalName;
    private int mImageCount;
    private ArrayList<Long> mImageIdList = new ArrayList<>();
    private ArrayList<String> mImageNameList = new ArrayList<>();
    private int mMiniDatabaseOrder;

    public ImageFolderInfo(String str) {
        mCanonicalName = str;
        mMiniDatabaseOrder = -1;
    }

    public boolean addImageLastIfPossible(long j, String str, int i) {
        if (this.mMiniDatabaseOrder < 0) {
            mMiniDatabaseOrder = i;
        }
        mImageCount++;
        if (this.mImageIdList.size() >= 4) {
            return false;
        }
        mImageIdList.add(Long.valueOf(j));
        mImageNameList.add(str);
        return true;
    }

    public long getId(int i) {
        if (i >= mImageIdList.size() || i < 0) {
            return -1;
        }
        return mImageIdList.get(i).longValue();
    }

    public String getFileName(int i) {
        if (i >= mImageNameList.size() || i < 0) {
            return null;
        }
        return mImageNameList.get(i);
    }

    public int getFileIdCount() {
        return mImageIdList.size();
    }

    public int getImageCount() {
        return mImageCount;
    }

    public int getMiniDatabaseOrder() {
        return mMiniDatabaseOrder;
    }

    static class DatabaseOrderComparator implements Comparator<ImageFolderInfo> {
        DatabaseOrderComparator() {
        }

        public int compare(ImageFolderInfo imageFolderInfo, ImageFolderInfo imageFolderInfo2) {
            int miniDatabaseOrder = imageFolderInfo.getMiniDatabaseOrder();
            int miniDatabaseOrder2 = imageFolderInfo2.getMiniDatabaseOrder();
            if (miniDatabaseOrder > miniDatabaseOrder2) {
                return 1;
            }
            return miniDatabaseOrder == miniDatabaseOrder2 ? 0 : -1;
        }
    }
}
