2828import java .util .List ;
2929import java .util .concurrent .ConcurrentLinkedQueue ;
3030
31+ import de .greenrobot .event .EventBus ;
32+
3133import static com .proxerme .library .connection .ProxerException .ErrorCodes .PROXER ;
3234import static com .proxerme .library .connection .ProxerException .ErrorCodes .UNKNOWN ;
3335import static com .proxerme .library .connection .ProxerTag .CONFERENCES ;
@@ -164,7 +166,7 @@ public static void cleanup() {
164166
165167 /**
166168 * An abstract representation of a callback, passed to the
167- * {@link ProxerRequest#execute(ResultCallback )} method.
169+ * {@link ProxerRequest#execute()} method.
168170 *
169171 * @param <T> The generic parameter.
170172 */
@@ -194,7 +196,7 @@ public static abstract class ProxerRequest<T> {
194196
195197 /**
196198 * Builds the request, to be used in the
197- * {@link #execute(ResultCallback )} or
199+ * {@link #execute()} or
198200 * {@link #executeSynchronized()} method.
199201 *
200202 * @return The {@link RequestBuilder} to use for further invocations.
@@ -213,11 +215,10 @@ public static abstract class ProxerRequest<T> {
213215 /**
214216 * Asynchronously executes this request.
215217 *
216- * @param callback The callback for notifications about the Result.
217218 * @see #executeSynchronized()
218219 */
219220 @ RequiresPermission (android .Manifest .permission .INTERNET )
220- public final void execute (@ NonNull final ResultCallback < T > callback ) {
221+ public final void execute () {
221222 buildRequest ().throwIfNotSuccess ().tag (String .valueOf (getTag ())).request (new Callback () {
222223 @ Override
223224 public void response (Request request , final Response response ,
@@ -230,36 +231,16 @@ public void run() {
230231 JSONObject json = response .asJsonObject ();
231232
232233 if (json == null ) {
233- handler .post (new Runnable () {
234- @ Override
235- public void run () {
236- callback .onError (new ProxerException (UNKNOWN ));
237- }
238- });
234+ EventBus .getDefault ().post (new ProxerException (UNKNOWN ));
239235 } else {
240236 final T result = parse (json );
241237
242- handler .post (new Runnable () {
243- @ Override
244- public void run () {
245- callback .onResult (result );
246- }
247- });
238+ EventBus .getDefault ().post (result );
248239 }
249240 } catch (final JSONException e ) {
250- handler .post (new Runnable () {
251- @ Override
252- public void run () {
253- callback .onError (ErrorHandler .handleException (e ));
254- }
255- });
241+ EventBus .getDefault ().post (ErrorHandler .handleException (e ));
256242 } catch (final BridgeException e ) {
257- handler .post (new Runnable () {
258- @ Override
259- public void run () {
260- callback .onError (ErrorHandler .handleException (e ));
261- }
262- });
243+ EventBus .getDefault ().post (ErrorHandler .handleException (e ));
263244 }
264245
265246 parseThreads .remove (getThread ());
@@ -270,7 +251,7 @@ public void run() {
270251 parseThread .start ();
271252 } else {
272253 if (exception .reason () != BridgeException .REASON_REQUEST_CANCELLED ) {
273- callback . onError (ErrorHandler .handleException (exception ));
254+ EventBus . getDefault (). post (ErrorHandler .handleException (exception ));
274255 }
275256 }
276257 }
@@ -282,7 +263,7 @@ public void run() {
282263 *
283264 * @return The result, specified by this class.
284265 * @throws ProxerException An Exception, which might occur, while executing the request.
285- * @see #execute(ResultCallback )
266+ * @see #execute()
286267 */
287268 @ WorkerThread
288269 @ RequiresPermission (android .Manifest .permission .INTERNET )
0 commit comments