package org.keyscience.models;

import android.content.Context;

import org.keyscience.R;

import java.util.ArrayList;

public class OurPartnersModel {

    private int imageID;
    private String link;


    public static ArrayList<OurPartnersModel> getData(Context context) {
        ArrayList<OurPartnersModel> dataList = new ArrayList<>();
        int[] images = getImages();
        String[] links = getLinks(context);
        for (int i = 0; i < images.length; i++) {
            OurPartnersModel ourPartnersModel = new OurPartnersModel();
            ourPartnersModel.setImageID(images[i]);
            ourPartnersModel.setLink(links[i]);
            dataList.add(ourPartnersModel);
        }
        return dataList;
    }


    public static ArrayList<OurPartnersModel> getDataOnlyFour(Context context) {
        ArrayList<OurPartnersModel> dataList = new ArrayList<>();
        int[] images = getImages();
        String[] links = getLinks(context);
        // retrieve only the first four items
        for (int i = 0; i < 4; i++) {
            OurPartnersModel ourPartnersModel = new OurPartnersModel();
            ourPartnersModel.setImageID(images[i]);
            ourPartnersModel.setLink(links[i]);
            dataList.add(ourPartnersModel);
        }
        return dataList;
    }

    public static ArrayList<OurPartnersModel> getDataLastItems(Context context) {
        ArrayList<OurPartnersModel> dataList = new ArrayList<>();
        int[] images = getImages();
        String[] links = getLinks(context);
        // ignore first four since we already have them
        for (int i = 4; i < images.length; i++) {
            OurPartnersModel ourPartnersModel = new OurPartnersModel();
            ourPartnersModel.setImageID(images[i]);
            ourPartnersModel.setLink(links[i]);
            dataList.add(ourPartnersModel);
        }
        return dataList;
    }

    // order in which items are stored in this array must match the subTitles adn titles array order as well.
    private static int[] getImages() {
        int[] images = {
                R.drawable.kbcf_logo_square_thegem_person_thegem_person, R.drawable.village_logo_square_thegem_person_thegem_person, R.drawable.um_rsmas_logo_thegem_person_thegem_person,
                R.drawable.knight_foundation_logo_thegem_person_thegem_person, R.drawable.kbcf_logo_square_thegem_person_thegem_person, R.drawable.fairchild_challenge_logo_thegem_person_thegem_person,
                R.drawable.florida_park_service_thegem_person, R.drawable.the_islander_news_thegem_person, R.drawable.keybis_thegem_person,
                R.drawable.keybiscayne_k_8_center_thegem_person, R.drawable.keybiscayne_magazine_thegem_person, R.drawable.kb_chamber_of_commerce_thegem_person,
                R.drawable.kb_community_church_thegem_person, R.drawable.kb_presbyterian_school_thegem_person, R.drawable.biscayne_nature_center_thegem_person,
                R.drawable.mast_academy_thegem_person, R.drawable.principals_coalition_thegem_person, R.drawable.st_agnes_academy_thegem_person,
                R.drawable.st_christophers_by_the_sea_thegem_person
        };
        return images;
    }

    private static String[] getLinks(Context context) {
        String[] titles = {
                context.getString(R.string.KBCF), context.getString(R.string.VILLAGE), context.getString(R.string.UM),
                context.getString(R.string.KNIGHT), context.getString(R.string.Biscayne_Bay_Waterkeepers), context.getString(R.string.Fairchild),
                context.getString(R.string.FSP), context.getString(R.string.ISLANDER), context.getString(R.string.KB_PORTAL),
                context.getString(R.string.KB_SCHOOL), context.getString(R.string.KB_MAG), context.getString(R.string.KB_CHAMBER),
                context.getString(R.string.KBCC), context.getString(R.string.KBPresbyterian), context.getString(R.string.KB_NATURE),
                context.getString(R.string.MAST), context.getString(R.string.PRINCIPALS_COALITION), context.getString(R.string.St_AGNES),
                context.getString(R.string.St_Christophers)};
        return titles;
    }

    public int getImageID() {
        return imageID;
    }

    public void setImageID(int imageID) {
        this.imageID = imageID;
    }

    public String getLink() {
        return link;
    }

    public void setLink(String link) {
        this.link = link;
    }
}
