package epson.print;

import android.os.Parcel;
import android.os.Parcelable;

import java.util.ArrayList;

public class EPImageList implements Parcelable {
    public static final Creator<EPImageList> CREATOR = new Creator<EPImageList>() {
        public EPImageList createFromParcel(Parcel parcel) {
            return new EPImageList(parcel);
        }

        public EPImageList[] newArray(int i) {
            return new EPImageList[i];
        }
    };
    public int apfModeInPrinting;
    public ArrayList<EPImage> imageList;
    private int mClearlyVivid;
    private boolean mMultiFileMode;
    private int mRenderingMode;
    private int mSharpness;
    private int paperHeight;
    private int paperWidth;

    public int describeContents() {
        return 0;
    }

    public EPImageList() {
        imageList = new ArrayList<>();
        paperWidth = 0;
        paperHeight = 0;
        mMultiFileMode = false;
        mMultiFileMode = false;
        apfModeInPrinting = 0;
        mSharpness = 0;
        mClearlyVivid = 0;
        mRenderingMode = 0;
    }

    public int getSharpness() {
        return mSharpness;
    }

    public void setSharpness(int i) {
        mSharpness = i;
    }

    public int getClearlyVivid() {
        return mClearlyVivid;
    }

    public void setClearlyVivid(int i) {
        mClearlyVivid = i;
    }

    public boolean add(String str) {
        ArrayList<EPImage> arrayList = imageList;
        return arrayList.add(new EPImage(str, arrayList.size()));
    }

    public boolean add(EPImage ePImage) {
        return imageList.add(ePImage);
    }

    public boolean add(int i, EPImage ePImage) {
        if (i >= imageList.size()) {
            return imageList.add(ePImage);
        }
        imageList.add(i, ePImage);
        return true;
    }

    public EPImage set(int i, String str) {
        if (i < 0 || i >= imageList.size()) {
            return null;
        }
        return imageList.set(i, new EPImage(str, i));
    }

    public EPImage set(int i, EPImage ePImage) {
        if (i < 0 || i >= imageList.size()) {
            return null;
        }
        return imageList.set(i, ePImage);
    }

    public EPImage remove(int i) {
        if (i < 0 || i >= imageList.size()) {
            return null;
        }
        return imageList.remove(i);
    }

    public EPImage remove(String str) {
        for (int i = 0; i < imageList.size(); i++) {
            if (this.imageList.get(i).loadImageFileName.equalsIgnoreCase(str)) {
                return imageList.remove(i);
            }
        }
        return null;
    }

    public void clear() {
        imageList.clear();
    }

    public void setFileType(int i) {
        for (int i2 = 0; i2 < imageList.size(); i2++) {
            imageList.get(i2).setType(i);
        }
    }

    public void setMultifileMode(boolean z) {
        mMultiFileMode = z;
    }

    public boolean isMultifileMode() {
        return mMultiFileMode;
    }

    public void clearExceptSrcFileName() {
        ArrayList<EPImage> arrayList = new ArrayList<>();
        for (int i = 0; i < imageList.size(); i++) {
            arrayList.add(new EPImage(this.imageList.get(i).loadImageFileName, arrayList.size()));
        }
        imageList = null;
        System.gc();
        imageList = arrayList;
    }

    public int size() {
        return imageList.size();
    }

    public EPImage get(int i) {
        if (i < 0 || i >= imageList.size()) {
            return null;
        }
        return imageList.get(i);
    }

    public void writeToParcel(Parcel parcel, int i) {
        parcel.writeTypedList(this.imageList);
        parcel.writeInt(getPaperWidth());
        parcel.writeInt(getPaperHeight());
        parcel.writeBooleanArray(new boolean[]{mMultiFileMode});
        parcel.writeInt(this.apfModeInPrinting);
        parcel.writeInt(mSharpness);
        parcel.writeInt(mClearlyVivid);
        parcel.writeInt(mRenderingMode);
    }

    private EPImageList(Parcel parcel) {
        imageList = new ArrayList<>();
        paperWidth = 0;
        paperHeight = 0;
        mMultiFileMode = false;
        imageList = parcel.createTypedArrayList(EPImage.CREATOR);
        setPaperWidth(parcel.readInt());
        setPaperHeight(parcel.readInt());
        boolean[] zArr = new boolean[1];
        parcel.readBooleanArray(zArr);
        mMultiFileMode = zArr[0];
        apfModeInPrinting = parcel.readInt();
        mSharpness = parcel.readInt();
        mClearlyVivid = parcel.readInt();
        mRenderingMode = parcel.readInt();
    }

    public EPImageList(ArrayList<EPImage> arrayList, int i) {
        imageList = new ArrayList<>();
        paperWidth = 0;
        paperHeight = 0;
        mMultiFileMode = false;
        imageList = arrayList;
    }

    public int getPaperWidth() {
        return paperWidth;
    }

    public void setPaperWidth(int i) {
        paperWidth = i;
    }

    public int getPaperHeight() {
        return paperHeight;
    }

    public void setPaperHeight(int i) {
        paperHeight = i;
    }

    public void setRenderingMode(int i) {
        mRenderingMode = i;
    }

    public int getRenderingMode() {
        return mRenderingMode;
    }
}
