mirror of
https://github.com/hmalik144/Android-developer-tech-test---Deloitte.git
synced 2025-12-10 02:55:22 +00:00
Update to include variable toast messages based on api calls
This commit is contained in:
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
@@ -10,7 +10,8 @@ import java.net.URL
|
|||||||
|
|
||||||
class AsyncApiCall(
|
class AsyncApiCall(
|
||||||
val urlString : String,
|
val urlString : String,
|
||||||
val callBack : ResponseListener?
|
val callBack : ResponseListener?,
|
||||||
|
val toastErrorString : String
|
||||||
): AsyncTask<String, Void, String>() {
|
): AsyncTask<String, Void, String>() {
|
||||||
|
|
||||||
override fun onPreExecute() {
|
override fun onPreExecute() {
|
||||||
@@ -50,7 +51,7 @@ class AsyncApiCall(
|
|||||||
|
|
||||||
override fun onPostExecute(result: String) {
|
override fun onPostExecute(result: String) {
|
||||||
if (result.isEmpty()){
|
if (result.isEmpty()){
|
||||||
callBack?.onFailure("Failed to retrieve")
|
callBack?.onFailure(toastErrorString)
|
||||||
}else{
|
}else{
|
||||||
callBack?.onSuccess()
|
callBack?.onSuccess()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ class CartViewModel(
|
|||||||
val response =
|
val response =
|
||||||
AsyncApiCall(
|
AsyncApiCall(
|
||||||
"https://private-anon-21a48b3d0e-ddshop.apiary-mock.com/cart/1",
|
"https://private-anon-21a48b3d0e-ddshop.apiary-mock.com/cart/1",
|
||||||
cartResponseListener
|
cartResponseListener,
|
||||||
|
"Failed to delete item"
|
||||||
)
|
)
|
||||||
.execute()
|
.execute()
|
||||||
.get()
|
.get()
|
||||||
@@ -37,9 +38,4 @@ class CartViewModel(
|
|||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getTotalPrice(): String{
|
|
||||||
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,8 @@ class ListViewModel(
|
|||||||
val response =
|
val response =
|
||||||
AsyncApiCall(
|
AsyncApiCall(
|
||||||
"https://private-anon-f3c1195210-ddshop.apiary-mock.com/products",
|
"https://private-anon-f3c1195210-ddshop.apiary-mock.com/products",
|
||||||
responseListener
|
responseListener,
|
||||||
|
"Failed to insert"
|
||||||
)
|
)
|
||||||
.execute()
|
.execute()
|
||||||
.get()
|
.get()
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ class MainViewModel(
|
|||||||
val jsonResponse =
|
val jsonResponse =
|
||||||
AsyncApiCall(
|
AsyncApiCall(
|
||||||
"https://private-anon-f3c1195210-ddshop.apiary-mock.com/products",
|
"https://private-anon-f3c1195210-ddshop.apiary-mock.com/products",
|
||||||
responseListener
|
responseListener,
|
||||||
|
"Failed To retrieve list"
|
||||||
)
|
)
|
||||||
.execute()
|
.execute()
|
||||||
.get()
|
.get()
|
||||||
|
|||||||
@@ -24,7 +24,8 @@ class WishListViewModel(
|
|||||||
val response =
|
val response =
|
||||||
AsyncApiCall(
|
AsyncApiCall(
|
||||||
"https://private-anon-f3c1195210-ddshop.apiary-mock.com/products",
|
"https://private-anon-f3c1195210-ddshop.apiary-mock.com/products",
|
||||||
wishResponseListener
|
wishResponseListener,
|
||||||
|
"Failed to insert item"
|
||||||
)
|
)
|
||||||
.execute()
|
.execute()
|
||||||
.get()
|
.get()
|
||||||
|
|||||||
Reference in New Issue
Block a user