當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。