当前位置: 首页>>代码示例>>Java>>正文


Java ResultCallback.onResult方法代码示例

本文整理汇总了Java中com.google.android.gms.common.api.ResultCallback.onResult方法的典型用法代码示例。如果您正苦于以下问题:Java ResultCallback.onResult方法的具体用法?Java ResultCallback.onResult怎么用?Java ResultCallback.onResult使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.gms.common.api.ResultCallback的用法示例。


在下文中一共展示了ResultCallback.onResult方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setResultCallback

import com.google.android.gms.common.api.ResultCallback; //导入方法依赖的package包/类
@Override
public void setResultCallback(
        @NonNull final ResultCallback<? super Result> resultCallback) {
    if (!canceled && latch != null) {
        AsyncTask<Object, Object, Void> task = new AsyncTask<Object, Object, Void>() {

            /**
             * Override this method to perform a computation on a background thread. The
             * specified parameters are the parameters passed to {@link #execute}
             * by the caller of this task.
             * <p/>
             * This method can call {@link #publishProgress} to publish updates
             * on the UI thread.
             *
             * @param params The parameters of the task.
             * @return A result, defined by the subclass of this task.
             * @see #onPreExecute()
             * @see #onPostExecute
             * @see #publishProgress
             */
            @Override
            protected Void doInBackground(Object... params) {
                try {
                    latch.await();
                    resultCallback.onResult(new Result() {
                        @Override
                        public com.google.android.gms.common.api.Status getStatus() {
                            return canceled ? Canceled : Success;
                        }
                    });
                } catch (InterruptedException e) {
                    resultCallback.onResult(new Result() {
                        @Override
                        public com.google.android.gms.common.api.Status getStatus() {
                            return Canceled;
                        }
                    });
                }
                return null;
            }
        };
        task.execute(latch);
    } else {
        resultCallback.onResult(new Result() {
            @Override
            public com.google.android.gms.common.api.Status getStatus() {
                return canceled ? Canceled : Success;
            }
        });
    }
}
 
开发者ID:AndreFCruz,项目名称:feup-lpoo-armadillo,代码行数:52,代码来源:SnapshotCoordinator.java

示例2: setResultCallback

import com.google.android.gms.common.api.ResultCallback; //导入方法依赖的package包/类
@Override
public void setResultCallback(
        @NonNull final ResultCallback<? super Result> resultCallback) {
    if (!canceled && latch != null) {
        AsyncTask<Object, Object, Void> task = new AsyncTask<Object, Object, Void>() {

            /**
             * Override this method to perform a computation on a background thread. The
             * specified parameters are the parameters passed to {@link #execute}
             * by the caller of this task.
             * <p/>
             * This method can call {@link #publishProgress} to publish updates
             * on the UI thread.
             *
             * @param params The parameters of the task.
             * @return A result, defined by the subclass of this task.
             * @see #onPreExecute()
             * @see #onPostExecute
             * @see #publishProgress
             */
            @Override
            protected Void doInBackground(Object... params) {
                try {
                    latch.await();
                    resultCallback.onResult(new Result() {
                        @Override
                        public com.google.android.gms.common.api.Status getStatus() {
                            return canceled ? Canceled : Success;
                        }
                    });
                } catch (InterruptedException e) {
                    resultCallback.onResult(new Result() {
                        @Override
                        public com.google.android.gms.common.api.Status getStatus() {
                            return Canceled;
                        }
                    });
                }
                return null;
            }
        };
        task.execute(latch);
    } else {
        resultCallback.onResult(new Result() {
            @Override
            public Status getStatus() {
                return canceled ? Canceled : Success;
            }
        });
    }
}
 
开发者ID:Augugrumi,项目名称:SpaceRace,代码行数:52,代码来源:SnapshotCoordinator.java


注:本文中的com.google.android.gms.common.api.ResultCallback.onResult方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。