Created
January 21, 2015 14:40
-
-
Save andreinitescu/ed8e3f33e303ce5c4269 to your computer and use it in GitHub Desktop.
MvxActivity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// MvxActivity.cs | |
// (c) Copyright Cirrious Ltd. http://www.cirrious.com | |
// MvvmCross is licensed using Microsoft Public License (Ms-PL) | |
// Contributions and inspirations noted in readme.md and license.txt | |
// | |
// Project Lead - Stuart Lodge, @slodge, [email protected] | |
using System; | |
using System.Collections.Generic; | |
using Android.App; | |
using Android.Content; | |
using Cirrious.CrossCore.Droid.Views; | |
using Cirrious.MvvmCross.Binding.BindingContext; | |
using Cirrious.MvvmCross.Binding.Droid.BindingContext; | |
using Cirrious.MvvmCross.Droid.Views; | |
using Cirrious.MvvmCross.ViewModels; | |
namespace Cirrious.MvvmCross.Droid.FullFragging.Views | |
{ | |
public abstract class MvxActivity | |
: Cirrious.MvvmCross.Droid.Views.MvxActivity | |
{ | |
private readonly List<WeakReference<Fragment>> _fragList = new List<WeakReference<Fragment>>(); | |
public override void OnAttachFragment(Fragment fragment) | |
{ | |
base.OnAttachFragment(fragment); | |
_fragList.Add(new WeakReference<Fragment>(fragment)); | |
} | |
public List<Fragment> Fragments | |
{ | |
get | |
{ | |
var ret = new List<Fragment>(); | |
foreach (var wref in _fragList) | |
{ | |
Fragment f; | |
if (!wref.TryGetTarget(out f)) continue; | |
if (f.IsVisible) | |
ret.Add(f); | |
} | |
return ret; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment