public Object f(Object... args) { Response response = arguments(0); if (response.getText().matches(jsonpCbRexp)) { return GQ.create(response.getText().replaceFirst(jsonpCbRexp, "$1")); } else { return GQuery.Deferred().reject().promise(); } } });
public void f(Deferred dfd) { try { Response response = httpClient(settings, cors); int status = response.getStatusCode(); if (status <= 0 || status >= 400) { String statusText = status <= 0 ? "Bad CORS" : response.getStatusText(); dfd.reject(new RequestException("HTTP ERROR: " + status + " " + statusText + "\n" + response.getText()), null); } else { dfd.resolve(response, null); } } catch (Exception e) { e.printStackTrace(); dfd.reject(e, null); } } };
@Override public void onFailure(Exception reason) { dfd.reject(reason); }
private void settle(int action, Object... args) { if (action == DONE) dfd.resolve(args); if (action == FAIL) dfd.reject(args); if (action == PROGRESS) dfd.notify(args); } }