package com.pennapps.labs.pennmobile;

import android.content.Intent;
import android.support.v4.app.FragmentManager;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.widget.DrawerLayout;
import android.view.Menu;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;

public class MainActivity extends FragmentActivity {

    private DrawerLayout mDrawerLayout;
    private ListView mDrawerList;
    private String[] mFeatureTitles;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        mFeatureTitles = new String[] {"Registrar", "Directory", "Transit", "Dining"};

        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerList = (ListView) findViewById(R.id.left_drawer);

        mDrawerList.setAdapter(new ArrayAdapter<String>(this,
                R.layout.drawer_list_item, mFeatureTitles));
        mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    }


    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.main, menu);
        return true;
    }

    private class DrawerItemClickListener implements ListView.OnItemClickListener {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            selectItem(position);
        }

    }

    private void selectItem(int position) {
        // Fragment fragment = new DirectorySearchFragment();
        Fragment fragment = null;
        // Fragment fragment = new RegistrarSearchFragment();

        if (position == 0) {
            fragment = new RegistrarSearchFragment();
        } else if (position == 1) {
            fragment = new DirectorySearchFragment();
        } else if (position == 2) {
            fragment = new TransitExpListFragment();
        } else if (position == 3) {
            fragment = new DiningFragment();
        }

        FragmentManager fragmentManager = getSupportFragmentManager();
        fragmentManager.beginTransaction()
                .replace(R.id.content_frame, fragment)
                .commit();

        mDrawerList.setItemChecked(position, true);
        setTitle(mFeatureTitles[position]);
        mDrawerLayout.closeDrawer(mDrawerList);
    }

    public void setTitle(CharSequence title) {
        getActionBar().setTitle(title);
    }

    /*
    public void startDirectory(View v) {
        Intent intent = new Intent(this, DirectorySearchActivity.class);
        startActivity(intent);
    }


    public void startCourseSearch(View v) {
        Intent intent = new Intent(this, RegistrarSearchActivity.class);
        startActivity(intent);
    }

    public void startTransit(View v) {
        Intent intent = new Intent(this, TransitActivity.class);
        startActivity(intent);
    }
    */
}

@@ -36,39 +36,8 @@
 e;%0A%0A
-import android.content.Intent;%0A
 impo
@@ -1229,89 +1229,8 @@
 ) %7B%0A
-        // Inflate the menu; this adds items to the action bar if it is present.%0A
     
@@ -1609,158 +1609,33 @@
     
-// Fragment fragment = new DirectorySearchFragment();%0A        Fragment fragment = null;%0A        // Fragment fragment = new RegistrarSearchFragment();%0A
+Fragment fragment = null;
 %0A   
@@ -2416,470 +2416,30 @@
 tle(
-title);%0A    %7D%0A%0A    /*%0A    public void startDirectory(View v) %7B%0A        Intent intent = new Intent(this, DirectorySearchActivity.class);%0A        startActivity(intent);%0A    %7D%0A%0A%0A    public void startCourseSearch(View v) %7B%0A        Intent intent = new Intent(this, RegistrarSearchActivity.class);%0A        startActivity(intent);%0A    %7D%0A%0A    public void startTransit(View v) %7B%0A        Intent intent = new Intent(this, TransitActivity.class);%0A        startActivity(intent
+%22PennMobile: %22 + title
 );%0A 
@@ -2447,13 +2447,6 @@
   %7D%0A
-    */%0A
 %7D%0A

clean up lil