示例#1
0
        public void onCrimeSelected(Crime crime)
        {
            if (FindViewById(Resource.Id.detailFragmentContainer) == null)
            {
                // Start an instance of CrimePagerActivity
                var i = new Intent(this, typeof(CrimePagerActivity));
                i.PutExtra(CrimeFragment.EXTRA_CRIME_ID, crime.Id.ToString());
                StartActivity(i);
            }
            else
            {
                var fm = SupportFragmentManager;
                var ft = fm.BeginTransaction();

                var oldDetail = fm.FindFragmentById(Resource.Id.detailFragmentContainer);
                var newDetail = CrimeFragment.NewInstance(crime.Id);

                if (oldDetail != null)
                {
                    ft.Remove(oldDetail);
                }
                ft.Add(Resource.Id.detailFragmentContainer, newDetail);
                ft.Commit();
            }
        }
        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));
            }
        }
        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 void OnListItemClick(ListView l, View v, int position, long id)
        {
            Crime crime = _crimes[position];

            _callbacks.onCrimeSelected(crime);
        }
 public void OnCrimeUpdated(Crime crime)
 {
     // no implementation needed for CrimePagerActivity
 }
示例#7
0
 public void DeleteCrime(Crime c)
 {
     _crimes.Remove(c);
 }
示例#8
0
 public void AddCrime(Crime c)
 {
     _crimes.Add(c);
 }
示例#9
0
 public void OnCrimeUpdated(Crime crime)
 {
     var fm = SupportFragmentManager;
     var listFragment = (CrimeListFragment)fm.FindFragmentById(Resource.Id.fragmentContainer);
     listFragment.UpdateUI();
 }