package fishrungames.bashgid.core;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.Locale;

import fishrungames.bashgid.core.AlbumManager.AlbumFullData;
import fishrungames.bashgid.core.ChannelManager.ChannelFullData;

public class ArticleManager
{
	
	public static final SimpleDateFormat iso8601Format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.US);
	
	public static final int ARTICLE_TYPE_NORMAL = 0;
	public static final int ARTICLE_TYPE_NEWS = 1;
	
	public static class ArticleRecordData
	{
		
		public String name;
		public int type;
		public String title;
		public String content;
		public double geoLat;
		public double geoLon;
		public String address;
		public String phone;
		public String externalLink;
		public String externalLinkText;
		public Date dateTime;
		public int hidden;
		
		public ArticleRecordData(String name, int type, String title, String content, double geoLat, double geoLon, String address, String phone, String externalLink, String externalLinkText, Date dateTime, int hidden)
		{
			this.name = name;
			this.type = type;
			this.title = title;
			this.content = content;
			this.geoLat = geoLat;
			this.geoLon = geoLon;
			this.address = address;
			this.phone = phone;
			this.externalLink = externalLink;
			this.externalLinkText = externalLinkText;
			this.dateTime = dateTime;
			this.hidden = hidden;
		}
		
		public ArticleRecordData(ArticleRecordData copyFrom)
		{
			this.name = copyFrom.name;
			this.type = copyFrom.type;
			this.title = copyFrom.title;
			this.content = copyFrom.content;
			this.geoLat = copyFrom.geoLat;
			this.geoLon = copyFrom.geoLon;
			this.address = copyFrom.address;
			this.phone = copyFrom.phone;
			this.externalLink = copyFrom.externalLink;
			this.externalLinkText = copyFrom.externalLinkText;
			this.dateTime = copyFrom.dateTime;
			this.hidden = copyFrom.hidden;
		}
	}
	
	
	public static class ArticleFullData extends ArticleRecordData
	{
		public ArrayList<AlbumFullData> albumArr;
		public ArrayList<ChannelFullData> channelArr;
		
		public ArticleFullData(ArticleRecordData recordData)
		{
			super(recordData);
			albumArr = new ArrayList<AlbumFullData>();
			channelArr = new ArrayList<ChannelFullData>();
		}
	}
	
	public static class ArticleShortData extends ArticleRecordData
	{
		public String previewImageUrl;
		
		public ArticleShortData(ArticleRecordData recordData)
		{
			super(recordData);
			previewImageUrl = "";
		}
	}
	
	public static class ArticleShortDataSortComparator implements Comparator<ArticleShortData> {
	    public int compare(ArticleShortData record1, ArticleShortData record2) {
	        return record2.name.compareTo(record1.name);
	    }
	}
	
	public static class ArticleShortDataTimeSortComparator implements Comparator<ArticleShortData> {
	    public int compare(ArticleShortData record1, ArticleShortData record2) {
	        return record2.dateTime.compareTo(record1.dateTime);
	    }
	}
}
