package epson.print.phlayout;




import epson.print.EPImage;
import java.util.ArrayList;
import java.util.Iterator;

public class PhotoPreviewImageList {
    private ArrayList<EpImageWrapper> mEpImageWrapperList = new ArrayList<>();
    /* access modifiers changed from: private */
    public ArrayList<LayoutInfo> mLayoutInfoList = new ArrayList<>();

    public void clearExceptSrcFileName() {
    }

    public int size() {
        return this.mEpImageWrapperList.size();
    }

    public void add(@NonNull String str, int i) {
        add(new EpImageWrapper(str, (String) null, i));
    }

    public void add(@NonNull EpImageWrapper epImageWrapper) {
        this.mEpImageWrapperList.add(epImageWrapper);
        this.mLayoutInfoList.add(new LayoutInfo());
    }

    public void addOrgNameEpOrgName(@NonNull EpImageWrapper epImageWrapper) {
        this.mEpImageWrapperList.add(new EpImageWrapper(epImageWrapper.epImage.getOriginalFileName(), epImageWrapper.orgFilename, epImageWrapper.epImage.index));
        this.mLayoutInfoList.add(new LayoutInfo());
    }

    public void setList(@Nullable ArrayList<EpImageWrapper> arrayList) {
        clear();
        if (arrayList != null) {
            Iterator<EpImageWrapper> it = arrayList.iterator();
            while (it.hasNext()) {
                addOrgNameEpOrgName(it.next());
            }
        }
    }

    @NonNull
    public ArrayList<String> getGalleryFileList() {
        ArrayList<String> arrayList = new ArrayList<>();
        for (int i = 0; i < size(); i++) {
            EPImage ePImage = this.mEpImageWrapperList.get(i).epImage;
            if (ePImage == null) {
                arrayList.add((Object) null);
            } else {
                arrayList.add(ePImage.getOriginalFileName());
            }
        }
        return arrayList;
    }

    @Nullable
    public EPImage get(int i) {
        return this.mEpImageWrapperList.get(i).epImage;
    }

    public ArrayList<String> getArgumentFileList() {
        ArrayList<String> arrayList = new ArrayList<>();
        Iterator<EpImageWrapper> it = this.mEpImageWrapperList.iterator();
        while (it.hasNext()) {
            arrayList.add(it.next().getArgumentFilename());
        }
        return arrayList;
    }

    public void set(int i, @NonNull EPImage ePImage) {
        this.mEpImageWrapperList.get(i).epImage = ePImage;
    }

    public void clear() {
        this.mEpImageWrapperList.clear();
        this.mLayoutInfoList.clear();
    }

    public void remove(int i) {
        this.mEpImageWrapperList.remove(i);
        this.mLayoutInfoList.remove(i);
    }

    @NonNull
    public Element getElement(int i) {
        if (i >= 0 && i <= this.mEpImageWrapperList.size()) {
            return new Element(i);
        }
        throw new IndexOutOfBoundsException();
    }

    private static class LayoutInfo {
        int fitMode = 0;

        LayoutInfo() {
        }
    }

    public class Element {
        private int mIndex;

        @VisibleForTesting
        Element(int i) {
            this.mIndex = i;
        }

        public EPImage getEPImage() {
            return PhotoPreviewImageList.this.get(this.mIndex);
        }

        public void setFitMode(int i) {
            ((LayoutInfo) PhotoPreviewImageList.this.mLayoutInfoList.get(this.mIndex)).fitMode = i;
        }

        public int getFitMode() {
            return ((LayoutInfo) PhotoPreviewImageList.this.mLayoutInfoList.get(this.mIndex)).fitMode;
        }
    }

    public static class EpImageWrapper {
        public EPImage epImage;
        public String orgFilename;

        public EpImageWrapper(@NonNull String str, @Nullable String str2, int i) {
            this.epImage = new EPImage(str, i);
            this.orgFilename = str2;
        }

        public String getArgumentFilename() {
            String str = this.orgFilename;
            if (str != null) {
                return str;
            }
            return this.epImage.getOriginalFileName();
        }
    }
}
