diff --git a/Borepin/Borepin.Android/Borepin.Android.csproj b/Borepin/Borepin.Android/Borepin.Android.csproj
index aca6837..339d783 100644
--- a/Borepin/Borepin.Android/Borepin.Android.csproj
+++ b/Borepin/Borepin.Android/Borepin.Android.csproj
@@ -76,6 +76,10 @@
+
+
+
+
diff --git a/Borepin/Borepin.Android/PlatformInitializer.cs b/Borepin/Borepin.Android/PlatformInitializer.cs
index b26b6c6..ac5fbc0 100644
--- a/Borepin/Borepin.Android/PlatformInitializer.cs
+++ b/Borepin/Borepin.Android/PlatformInitializer.cs
@@ -1,7 +1,7 @@
using Borepin.Droid.Services;
+using Borepin.Service;
using Borepin.Service.Storage;
using Borepin.Service.Versioning;
-using FabAccessAPI;
using Prism;
using Prism.Ioc;
@@ -15,7 +15,7 @@ namespace Borepin.Droid
containerRegistry.Register();
containerRegistry.Register();
- containerRegistry.RegisterSingleton();
+ containerRegistry.RegisterSingleton();
}
}
}
\ No newline at end of file
diff --git a/Borepin/Borepin.Android/Services/APIBindedService.cs b/Borepin/Borepin.Android/Services/APIBindedService.cs
new file mode 100644
index 0000000..e84859c
--- /dev/null
+++ b/Borepin/Borepin.Android/Services/APIBindedService.cs
@@ -0,0 +1,50 @@
+using Android.App;
+using Android.Content;
+using Android.OS;
+using FabAccessAPI;
+
+namespace Borepin.Droid.Services
+{
+ [Service(Name= "org.fab_infra.fabaccess.APIService")]
+ public class APIBindedService : Android.App.Service
+ {
+ #region Private Members
+ private IAPI _API;
+ #endregion
+
+ #region Members
+ public IBinder Binder { get; private set; }
+ #endregion
+
+ #region Methods
+ public IAPI GetAPI()
+ {
+ return _API;
+ }
+
+ public override void OnCreate()
+ {
+ base.OnCreate();
+ _API = new API();
+ }
+
+ public override IBinder OnBind(Intent intent)
+ {
+ Binder = new APIBinder(this);
+ return Binder;
+ }
+
+ public override bool OnUnbind(Intent intent)
+ {
+ return base.OnUnbind(intent);
+ }
+
+ public override void OnDestroy()
+ {
+ Binder = null;
+ _API = null;
+ base.OnDestroy();
+ }
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Borepin/Borepin.Android/Services/APIBinder.cs b/Borepin/Borepin.Android/Services/APIBinder.cs
new file mode 100644
index 0000000..5deeb3b
--- /dev/null
+++ b/Borepin/Borepin.Android/Services/APIBinder.cs
@@ -0,0 +1,18 @@
+using Android.OS;
+
+namespace Borepin.Droid.Services
+{
+ public class APIBinder : Binder
+ {
+ #region Constructors
+ public APIBinder(APIBindedService service)
+ {
+ Service = service;
+ }
+ #endregion
+
+ #region Members
+ public APIBindedService Service { get; private set; }
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Borepin/Borepin.Android/Services/APIService.cs b/Borepin/Borepin.Android/Services/APIService.cs
new file mode 100644
index 0000000..815d895
--- /dev/null
+++ b/Borepin/Borepin.Android/Services/APIService.cs
@@ -0,0 +1,28 @@
+using Android.App;
+using Android.Content;
+using Borepin.Service;
+using FabAccessAPI;
+
+namespace Borepin.Droid.Services
+{
+ public class APIService : IAPIService
+ {
+ #region Private Members
+ private readonly APIServiceConnection _APIServiceConnection;
+ #endregion
+
+ #region Constructors
+ public APIService()
+ {
+ Context context = Application.Context;
+ Intent service = new Intent(context, typeof(APIBindedService));
+ context.BindService(service, _APIServiceConnection, Bind.AutoCreate);
+ }
+ #endregion
+
+ public IAPI GetAPI()
+ {
+ return _APIServiceConnection?.Binder?.Service?.GetAPI();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Borepin/Borepin.Android/Services/APIServiceConnection.cs b/Borepin/Borepin.Android/Services/APIServiceConnection.cs
new file mode 100644
index 0000000..319d008
--- /dev/null
+++ b/Borepin/Borepin.Android/Services/APIServiceConnection.cs
@@ -0,0 +1,32 @@
+using Android.Content;
+using Android.OS;
+using FabAccessAPI;
+
+namespace Borepin.Droid.Services
+{
+ class APIServiceConnection : Java.Lang.Object, IServiceConnection
+ {
+ #region Members
+ public bool IsConnected
+ {
+ get
+ {
+ return Binder != null;
+ }
+ }
+ public APIBinder Binder { get; private set; } = null;
+ #endregion
+
+ #region Methods
+ public void OnServiceConnected(ComponentName name, IBinder service)
+ {
+ Binder = service as APIBinder;
+ }
+
+ public void OnServiceDisconnected(ComponentName name)
+ {
+ Binder = null;
+ }
+ #endregion
+ }
+}
\ No newline at end of file
diff --git a/Borepin/Borepin.UWP/Borepin.UWP.csproj b/Borepin/Borepin.UWP/Borepin.UWP.csproj
index ce20094..2f9fcd5 100644
--- a/Borepin/Borepin.UWP/Borepin.UWP.csproj
+++ b/Borepin/Borepin.UWP/Borepin.UWP.csproj
@@ -98,6 +98,7 @@
+
diff --git a/Borepin/Borepin.UWP/PlatformInitializer.cs b/Borepin/Borepin.UWP/PlatformInitializer.cs
index 4fc4a5e..9eacb3c 100644
--- a/Borepin/Borepin.UWP/PlatformInitializer.cs
+++ b/Borepin/Borepin.UWP/PlatformInitializer.cs
@@ -3,7 +3,7 @@ using Prism;
using Prism.Ioc;
using Borepin.Service.Storage;
using Borepin.Service.Versioning;
-using FabAccessAPI;
+using Borepin.Service;
namespace Borepin.UWP
{
@@ -15,7 +15,7 @@ namespace Borepin.UWP
containerRegistry.Register();
containerRegistry.Register();
- containerRegistry.RegisterSingleton();
+ containerRegistry.RegisterSingleton();
}
}
}
diff --git a/Borepin/Borepin.UWP/Services/APIService.cs b/Borepin/Borepin.UWP/Services/APIService.cs
new file mode 100644
index 0000000..f985225
--- /dev/null
+++ b/Borepin/Borepin.UWP/Services/APIService.cs
@@ -0,0 +1,23 @@
+using Borepin.Service;
+using FabAccessAPI;
+
+namespace Borepin.UWP.Services
+{
+ public class APIService : IAPIService
+ {
+ #region Private Members
+ private readonly IAPI _API;
+ #endregion
+
+ #region Constructors
+ public APIService()
+ {
+ _API = new API();
+ }
+ #endregion
+ public IAPI GetAPI()
+ {
+ return _API;
+ }
+ }
+}
diff --git a/Borepin/Borepin.iOS/Borepin.iOS.csproj b/Borepin/Borepin.iOS/Borepin.iOS.csproj
index 9af051d..49518ba 100644
--- a/Borepin/Borepin.iOS/Borepin.iOS.csproj
+++ b/Borepin/Borepin.iOS/Borepin.iOS.csproj
@@ -81,6 +81,7 @@
+
diff --git a/Borepin/Borepin.iOS/PlatformInitializer.cs b/Borepin/Borepin.iOS/PlatformInitializer.cs
index 4827500..26a09b8 100644
--- a/Borepin/Borepin.iOS/PlatformInitializer.cs
+++ b/Borepin/Borepin.iOS/PlatformInitializer.cs
@@ -1,7 +1,7 @@
using Borepin.iOS.Services;
+using Borepin.Service;
using Borepin.Service.Storage;
using Borepin.Service.Versioning;
-using FabAccessAPI;
using Prism;
using Prism.Ioc;
@@ -15,7 +15,7 @@ namespace Borepin.iOS
containerRegistry.Register();
containerRegistry.Register();
- containerRegistry.RegisterSingleton();
+ containerRegistry.RegisterSingleton();
}
}
}
\ No newline at end of file
diff --git a/Borepin/Borepin.iOS/Services/APIService.cs b/Borepin/Borepin.iOS/Services/APIService.cs
new file mode 100644
index 0000000..f311dab
--- /dev/null
+++ b/Borepin/Borepin.iOS/Services/APIService.cs
@@ -0,0 +1,23 @@
+using Borepin.Service;
+using FabAccessAPI;
+
+namespace Borepin.iOS.Services
+{
+ public class APIService : IAPIService
+ {
+ #region Private Members
+ private readonly IAPI _API;
+ #endregion
+
+ #region Constructors
+ public APIService()
+ {
+ _API = new API();
+ }
+ #endregion
+ public IAPI GetAPI()
+ {
+ return _API;
+ }
+ }
+}
\ No newline at end of file
diff --git a/Borepin/Borepin/App.xaml.cs b/Borepin/Borepin/App.xaml.cs
index 702aad5..4fc87c3 100644
--- a/Borepin/Borepin/App.xaml.cs
+++ b/Borepin/Borepin/App.xaml.cs
@@ -26,11 +26,6 @@ namespace Borepin
{
InitializeComponent();
- INavigationParameters parameters = new NavigationParameters()
- {
- { "instance", 0 },
- };
-
await NavigationService.NavigateAsync(new Uri("https://borepin.fab-access.org/StartPage")).ConfigureAwait(false);
}
@@ -71,7 +66,7 @@ namespace Borepin
// IPreferenceStorageService
// ISecretStorageService
// IVersioningService
- // IAPI
+ // IAPIService
#endregion
}
}
diff --git a/Borepin/Borepin/Base/ConnectionModelBase.cs b/Borepin/Borepin/Base/ConnectionModelBase.cs
index e999e7d..87b67f0 100644
--- a/Borepin/Borepin/Base/ConnectionModelBase.cs
+++ b/Borepin/Borepin/Base/ConnectionModelBase.cs
@@ -1,9 +1,8 @@
-using Borepin.Service.BFFH;
-using Borepin.Service.BFFH.Exceptions;
+using Borepin.Service;
+using FabAccessAPI;
using Prism.Navigation;
using Prism.Services;
using System.Threading.Tasks;
-using Xamarin.Forms;
namespace Borepin.Base
{
@@ -14,14 +13,56 @@ namespace Borepin.Base
{
#region Private Fields
protected readonly IPageDialogService _PageDialogService;
- protected readonly IBFFHService _BFFHService;
+ protected readonly IAPI _API;
#endregion
#region Constructors
- protected ConnectionModelBase(INavigationService navigationService, IPageDialogService pageDialogService, IBFFHService bFFHService) : base(navigationService)
+ protected ConnectionModelBase(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService) : base(navigationService)
{
_PageDialogService = pageDialogService;
- _BFFHService = bFFHService;
+ _API = apiService.GetAPI();
+ _API.ConnectionStatusChanged += OnConnectionStatusChanged;
+
+ IsConnected = _API.IsConnected;
+ }
+ #endregion
+
+ #region Methods
+ public void OnConnectionStatusChanged(object sender, ConnectionStatusChange args)
+ {
+ switch(args)
+ {
+ case ConnectionStatusChange.Connected:
+ IsConnected = true;
+ LoadAPIData();
+ break;
+ case ConnectionStatusChange.Reconnected:
+ ReloadAPIData();
+ break;
+ case ConnectionStatusChange.ConnectionLoss:
+ case ConnectionStatusChange.Disconnected:
+ IsConnected = false;
+ break;
+ }
+ }
+
+ public virtual Task LoadAPIData()
+ {
+ return Task.CompletedTask;
+ }
+ public virtual Task ReloadAPIData()
+ {
+ return Task.CompletedTask;
+ }
+
+ public virtual Task LoadInstance(object instance)
+ {
+ return Task.CompletedTask;
+ }
+
+ public virtual Task