From 6dc8dce2af64ae8280a93b7e210e4aeff75ec38a Mon Sep 17 00:00:00 2001
From: Bhawak Pokhrel <bhawak.pokhrel@gmail.com>
Date: Mon, 24 Aug 2020 12:43:55 +0545
Subject: [PATCH] bug fixes

---
 .../main/java/com/baato/baatolibrary/services/BaatoPlace.java  | 3 +++
 .../java/com/baato/baatolibrary/services/BaatoReverse.java     | 2 +-
 .../java/com/baato/baatolibrary/services/BaatoRouting.java     | 1 +
 .../main/java/com/baato/baatolibrary/services/BaatoSearch.java | 1 +
 4 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoPlace.java b/baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoPlace.java
index fd5df3d..018d969 100644
--- a/baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoPlace.java
+++ b/baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoPlace.java
@@ -1,6 +1,8 @@
 package com.baato.baatolibrary.services;
 
 import android.content.Context;
+import android.util.Log;
+import android.widget.Toast;
 
 import androidx.annotation.NonNull;
 
@@ -93,6 +95,7 @@ public void onResponse(Call<PlaceAPIResponse> call, Response<PlaceAPIResponse> r
                 else {
                     try {
                         baatoPlaceListener.onFailed(new Throwable(response.errorBody().string()));
+                        cancelRequest();
                     } catch (IOException e) {
                         e.printStackTrace();
                     }
diff --git a/baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoReverse.java b/baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoReverse.java
index 6151e02..39e5d91 100644
--- a/baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoReverse.java
+++ b/baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoReverse.java
@@ -107,7 +107,7 @@ public void onResponse(Call<PlaceAPIResponse> call, Response<PlaceAPIResponse> r
                 else {
                     try {
                         baatoReverseRequestListener.onFailed(new Throwable(response.errorBody().string()));
-                        Log.d(TAG, "onResponse: ");
+                        cancelRequest();
                     } catch (Exception e) {
                         e.printStackTrace();
                     }
diff --git a/baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoRouting.java b/baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoRouting.java
index db40b9c..e142e33 100644
--- a/baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoRouting.java
+++ b/baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoRouting.java
@@ -135,6 +135,7 @@ public void onResponse(Call<DirectionsAPIResponse> call, Response<DirectionsAPIR
                         } else {
                             try {
                                 baatoRoutingRequestListener.onFailed(new Throwable(response.errorBody().string()));
+                                cancelRequest();
                             } catch (IOException e) {
                                 e.printStackTrace();
                             }
diff --git a/baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoSearch.java b/baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoSearch.java
index d4659ad..5b22961 100644
--- a/baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoSearch.java
+++ b/baatolibrary/src/main/java/com/baato/baatolibrary/services/BaatoSearch.java
@@ -130,6 +130,7 @@ public void onResponse(Call<SearchAPIResponse> call, Response<SearchAPIResponse>
                 else {
                     try {
                         baatoSearchRequestListener.onFailed(new Throwable(response.errorBody().string()));
+                        cancelRequest();
                     } catch (IOException e) {
                         e.printStackTrace();
                     }