package cz.vutbr.fit.iha.household;

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

import android.content.Context;
import cz.vutbr.fit.iha.Constants;
import cz.vutbr.fit.iha.adapter.Adapter;
import cz.vutbr.fit.iha.adapter.location.Location;
import cz.vutbr.fit.iha.adapter.parser.XmlParsers;
import cz.vutbr.fit.iha.household.User.Gender;

/**
 * Represents demo household with adapters and devices loaded from local assets files.
 * 
 * @author Robyer
 */
public final class DemoHousehold extends Household {
	
	private final Context mContext;
	
	public DemoHousehold(Context context) {
		mContext = context;

		prepareUser();
		prepareAdapters();
	}
	
	/**
	 * Prepare logged in user.
	 */
	private void prepareUser() {
		user.setName("John Doe");
		user.setEmail("john@doe.com");
		user.setGender(Gender.Male);
	}
	
	/**
	 * Prepare demo adapters.
	 */
	private void prepareAdapters() {
		this.adapters = new ArrayList<Adapter>();
		
		try {
			Adapter adapter = XmlParsers.getDemoAdapterFromAsset(mContext, Constants.ASSET_ADAPTERS_FILENAME);
			List<Location> locations = XmlParsers.getDemoLocationsFromAsset(mContext, Constants.ASSET_LOCATIONS_FILENAME);
			adapter.setLocations(locations);
			
			this.adapters.add(adapter);
		}
		catch(Exception e){
			e.printStackTrace();
		}	
	}
	
}

@@ -1054,32 +1054,121 @@
 %0A%09%09%09
-List%3CLocation%3E l
+adapter.setId(%2201233145645792%22); // original from xml%0A%09%09%09adapter.setName(%22Home adapter%22);%0A%09%09%09adapter.setL
 ocations
  = X
@@ -1163,19 +1163,17 @@
 ocations
- = 
+(
 XmlParse
@@ -1250,49 +1250,336 @@
 AME)
-;%0A%09%09%09adapter.setLocations(locations);%0A%09%09%09
+);%0A%09%09%09this.adapters.add(adapter);%0A%0A%09%09%09adapter = XmlParsers.getDemoAdapterFromAsset(mContext, Constants.ASSET_ADAPTERS_FILENAME);%0A%09%09%09adapter.setId(%2216457841561538%22); // random one%0A%09%09%09adapter.setName(%22Testing duplicate%22);%0A%09%09%09adapter.setLocations(XmlParsers.getDemoLocationsFromAsset(mContext, Constants.ASSET_LOCATIONS_FILENAME));
 %0A%09%09%09

Add more adapters for Demo Mode