| 1 | package ro.ieval.unical; |
| 2 | import android.content.Intent; |
| 3 | import android.content.SharedPreferences; |
| 4 | import android.os.Bundle; |
| 5 | import android.preference.PreferenceManager; |
| 6 | import android.view.Menu; |
| 7 | import android.view.MenuInflater; |
| 8 | import android.view.MenuItem; |
| 9 | |
| 10 | public class MainActivity extends android.app.Activity { |
| 11 | |
| 12 | @Override |
| 13 | protected void onCreate(final Bundle savedInstanceState) { |
| 14 | super.onCreate(savedInstanceState); |
| 15 | |
| 16 | final SharedPreferences prefs=PreferenceManager.getDefaultSharedPreferences(this); |
| 17 | if(prefs.getBoolean("FirstTime", true)) { |
| 18 | prefs.edit().putBoolean("FirstTime", false).commit(); |
| 19 | final Intent i=new Intent(this,LoginActivity.class); |
| 20 | startActivity(i); |
| 21 | } |
| 22 | |
| 23 | final Intent intent=new Intent(this, EventListActivity.class); |
| 24 | startActivity(intent); |
| 25 | } |
| 26 | |
| 27 | @Override |
| 28 | public boolean onCreateOptionsMenu(final Menu menu) { |
| 29 | final MenuInflater inflater = getMenuInflater(); |
| 30 | inflater.inflate(R.menu.main, menu); |
| 31 | return true; |
| 32 | } |
| 33 | |
| 34 | @Override |
| 35 | public boolean onOptionsItemSelected(final MenuItem item) { |
| 36 | switch (item.getItemId()) { |
| 37 | case R.id.NewEvent: |
| 38 | final Intent i=new Intent(this,AddEventActivity.class); |
| 39 | startActivity(i); |
| 40 | return true; |
| 41 | default: |
| 42 | return false; |
| 43 | } |
| 44 | } |
| 45 | } |