當前位置: 首頁>>代碼示例>>Java>>正文


Java ServiceFilterResponseCallback類代碼示例

本文整理匯總了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);
        }
    });
}
 
開發者ID:Azure,項目名稱:azure-mobile-apps-android-client,代碼行數:26,代碼來源:MobileServiceConnection.java

示例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);
		}
	});
}
 
開發者ID:Azure-Readiness,項目名稱:AndroidCamp,代碼行數:28,代碼來源:ToDoActivity.java

示例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);
		}
	});
}
 
開發者ID:Microsoft,項目名稱:Android-LensRocket,代碼行數:44,代碼來源:LensRocketService.java


注:本文中的com.microsoft.windowsazure.mobileservices.ServiceFilterResponseCallback類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。