예제 #1
0
 /// <summary>
 /// Once
 /// </summary>
 /// <param name="activity"></param>
 /// <returns></returns>
 public static IObservable <ActivityState> OnDestroying(this ActivityBase activity)
 {
     return(activity
            .Events
            .Where(e => e.Key == nameof(ActivityBase.ActivityState))
            .Select(x => (ActivityState)x.Value)
            .Where(state => state == ActivityState.Destroying)
            .Take(1));
 }
예제 #2
0
        /// <summary>
        /// TODO: -> NotificationManager IsDisable(INotification)
        /// </summary>
        public static IDisposable SubscribeNotification(
            this ActivityBase activity,
            IObservable <IEvent> activityEvents,
            INotification notification)
        {
            var waiting = false;
            var enabled = true;

            var source = new CancellationTokenSource();

            return(activityEvents
                   .Select(x => new
            {
                waiting,
                enabled,
                // activity.ActivityState,
                activity.IsDestroyed,
                source.IsCancellationRequested
            })
                   .Where(x => !x.waiting)
                   .Do(x =>
            {
                if (!x.IsCancellationRequested && x.IsDestroyed)
                {
                    source.Cancel();
                }
            })
                   .TakeWhile(x =>
                              x.enabled && // it's Disabled ?
                              !x.IsDestroyed &&
                              !x.IsCancellationRequested)

                   .Subscribe(async x =>
            {
                var result = await notification.Notify(activity, source.Token);
                enabled = !result.Ok;
                waiting = false;

                if (source.IsCancellationRequested)
                {
                    return;
                }

                source.Cancel();
            }));
        }
예제 #3
0
 public FragmentNavigator(ActivityBase activity, IFragmentFactory fragmentFactory)
 {
     _activity        = activity;
     _fragmentFactory = fragmentFactory;
 }
예제 #4
0
 public INavigator Create(ActivityBase activity)
 {
     return(new FragmentNavigator(activity, Container.Resolve <FragmentFactory>()));
 }
예제 #5
0
 public static IObservable <IEvent> WhenBackPressed(this ActivityBase activity)
 {
     return(activity.Events.Where(e => e.Key == nameof(activity.OnBackPressed)));
 }