package com.slaterama.quantumsheep.view;

import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

import com.slaterama.quantumsheep.R;

public class MainActivity extends AppCompatActivity
		implements AdapterView.OnItemClickListener {

	private ListView mListView;

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

		mListView = (ListView) findViewById(android.R.id.list);
		mListView.setOnItemClickListener(this);
		mListView.setAdapter(new ArrayAdapter<>(this,
				android.R.layout.simple_list_item_1,
				getResources().getStringArray(R.array.main_menu)));
	}

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.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);
    }

	@Override
	public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
		Intent intent;
		switch (position) {
			case 0:
				intent = new Intent(this, MvpActivity.class);
				intent.putExtra("user_id", 1);
				startActivity(intent);
				break;
			case 1:
				intent = new Intent(this, MvpActivity.class);
				intent.putExtra("user_id", 3);
				startActivity(intent);
				break;
			default:
				Toast.makeText(this, R.string.toast_not_yet_supported, Toast.LENGTH_SHORT).show();
		}
	}
}
