Exemple #1
0
        /// <summary>
        /// An internal implementation that obtains an <see cref="AndroidJavaObject"/> of AppUpdateInfo from Play Core
        /// Java's getAppUpdateInfo() method and converts it to an internal <see cref="AppUpdateInfo"/>.
        /// </summary>
        /// <returns>
        /// A <see cref="PlayAsyncOperation{AppUpdateInfo, AppUpdateErrorCode}"/> that
        /// returns <see cref="AppUpdateInfo"/> on successful callback
        /// or returns <see cref="AppUpdateErrorCode"/> on failure callback.
        /// </returns>
        public PlayAsyncOperation <AppUpdateInfo, AppUpdateErrorCode> GetAppUpdateInfoInternal()
        {
            var appUpdateAsyncOperation = new AppUpdateAsyncOperation <AppUpdateInfo>();
            var appUpdateInfoTask       = GetAppUpdateInfo();

            appUpdateInfoTask.RegisterOnSuccessCallback(javaUpdateInfo =>
            {
                appUpdateAsyncOperation.SetResult(new AppUpdateInfo(javaUpdateInfo));
                appUpdateInfoTask.Dispose();
            });
            appUpdateInfoTask.RegisterOnFailureCallback((reason, errorCode) =>
            {
                appUpdateAsyncOperation.SetError(AppUpdatePlayCoreTranslator.TranslatePlayCoreErrorCode(errorCode));
                appUpdateInfoTask.Dispose();
            });
            return(appUpdateAsyncOperation);
        }
Exemple #2
0
        /// <summary>
        /// An internal implementation that wraps Play Core Java's completeUpdate() method that triggers the completion
        /// of the update for a flexible update flow.
        /// </summary>
        /// <returns>
        /// A <see cref="PlayAsyncOperation{VoidResult, AppUpdateErrorCode}"/> that returns an
        /// <see cref="AppUpdateErrorCode"/> on failure.
        /// If the update succeeds, the app restarts and this callback never fires.
        /// </returns>
        public PlayAsyncOperation <VoidResult, AppUpdateErrorCode> CompleteUpdateInternal()
        {
            var completeUpdateAsyncOperation = new AppUpdateAsyncOperation <VoidResult>();
            var completeUpdateTask           = _appUpdateManagerPlayCore.CompleteUpdate();

            completeUpdateTask.RegisterOnSuccessCallback(voidResult =>
            {
                completeUpdateAsyncOperation.SetResult(voidResult);
                completeUpdateTask.Dispose();
            });
            completeUpdateTask.RegisterOnFailureCallback((reason, errorCode) =>
            {
                completeUpdateAsyncOperation.SetError(
                    AppUpdatePlayCoreTranslator.TranslatePlayCoreErrorCode(errorCode));
                completeUpdateTask.Dispose();
            });
            return(completeUpdateAsyncOperation);
        }