本文整理匯總了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;
}
});
}
}
示例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;
}
});
}
}