chunk 2: remaining non-audio non-NewImport assets
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"name": "Google.Play.Core",
|
||||
"references": [],
|
||||
"includePlatforms": [
|
||||
"Android",
|
||||
"Editor"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b649415412a3d4e8a83df256b07478bb
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5ce086e6077594a2293b3717d002b800
|
||||
folderAsset: yes
|
||||
timeCreated: 1580835047
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 84d31a25d624346459133b65425fd20b
|
||||
folderAsset: yes
|
||||
timeCreated: 1580835047
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright 2019 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
namespace Google.Play.Core.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Mirror of a subset of Activity constants of
|
||||
/// <a href="https://developer.android.com/reference/android/app/Activity.html#constants_2"></a> and
|
||||
/// <a href="https://developer.android.com/reference/com/google/android/play/core/install/model/ActivityResult"></a>.
|
||||
/// </summary>
|
||||
public static class ActivityResult
|
||||
{
|
||||
/// <summary>
|
||||
/// Operation succeeded.
|
||||
/// </summary>
|
||||
public const int ResultOk = -1;
|
||||
|
||||
/// <summary>
|
||||
/// Operation cancelled.
|
||||
/// </summary>
|
||||
public const int ResultCancelled = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Operation for In-app update failed.
|
||||
/// </summary>
|
||||
public const int ResultFailed = 1;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8879ad8a300b4bde86c4f579dfede0d2
|
||||
timeCreated: 1566858727
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2019 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
namespace Google.Play.Core.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of constants used for interfacing with the Play Core library.
|
||||
/// </summary>
|
||||
public static class PlayCoreConstants
|
||||
{
|
||||
public const string PlayCorePackagePrefix = "com.google.android.play.core.";
|
||||
public const string GmsCorePackagePrefix = "com.google.android.gms.";
|
||||
public const string AssetPackPackagePrefix = PlayCorePackagePrefix + "assetpacks.";
|
||||
public const string IntegrityPackagePrefix = PlayCorePackagePrefix + "integrity.";
|
||||
public const int InternalErrorCode = -100;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e622666acb2d4781a7584f92b9a2b2e
|
||||
timeCreated: 1549654052
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,98 @@
|
||||
// Copyright 2019 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Google.Play.Core.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Callbacks from Play Core can come from multiple threads.
|
||||
/// This class provides methods to forward those to Unity's main thread, where Unity APIs can be called.
|
||||
/// </summary>
|
||||
public class PlayCoreEventHandler : MonoBehaviour
|
||||
{
|
||||
private static PlayCoreEventHandler _instance;
|
||||
|
||||
// This must be called from Main thread.
|
||||
public static void CreateInScene()
|
||||
{
|
||||
var obj = new GameObject {name = "PlayCoreEventHandler"};
|
||||
DontDestroyOnLoad(obj);
|
||||
obj.AddComponent<PlayCoreEventHandler>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Schedules an action to invoke on Unity's main thread.
|
||||
/// </summary>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// If there is no instance of PlayCoreEventHandler present in the scene, either because CreateInScene() was
|
||||
/// never called or because the instance was somehow destroyed.
|
||||
/// </exception>
|
||||
public static void HandleEvent(Action action)
|
||||
{
|
||||
if (_instance == null)
|
||||
{
|
||||
throw new InvalidOperationException("An instance of PlayCoreEventHandler is not present in the scene.");
|
||||
}
|
||||
|
||||
_instance.HandleEventInternal(action);
|
||||
}
|
||||
|
||||
// Queue accessed by multiple threads.
|
||||
// Note: ConcurrentQueue isn't available in .NET 3.5.
|
||||
private readonly Queue<Action> _sharedEventQueue = new Queue<Action>();
|
||||
|
||||
// Queue that is only accessed on the main thread.
|
||||
private readonly Queue<Action> _localEventQueue = new Queue<Action>();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (_instance != null)
|
||||
{
|
||||
Destroy(this);
|
||||
return;
|
||||
}
|
||||
|
||||
_instance = this;
|
||||
}
|
||||
|
||||
private void HandleEventInternal(Action action)
|
||||
{
|
||||
lock (_sharedEventQueue)
|
||||
{
|
||||
_sharedEventQueue.Enqueue(action);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
lock (_sharedEventQueue)
|
||||
{
|
||||
while (_sharedEventQueue.Count > 0)
|
||||
{
|
||||
var action = _sharedEventQueue.Dequeue();
|
||||
_localEventQueue.Enqueue(action);
|
||||
}
|
||||
}
|
||||
|
||||
// Invoke events outside of the lock because they may take an indeterminate amount of time.
|
||||
while (_localEventQueue.Count > 0)
|
||||
{
|
||||
_localEventQueue.Dequeue().Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 051d5ab221b254fb3bb403a4eaae0df9
|
||||
timeCreated: 1555349623
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,96 @@
|
||||
// Copyright 2019 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Google.Play.Core.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// A collection of helper methods for interfacing with the Play Core library.
|
||||
/// </summary>
|
||||
public static class PlayCoreHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts the specified AndroidJavaObject representing a "java.util.List" into a C# List.
|
||||
/// </summary>
|
||||
/// <typeparam name="TAndroidJava">
|
||||
/// The type of the objects in the returned list.
|
||||
/// Must be a primitive type or an AndroidJavaObject.
|
||||
/// </typeparam>
|
||||
/// <returns>A List with the contents of the provided Java list</returns>
|
||||
public static List<TAndroidJava> ConvertJavaList<TAndroidJava>(AndroidJavaObject javaList)
|
||||
{
|
||||
var count = javaList.Call<int>("size");
|
||||
|
||||
var results = new List<TAndroidJava>();
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
results.Add(javaList.Call<TAndroidJava>("get", i));
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the specified AndroidJavaObject representing a "java.util.Map" into a C# Dictionary.
|
||||
/// </summary>
|
||||
/// <typeparam name="TAndroidJavaKey">
|
||||
/// The type of the keys in the returned dictionary.
|
||||
/// Must be a primitive type or an AndroidJavaObject.
|
||||
/// </typeparam>
|
||||
/// <typeparam name="TAndroidJavaValue">
|
||||
/// The type of the values in the returned dictionary.
|
||||
/// Must be a primitive type or an AndroidJavaObject.
|
||||
/// </typeparam>
|
||||
/// <returns>A Dictionary with the contents of the provided Java map</returns>
|
||||
public static Dictionary<TAndroidJavaKey, TAndroidJavaValue> ConvertJavaMap<TAndroidJavaKey, TAndroidJavaValue>(
|
||||
AndroidJavaObject javaMap)
|
||||
{
|
||||
using (var entrySet = javaMap.Call<AndroidJavaObject>("entrySet"))
|
||||
using (var entrySetIterator = entrySet.Call<AndroidJavaObject>("iterator"))
|
||||
{
|
||||
var results = new Dictionary<TAndroidJavaKey, TAndroidJavaValue>();
|
||||
while (entrySetIterator.Call<bool>("hasNext"))
|
||||
{
|
||||
using (var entry = entrySetIterator.Call<AndroidJavaObject>("next"))
|
||||
{
|
||||
var key = entry.Call<TAndroidJavaKey>("getKey");
|
||||
var value = entry.Call<TAndroidJavaValue>("getValue");
|
||||
results.Add(key, value);
|
||||
}
|
||||
}
|
||||
|
||||
return results;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts the specified AndroidJavaObject representing a "java.lang.String" into a C# string.
|
||||
/// </summary>
|
||||
public static string ConvertJavaString(AndroidJavaObject javaString)
|
||||
{
|
||||
return IsNull(javaString) ? null : javaString.Call<string>("toString");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the specified <see cref="AndroidJavaObject"/> is null or if the underlying Java object is
|
||||
/// null, false otherwise.
|
||||
/// </summary>
|
||||
public static bool IsNull(AndroidJavaObject javaObject)
|
||||
{
|
||||
return javaObject == null || javaObject.GetRawObject().ToInt32() == 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: eeadf4c79cb514f2c9b8a924b97d4b60
|
||||
timeCreated: 1550793799
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
// Copyright 2019 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Google.Play.Core.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Proxy for Play Core's OnFailureListener class.
|
||||
/// Allows C# classes to be alerted when a Play Core Task throws an exception.
|
||||
/// </summary>
|
||||
public class PlayCoreOnFailureListener : AndroidJavaProxy
|
||||
{
|
||||
public event Action<string, int> OnTaskFailed = delegate { };
|
||||
|
||||
public PlayCoreOnFailureListener() : base(PlayCoreConstants.PlayCorePackagePrefix + "tasks.OnFailureListener")
|
||||
{
|
||||
}
|
||||
|
||||
// Proxied java calls. Method names are camelCase to match the corresponding java methods.
|
||||
public void onFailure(AndroidJavaObject exception)
|
||||
{
|
||||
var message = exception.Call<string>("getMessage");
|
||||
|
||||
int errorCode;
|
||||
try
|
||||
{
|
||||
// If exception is not a TaskException, this call will throw an AndroidJavaException.
|
||||
errorCode = exception.Call<int>("getErrorCode");
|
||||
}
|
||||
catch (AndroidJavaException)
|
||||
{
|
||||
errorCode = PlayCoreConstants.InternalErrorCode;
|
||||
}
|
||||
|
||||
PlayCoreEventHandler.HandleEvent(() => OnTaskFailed.Invoke(message, errorCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 637ec35fe288545c4b13d394a08a0c70
|
||||
timeCreated: 1549660839
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright 2019 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Google.Play.Core.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Proxy for Play Core's OnSuccessListener class.
|
||||
/// Allows C# classes to be alerted when a Play Core Task succeeds, and to get the result of that Task.
|
||||
/// </summary>
|
||||
/// <typeparam name="TAndroidJava">
|
||||
/// The return type of the proxied Play Core Task.
|
||||
/// Must be a primitive type (e.g. bool, int, or float) or an AndroidJavaObject.
|
||||
/// </typeparam>
|
||||
public class PlayCoreOnSuccessListener<TAndroidJava> : AndroidJavaProxy
|
||||
{
|
||||
/// <summary>
|
||||
/// Triggers when the associated Play Core Task succeeds.
|
||||
/// </summary>
|
||||
public event Action<TAndroidJava> OnTaskSucceeded = delegate { };
|
||||
|
||||
public PlayCoreOnSuccessListener() : base(PlayCoreConstants.PlayCorePackagePrefix + "tasks.OnSuccessListener")
|
||||
{
|
||||
}
|
||||
|
||||
// Proxied java calls. Method names are camelCase to match the corresponding java methods.
|
||||
public void onSuccess(TAndroidJava result)
|
||||
{
|
||||
PlayCoreEventHandler.HandleEvent(() => OnTaskSucceeded.Invoke(result));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fef4772d6fe7446e9a4dcfabf3ea9e74
|
||||
timeCreated: 1549660825
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,85 @@
|
||||
// Copyright 2019 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Google.Play.Core.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Wraps Play Services Task which represent asynchronous operations.
|
||||
/// Allows C# classes to register callbacks for when a task succeeds or fails.
|
||||
/// </summary>
|
||||
/// <typeparam name="TAndroidJava">
|
||||
/// The type of the object that the underlying Play Services Task will provide, once it completes.
|
||||
/// Must be a primitive type (e.g. bool, int, or float) or an AndroidJavaObject.
|
||||
/// </typeparam>
|
||||
public class PlayServicesTask<TAndroidJava> : IDisposable
|
||||
{
|
||||
private readonly AndroidJavaObject _javaTask;
|
||||
|
||||
public PlayServicesTask(AndroidJavaObject javaTask)
|
||||
{
|
||||
if (javaTask == null)
|
||||
{
|
||||
throw new ArgumentNullException("javaTask must not be null.");
|
||||
}
|
||||
|
||||
_javaTask = javaTask;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register a callback that will fire when the underlying Play Services Task succeeds.
|
||||
/// </summary>
|
||||
/// <param name="onSuccess">
|
||||
/// The action that will be invoked with the result of the underlying Play Services Task.
|
||||
/// </param>
|
||||
public void RegisterOnSuccessCallback(Action<TAndroidJava> onSuccess)
|
||||
{
|
||||
var listenerProxy = new TaskOnSuccessListener<TAndroidJava>();
|
||||
listenerProxy.OnTaskSucceeded += onSuccess;
|
||||
AddOnSuccessListener(listenerProxy);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Register a callback that will fire when the underlying Play Services Task fails.
|
||||
/// </summary>
|
||||
/// <param name="onFailure">
|
||||
/// The action that will be invoked when the underlying Play Services Task fails.
|
||||
/// The action will be passed a human-readable string describing the exception which caused the failure,
|
||||
/// along with a corresponding error code.
|
||||
/// </param>
|
||||
public void RegisterOnFailureCallback(Action<string, int> onFailure)
|
||||
{
|
||||
var listenerProxy = new TaskOnFailureListener();
|
||||
listenerProxy.OnTaskFailed += onFailure;
|
||||
AddOnFailureListener(listenerProxy);
|
||||
}
|
||||
|
||||
private void AddOnSuccessListener(AndroidJavaProxy listenerProxy)
|
||||
{
|
||||
_javaTask.Call<AndroidJavaObject>("addOnSuccessListener", listenerProxy).Dispose();
|
||||
}
|
||||
|
||||
private void AddOnFailureListener(AndroidJavaProxy listenerProxy)
|
||||
{
|
||||
_javaTask.Call<AndroidJavaObject>("addOnFailureListener", listenerProxy).Dispose();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_javaTask.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9afdeebfe3f48029a48abd58942c338
|
||||
timeCreated: 1641857795
|
||||
@@ -0,0 +1,52 @@
|
||||
// Copyright 2019 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Google.Play.Core.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Proxy for Play Services Task's OnFailureListener class.
|
||||
/// Allows C# classes to be alerted when a Play Core Task throws an exception.
|
||||
/// </summary>
|
||||
public class TaskOnFailureListener : AndroidJavaProxy
|
||||
{
|
||||
public event Action<string, int> OnTaskFailed = delegate { };
|
||||
|
||||
public TaskOnFailureListener() : base(PlayCoreConstants.GmsCorePackagePrefix + "tasks.OnFailureListener")
|
||||
{
|
||||
}
|
||||
|
||||
// Proxied java calls. Method names are camelCase to match the corresponding java methods.
|
||||
public void onFailure(AndroidJavaObject exception)
|
||||
{
|
||||
var message = exception.Call<string>("getMessage");
|
||||
|
||||
int errorCode;
|
||||
try
|
||||
{
|
||||
// If exception object doesn't provide getErrorCode method, this call will throw an
|
||||
// AndroidJavaException.
|
||||
errorCode = exception.Call<int>("getErrorCode");
|
||||
}
|
||||
catch (AndroidJavaException)
|
||||
{
|
||||
errorCode = PlayCoreConstants.InternalErrorCode;
|
||||
}
|
||||
|
||||
PlayCoreEventHandler.HandleEvent(() => OnTaskFailed.Invoke(message, errorCode));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28db08947f4640aebf4a5f1c15012e4a
|
||||
timeCreated: 1641857543
|
||||
@@ -0,0 +1,45 @@
|
||||
// Copyright 2019 Google LLC
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// https://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Google.Play.Core.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Proxy for Play Services Task's OnSuccessListener class.
|
||||
/// Allows C# classes to be alerted when a Play Core Task succeeds, and to get the result of that Task.
|
||||
/// </summary>
|
||||
/// <typeparam name="TAndroidJava">
|
||||
/// The return type of the proxied Play Core Task.
|
||||
/// Must be a primitive type (e.g. bool, int, or float) or an AndroidJavaObject.
|
||||
/// </typeparam>
|
||||
public class TaskOnSuccessListener<TAndroidJava> : AndroidJavaProxy
|
||||
{
|
||||
/// <summary>
|
||||
/// Triggers when the associated Play Core Task succeeds.
|
||||
/// </summary>
|
||||
public event Action<TAndroidJava> OnTaskSucceeded = delegate { };
|
||||
|
||||
public TaskOnSuccessListener() : base(PlayCoreConstants.GmsCorePackagePrefix + "tasks.OnSuccessListener")
|
||||
{
|
||||
}
|
||||
|
||||
// Proxied java calls. Method names are camelCase to match the corresponding java methods.
|
||||
public void onSuccess(TAndroidJava result)
|
||||
{
|
||||
PlayCoreEventHandler.HandleEvent(() => OnTaskSucceeded.Invoke(result));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: edce53eedcfb478f9738baa1e4a54319
|
||||
timeCreated: 1641857602
|
||||
Reference in New Issue
Block a user