package fsir.tqqe;

import java.util.ArrayList;
import java.util.List;

public class Gtor {
    private static Gtor sInstance;
    private List<Rdrk> mPhotoList;

    private Gtor() {
        mPhotoList = new ArrayList<>();
    }

    public static synchronized Gtor getInstance() {
        if (sInstance == null) {
            sInstance = new Gtor();
        }
        return sInstance;
    }

    public void addPhoto(Rdrk photo) {
        if (!mPhotoList.contains(photo)) {
            boolean mBoolean = mPhotoList.add(photo);
        }
    }

    public void removePhoto(Rdrk photo) {
        if (mPhotoList.contains(photo)) {
            boolean mBoolean = mPhotoList.remove(photo);
        }
    }

    public void clearCache() {
        if(!mPhotoList.isEmpty()){
            mPhotoList.clear();
        }

    }

    public List<Rdrk> getPhotoList() {
        return mPhotoList;
    }

    public Rdrk getPositionData(int position) {
        if (position >= 0 && position < mPhotoList.size()) {
            return mPhotoList.get(position);
        } else {
            return null;
        }
    }

    public int getCount() {

        return mPhotoList.size();
    }
}
