Java 类android.accounts.NetworkErrorException 实例源码

项目:account-transfer-api    文件:Authenticator.java   
@Override
public Bundle addAccount(
        AccountAuthenticatorResponse response,
        String accountType,
        String authTokenType,
        String[] requiredFeatures,
        Bundle options)
        throws NetworkErrorException {
    Log.d(TAG, "addAccount");

    final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);

    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}
项目:DOUSalaries    文件:ErrorHandlerHelper.java   
private Throwable getProperException(Throwable throwable)  {
    if (throwable instanceof HttpException) {
        HttpException httpException = (HttpException) throwable;
        Response response = httpException.response();
        String errorBody = null;
        try {
            String error = response.errorBody().string();
            Document htmlFile = Jsoup.parse(error, "ISO-8859-1");
            errorBody = htmlFile.body().text();
            Timber.d("response.errorBody()=%s, errorBody = %s", error, errorBody );
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (errorBody == null ) {
            return getThrowable(response.message(), response.code(), throwable);
        } else {
             return new NounResponseException(errorBody);
        }
    } else if (throwable instanceof IOException) {
        return new InternetConnectionException();
    } else if (throwable instanceof NetworkErrorException) {
        return new InternetConnectionException();
    }
    return throwable;
}
项目:TheNounProject    文件:ErrorHandlerHelper.java   
private Throwable getProperException(Throwable throwable)  {
    if (throwable instanceof HttpException) {
        HttpException httpException = (HttpException) throwable;
        Response response = httpException.response();
        String errorBody = null;
        try {
            String error = response.errorBody().string();
            Document htmlFile = Jsoup.parse(error, "ISO-8859-1");
            errorBody = htmlFile.body().text();
            Timber.d("response.errorBody()=%s, errorBody = %s", error, errorBody );
        } catch (IOException e) {
            e.printStackTrace();
        }
        if (errorBody == null ) {
            return getThrowable(response.message(), response.code(), throwable);
        } else {
             return new NounResponseException(errorBody);
        }
    } else if (throwable instanceof IOException) {
        return new InternetConnectionException();
    } else if (throwable instanceof NetworkErrorException) {
        return new InternetConnectionException();
    }
    return throwable;
}
项目:LaravelNewsApp    文件:Authenticator.java   
@Override
public Bundle addAccount(
        AccountAuthenticatorResponse r,
        String s,
        String s2,
        String[] strings,
        Bundle bundle) throws NetworkErrorException {
    return null;
}
项目:LaravelNewsApp    文件:Authenticator.java   
@Override
public Bundle confirmCredentials(
        AccountAuthenticatorResponse r,
        Account account,
        Bundle bundle) throws NetworkErrorException {
    return null;
}
项目:LaravelNewsApp    文件:Authenticator.java   
@Override
public Bundle getAuthToken(
        AccountAuthenticatorResponse r,
        Account account,
        String s,
        Bundle bundle) throws NetworkErrorException {
    throw new UnsupportedOperationException();
}
项目:LaravelNewsApp    文件:Authenticator.java   
@Override
public Bundle updateCredentials(
        AccountAuthenticatorResponse r,
        Account account,
        String s, Bundle bundle) throws NetworkErrorException {
    throw new UnsupportedOperationException();
}
项目:FBEventSync    文件:Authenticator.java   
@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType,
                         String authTokenType, String[] requiredFeatures, Bundle options) throws NetworkErrorException {
    final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
    intent.setAction(Intent.ACTION_VIEW);
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
    intent.putExtra(AuthenticatorActivity.ARG_AUTH_TOKEN_TYPE, authTokenType);
    intent.putExtra(AuthenticatorActivity.ARG_IS_ADDING_NEW_ACCOUNT, true);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);

    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}
项目:FBEventSync    文件:Authenticator.java   
@Override
public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account,
                          String[] features) throws NetworkErrorException {
    final Bundle result = new Bundle();
    result.putBoolean(AccountManager.KEY_BOOLEAN_RESULT, false);
    return result;
}
项目:Weather-Guru-MVP    文件:ErrorHandlerHelper.java   
public Throwable getProperException(Throwable throwable) {
  if (throwable instanceof HttpException) {
    HttpException httpException = (HttpException) throwable;
    Response response = httpException.response();

    // try to parse the error
    Converter<ResponseBody, DataResponseModel> converter =
        retrofit.responseBodyConverter(DataResponseModel.class, new Annotation[0]);
    DataResponseModel error = null;
    try {
      error = converter.convert(response.errorBody());
    } catch (IOException | JsonSyntaxException e) {
      e.printStackTrace();
    }

    if (error == null || error.getData() == null || error.getData().getError() == null) {
      return getThrowable(response.message(), response.code(), throwable);
    } else {
      return new ParsedResponseException(error.getData().getError().get(0).getMsg());
    }
  } else if (throwable instanceof IOException) {
    return new InternetConnectionException();
  } else if (throwable instanceof NetworkErrorException) {
    return new InternetConnectionException();
  }
  return throwable;
}
项目:PeSanKita-android    文件:AccountAuthenticatorService.java   
@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,
                         String[] requiredFeatures, Bundle options)
    throws NetworkErrorException
{
  return null;
}
项目:Phony-Android    文件:PhonyAuthenticator.java   
@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options) throws NetworkErrorException {
    Log.d(TAG, "addAccount: called.");

    final Intent intent = new Intent(mContext, AuthenticatorActivity.class);
    intent.putExtra(AccountManager.KEY_ACCOUNT_TYPE, accountType);
    intent.putExtra(AuthenticatorActivity.ARG_IS_ADDING_NEW_ACCOUNT, true);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);

    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}
项目:react-native-sync-adapter    文件:DummyAuthenticator.java   
@Override
public Bundle addAccount(
        AccountAuthenticatorResponse r,
        String s,
        String s2,
        String[] strings,
        Bundle bundle) throws NetworkErrorException {
    return null;
}
项目:react-native-sync-adapter    文件:DummyAuthenticator.java   
@Override
public Bundle confirmCredentials(
        AccountAuthenticatorResponse r,
        Account account,
        Bundle bundle) throws NetworkErrorException {
    return null;
}
项目:react-native-sync-adapter    文件:DummyAuthenticator.java   
@Override
public Bundle getAuthToken(
        AccountAuthenticatorResponse r,
        Account account,
        String s,
        Bundle bundle) throws NetworkErrorException {
    throw new UnsupportedOperationException();
}
项目:react-native-sync-adapter    文件:DummyAuthenticator.java   
@Override
public Bundle updateCredentials(
        AccountAuthenticatorResponse r,
        Account account,
        String s, Bundle bundle) throws NetworkErrorException {
    throw new UnsupportedOperationException();
}
项目:AndroidBasicLibs    文件:ApiSubscriber.java   
@Override
public void onStart() {
    super.onStart();
    if (!Network.isConnected(contextWeakReference.get())) {
        onError(new ApiException(new NetworkErrorException(), ApiCode.Request.NETWORK_ERROR));
    }
}
项目:Udacity_Sunshine    文件:SunshineAuthenticator.java   
@Override
public Bundle addAccount(
        AccountAuthenticatorResponse r,
        String s,
        String s2,
        String[] strings,
        Bundle bundle) throws NetworkErrorException {
    return null;
}
项目:Udacity_Sunshine    文件:SunshineAuthenticator.java   
@Override
public Bundle confirmCredentials(
        AccountAuthenticatorResponse r,
        Account account,
        Bundle bundle) throws NetworkErrorException {
    return null;
}
项目:Udacity_Sunshine    文件:SunshineAuthenticator.java   
@Override
public Bundle getAuthToken(
        AccountAuthenticatorResponse r,
        Account account,
        String s,
        Bundle bundle) throws NetworkErrorException {
    throw new UnsupportedOperationException();
}
项目:Udacity_Sunshine    文件:SunshineAuthenticator.java   
@Override
public Bundle updateCredentials(
        AccountAuthenticatorResponse r,
        Account account,
        String s, Bundle bundle) throws NetworkErrorException {
    throw new UnsupportedOperationException();
}
项目:FuelUp    文件:Authenticator.java   
@Override
public Bundle addAccount(
        AccountAuthenticatorResponse r,
        String s,
        String s2,
        String[] strings,
        Bundle bundle) throws NetworkErrorException {
    return null;
}
项目:FuelUp    文件:Authenticator.java   
@Override
public Bundle confirmCredentials(
        AccountAuthenticatorResponse r,
        Account account,
        Bundle bundle) throws NetworkErrorException {
    return null;
}
项目:FuelUp    文件:Authenticator.java   
@Override
public Bundle getAuthToken(
        AccountAuthenticatorResponse r,
        Account account,
        String s,
        Bundle bundle) throws NetworkErrorException {
    throw new UnsupportedOperationException();
}
项目:FuelUp    文件:Authenticator.java   
@Override
public Bundle updateCredentials(
        AccountAuthenticatorResponse r,
        Account account,
        String s, Bundle bundle) throws NetworkErrorException {
    throw new UnsupportedOperationException();
}
项目:ChatExchange-old    文件:Authenticator.java   
@Override
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle options) throws NetworkErrorException
{
    AccountManager accountManager = AccountManager.get(mContext);
    String authToken = accountManager.peekAuthToken(account, authTokenType);
    if (!authToken.isEmpty())
    {
        Bundle bundle = new Bundle();
        bundle.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
        bundle.putString(AccountManager.KEY_AUTHTOKEN, authToken);
        return bundle;
    }
    return newAccount(response);
}
项目:KTools    文件:BaseApi.java   
protected Service createProxyService(final Service service) {
    Class<Service> serviceClass = getServiceClass();
    return (Service) Proxy.newProxyInstance(serviceClass.getClassLoader(), new Class[]{serviceClass}, new InvocationHandler() {
        @Override
        public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
            if (NetworkUtils.isNetAvailable()) {
                return ((Flowable) method.invoke(service, args)).subscribeOn(Schedulers.io());
            } else {
                return Flowable.error(new NetworkErrorException()).subscribeOn(Schedulers.io());
            }
        }
    });
}
项目:Cable-Android    文件:AccountAuthenticatorService.java   
@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,
                         String[] requiredFeatures, Bundle options)
    throws NetworkErrorException
{
  return null;
}
项目:leoapp-sources    文件:StubAuthenticator.java   
@Override
public Bundle addAccount(
        AccountAuthenticatorResponse r,
        String s,
        String s2,
        String[] strings,
        Bundle bundle) throws NetworkErrorException {
    return null;
}
项目:leoapp-sources    文件:StubAuthenticator.java   
@Override
public Bundle confirmCredentials(
        AccountAuthenticatorResponse r,
        Account account,
        Bundle bundle) throws NetworkErrorException {
    return null;
}
项目:leoapp-sources    文件:StubAuthenticator.java   
@Override
public Bundle getAuthToken(
        AccountAuthenticatorResponse r,
        Account account,
        String s,
        Bundle bundle) throws NetworkErrorException {
    throw new UnsupportedOperationException();
}
项目:leoapp-sources    文件:StubAuthenticator.java   
@Override
public Bundle updateCredentials(
        AccountAuthenticatorResponse r,
        Account account,
        String s,
        Bundle bundle) throws NetworkErrorException {
    throw new UnsupportedOperationException();
}
项目:FastLib    文件:BaseRepository.java   
/**
 * @param observable 用于解析 统一返回实体统一做相应的错误码--如登录失效
 * @param <T>
 * @return
 */
protected <T> Observable<T> transform(Observable<BaseEntity<T>> observable) {
    return FastTransformer.switchSchedulers(observable)
            .flatMap(new Function<BaseEntity<T>, ObservableSource<T>>() {
                @Override
                public ObservableSource<T> apply(@NonNull BaseEntity<T> result) throws Exception {
                    if (result == null) {
                        return Observable.error(new NetworkErrorException());
                    } else {
                        return Observable.just(result.data);
                    }
                }
            });
}
项目:TVGuide    文件:TvGuideAuthenticator.java   
@Override
public Bundle addAccount(
        AccountAuthenticatorResponse r,
        String s,
        String s2,
        String[] strings,
        Bundle bundle) throws NetworkErrorException {
    return null;
}
项目:TVGuide    文件:TvGuideAuthenticator.java   
@Override
public Bundle confirmCredentials(
        AccountAuthenticatorResponse r,
        Account account,
        Bundle bundle) throws NetworkErrorException {
    return null;
}
项目:TVGuide    文件:TvGuideAuthenticator.java   
@Override
public Bundle getAuthToken(
        AccountAuthenticatorResponse r,
        Account account,
        String s,
        Bundle bundle) throws NetworkErrorException {
    throw new UnsupportedOperationException();
}
项目:TVGuide    文件:TvGuideAuthenticator.java   
@Override
public Bundle updateCredentials(
        AccountAuthenticatorResponse r,
        Account account,
        String s, Bundle bundle) throws NetworkErrorException {
    throw new UnsupportedOperationException();
}
项目:EasyAppleSyncAdapter    文件:ICalAuthenticator.java   
@Override
public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType,
                         String[] requiredFeatures, Bundle options) throws NetworkErrorException {
    final Intent intent = new Intent(context, loginActivity);
    intent.putExtra(GlobalConstant.ACCOUNT_TYPE, accountType);
    intent.putExtra(GlobalConstant.AUTH_TYPE, authTokenType);
    intent.putExtra(IS_ADDING_NEW_ACCOUNT, true);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}
项目:EasyAppleSyncAdapter    文件:ICalAuthenticator.java   
@Override
public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType,
                           Bundle options) throws NetworkErrorException {
    final AccountManager am = AccountManager.get(context);
    String authToken = am.peekAuthToken(account, authTokenType);

    // get new token if there is no one
    if (TextUtils.isEmpty(authToken)) {
        String password = am.getPassword(account);
        if (password != null) {
            try {
                password = Crypto.armorDecrypt(password, context);
                authToken = serverHandler.userSignIn(account.name, password);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    // there is new token, return it
    if (!TextUtils.isEmpty(authToken)) {
        final Bundle result = new Bundle();
        result.putString(AccountManager.KEY_ACCOUNT_NAME, account.name);
        result.putString(AccountManager.KEY_ACCOUNT_TYPE, account.type);
        result.putString(AccountManager.KEY_AUTHTOKEN, authToken);
        return result;
    }

    // no token and no password, show login screen
    final Intent intent = new Intent(context, loginActivity);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
    intent.putExtra(GlobalConstant.ACCOUNT_TYPE, account.type);
    intent.putExtra(GlobalConstant.ACCOUNT_NAME, account.name);
    intent.putExtra(IS_ADDING_NEW_ACCOUNT, false);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
}
项目:EasyAppleSyncAdapter    文件:ICalAuthenticator.java   
@Override
public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features)
        throws NetworkErrorException {
    final Bundle result = new Bundle();
    result.putBoolean(KEY_BOOLEAN_RESULT, false);
    return result;
}