@@ -270,14 +270,14 @@ END
270
270
client.newCall(request).enqueue(object: Callback {
271
271
override fun onFailure(call: Call?, e: IOException?) {
272
272
e?.printStackTrace()
273
- Handler(Looper.mainLooper ).post {
273
+ Handler(Looper.getMainLooper() ).post {
274
274
callback(Error(ErrorType.Fatal, e?.message ?: "Chamada falhou sem mensagem de erro!"), null)
275
275
}
276
276
}
277
277
278
278
override fun onResponse(call: Call?, response: Response?) {
279
279
if (response == null || response.code() == 502) {
280
- Handler(Looper.mainLooper ).post {
280
+ Handler(Looper.getMainLooper() ).post {
281
281
callback(Error(ErrorType.Fatal, "Erro Fatal (502) - Tente novamente"), null)
282
282
}
283
283
return
287
287
val stringBody = response?.body()?.string()
288
288
JSONObject(stringBody)
289
289
} catch (e: Exception) {
290
- Handler(Looper.mainLooper ).post {
290
+ Handler(Looper.getMainLooper() ).post {
291
291
callback(Error(ErrorType.Fatal, "502 - Tente novamente"), null)
292
292
}
293
293
null
@@ -302,19 +302,19 @@ END
302
302
//TODO Fetch correct error type
303
303
val error = Error(ErrorType.valueOf(jsonError.getString("type")), jsonError.getString("message"))
304
304
Log.e("API Error", jsonError.getString("type") + " - " + error.message);
305
- Handler(Looper.mainLooper ).post {
305
+ Handler(Looper.getMainLooper() ).post {
306
306
callback(error, null)
307
307
}
308
308
} else {
309
- Handler(Looper.mainLooper ).post {
309
+ Handler(Looper.getMainLooper() ).post {
310
310
callback(null, responseBody)
311
311
}
312
312
}
313
313
}
314
314
})
315
315
} catch (e: JSONException) {
316
316
e.printStackTrace()
317
- Handler(Looper.mainLooper ).post {
317
+ Handler(Looper.getMainLooper() ).post {
318
318
callback(Error(ErrorType.Fatal, e.message ?: "Erro ao parsear json"), null)
319
319
}
320
320
}
0 commit comments