Java 类retrofit.client.Response 实例源码

项目:android-instant-apps    文件:PhotoService.java   
public void getPhotosAsync(final PhotoCallback callback) {
    if (mPhotos == null) {
        new RestAdapter.Builder()
                .setEndpoint(UnsplashService.ENDPOINT)
                .build()
                .create(UnsplashService.class).getFeed(new Callback<List<Photo>>() {
            @Override
            public void success(List<Photo> photos, Response response) {
                // the first items not interesting to us, get the last <n>
                mPhotos = new ArrayList<>(photos.subList(photos.size() - PHOTO_COUNT,
                        photos.size()));
                callback.success(mPhotos);
            }

            @Override
            public void failure(RetrofitError error) {
                callback.error();
                Log.e(TAG, "Could not load photos, " + error);
            }
        });
    } else {
        callback.success(mPhotos);
    }
}
项目:MADBike    文件:MADBikeNotificationOpenedHandler.java   
private void sendRequestOpenedPush(OSNotificationOpenResult result) {
    RestAdapter retrofit = new RestAdapter.Builder()
            .setEndpoint("https://onesignal.com/api/v1/")
            .build();

    OneSignalApi service = retrofit.create(OneSignalApi.class);
    service.openedOneSignalPush(String.valueOf(result.notification.androidNotificationId), new OneSignalBody(), new Callback<OneSignalResponse>() {
        @Override
        public void success(OneSignalResponse oneSignalResponse, Response response) {
            Log.d("RETROFIT", "Is success:" + oneSignalResponse.isSuccess());
        }

        @Override
        public void failure(RetrofitError error) {
            Log.e("RETROFIT", error.toString());
        }
    });
}
项目:MADBike    文件:PostWeatherInteractor.java   
@Override
public void execute() throws Throwable {
    RestAdapter restAdapter = new RestAdapter.Builder().setEndpoint(context.getString(R.string.weather_url)).build();
    Apis apis = restAdapter.create(Apis.class);
    apis.getWeatherData(6359304, Locale.getDefault().getLanguage(), "metric", "43cd5e05d25e37bdffbad27e42619e3f", new Callback<WeatherResponse>() {
        @Override
        public void success(WeatherResponse weatherResponse, Response response) {
            EventBus.getDefault().post(weatherResponse);
        }

        @Override
        public void failure(RetrofitError error) {
            EventBus.getDefault().post(new WeatherResponse());
        }
    });

}
项目:owa-notifier    文件:OutlookService.java   
@GET("/v1.0/me/mailfolders/{folderid}/messages")
Response getMessages(
  @Path("folderid") String folderId,
  @Query("$orderby") String orderBy,
  @Query("$select") String select,
  @Query("$filter") String filter,
  @Query("$top") Integer maxResults
);
项目:Hello-Music-droid    文件:LastFmClient.java   
public void getUserLoginInfo(UserLoginQuery userLoginQuery, final UserListener listener) {
    mUserRestService.getUserLoginInfo(UserLoginQuery.Method, JSON, API_KEY, generateMD5(userLoginQuery.getSignature()), userLoginQuery.mUsername, userLoginQuery.mPassword, new Callback<UserLoginInfo>() {
        @Override
        public void success(UserLoginInfo userLoginInfo, Response response) {
            Log.d("Logedin", userLoginInfo.mSession.mToken + " " + userLoginInfo.mSession.mUsername);
            Bundle extras = new Bundle();
            extras.putString("lf_token", userLoginInfo.mSession.mToken);
            extras.putString("lf_user", userLoginInfo.mSession.mUsername);
            PreferencesUtility.getInstance(context).updateService(extras);
            mUserSession = userLoginInfo.mSession;
            mUserSession.update(context);
            listener.userSuccess();
        }

        @Override
        public void failure(RetrofitError error) {
            listener.userInfoFailed();
        }
    });
}
项目:Expert-Android-Programming    文件:ProfilePhotoFragment.java   
private void getUserReviews() {

        RetroInterface.getZomatoRestApi().getUserPhotos(
                user_id,
                new Callback<RestaurantImageResponse>() {
                    @Override
                    public void success(RestaurantImageResponse restaurantImageResponse, Response response) {

                        if(restaurantImageResponse!=null)
                        {
                            restaurantImages = restaurantImageResponse.getItems();
                            profileRestaurantImageAdapter.refresh(restaurantImages);
                        }

                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );


    }
项目:Expert-Android-Programming    文件:ProfileDinelineFragment.java   
private void getUserReviews() {

        RetroInterface.getZomatoRestApi().getUserDineline(
                user_id,
                new Callback<DinelineResponse>() {
                    @Override
                    public void success(DinelineResponse dinelineResponse, Response response) {

                        if (dinelineResponse != null) {
                            dinelineItems = dinelineResponse.getItems();
                            profileDinelineAdapter.refresh(dinelineItems);
                        }

                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );


    }
项目:Expert-Android-Programming    文件:ProfileReviewFragment.java   
private void getUserReviews() {

        RetroInterface.getZomatoRestApi().getUserReviews(
                user_id,
                new Callback<ProfileReviewResponse>() {
                    @Override
                    public void success(ProfileReviewResponse restaurantDetailResponse, Response response) {

                        if(restaurantDetailResponse!=null)
                        {
                            reviewItems = restaurantDetailResponse.getItems();
                            reviewAdapter.refresh(reviewItems);
                        }

                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );


    }
项目:Expert-Android-Programming    文件:SavedCollectionFragment.java   
private void getAllCollections() {

        RetroInterface.getZomatoRestApi().getSavedCollection(
                SessionPreference.getUserId(context) + "",
                new Callback<CollectionResponse>() {
                    @Override
                    public void success(CollectionResponse collectionResponse, Response response) {

                        if (collectionResponse != null && collectionResponse.isSuccess()) {
                            items = collectionResponse.getItems();
                            recyclerViewAdapter.refresh(items);
                        }
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );

    }
项目:Expert-Android-Programming    文件:SuggestedCollectionFragment.java   
private void getAllCollections() {

        RetroInterface.getZomatoRestApi().getRecommendedCollection(
                SessionPreference.getUserId(context) + "",
                new Callback<CollectionResponse>() {
                    @Override
                    public void success(CollectionResponse collectionResponse, Response response) {

                        if(collectionResponse!=null && collectionResponse.isSuccess()){
                            items = collectionResponse.getItems();
                            recyclerViewAdapter.refresh(items);
                        }

                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );

    }
项目:Expert-Android-Programming    文件:MyCollectionFragment.java   
private void getAllCollections() {

        RetroInterface.getZomatoRestApi().getMyCollection(
                SessionPreference.getUserId(context) + "",
                new Callback<CollectionResponse>() {
                    @Override
                    public void success(CollectionResponse collectionResponse, Response response) {

                        if(collectionResponse!=null && collectionResponse.isSuccess()){
                            items = collectionResponse.getItems();
                            recyclerViewAdapter.refresh(items);
                        }
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );

    }
项目:Expert-Android-Programming    文件:FollowingCollectionFragment.java   
private void getAllCollections() {

        RetroInterface.getZomatoRestApi().getFollowCollection(
                SessionPreference.getUserId(context) + "",
                new Callback<CollectionResponse>() {
                    @Override
                    public void success(CollectionResponse collectionResponse, Response response) {

                        if(collectionResponse!=null && collectionResponse.isSuccess()){
                            items = collectionResponse.getItems();
                            recyclerViewAdapter.refresh(items);
                        }
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );

    }
项目:Expert-Android-Programming    文件:SelectLocationActivity.java   
private void updateLocation(final UserLocation location) {

        RetroInterface.getZomatoRestApi().setUserLocation(
                SessionPreference.getUserId(context) + "",
                location.getId() + "",
                new Callback<NormalResponse>() {
                    @Override
                    public void success(NormalResponse normalResponse, Response response) {
                        LocationPreference.setLocationParams(context, location);
                        finish();
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );
    }
项目:Expert-Android-Programming    文件:SelectLocationActivity.java   
private void getRecentLocations() {

        RetroInterface.getZomatoRestApi().getPopularLocation(
                "",
                new Callback<UserLocationResponse>() {
                    @Override
                    public void success(UserLocationResponse userLocationResponse, Response response) {
                        recentItems = userLocationResponse.getUserLocations();
                        recentLocationAdapter.refresh(recentItems);
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );

    }
项目:Expert-Android-Programming    文件:EditProfileActivity.java   
private void getUserProfile() {

        RetroInterface.getZomatoRestApi().getProfileDetails(
                SessionPreference.getUserId(context) + "",
                SessionPreference.getUserId(context) + "",
                new Callback<ProfileDetailResponse>() {
                    @Override
                    public void success(ProfileDetailResponse profileDetailResponse, Response response) {

                        if (profileDetailResponse != null && profileDetailResponse.getItems() != null) {
                            ProfileDetailItem detailItem = profileDetailResponse.getItems();

                            setUserDetails(detailItem.getUser());
                        }

                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }

        );

    }
项目:Expert-Android-Programming    文件:EditProfileActivity.java   
public void onDoneClick(View view) {

        String user_name = userName.getText().toString();
        String user_phone_no = phoneNo.getText().toString();
        String user_description = description.getText().toString();

        RetroInterface.getZomatoRestApi().setUserDetails(
                SessionPreference.getUserId(context) + "",
                user_name,
                user_phone_no,
                user_description,
                new Callback<NormalResponse>() {
                    @Override
                    public void success(NormalResponse normalResponse, Response response) {
                        finish();
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );

    }
项目:Expert-Android-Programming    文件:UserCollectionActivity.java   
private void getAllCollections() {

        RetroInterface.getZomatoRestApi().getMyCollection(
                user_id + "",
                new Callback<CollectionResponse>() {
                    @Override
                    public void success(CollectionResponse collectionResponse, Response response) {

                        if(collectionResponse!=null && collectionResponse.isSuccess()){
                            allList = collectionResponse.getItems();
                            allAdapter.refresh(allList);
                        }
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );

    }
项目:Expert-Android-Programming    文件:BeenThereActivity.java   
private void getBennThereRestaurants() {

        UserLocation location = LocationPreference.getUserLocation(context);
        RetroInterface.getZomatoRestApi().getBeenThereRestaurants(
                user_id + "",
                location.getLatitude() + "",
                location.getLongitude() + "",
                new Callback<RestaurantResponse>() {
                    @Override
                    public void success(RestaurantResponse restaurantResponse, Response response) {
                        if (restaurantResponse != null && restaurantResponse.isSuccess()) {
                            allList = restaurantResponse.getItems();
                            allAdapter.refresh(allList);
                        }
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );

    }
项目:Expert-Android-Programming    文件:SetHandleActivity.java   
private void updateHandle(String handle) {

        RetroInterface.getZomatoRestApi().setUserHandle(
                SessionPreference.getUserId(context) + "",
                handle,
                new Callback<NormalResponse>() {
                    @Override
                    public void success(NormalResponse normalResponse, Response response) {
                        if (normalResponse.isSuccess()) {
                           // Toas.show(context, "Handle set Successfully");
                            showError("Handle set Successfully", true);
                            finish();
                        } else {
                           // Toas.show(context, "Handle already in use");
                            showError("Handle already in use", false);
                        }
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );
    }
项目:Expert-Android-Programming    文件:AllMenuActivity.java   
private void getRestaurantMenu() {

        RetroInterface.getZomatoRestApi().getRestaurantMenu(
                SessionPreference.getUserId(context) + "",
                restaurant_branch_id,
                new Callback<RestaurantImageResponse>() {
                    @Override
                    public void success(RestaurantImageResponse restaurantImageResponse, Response response) {

                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );

    }
项目:Expert-Android-Programming    文件:AllPhotosActivity.java   
private void getAllPhotos() {

        RetroInterface.getZomatoRestApi().getRestaurantPhotos(
                SessionPreference.getUserId(context) + "",
                restaurant_branch_id,
                new Callback<RestaurantImageResponse>() {
                    @Override
                    public void success(RestaurantImageResponse restaurantImageResponse, Response response) {

                        if(restaurantImageResponse!=null){
                            allList = restaurantImageResponse.getItems();
                            adapter.refresh(allList);
                        }
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );

    }
项目:Expert-Android-Programming    文件:AddAddressActivity.java   
private void deleteCurrent(final UserAddress saveAddress) {

        RetroInterface.getZomatoRestApi().deleteUserAddress(
                userAddress.getId() + "",
                new Callback<UserAddressResponse>() {
                    @Override
                    public void success(UserAddressResponse userAddressResponse, Response response) {
                        addAddress(saveAddress);
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );
    }
项目:Expert-Android-Programming    文件:AddAddressActivity.java   
private void addAddress(UserAddress saveAddress) {

        RetroInterface.getZomatoRestApi().addUserAddress(
                CommonFunctions.getHashMap(saveAddress),
                new Callback<UserAddressResponse>() {
                    @Override
                    public void success(UserAddressResponse userResponse, Response response) {

                        if (userResponse != null && userResponse.isSuccess()) {
                            finish();
                        }
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );
    }
项目:Expert-Android-Programming    文件:AddressBookActivity.java   
private void deleteAddress(int pos) {
    UserAddress address = userAddresses.get(pos);

    RetroInterface.getZomatoRestApi().deleteUserAddress(
            address.getId() + "",
            new Callback<UserAddressResponse>() {
                @Override
                public void success(UserAddressResponse userAddressResponse, Response response) {
                    getUserAddresses();
                }

                @Override
                public void failure(RetrofitError error) {

                }
            }
    );

}
项目:Expert-Android-Programming    文件:BookmarkActivity.java   
private void getBookmarkedRestaurants() {

        UserLocation location = LocationPreference.getUserLocation(context);
        RetroInterface.getZomatoRestApi().getBookmarkedRestaurants(
                SessionPreference.getUserId(context) + "",
                location.getLatitude() + "",
                location.getLongitude() + "",
                new Callback<RestaurantResponse>() {
                    @Override
                    public void success(RestaurantResponse restaurantResponse, Response response) {
                        if (restaurantResponse != null && restaurantResponse.isSuccess()) {
                            allList = restaurantResponse.getItems();
                            allAdapter.refresh(allList);
                        }
                    }

                    @Override
                    public void failure(RetrofitError error) {

                    }
                }
        );
    }
项目:MangoBloggerAndroidApp    文件:SignupActivity.java   
private void signUp(String nonceId, final String username, final String email,final String password) {
    mAuthApi.registerUser(username, email, nonceId, username, "both", password, new Callback<RegisterResponse>() {
        @Override
        public void success(RegisterResponse registerResponse, Response response) {
            if(registerResponse.getStatus().equals("ok")) {

                User user = new User(registerResponse.getUser_id(), username, email, username,
                        true, registerResponse.getCookie());
                PreferenceUtil.writeUserToPreferences(getApplicationContext(), user);
                hideProgressDialog();
                startApp();
            } else {
                hideProgressDialog();
                showAuthError(R.id.error_text, registerResponse.getError());
            }
        }
        @Override
        public void failure(RetrofitError error) {
            hideProgressDialog();
            Log.e("Failure : Register", error.getLocalizedMessage()+error.getUrl());
            showAuthError(R.id.error_text, "Unknown error occurred");
        }
    });
}
项目:MangoBloggerAndroidApp    文件:ResetPasswordActivity.java   
private void resetPassword(String username) {
    if(!AppUtils.isNetworkConnected(this)) {
        showErrorDialog();
    } else  {
        showProgressDialog();
        initAdapter().resetPassword(username, new Callback<ResetPasswordResponse>() {
            @Override
            public void success(ResetPasswordResponse resetPasswordResponse, Response response) {
                if(resetPasswordResponse.getStatus().equals("ok")) {
                    hideProgressDialog();
                    setResponseMessage(R.color.global_color_green_primary, "Password reset has been sent on your registered email. Check your Inbox");
                } else {
                    hideProgressDialog();
                    setResponseMessage(R.color.bg_screen1, resetPasswordResponse.getMsg());
                }
            }

            @Override
            public void failure(RetrofitError error) {
                setResponseMessage(R.color.bg_screen1, "Some unknown error occurred");
                hideProgressDialog();
            }
        });
    }
}
项目:android-unsplash    文件:MainActivity.java   
private void displayData() {
    if (relevantPhotos != null) {
        populateGrid();
    } else {
        UnsplashService unsplashApi = new RestAdapter.Builder()
                .setEndpoint(UnsplashService.ENDPOINT)
                .build()
                .create(UnsplashService.class);
        unsplashApi.getFeed(new Callback<List<Photo>>() {
            @Override
            public void success(List<Photo> photos, Response response) {
                // the first items not interesting to us, get the last <n>
                relevantPhotos = new ArrayList<>(photos.subList(photos.size() - PHOTO_COUNT,
                        photos.size()));
                populateGrid();
            }

            @Override
            public void failure(RetrofitError error) {
                Log.e(TAG, "Error retrieving Unsplash feed:", error);
            }
        });
    }
}
项目:assistance-platform-server    文件:PlatformClient.java   
public void updateModule(ModuleBundle bundle, Consumer<Void> onSuccess, Consumer<Void> onError) {
  Callback<Void> callback = new Callback<Void>() {

    @Override
    public void failure(RetrofitError error) {
      logger.warn("Failed to update module information on platform " + errorFromRetrofit(error));

      onError.accept(null);
    }

    @Override
    public void success(Void arg0, Response arg1) {
      logger.info("Successfully updated module information on platform");

      onSuccess.accept(null);
    }
  };

  service.update(bundleToRequest(bundle), callback);
}
项目:assistance-platform-server    文件:PlatformClient.java   
public void localizeModule(ModuleBundle bundle, Consumer<Void> onError) {
  Callback<Void> callback = new Callback<Void>() {

    @Override
    public void failure(RetrofitError error) {
      logger
          .warn("Failed to localize module information on platform " + errorFromRetrofit(error));

      onError.accept(null);
    }

    @Override
    public void success(Void arg0, Response arg1) {
      logger.info("Successfully localized module information on platform");
    }
  };

  for (ModuleLocalizationRequest locRequest : bundleLocalizationRequests(bundle)) {
    service.localize(locRequest, callback);
  }
}
项目:msf_communique    文件:Communicator.java   
/**
 * function to post pilot enrollments to the server
 * @param patient
 * @param comment
 * @param program
 * @param date
 */
public void enrollmentPost(String patient, String comment, String program, String date){
    Callback<Enrollment> callback = new Callback<Enrollment>() {

        @Override
        public void success(Enrollment serverResponse, Response response2) {
            if(serverResponse.getResponseCode() == 0){
                BusProvider.getInstance().post(produceEnrollmentServerEvent(serverResponse));
            }else{
                BusProvider.getInstance().post(produceErrorEvent(serverResponse.getResponseCode(),
                        serverResponse.getMessage()));
            }
        }

        @Override
        public void failure(RetrofitError error) {
            if(error != null ){
                Log.e(TAG, error.getMessage());
                error.printStackTrace();
            }
            BusProvider.getInstance().post(produceErrorEvent(-200,error.getMessage()));
        }
    };
   communicatorInterface.postEnrollments(patient, comment, program, date, callback);
}
项目:mobile_app_android    文件:NewTaskFragment.java   
private void requestEditTask() {
    waitDialog.show();
    RestServiceGenerator.getApiService().updateIssue(String.valueOf(mIssueId),
            new UpdateIssueRequest(mIssueHash), new Callback<IssueResponse>() {
                @Override
                public void success(IssueResponse o, Response response) {
                    waitDialog.dismiss();
                    mShouldSave = false;
                    finish();
                }

                @Override
                public void failure(RetrofitError error) {
                    waitDialog.dismiss();
                    Utils.handleError(getChildFragmentManager(), error);
                }
            });
}
项目:msf_communique    文件:Communicator.java   
/**
 * function to delete patient medication
 * @param regimenID
 */
public void regimenDelete(long regimenID){
    Callback<Regimen> callback = new Callback<Regimen>() {
        @Override
        public void success(Regimen serverResponse, Response response2) {
            BusProvider.getInstance().post(produceRegimenServerResponse(serverResponse));
           //Log.d(TAG,"Success, regimen deleted "+ regimenID);
        }

        @Override
        public void failure(RetrofitError error) {
            if(error != null ){
                Log.e(TAG, error.getMessage());
                error.printStackTrace();
            }
            BusProvider.getInstance().post(produceErrorEvent(-200,error.getMessage()));
        }
    };
    communicatorInterface.deleteRegimen(regimenID, callback);
}
项目:xowa_android    文件:WikipediaZeroHandler.java   
/** For Retrofit responses */
public void onHeaderCheck(final Response response) {
    if (!WIKIPEDIA_ZERO_DEV_MODE_ON || acquiringCarrierMessage) {
        return;
    }
    new Handler(Looper.getMainLooper()).post(new Runnable() {
        @Override
        public void run() {
            try {
                if (hostSupportsZeroHeaders(new URL(response.getUrl()).getHost())) {
                    String xcs = getHeader(response, "X-CS");
                    if (xcs != null) {
                        if (!xcs.equals(carrierString)) {
                            identifyZeroCarrier(xcs);
                        }
                    } else if (zeroEnabled) {
                        zeroOff();
                    }
                }
            } catch (MalformedURLException e) {
                throw new RuntimeException("interesting response", e);
            }
        }
    });
}
项目:droidddle    文件:AddToBucketActivity.java   
@Override
public void onClicked(Bucket data) {
    if (!Utils.hasInternet(this)) {
        Toast.makeText(this, R.string.check_network, Toast.LENGTH_SHORT).show();
        return;
    }
    Observable<Response> observable = ApiFactory.getService(this).addShotToBucket(data.id, mShotId);
    observable.subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread())
            .subscribe(new SucessCallback<Response>(this, R.string.shot_add_to_bucket_success) {
                @Override
                public void call(Response o) {
                    super.call(o);
                    finish();
                }
            }, new ErrorCallback(this));
}
项目:mobile_app_android    文件:NewTaskFragment.java   
private void getAvailableValuesForNewTask() {
    // user is signed into Easy redmine, available values from Easy redmine api will be
    // populated
    RestServiceGenerator.createApiDescription().getAvailableEasyIssue(new CheckFieldIssueRequest(mIssueHash, isInitialLoadingCompleted),
            String.valueOf(mProjectId), new Callback<EasyRedmineValidationResponse>() {
                @Override
                public void success(EasyRedmineValidationResponse easyRedmineValidationResponse,
                                    Response response) {
                    isInitialLoadingCompleted = true;
                    progressDialog.hide();
                    mIssue = easyRedmineValidationResponse.formAttributes.issue;
                    TaskUtils.setIssueHash(mIssueHash, mProjectId, mIssue, getFragmentActivity().isEasyRedmine());
                    mProjectId = mIssueHash.projectId;
                    populateForms(easyRedmineValidationResponse); // we have valid options for this form
                }

                @Override
                public void failure(RetrofitError error) {
                    Utils.handleError(getChildFragmentManager(), error);
                    isInitialLoadingCompleted = true;
                    progressDialog.hide();
                }
            });
}
项目:Popdeem-SDK-Android    文件:PDAPIClient.java   
/**
 * Get User Token Interceptor
 *
 * @return Interceptor with User Token Header or null if no token is saved.
 */
private Interceptor getUserTokenInterceptor() {
    final String userToken = PDUtils.getUserToken();
    Log.i("User Token", "getUserTokenInterceptor: " + userToken);
    if (userToken == null) {
        return null;
    }

    return new Interceptor() {
        @Override
        public okhttp3.Response intercept(Chain chain) throws IOException {
            return chain.proceed(chain.request().newBuilder()
                    .addHeader(PDAPIConfig.REQUEST_HEADER_USER_TOKEN, userToken)
                    .build());
        }
    };
}
项目:enlightns-android    文件:EnlightnsAPIHelper.java   
@Override
public Throwable handleError(RetrofitError cause) {
    Response r = cause.getResponse();
    if (r != null) {
        switch (r.getStatus()) {
            case 500:
                Log.d(TAG, "500 error during request to " + r.getUrl());
                return new ServerErrorException(cause.getMessage());
            case 403:
                Log.d(TAG, "403 error during request to " + r.getUrl());
                return new ForbiddenException(cause.getMessage());
            case 404:
                Log.d(TAG, "404 error during request to " + r.getUrl());
                return new NotFoundException(cause.getMessage());
            case 400:
                Log.d(TAG, "400 error during request to " + r.getUrl());
                return new BadRequestException(cause.getMessage());
        }
    }

    return cause;
}
项目:LETO-Toggl_Android    文件:MainActivity.java   
private void setupWeek(){
    Date today = new Date();
    Calendar cal = new GregorianCalendar();
    cal.setTime(today);
    cal.add(Calendar.DAY_OF_WEEK, -cal.get(Calendar.DAY_OF_WEEK));
    Date today7 = cal.getTime();
    LetoTogglRestClient.getPureApi().getTimeEntries(MyUtils.getISO8601StringForDate(today7), MyUtils.getISO8601StringForDate(today), new Callback<List<TimeEntry>>() {
        @Override
        public void success(List<TimeEntry> timeEntries, Response response) {
            Log.d(TAG, "SUCCESS: Last week entries");
            mWeekTimeEntries = MyUtils.createCompleteEntriesModel(timeEntries, SharedObjects.mProjects, SharedObjects.mClients);
            setuWeekProjects(mWeekTimeEntries);
            setupWeekPlot(mWeekTimeEntries);
        }

        @Override
        public void failure(RetrofitError error) {
            Log.d(TAG, "ERROR: Last week entries");
            Snackbar snackbar = Snackbar.make(findViewById(android.R.id.content), getString(R.string.no_internet), Snackbar.LENGTH_LONG);
            snackbar.show();
        }
    });
}
项目:mobile_app_android    文件:EditTaskFragment.java   
private void initStatus(List<IssueStatus> entities) {
    if (entities != null) {
        // we have values for statuses (EasyRedmine)
        populateStatus(entities);
    } else {
        // we don't have values for statuses - download from api (Redmine)

        RestServiceGenerator.getApiService().getIssueStatuses(new Callback<IssueStatusesResponse>() {
            @Override
            public void success(final IssueStatusesResponse issueResponse, Response response) {
                if (getActivity() == null) {
                    return;
                }

                populateStatus(issueResponse.issueStatuses);
            }

            @Override
            public void failure(RetrofitError error) {

            }
        });
    }

}