package com.mc.emergency;

import android.content.res.Resources;
import android.support.v7.app.ActionBarActivity;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ExpandableListView;
import android.widget.GridView;
import android.widget.TextView;


public class MainActivity extends ActionBarActivity {

    private ExpandableHeightGridView gridViewTypes;
    private ExpandableHeightGridView gridViewNumbers;

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

        Resources res = getResources();

        // set types on gridView

        gridViewTypes = (ExpandableHeightGridView) this.findViewById(R.id.mainGridViewTypes);
        CustomGridAdapter gridAdapterTypes = new CustomGridAdapter(MainActivity.this, res.getStringArray(R.array.emergency_types),res.getStringArray(R.array.emergency_types_images));
        gridViewTypes.setAdapter(gridAdapterTypes);
        gridViewTypes.setExpanded(true);
        gridViewTypes.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //text.setText((String) (gridView.getItemAtPosition(position)));
                Log.i("ITEM_CLICKED", "" + (String) (gridViewTypes.getItemAtPosition(position)));
            }
        });


        gridViewNumbers = (ExpandableHeightGridView) this.findViewById(R.id.mainGridViewNumbers);
        CustomGridAdapter gridAdapterNumbers = new CustomGridAdapter(MainActivity.this, res.getStringArray(R.array.emergency_numbers_text), res.getStringArray(R.array.emergency_numbers_images));
        gridViewNumbers.setAdapter(gridAdapterNumbers);
        gridViewNumbers.setExpanded(true);
        gridViewNumbers.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                //text.setText((String) (gridView.getItemAtPosition(position)));
                Log.i("ITEM_CLICKED", "" + (String) (gridViewNumbers.getItemAtPosition(position)));
            }
        });



    }


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

}

@@ -47,21 +47,76 @@
 ent.
-res.Resources
+Intent;%0Aimport android.content.res.Resources;%0Aimport android.net.Uri
 ;%0Aim
@@ -598,16 +598,50 @@
 Numbers;
+%0A    private static Resources res;
 %0A%0A    @O
@@ -806,26 +806,16 @@
         
-Resources 
 res = ge
@@ -2230,32 +2230,33 @@
 ion, long id) %7B%0A
+%0A
                 
@@ -2259,170 +2259,240 @@
     
-//text.setText((String) (gridView.getItemAtPosition(position)));%0A                Log.i(%22ITEM_CLICKED%22, %22%22 + (String) (gridViewNumbers.getItemAtPosition(position))
+Intent dial = new Intent();%0A                dial.setAction(%22android.intent.action.DIAL%22);%0A                dial.setData(Uri.parse(%22tel:%22 + res.getStringArray(R.array.emergency_numbers)%5Bposition%5D ));%0A                startActivity(dial
 );%0A 

Call function added