Here’s my hack. If there is a better solution please let me know or update the stackoverflow.com link.
Can the API be improved to avoid creating the List if it already exists? There should be a reasonable default and the opposite functionality can be another parameter passed in the POST call. e.g. by default the API would allow duplicates, but the API could take a duplicate=no parameter if needed.
interface CustomService {
@POST("/1.1/lists/create.json")
void createList(@Query("name") String name, @Query("mode") String mode, Callback<JsonElement> cb);
}
MyTwitterApiClient api = new MyTwitterApiClient(session);
api.getCustomService().createList("MyListName", "private", new Callback<JsonElement>() {
@Override
public void success(Result<JsonElement> result) {
Log.d(TAG, " [success] status: " + result.response.getStatus());
JsonElement je = result.data;
Log.d(TAG, " [success] data: " + je.getAsJsonObject().toString());
}
@Override
public void failure(TwitterException e) { }
});