Esempio n. 1
0
        public void OnCrimeUpdated()
        {
            Android.Support.V4.App.FragmentManager fm = SupportFragmentManager;
            CrimeListFragment listFragment            = (CrimeListFragment)fm.FindFragmentById(Resource.Id.fragmentContainer);

            listFragment.UpdateUI();
        }
Esempio n. 2
0
        public void OnCrimeSelected(Crime crime)
        {
            if (FindViewById(Resource.Id.detailFragmentContainter) == null)
            {
                // Start an instance of CrimePagerActivity
                Intent i = new Intent(this, typeof(CrimePagerActivity));
                i.PutExtra(CrimeFragment.EXTRA_CRIME_ID, crime.Id);
                StartActivity(i);
            }
            else
            {
                Android.Support.V4.App.FragmentManager     fm = SupportFragmentManager;
                Android.Support.V4.App.FragmentTransaction ft = fm.BeginTransaction();

                Android.Support.V4.App.Fragment oldDetail = fm.FindFragmentById(Resource.Id.detailFragmentContainter);
                Android.Support.V4.App.Fragment newDetail = CrimeFragment.NewInstance(crime.Id);

                if (oldDetail != null)
                {
                    ft.Remove(oldDetail);
                }

                ft.Add(Resource.Id.detailFragmentContainter, newDetail);
                ft.Commit();
            }
        }
Esempio n. 3
0
 //Set map
 private void SetUpMap()
 {
     if (mMap == null)
     {
         FragmentManager.FindFragmentById <MapFragment>(Resource.Id.map).GetMapAsync(this);
     }
 }
Esempio n. 4
0
 public void RemoveDetailView()
 {
     if (FindViewById(Resource.Id.detailFragmentContainter) != null)
     {
         Android.Support.V4.App.FragmentManager     fm        = SupportFragmentManager;
         Android.Support.V4.App.FragmentTransaction ft        = fm.BeginTransaction();
         Android.Support.V4.App.Fragment            oldDetail = fm.FindFragmentById(Resource.Id.detailFragmentContainter);
         if (oldDetail != null)
         {
             ft.Remove(oldDetail);
         }
         ft.Commit();
     }
 }
Esempio n. 5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_sessions);

            Intent intent = new Intent();

            intent.SetData(ScheduleContract.Tracks.CONTENT_URI);
            intent.PutExtra(TracksFragment.EXTRA_NEXT_TYPE, TracksFragment.NEXT_TYPE_SESSIONS);

            FragmentManager fm = SupportFragmentManager;

            mTracksDropdownFragment = (TracksDropdownFragment)fm.FindFragmentById(Resource.Id.fragment_tracks_dropdown);
            mTracksDropdownFragment.ReloadFromArguments(IntentToFragmentArguments(intent));
        }
        ///<inheritdoc/>
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.AbstractFragmentActivityLayout);

            SetSupportActionBar(FindViewById <Toolbar>(Resource.Id.questCreateToolbar));

            FragmentManager manager  = SupportFragmentManager;
            Fragment        fragment = manager.FindFragmentById(Resource.Id.fragmentContainerId);

            if (fragment == null)
            {
                manager.
                BeginTransaction().
                Add(Resource.Id.fragmentContainerId, CreateFragment()).
                Commit();
            }
        }
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var pager = new ViewPager(inflater.Context)
            {
                Id      = 0x34532,
                Adapter = new MonkeyPageAdapter(ChildFragmentManager),
            };

            pager.PageSelected += async(sender, e) => {
                var map        = (SupportMapFragment)FragmentManager.FindFragmentById(Resource.Id.map);
                var monkeyName = ((MonkeyPageAdapter)pager.Adapter).GetMonkeyAtPosition(e.Position);
                var location   = await WikipediaApi.FetchHabitatLocation(monkeyName);

                var latLng = new Android.Gms.Maps.Model.LatLng(location.Item1, location.Item2);
                map.Map.AnimateCamera(CameraUpdateFactory.NewLatLng(latLng), 250, null);
                if (existingMarker != null)
                {
                    existingMarker.Remove();
                }
                existingMarker = map.Map.AddMarker(new MarkerOptions().SetPosition(latLng));
            };

            return(pager);
        }
        public bool SetContent(object view, object content)
        {
            var targetView = view as ViewGroup;

            if (targetView == null)
            {
                return(false);
            }
            if (content == null)
            {
                FragmentManager fragmentManager = targetView.GetFragmentManager();
                Fragment        oldFragment     = fragmentManager?.FindFragmentById(targetView.Id);
                if (oldFragment != null && !fragmentManager.IsDestroyed)
                {
                    BeginTransaction(fragmentManager, targetView, null)
                    .Remove(oldFragment)
                    .CommitAllowingStateLoss();
                    fragmentManager.ExecutePendingTransactions();
                    return(true);
                }
                return(false);
            }
            var fragment = content as Fragment;

            if (fragment == null)
            {
                return(false);
            }
            AndroidToolkitExtensions.ValidateViewIdFragment(targetView, fragment);
            FragmentManager manager = targetView.GetFragmentManager();

            if (manager == null)
            {
                return(false);
            }
            FragmentTransaction transaction = BeginTransaction(manager, targetView, fragment);
            var addToBackStack = targetView.GetBindingMemberValue(AttachedMembers.ViewGroup.AddToBackStack);

            if (addToBackStack && fragment.Arguments != null)
            {
                addToBackStack = !fragment.Arguments.GetBoolean(AddedToBackStackKey);
            }

            if (fragment.IsDetached)
            {
                transaction.Attach(fragment);
            }
            else
            {
                if (addToBackStack)
                {
                    if (fragment.Arguments == null)
                    {
                        fragment.Arguments = new Bundle();
                    }
                    fragment.Arguments.PutBoolean(AddedToBackStackKey, true);
                }
                transaction.Replace(targetView.Id, fragment);
            }
            if (addToBackStack)
            {
                transaction.AddToBackStack(null);
            }

            transaction.Commit();
            manager.ExecutePendingTransactions();
            return(true);
        }