private void TrackAdapter_ItemClick(object sender, int e)
        {
            ViewModel.PropertyChanged -= ViewModel_PropertyChanged;

            var details = FragmentManager.FindFragmentById(Resource.Id.trackDetailFragment) as TrackDetailFragment;

            ViewModel.SelectedTrack = ViewModel.Tracks[e];

            if (details == null)
            {
                // Make new fragment to show this selection.
                details = TrackDetailFragment.NewInstance(ViewModel.SelectedTrack);
                // Execute a transaction, replacing any existing
                // fragment with this one inside the frame.
                var ft = FragmentManager.BeginTransaction();
                ft.Replace(Resource.Id.content_frame, details, "TrackFragTag");
                ft.SetTransition((int)FragmentTransit.EnterMask);
                ft.AddToBackStack("TrackFragTag");
                ft.Commit();
            }
            else
            {
                // Otherwise we need to launch a new Activity to display
                // the dialog fragment with selected artist.
                var intent = new Intent();
                intent.SetClass(Activity, typeof(TrackDetailFragment));
                intent.PutExtra("current_track", JsonConvert.SerializeObject(ViewModel.SelectedTrack));
                StartActivity(intent);
            }
        }
示例#2
0
        public static TrackDetailFragment NewInstance(MTrack selectedTrack)
        {
            var detailsFrag = new TrackDetailFragment {
                Arguments = new Bundle()
            };

            detailsFrag.Arguments.PutString("current_track", JsonConvert.SerializeObject(selectedTrack));
            return(detailsFrag);
        }