Commit 2862c4ae authored by Nihar Thakkar's avatar Nihar Thakkar
Browse files

Improve "more apps" error handling

parent e8ecd39c
......@@ -102,14 +102,17 @@ class CategoryActivity : AppCompatActivity(), ApplicationManagerServiceConnectio
// Bind to the screen error
categoryViewModel.getScreenError().observe(this, Observer {
if (it != null) {
errorDescription.text = getString(it.description)
errorContainer.visibility = View.VISIBLE
progressBar.visibility = View.GONE
loadMoreContainer.visibility = View.GONE
if (!isLoadingMoreApplications) {
errorDescription.text = getString(it.description)
errorContainer.visibility = View.VISIBLE
progressBar.visibility = View.GONE
loadMoreContainer.visibility = View.GONE
} else {
isLoadingMoreApplications = false
}
} else {
errorContainer.visibility = View.GONE
}
isLoadingMoreApplications = false
})
applicationManagerServiceConnection.bindService(this)
......
......@@ -40,20 +40,12 @@ class CategoryModel : CategoryModelInterface {
categoryApplicationsList.value = result
}
} else {
if (page == 1) {
screenError.value = error
} else {
screenError.value = null
}
screenError.value = error
}
})
page++
} else {
if (page == 1) {
screenError.value = Error.NO_INTERNET
} else {
screenError.value = null
}
screenError.value = Error.NO_INTERNET
}
}
......@@ -70,10 +62,10 @@ class CategoryModel : CategoryModelInterface {
}
}
}
if (listApplications != null) {
return listApplications!!.getApplications(applicationManager, context)
return if (listApplications != null) {
listApplications!!.getApplications(applicationManager, context)
} else {
return null
null
}
}
......
......@@ -130,14 +130,17 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On
// Bind to the screen error
searchViewModel.getScreenError().observe(this, Observer {
if (it != null) {
errorDescription.text = activity!!.getString(it.description)
errorContainer.visibility = View.VISIBLE
progressBar.visibility = View.GONE
loadMoreContainer.visibility = View.GONE
if (!isLoadingMoreApplications) {
errorDescription.text = activity!!.getString(it.description)
errorContainer.visibility = View.VISIBLE
progressBar.visibility = View.GONE
loadMoreContainer.visibility = View.GONE
} else {
isLoadingMoreApplications = false
}
} else {
errorContainer.visibility = View.GONE
}
isLoadingMoreApplications = false
})
// Handle suggestion clicks
......
......@@ -47,11 +47,7 @@ class SearchModel : SearchModelInterface {
SearchElement(searchQuery, pageNumber, applicationManager!!, this)
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, context)
} else {
if (pageNumber == 1) {
screenError.value = Error.NO_INTERNET
} else {
screenError.value = null
}
screenError.value = Error.NO_INTERNET
}
}
......@@ -64,17 +60,11 @@ class SearchModel : SearchModelInterface {
} else {
this.applicationList.value = applicationList
}
if (applicationList.isEmpty() && pageNumber == 1) {
if (applicationList.isEmpty()) {
screenError.value = Error.NO_RESULTS
} else {
screenError.value = null
}
} else {
if (pageNumber == 1) {
screenError.value = error
} else {
screenError.value = null
}
screenError.value = error
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment