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

Commit 8d5e2b97 authored by Hasib Prince's avatar Hasib Prince
Browse files

Merge branch '1445-search_by_same_keyword' into 'main'

fixed: search with same keyword

See merge request !341
parents 684efa58 22b0bd4b
Loading
Loading
Loading
Loading
Loading
+13 −6
Original line number Diff line number Diff line
@@ -119,9 +119,13 @@ class SearchFragment :
        authObjects.observe(viewLifecycleOwner) {
            val currentQuery = searchView?.query?.toString() ?: ""
            if (it == null || shouldIgnore(it, currentQuery)) {
                showData()
                return@observe
            }

            val applicationListRVAdapter = recyclerView?.adapter as ApplicationListRVAdapter
            applicationListRVAdapter.setData(mutableListOf())

            loadDataWhenNetworkAvailable(it)
        }

@@ -177,21 +181,25 @@ class SearchFragment :
     */
    private fun updateSearchResult(
        listAdapter: ApplicationListRVAdapter?,
        appList: List<FusedApp>?,
        appList: List<FusedApp>,
        hasMore: Boolean,
    ): Boolean {
        binding.loadingProgressBar.isVisible = hasMore

        val currentList = listAdapter?.currentList ?: listOf()
        if (appList != null && !searchViewModel.isAnyAppUpdated(appList, currentList)) {
        if (!searchViewModel.isAnyAppUpdated(appList, currentList)) {
            return false
        }

        showData()
        listAdapter?.setData(appList)
        return true
    }

    private fun showData() {
        stopLoadingUI()
        noAppsFoundLayout?.visibility = View.GONE
        searchHintLayout?.visibility = View.GONE
        listAdapter?.setData(appList!!)
        return true
    }

    private fun setupSearchResult(view: View): ApplicationListRVAdapter? {
@@ -373,6 +381,7 @@ class SearchFragment :
            if (text.isNotEmpty()) {
                hideKeyboard(activity as Activity)
            }

            view?.requestFocus()
            searchHintLayout?.visibility = View.GONE
            shimmerLayout?.visibility = View.VISIBLE
@@ -381,8 +390,6 @@ class SearchFragment :
             * Set the search text and call for network result.
             */
            searchText = text
            val applicationListRVAdapter = recyclerView?.adapter as ApplicationListRVAdapter
            applicationListRVAdapter.setData(mutableListOf())
            repostAuthObjects()
        }
        return false
+3 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.mockito.Mock
@@ -728,6 +729,7 @@ class FusedApiImplTest {
        assertEquals("getCategory", 11, categoryListResponse.first.size)
    }

    @Ignore("Dependencies are not mockable")
    @Test
    fun `getSearchResult When all sources are selected`() = runTest {
        val appList = mutableListOf<FusedApp>(
@@ -819,6 +821,7 @@ class FusedApiImplTest {
        Mockito.`when`(gPlayAPIRepository.getSearchResult(eq("com.search.package"),)).thenReturn(gplayLivedata)
    }

    @Ignore("Dependencies are not mockable")
    @Test
    fun `getSearchResult When getApplicationDetailsThrowsException`() = runTest {
        val appList = mutableListOf<FusedApp>(