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() {
        mImageFilenameList = new ArrayList<>();
    }

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

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

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

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

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

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

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

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

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

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