using System.Collections.Generic;
using Com.Good.GD;
using Android.Util;
namespace Example.Droid
{
public class GDEventListener : Java.Lang.Object, IGDAppEventListener
{
private static GDEventListener _instance;
private bool _started;
string tag = "GDEventListener";
public static GDEventListener Instance
{
get
{
if (_instance == null)
{
_instance = new GDEventListener();
}
return _instance;
}
}
public void OnGDEvent(GDAppEvent anEvent)
{
if (anEvent.EventType == GDAppEventType.GDAppEventAuthorized)
{
OnAuthorized(anEvent);
}
else if (anEvent.EventType == GDAppEventType.GDAppEventNotAuthorized)
{
OnNotAuthorized(anEvent);
}
else if (anEvent.EventType == GDAppEventType.GDAppEventRemoteSettingsUpdate)
{
//handle app config changes
...
}
else if (anEvent.EventType == GDAppEventType.GDAppEventServicesUpdate)
{
//handle event service update
...
}
else if (anEvent.EventType == GDAppEventType.GDAppEventEntitlementsUpdate)
{
//handle event entitlement update
...
}
else
{
Log.Info(tag, "Unhandled GDEvent " + anEvent.EventType);
}
}
private void OnNotAuthorized(GDAppEvent anEvent)
{
GDAppResultCode code = anEvent.ResultCode;
if (code == GDAppResultCode.GDErrorActivationFailed ||
code == GDAppResultCode.GDErrorProvisioningFailed ||
code == GDAppResultCode.GDErrorPushConnectionTimeout ||
code == GDAppResultCode.GDErrorIdleLockout ||
code == GDAppResultCode.GDErrorRemoteLockout ||
code == GDAppResultCode.GDErrorPasswordChangeRequired ||
code == GDAppResultCode.GDErrorSecurityError ||
code == GDAppResultCode.GDErrorBlocked ||
code == GDAppResultCode.GDErrorAppDenied ||
code == GDAppResultCode.GDErrorWiped)
{
Log.Info(tag, "OnNotAuthorized " + anEvent.Message);
}
else if (code == GDAppResultCode.GDErrorIdleLockout)
{
Log.Info(tag, "OnNotAuthorized");
}
else
{
Log.Info(tag, "Unhandled not authorized event");
}
}
private void OnAuthorized(GDAppEvent anEvent)
{
GDAppResultCode code = anEvent.ResultCode;
if (code == GDAppResultCode.GDErrorNone)
{
if (!_started)
{
_started = true;
//Launch app UI Here
...
}
}
else
{
Log.Info(tag, "Authorized startup with an error");
}
}
}
public class GDStateListener : Java.Lang.Object, IGDStateListener
{
private static GDStateListener _instance;
public static GDStateListener Instance
{
get
{
if (_instance == null)
_instance = new GDStateListener();
return _instance;
}
}
public void OnAuthorized()
{
//Handle Authorized
...
}
public void OnLocked()
{
//Handle Locked
...
}
public void OnUpdateConfig(IDictionary<String, Java.Lang.Object> settings)
{
//Handle UpdateConfig
...
}
public void OnUpdatePolicy(IDictionary<String, Java.Lang.Object> policyValues)
{
//Handle UpdatePolicy
...
}
public void OnUpdateServices()
{
//Handle UpdateServices
...
}
public void OnWiped()
{
//Handle Wiped
...
}
public void OnUpdateEntitlements()
{
//Handle Wiped
...
}
}
}