package epson.print.imgsel;

import java.util.ArrayList;

public class ImageSelector {
    public static final int MAX_SELECT_NUMBER = 30;
    private ArrayList<String> mImageFilenameList;

    public ImageSelector() {
        this.mImageFilenameList = new ArrayList<>();
    }

    public ImageSelector(ArrayList<String> arrayList) {
        this.mImageFilenameList = arrayList;
        if (this.mImageFilenameList == null) {
            this.mImageFilenameList = new ArrayList<>();
        }
    }

    public void replaceFiles(ArrayList<String> arrayList) {
        this.mImageFilenameList = arrayList;
    }

    public boolean toggleSelect(String str) {
        if (this.mImageFilenameList.contains(str)) {
            this.mImageFilenameList.remove(str);
            return false;
        } else if (selectedNumber() >= 30) {
            return false;
        } else {
            this.mImageFilenameList.add(str);
            return true;
        }
    }

    public boolean add(String str) {
        if (selectedNumber() >= 30 || this.mImageFilenameList.contains(str)) {
            return false;
        }
        this.mImageFilenameList.add(str);
        return true;
    }

    public boolean remove(String str) {
        this.mImageFilenameList.remove(str);
        return true;
    }

    public void clear() {
        this.mImageFilenameList.clear();
    }

    public boolean isSelected(String str) {
        return this.mImageFilenameList.contains(str);
    }

    public ArrayList<String> getFileArrayList() {
        return this.mImageFilenameList;
    }

    public int selectedNumber() {
        return this.mImageFilenameList.size();
    }

    public boolean canAdd() {
        return this.mImageFilenameList.size() < 30;
    }
}
