package com.example.stockprophit;

import java.util.ArrayList;
import java.util.Arrays;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.content.res.Resources;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.support.v4.app.NavUtils;

public class TopFiveActivity extends Activity {

	//Resources res = getResources();
	//String[] five = res.getStringArray(R.array.ticker_array);
	//ArrayList<String> fiveList = new ArrayList<String>(Arrays.asList(five));
	//for(int i=fivelist.size-1;i>=5;i--)
	//{
	//	fivelist.remove(i);
	//}
	//ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1, fiveList);
	//ListView lv = (ListView) findViewById(R.id.top_list);
	//lv.setAdapter(adapter);
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_top_five); //create page using activity_top_five template
		// Show the Up button in the action bar.
		getActionBar().setDisplayHomeAsUpEnabled(true);
	}
 
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.activity_top_five, menu);
		return true;
	}

	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		switch (item.getItemId()) {
		case android.R.id.home:
			// This ID represents the Home or Up button. In the case of this
			// activity, the Up button is shown. Use NavUtils to allow users
			// to navigate up one level in the application structure. For
			// more details, see the Navigation pattern on Android Design:
			//
			// http://developer.android.com/design/patterns/navigation.html#up-vs-back
			//
			NavUtils.navigateUpFromSameTask(this);
			return true;
		}
		return super.onOptionsItemSelected(item);
	}
	
	public void goHome(View view) // go to home page
	{
		Intent intent = new Intent(this, MainActivity.class);
		startActivity(intent);
	}
	
	public void goFavorites(View view) //go to favorites page
    {
    	Intent intent = new Intent(this, FavoritesActivity.class);
    	startActivity(intent);
    }
    
	public void goSocial(View view) // go to social
    {
    	GlobalVariables gv = (GlobalVariables)getApplicationContext();
    	if(gv.getStatus() == 4) //check to see if logged in
    	{
    		// if logged in then go to social activity
    		Intent intent = new Intent(this, SocialActivity.class);
    		startActivity(intent);
    	}
    	else
    	{
    		// if not logged in the go to login activity
    		gv.setStatus(0);
    		Intent intent = new Intent(this, LoginActivity.class);
    		startActivity(intent);
    	}
    }

}
