void _addCrimeButton_Click(object sender, EventArgs e) { var crime = new Crime(); CrimeLab.Create(Activity).AddCrime(crime); _callbacks.onCrimeSelected(crime); }
public override bool OnOptionsItemSelected(IMenuItem item) { switch (item.ItemId) { case Resource.Id.menu_item_new_crime: var crime = new Crime(); CrimeLab.Create(Activity).AddCrime(crime); _callbacks.onCrimeSelected(crime); return(true); case Resource.Id.menu_item_show_subtitle: if (Activity.ActionBar.Subtitle == null) { _subtitileVisible = true; Activity.ActionBar.SetSubtitle(Resource.String.subtitle); item.SetTitle(Resource.String.hide_subtitle); } else { _subtitileVisible = false; Activity.ActionBar.Subtitle = null; item.SetTitle(Resource.String.show_subtitle); } return(true); default: return(base.OnOptionsItemSelected(item)); } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Create your application here _viewPager = new ViewPager(this); _viewPager.Id = Resource.Id.viewPager; SetContentView(_viewPager); _crimes = CrimeLab.Create(this).Crimes; var fm = SupportFragmentManager; var fspa = new MyFragmentStatePagerAdapter(fm); fspa.Crimes = _crimes; _viewPager.Adapter = fspa; _viewPager.SetOnPageChangeListener(new MyPageChangeListener(this, this, _crimes)); var crimeId = new Guid(Intent.GetStringExtra(CrimeFragment.EXTRA_CRIME_ID)); for (int i = 0; i < _crimes.Count; i++) { if (_crimes[i].Id == crimeId) { _viewPager.CurrentItem = i; break; } } }
public static CrimeLab Create(Context context) { lock (_creationLock) { if (_crimeLab == null) { _crimeLab = new CrimeLab(context.ApplicationContext); } } return(_crimeLab); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); var crimeId = new Guid(Arguments.GetString(EXTRA_CRIME_ID)); var crimeLab = CrimeLab.Create(Activity); _crime = crimeLab.GetCrime(crimeId); HasOptionsMenu = true; }
public override bool OnContextItemSelected(IMenuItem item) { var info = item.MenuInfo as Android.Widget.AdapterView.AdapterContextMenuInfo; var position = info.Position; var adapter = ListAdapter as CrimeListAdapter; var crime = adapter[position]; switch (item.ItemId) { case Resource.Id.menu_item_delete_crime: CrimeLab.Create(Activity).DeleteCrime(crime); adapter.NotifyDataSetChanged(); return(true); } return(base.OnContextItemSelected(item)); }
public override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); HasOptionsMenu = true; Activity.SetTitle(Resource.String.crimes_title); var crimeLab = CrimeLab.Create(Activity); _crimes = crimeLab.Crimes; var adapter = new CrimeListAdapter(Activity, _crimes); ListAdapter = adapter; RetainInstance = true; _subtitileVisible = false; }
public override void OnPause() { base.OnPause(); CrimeLab.Create(Activity).SaveCrimes(); }