2014-04-14 66 views

回答

9

使用一個空的回調:

public final class Callbacks { 
    private static final Callback<Object> EMPTY = new Callback<Object> { 
    @Override public void success(Object value, Response response) {} 
    @Override public void failure(RetrofitError error) {} 
    } 

    @SuppressWarnings("unchecked") 
    public static <T> Callback<T> empty() { 
    return (Callback<T>) EMPTY; 
    } 
} 

然後在你的代碼:

apiService.someEndpoint(Callbacks.empty());