コード例 #1
0
        private void AddBackgroundJob(Action execute, Action callback, AndroidCallback androidCallback)
        {
            AndroidJob job = new AndroidJob(
                action: execute,
                androidCallback: androidCallback,
                callback: callback);

            backgroundJobs.Enqueue(job);
            Dequeue();
        }
コード例 #2
0
        public void SaveToGallery(byte[] image, Action <string> callback)
        {
            AndroidCallback androidCallback = new AndroidCallback();

            AddBackgroundJob(
                execute: () => androidGallery.CallStatic("SaveToGallery", image, context, androidCallback),
                callback: () =>
            {
                Debug.Log($"AndroidGallery finished SaveToGallery call with result {androidCallback.Result}");
                callback(androidCallback.Result);
            },
                androidCallback: androidCallback);
        }
コード例 #3
0
        // TODO: AT - this is actually save photo in app the returns the image
        // need to refactor name and hard coded path
        // we can load the photo using the Database
        public void LoadPhoto(string uri, Action <Texture2D> callback)
        {
            AndroidCallback androidCallback = new AndroidCallback();

            AddBackgroundJob(
                execute: () => androidGallery.CallStatic("CallLoadPhoto", uri, context, androidCallback),
                callback: () =>
            {
                Debug.Log($"AndroidGallery finished LoadPhoto call with result {androidCallback.Result}");
                androidCallbackHelper.StartCoroutine(GetTexture(androidCallback.Result, callback));
            },
                androidCallback: androidCallback);
        }
コード例 #4
0
        public void SelectPhotoPath(Action <string> callback)
        {
            AndroidCallback androidCallback = new AndroidCallback();

            AddForegroundJob(
                execute: () => androidGallery.CallStatic("CallPickPhoto", context, androidCallback),
                callback: () =>
            {
                Debug.Log($"AndroidGallery finished SelectPhotoPath call with result {androidCallback.Result}");
                callback(androidCallback.Result);
            },
                androidCallback: androidCallback);
        }
コード例 #5
0
        private void AddForegroundJob(Action execute, Action callback, AndroidCallback androidCallback)
        {
            if (CurrentBackgroundJob != null && !CurrentForegroundJob.CallbackCalled)
            {
                Debug.LogError("AndroidPhotoGallery: There can only be one foreground task at a time");
                return;
            }
            ;
            AndroidJob job = new AndroidJob(
                action: execute,
                androidCallback: androidCallback,
                callback: callback);

            CurrentForegroundJob = job;
            job.Execute();
        }
コード例 #6
0
 public AndroidJob(Action action, AndroidCallback androidCallback, Action callback)
 {
     this.androidCallback = androidCallback;
     this.action          = action;
     this.callback        = callback;
 }