本文整理匯總了Java中com.microsoft.windowsazure.mobileservices.ServiceFilterResponseCallback類的典型用法代碼示例。如果您正苦於以下問題:Java ServiceFilterResponseCallback類的具體用法?Java ServiceFilterResponseCallback怎麽用?Java ServiceFilterResponseCallback使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
ServiceFilterResponseCallback類屬於com.microsoft.windowsazure.mobileservices包,在下文中一共展示了ServiceFilterResponseCallback類的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: start
import com.microsoft.windowsazure.mobileservices.ServiceFilterResponseCallback; //導入依賴的package包/類
/**
* Execute a request-response operation with a Mobile Service
*
* @param request The request to execute
* @param responseCallback Callback to invoke after the request is executed
*/
public void start(final ServiceFilterRequest request, final ServiceFilterResponseCallback responseCallback) {
ListenableFuture<ServiceFilterResponse> startFuture = start(request);
Futures.addCallback(startFuture, new FutureCallback<ServiceFilterResponse>() {
@Override
public void onFailure(Throwable exception) {
if (exception instanceof Exception) {
responseCallback.onResponse(MobileServiceException.getServiceResponse(exception), (Exception) exception);
} else {
responseCallback.onResponse(MobileServiceException.getServiceResponse(exception), new Exception(exception));
}
}
@Override
public void onSuccess(ServiceFilterResponse response) {
responseCallback.onResponse(response, null);
}
});
}
示例2: handleRequest
import com.microsoft.windowsazure.mobileservices.ServiceFilterResponseCallback; //導入依賴的package包/類
@Override
public void handleRequest(ServiceFilterRequest request, NextServiceFilterCallback nextServiceFilterCallback,
final ServiceFilterResponseCallback responseCallback) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (mProgressBar != null) mProgressBar.setVisibility(ProgressBar.VISIBLE);
}
});
nextServiceFilterCallback.onNext(request, new ServiceFilterResponseCallback() {
@Override
public void onResponse(ServiceFilterResponse response, Exception exception) {
runOnUiThread(new Runnable() {
@Override
public void run() {
if (mProgressBar != null) mProgressBar.setVisibility(ProgressBar.GONE);
}
});
if (responseCallback != null) responseCallback.onResponse(response, exception);
}
});
}
示例3: handleRequest
import com.microsoft.windowsazure.mobileservices.ServiceFilterResponseCallback; //導入依賴的package包/類
@Override
public void handleRequest(final ServiceFilterRequest request, final NextServiceFilterCallback nextServiceFilterCallback,
final ServiceFilterResponseCallback responseCallback) {
if (!NetworkUtilities.isNetworkOnline(mContext)) {
getActivityContext().runOnUiThread(new Runnable() {
@Override
public void run() {
LensRocketAlert.showSimpleErrorDialog(getActivityContext(), "You must be connected to the internet for this to work.");
}
});
responseCallback.onResponse(null, new NoNetworkConnectivityException());
return;
}
nextServiceFilterCallback.onNext(request, new ServiceFilterResponseCallback() {
@Override
public void onResponse(ServiceFilterResponse response, Exception ex) {
if (ex == null) {
StatusLine status = response.getStatus();
int statusCode = status.getStatusCode();
if (statusCode == 401) {
//Kick user out
LensRocketLogger.i(TAG, "401 received, forcing logout");
//TODO force logout
}
} else if (ex.getCause() != null) {
if (UnknownHostException.class.isInstance(ex.getCause())) {
LensRocketLogger.e(TAG, "UnknownHost");
getActivityContext().runOnUiThread(new Runnable() {
@Override
public void run() {
LensRocketAlert.showSimpleErrorDialog(getActivityContext(), "You must be connected to the internet for this to work.");
}
});
} else {
LensRocketLogger.e(TAG, "Error in handle request: " + ex.getCause().getMessage());
}
} else
LensRocketLogger.e(TAG, "Error in handle request: " + ex.getMessage());
if (responseCallback != null) responseCallback.onResponse(response, ex);
}
});
}