package com.example.yalepublicandroid;

// import android.support.v7.app.ActionBarActivity;
import android.content.Intent;
import android.net.Uri;
import android.support.v7.app.ActionBar;
import android.support.v7.app.ActionBarActivity;
import android.support.v4.app.Fragment;
import android.annotation.SuppressLint;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.Toast;
import android.os.Build;

@SuppressLint("NewApi")
public class MainActivity extends ActionBarActivity {

    double screenWidth;
    double screenHeight;
    
    private OnClickListener buttonClickListener = new OnClickListener(){
        @Override
         public void onClick(View v) {
             switch(v.getId()){
             case R.id.bNews:
                 break;
             case R.id.bDirectory:
                 break;
             case R.id.bMaps:
                 break;
             case R.id.bVideos:
                 break;
             case R.id.bPhotos:
                 break;
             case R.id.bEvents:
                 break;
             case R.id.bTransit:
                 Uri uriUrl1 = Uri.parse("http://yale.transloc.com");
                 Intent launchBrowser1 = new Intent(Intent.ACTION_VIEW, uriUrl1);
                 startActivity(launchBrowser1);
                 break;
             case R.id.bAthletics:
                 Uri uriUrl2 = Uri.parse("http://www.yalebulldogs.com/landing/index");
                 Intent launchBrowser2 = new Intent(Intent.ACTION_VIEW, uriUrl2);
                 startActivity(launchBrowser2);
                 break;
             case R.id.bArts:
                 Uri uriUrl3 = Uri.parse("http://artscalendar.yale.edu");
                 Intent launchBrowser3 = new Intent(Intent.ACTION_VIEW, uriUrl3);
                 startActivity(launchBrowser3);
                 break;
             }
         };
    };
    
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        /*Configuration config = getResources().getConfiguration();
        DisplayMetrics dm = getResources().getDisplayMetrics();
        screenWidth = (double)config.screenWidthDp * dm.density;
        screenHeight = (double)config.screenHeightDp * dm.density;
        final GridView gridview = (GridView) findViewById(R.id.gridview);
        gridview.setPadding((int)(screenWidth/12.0), (int) (screenHeight*(1.5/20)), (int)(screenWidth/12.0), 0);
        gridview.setVerticalSpacing((int)(screenHeight*(1.5/20)));
        gridview.setHorizontalSpacing((int)(screenWidth/6.0));
        Log.d("relative layout", "before adapter was set");
        gridview.setAdapter(new MenuAdapter(this, screenWidth));
        Log.d("Menu", String.valueOf(gridview.getPaddingTop()));
        gridview.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                Log.i("ITEM_CLICKED", "" + String.valueOf(gridview.getItemAtPosition(position)));
                Toast toast = new Toast(getApplicationContext());
                toast.setText(String.valueOf(gridview.getItemAtPosition(position)));
                toast.show();
            }
        });*/
        registerButtons();
    }
    

    @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;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }

    /**
     * A placeholder fragment containing a simple view.
     */
    public static class PlaceholderFragment extends Fragment {

        public PlaceholderFragment() {
        }

        @Override
        public View onCreateView(LayoutInflater inflater, ViewGroup container,
                Bundle savedInstanceState) {
            View rootView = inflater.inflate(R.layout.fragment_main, container,
                    false);
            return rootView;
        }
    }
    
    
    private void register(int buttonResourceId){
        findViewById(buttonResourceId).setOnClickListener(buttonClickListener);
    }
    
    private void registerButtons(){
        register(R.id.bNews);
        register(R.id.bDirectory);
        register(R.id.bMaps);
        register(R.id.bVideos);
        register(R.id.bPhotos);
        register(R.id.bEvents);
        register(R.id.bTransit);
        register(R.id.bAthletics);
        register(R.id.bArts);
        ;
    }
    

}

@@ -1014,33 +1014,32 @@
 verride%0A        
- 
 public void onCl
@@ -1068,15 +1068,15 @@
     
- 
 switch
+ 
 (v.g
@@ -1082,19 +1082,19 @@
 getId())
+ 
 %7B%0A
- 
         
@@ -1126,33 +1126,31 @@
             
- 
 break;%0A
- 
             
@@ -1183,33 +1183,31 @@
             
- 
 break;%0A
- 
             
@@ -1235,33 +1235,31 @@
             
- 
 break;%0A
- 
             
@@ -1289,33 +1289,31 @@
             
- 
 break;%0A
- 
             
@@ -1343,33 +1343,31 @@
             
- 
 break;%0A
- 
             
@@ -1397,33 +1397,31 @@
             
- 
 break;%0A
- 
             
@@ -1448,33 +1448,32 @@
                 
- 
 Uri uriUrl1 = Ur
@@ -1505,25 +1505,24 @@
 sloc.com%22);%0A
- 
             
@@ -1598,33 +1598,32 @@
                 
- 
 startActivity(la
@@ -1633,25 +1633,24 @@
 hBrowser1);%0A
- 
             
@@ -1664,33 +1664,32 @@
 ak;%0A            
- 
 case R.id.bAthle
@@ -1694,17 +1694,16 @@
 letics:%0A
- 
         
@@ -1788,33 +1788,32 @@
                 
- 
 Intent launchBro
@@ -1857,25 +1857,24 @@
 , uriUrl2);%0A
- 
             
@@ -1920,33 +1920,31 @@
             
- 
 break;%0A
- 
             
@@ -1956,25 +1956,24 @@
 R.id.bArts:%0A
- 
             
@@ -2029,25 +2029,24 @@
 yale.edu%22);%0A
- 
             
@@ -2122,33 +2122,32 @@
                 
- 
 startActivity(la
@@ -2169,33 +2169,32 @@
                 
- 
 break;%0A         
@@ -2192,28 +2192,26 @@
             
- 
 %7D%0A
- 
         %7D;%0A 

Make whitespace uniform in the switch statement