Skip to content

Commit 8cbc3fd

Browse files
committed
Improve handler usage
1 parent 905a236 commit 8cbc3fd

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

library/src/main/java/com/proxerme/library/connection/ProxerConnection.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -230,26 +230,24 @@ public void response(Request request, final Response response, BridgeException e
230230
Thread parseThread = new Thread(new Runnable() {
231231
@Override
232232
public void run() {
233-
Handler handler = new Handler(Looper.getMainLooper());
234-
235233
try {
236234
final T result = parse(response.asJsonObject());
237235

238-
handler.post(new Runnable() {
236+
new Handler(Looper.getMainLooper()).post(new Runnable() {
239237
@Override
240238
public void run() {
241239
callback.onResult(result);
242240
}
243241
});
244242
} catch (final JSONException e) {
245-
handler.post(new Runnable() {
243+
new Handler(Looper.getMainLooper()).post(new Runnable() {
246244
@Override
247245
public void run() {
248246
callback.onError(ErrorHandler.handleException(e));
249247
}
250248
});
251249
} catch (final BridgeException e) {
252-
handler.post(new Runnable() {
250+
new Handler(Looper.getMainLooper()).post(new Runnable() {
253251
@Override
254252
public void run() {
255253
callback.onError(ErrorHandler.handleException(e));

0 commit comments

Comments
 (0)