package astrology.findyourfate.com;

 
import java.util.ArrayList;

import java.util.HashMap;
import java.util.List;
import android.app.ActionBar;
import android.app.Fragment;
import android.content.Context;
 import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
 

public class homeservice extends Fragment {
	
	public homeservice(){}
	ListView mDrawerList; 
 
	String text = "";
	 Fragment fragment = null;
	@Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
		

        View rootView = inflater.inflate(R.layout.frag_ourservice, container, false);
         
        mDrawerList = (ListView)rootView.findViewById(R.id.services); 
       
          String[] items = getResources().getStringArray(R.array.OurServices2);
          
         final ArrayList<String> list = new ArrayList<String>();
         for (int i = 0; i < items.length; ++i) {
           list.add(items[i]);
         }
            
         
         final StableArrayAdapter adapter = new StableArrayAdapter(getActivity(), android.R.layout.simple_list_item_1, list);
          mDrawerList.setAdapter(adapter); 
         mDrawerList.setOnItemClickListener(new AdapterView.OnItemClickListener() {        	 
           @Override
           public void onItemClick(AdapterView<?> parent,  View view,
               int position, long id) {
              String item = (String) parent.getItemAtPosition(position);
             
               mDrawerList.setVisibility(View.GONE);
              
           // Toast.makeText(getActivity(), "item:"+item+position,Toast.LENGTH_SHORT).show();
             
              if(position==0) 
  			{
            	  	fragment = new askquestion();
               	     android.app.FragmentManager fragmentManager = getFragmentManager();
               	    android.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
               	   fragmentTransaction.replace(R.id.tabcontent, fragment);
               	  fragmentTransaction.commit();
               	 getActivity().getActionBar().setTitle("Ask a Question");
                 getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE);
  			 
  		}
  		else if(position==1) 
  		{
  		  
  		fragment = new matchmaking();
     	     android.app.FragmentManager fragmentManager = getFragmentManager();
     	    android.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
     	   fragmentTransaction.replace(R.id.tabcontent, fragment);
     	  fragmentTransaction.commit();
     	 getActivity().getActionBar().setTitle("Match Making");
         getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE);
		  	}
  		else if(position==2) 
  		{
  			fragment = new namechange();
    	     android.app.FragmentManager fragmentManager = getFragmentManager();
    	    android.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    	   fragmentTransaction.replace(R.id.tabcontent, fragment);
    	  fragmentTransaction.commit();
    		 getActivity().getActionBar().setTitle("Names Correction");
             getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE);
			  	}
  		else if(position==3) 
  		{
  			fragment = new dreamanalysis();
    	     android.app.FragmentManager fragmentManager = getFragmentManager();
    	    android.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
    	   fragmentTransaction.replace(R.id.tabcontent, fragment);
    	  fragmentTransaction.commit();
  			 
    		 getActivity().getActionBar().setTitle("Dream Analysis" );
             getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE);
		  	}
  		
  		else if(position==4) 
  		{
  			fragment = new nadifirstpage();
   	     android.app.FragmentManager fragmentManager = getFragmentManager();
   	    android.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
   	   fragmentTransaction.replace(R.id.tabcontent, fragment);
   	  fragmentTransaction.commit();
 	 getActivity().getActionBar().setTitle("Nadi Reading");
     getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE);
	   	}
  		else if(position==5) 
  		{
  			fragment = new natalchart();
   	     android.app.FragmentManager fragmentManager = getFragmentManager();
   	    android.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
   	   fragmentTransaction.replace(R.id.tabcontent, fragment);
   	  fragmentTransaction.commit();
 	 getActivity().getActionBar().setTitle("Natal Chart");
     getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE);
	 
  	}
  		else if(position==6) 
  		{
  			fragment = new palmreading();
   	     android.app.FragmentManager fragmentManager = getFragmentManager();
   	    android.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
   	   fragmentTransaction.replace(R.id.tabcontent, fragment);
   	  fragmentTransaction.commit();
 	 getActivity().getActionBar().setTitle("Palmistry");
     getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE);
	   	}
  		else if(position==7) 
  		{
  			fragment = new compatreading();
   	     android.app.FragmentManager fragmentManager = getFragmentManager();
   	    android.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
   	   fragmentTransaction.replace(R.id.tabcontent, fragment);
   	  fragmentTransaction.commit();
 	 getActivity().getActionBar().setTitle("Compatibility Reading");
     getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE);
	
  	}
   		else if(position==8) 
  		{
  			fragment = new vastu();
   	     android.app.FragmentManager fragmentManager = getFragmentManager();
   	    android.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
   	   fragmentTransaction.replace(R.id.tabcontent, fragment);
   	  fragmentTransaction.commit();
 	 getActivity().getActionBar().setTitle("Vastu");
     getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_SHOW_TITLE);
		
  	}    }
           
         });
      
         return rootView;  
           }  
 	 
 	private class StableArrayAdapter extends ArrayAdapter<String> {

 	    HashMap<String, Integer> mIdMap = new HashMap<String, Integer>();

 	    public StableArrayAdapter(Context context, int textViewResourceId,
 	        List<String> objects) {
 	      super(context, textViewResourceId, objects);
 	      for (int i = 0; i < objects.size(); ++i) {
 	        mIdMap.put(objects.get(i), i);
 	      }
 	    }

 	    @Override
 	    public long getItemId(int position) {
 	      String item = getItem(position);
 	      
 	      return mIdMap.get(item);
 	    }

 	    @Override
 	    public boolean hasStableIds() {
 	      return true;
 	    }

 	  }
 	
 	 
 	} 

