package fishrungames.bashgid;

import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

public class MainFragment extends Fragment {

	ListView left_drawer;
	
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		View rootView = inflater.inflate(R.layout.fragment_main, container, false);

		left_drawer = (ListView) rootView.findViewById(R.id.left_drawer);
		
		left_drawer.setAdapter(new DrawerAdapter(getActivity()));
		
		return rootView;
	}
	
	
	public class DrawerAdapter extends BaseAdapter {
	    private Context mContext;

	    public DrawerAdapter(Context c) {
	        mContext = c;
	    }

	    public int getCount() {
	        return 3;
	    }

	    public Object getItem(int position) {
	        return null;
	    }

	    public long getItemId(int position) {
	        return 0;
	    }

	    // create a new ImageView for each item referenced by the Adapter
	    public View getView(int position, View convertView, ViewGroup parent) {
	        
	    	
	    	View view;
	        if (convertView == null) {  // if it's not recycled, initialize some attributes
	        	LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	        	view = inflater.inflate(R.layout.drawer_list_element, null);
	        	
	   
	        } else {
	        	view = convertView;
	        }
	        
	        TextView textView = (TextView) view.findViewById(R.id.textView);
	        
	        if (position == 0)
	        {
	        	textView.setText("Справочник");
	        }
	        else if (position == 1)
	        {
	        	textView.setText("Новости");
	        }
	        else
	        {
	        	textView.setText("Карта");
	        }
	        
	        
	        return view;
	    }
	}
}
