package fishrungames.bashgid.core;

import java.util.ArrayList;

public class AlbumManager
{
	public static class AlbumStruct
	{
		public String name;
		public ArrayList<String> imageIds = new ArrayList<String>();
		
		public AlbumStruct(String name)
		{
			this.name = name;
		}
	}
	
	private ArrayList<AlbumStruct> AlbumArr = new ArrayList<AlbumStruct>();
	
	public static AlbumManager instance = null;
	
	public static AlbumManager getInstance()
	{
		if (instance == null)
		{
			instance = new AlbumManager();
		}
		
		return instance;
	}
	
	public void AddPhotoToAlbum(String albumName, String imageId)
	{
		
		synchronized (AlbumArr)
		{
			boolean albumExists = false;
			
			for (AlbumStruct albumStruct : AlbumArr)
			{
				if (albumStruct.name.equals(albumName))
				{
					albumStruct.imageIds.add(imageId);
					albumExists = true;
				}
			}
			
			if (!albumExists)
			{
				AlbumStruct albumStruct = new AlbumStruct(albumName);
				
				albumStruct.imageIds.add(imageId);
				
				AlbumArr.add(albumStruct);
			}
			
		}
	}
	
	public ArrayList<AlbumStruct> getAlbums()
	{
		ArrayList<AlbumStruct> albums = new ArrayList<AlbumStruct>();
		
		synchronized(AlbumArr)
		{
			albums.addAll(AlbumArr);
		}
				
		return albums;
	}
	
	
	
	
}
