Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

Improve "more apps" error handling

parent e8ecd39c
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -102,14 +102,17 @@ class CategoryActivity : AppCompatActivity(), ApplicationManagerServiceConnectio
        // Bind to the screen error
        categoryViewModel.getScreenError().observe(this, Observer {
            if (it != null) {
                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)
+5 −13
Original line number Diff line number Diff line
@@ -40,20 +40,12 @@ class CategoryModel : CategoryModelInterface {
                        categoryApplicationsList.value = result
                    }
                } else {
                    if (page == 1) {
                    screenError.value = error
                    } else {
                        screenError.value = null
                    }
                }
            })
            page++
        } else {
            if (page == 1) {
            screenError.value = Error.NO_INTERNET
            } else {
                screenError.value = null
            }
        }
    }

@@ -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
        }
    }

+8 −5
Original line number Diff line number Diff line
@@ -130,14 +130,17 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On
        // Bind to the screen error
        searchViewModel.getScreenError().observe(this, Observer {
            if (it != null) {
                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
+3 −13
Original line number Diff line number Diff line
@@ -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
            }
        }
    }

@@ -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
            }
        }
    }
}