Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 0 additions & 18 deletions src/ReactiveUI.AndroidSupport/ReactiveFragment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,11 @@
// See the LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Text;
using System.Threading;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Util;
using Android.Views;
using Android.Widget;
using Splat;

namespace ReactiveUI.AndroidSupport
{
Expand Down
14 changes: 0 additions & 14 deletions src/ReactiveUI.AndroidSupport/ReactiveFragmentActivity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,31 +4,17 @@
// See the LICENSE file in the project root for full license information.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Diagnostics.Contracts;
using System.Linq;
using System.Reactive;
using System.Reactive.Concurrency;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using System.Reactive.Threading.Tasks;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Android.App;
using Android.Content;
using Android.OS;
using Android.Runtime;
using Android.Support.V4.App;
using Android.Views;
using Android.Widget;
using Splat;

namespace ReactiveUI.AndroidSupport
{
Expand Down
4 changes: 1 addition & 3 deletions src/ReactiveUI.AndroidSupport/ReactivePagerAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
using System.Collections.Specialized;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reactive.Disposables;
using System.Threading;
using Android.Support.V4.View;
using Android.Views;
using DynamicData;
Expand All @@ -31,7 +29,7 @@ public class ReactivePagerAdapter<TViewModel> : PagerAdapter, IEnableLogger
private readonly SourceList<TViewModel> _list;
private readonly Func<TViewModel, ViewGroup, View> _viewCreator;
private readonly Action<TViewModel, View> _viewInitializer;
private IDisposable _inner;
private readonly IDisposable _inner;

/// <summary>
/// Initializes a new instance of the <see cref="ReactivePagerAdapter{TViewModel}"/> class.
Expand Down
153 changes: 153 additions & 0 deletions src/ReactiveUI.AndroidSupport/ReactivePreferenceFragment.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
// Copyright (c) 2019 .NET Foundation and Contributors. All rights reserved.
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for full license information.

using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Reactive;
using System.Reactive.Linq;
using System.Reactive.Subjects;
using Android.Runtime;
using Android.Support.V7.Preferences;

namespace ReactiveUI.AndroidSupport
{
/// <summary>
/// This is a PreferenceFragment that is both an Activity and has ReactiveObject powers
/// (i.e. you can call RaiseAndSetIfChanged).
/// </summary>
/// <typeparam name="TViewModel">The view model type.</typeparam>
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleType", Justification = "Classes with the same class names within.")]
public abstract class ReactivePreferenceFragment<TViewModel> : ReactivePreferenceFragment, IViewFor<TViewModel>, ICanActivate
where TViewModel : class
{
private TViewModel _viewModel;

/// <summary>
/// Initializes a new instance of the <see cref="ReactivePreferenceFragment{TViewModel}"/> class.
/// </summary>
protected ReactivePreferenceFragment()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="ReactivePreferenceFragment{TViewModel}"/> class.
/// </summary>
/// <param name="handle">The handle.</param>
/// <param name="ownership">The ownership.</param>
protected ReactivePreferenceFragment(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}

/// <inheritdoc/>
public TViewModel ViewModel
{
get => _viewModel;
set => this.RaiseAndSetIfChanged(ref _viewModel, value);
}

/// <inheritdoc/>
object IViewFor.ViewModel
{
get => _viewModel;
set => _viewModel = (TViewModel)value;
}
}

/// <summary>
/// This is a PreferenceFragment that is both an Activity and has ReactiveObject powers
/// (i.e. you can call RaiseAndSetIfChanged).
/// </summary>
[SuppressMessage("StyleCop.CSharp.MaintainabilityRules", "SA1402:FileMayOnlyContainASingleType", Justification = "Classes with the same class names within.")]
public abstract class ReactivePreferenceFragment : PreferenceFragmentCompat, IReactiveNotifyPropertyChanged<ReactivePreferenceFragment>, IReactiveObject, IHandleObservableErrors
{
private readonly Subject<Unit> _activated = new Subject<Unit>();
private readonly Subject<Unit> _deactivated = new Subject<Unit>();

/// <summary>
/// Initializes a new instance of the <see cref="ReactivePreferenceFragment"/> class.
/// </summary>
protected ReactivePreferenceFragment()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="ReactivePreferenceFragment"/> class.
/// </summary>
/// <param name="handle">The handle.</param>
/// <param name="ownership">The ownership.</param>
protected ReactivePreferenceFragment(IntPtr handle, JniHandleOwnership ownership)
: base(handle, ownership)
{
}

/// <inheritdoc/>
public event PropertyChangingEventHandler PropertyChanging;

/// <inheritdoc/>
public event PropertyChangedEventHandler PropertyChanged;

/// <inheritdoc />
public IObservable<IReactivePropertyChangedEventArgs<ReactivePreferenceFragment>> Changing => this.GetChangingObservable();

/// <inheritdoc />
public IObservable<IReactivePropertyChangedEventArgs<ReactivePreferenceFragment>> Changed => this.GetChangedObservable();

/// <inheritdoc/>
public IObservable<Exception> ThrownExceptions => this.GetThrownExceptionsObservable();

/// <summary>
/// Gets a signal when the fragment is activated.
/// </summary>
public IObservable<Unit> Activated => _activated.AsObservable();

/// <summary>
/// Gets a signal when the fragment is deactivated.
/// </summary>
public IObservable<Unit> Deactivated => _deactivated.AsObservable();

/// <inheritdoc/>
public IDisposable SuppressChangeNotifications() => IReactiveObjectExtensions.SuppressChangeNotifications(this);

/// <inheritdoc/>
void IReactiveObject.RaisePropertyChanged(PropertyChangedEventArgs args)
{
PropertyChanged?.Invoke(this, args);
}

/// <inheritdoc/>
void IReactiveObject.RaisePropertyChanging(PropertyChangingEventArgs args)
{
PropertyChanging?.Invoke(this, args);
}

/// <inheritdoc/>
public override void OnPause()
{
base.OnPause();
_deactivated.OnNext(Unit.Default);
}

/// <inheritdoc/>
public override void OnResume()
{
base.OnResume();
_activated.OnNext(Unit.Default);
}

/// <inheritdoc/>
protected override void Dispose(bool disposing)
{
if (disposing)
{
_activated?.Dispose();
_deactivated?.Dispose();
}

base.Dispose(disposing);
}
}
}
7 changes: 1 addition & 6 deletions src/ReactiveUI.AndroidSupport/ReactiveRecyclerViewAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,9 @@
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Reflection;
using System.Runtime.Serialization;
using System.Threading;
using Android.Support.V7.Widget;
using Android.Views;
using DynamicData;
Expand All @@ -33,7 +28,7 @@ public abstract class ReactiveRecyclerViewAdapter<TViewModel> : RecyclerView.Ada
{
private readonly ISourceList<TViewModel> _list;

private IDisposable _inner;
private readonly IDisposable _inner;

/// <summary>
/// Initializes a new instance of the <see cref="ReactiveRecyclerViewAdapter{TViewModel}"/> class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
<PackageReference Include="Xamarin.Android.Support.Animated.Vector.Drawable" Version="27.0.*" />
<PackageReference Include="Xamarin.Android.Support.v4" Version="27.0.*" />
<PackageReference Include="Xamarin.Android.Support.v7.AppCompat" Version="27.0.*" />
<PackageReference Include="Xamarin.Android.Support.v7.Preference" Version="27.0.*" />
<PackageReference Include="Xamarin.Android.Support.v7.RecyclerView" Version="27.0.*" />
<PackageReference Include="Xamarin.Android.Support.Vector.Drawable" Version="27.0.*" />
<PackageReference Include="System.Runtime.Serialization.Primitives" Version="4.3.0" />
Expand Down
4 changes: 1 addition & 3 deletions src/ReactiveUI.AndroidX/ReactivePagerAdapter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
using System.Collections.Specialized;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reactive.Disposables;
using System.Threading;
using Android.Views;
using AndroidX.ViewPager.Widget;
using DynamicData;
Expand All @@ -31,7 +29,7 @@ public class ReactivePagerAdapter<TViewModel> : PagerAdapter, IEnableLogger
private readonly SourceList<TViewModel> _list;
private readonly Func<TViewModel, ViewGroup, View> _viewCreator;
private readonly Action<TViewModel, View> _viewInitializer;
private IDisposable _inner;
private readonly IDisposable _inner;

/// <summary>
/// Initializes a new instance of the <see cref="ReactivePagerAdapter{TViewModel}"/> class.
Expand Down
Loading