当前位置: 首页>>代码示例>>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;未经允许,请勿转载。