Loading app/src/main/java/io/eelo/appinstaller/search/SearchFragment.kt +17 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import android.view.ViewGroup import android.view.inputmethod.InputMethodManager import android.widget.LinearLayout import android.widget.ProgressBar import android.widget.RelativeLayout import android.widget.TextView import io.eelo.appinstaller.R import io.eelo.appinstaller.application.model.Application Loading @@ -36,6 +37,7 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On private lateinit var splashContainer: LinearLayout private var applicationList = ArrayList<Application>() private var applicationManager: ApplicationManager? = null private var isLoadingMoreApplications = false fun initialise(applicationManager: ApplicationManager) { this.applicationManager = applicationManager Loading @@ -56,6 +58,7 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On splashContainer = view.findViewById(R.id.splash_container) val errorContainer = view.findViewById<LinearLayout>(R.id.error_container) val errorDescription = view.findViewById<TextView>(R.id.error_description) val loadMoreContainer = view.findViewById<RelativeLayout>(R.id.load_more_container) searchViewModel.initialise(applicationManager!!) recyclerView.visibility = View.GONE Loading @@ -68,6 +71,7 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On } errorContainer.visibility = View.GONE view.findViewById<TextView>(R.id.error_resolve).setOnClickListener { loadMoreContainer.visibility = View.GONE progressBar.visibility = View.VISIBLE onQueryTextSubmit(searchView.query.toString()) } Loading @@ -83,11 +87,19 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On recyclerView.setHasFixedSize(true) recyclerView.layoutManager = LinearLayoutManager(context) recyclerView.adapter = ApplicationListAdapter(activity!!, applicationList) loadMoreContainer.visibility = View.GONE recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { if (!recyclerView.canScrollVertically(1)) { loadMoreContainer.visibility = View.VISIBLE recyclerView.scrollToPosition(applicationList.size - 1) if (!isLoadingMoreApplications) { isLoadingMoreApplications = true searchViewModel.loadMore(context!!) } } else { loadMoreContainer.visibility = View.GONE } } }) Loading @@ -105,6 +117,8 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On applicationList.addAll(it) progressBar.visibility = View.GONE recyclerView.adapter.notifyDataSetChanged() loadMoreContainer.visibility = View.GONE isLoadingMoreApplications = false if (applicationList.isEmpty()) { recyclerView.visibility = View.GONE } else { Loading @@ -119,9 +133,11 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On errorDescription.text = activity!!.getString(Common.getScreenErrorDescriptionId(it)) errorContainer.visibility = View.VISIBLE progressBar.visibility = View.GONE loadMoreContainer.visibility = View.GONE } else { errorContainer.visibility = View.GONE } isLoadingMoreApplications = false }) // Handle suggestion clicks Loading app/src/main/java/io/eelo/appinstaller/search/model/SearchModel.kt +6 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,8 @@ class SearchModel : SearchModelInterface { } else { if (pageNumber == 1) { screenError.value = Error.NO_INTERNET } else { screenError.value = null } } } Loading @@ -64,10 +66,14 @@ class SearchModel : SearchModelInterface { } if (applicationList.isEmpty() && pageNumber == 1) { screenError.value = Error.NO_RESULTS } else { screenError.value = null } } else { if (pageNumber == 1) { screenError.value = error } else { screenError.value = null } } } Loading app/src/main/res/layout/fragment_search.xml +15 −2 Original line number Diff line number Diff line Loading @@ -61,8 +61,21 @@ android:id="@+id/app_list" android:layout_width="match_parent" android:layout_height="0dp" android:scrollbars="none" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toTopOf="@id/load_more_container" app:layout_constraintTop_toBottomOf="@id/toolbar" /> <RelativeLayout android:id="@+id/load_more_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="@dimen/layout_padding_medium" app:layout_constraintBottom_toBottomOf="parent"> <ProgressBar android:layout_width="@dimen/load_more_progress_bar_size" android:layout_height="@dimen/load_more_progress_bar_size" android:layout_centerInParent="true" /> </RelativeLayout> </android.support.constraint.ConstraintLayout> No newline at end of file Loading
app/src/main/java/io/eelo/appinstaller/search/SearchFragment.kt +17 −1 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ import android.view.ViewGroup import android.view.inputmethod.InputMethodManager import android.widget.LinearLayout import android.widget.ProgressBar import android.widget.RelativeLayout import android.widget.TextView import io.eelo.appinstaller.R import io.eelo.appinstaller.application.model.Application Loading @@ -36,6 +37,7 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On private lateinit var splashContainer: LinearLayout private var applicationList = ArrayList<Application>() private var applicationManager: ApplicationManager? = null private var isLoadingMoreApplications = false fun initialise(applicationManager: ApplicationManager) { this.applicationManager = applicationManager Loading @@ -56,6 +58,7 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On splashContainer = view.findViewById(R.id.splash_container) val errorContainer = view.findViewById<LinearLayout>(R.id.error_container) val errorDescription = view.findViewById<TextView>(R.id.error_description) val loadMoreContainer = view.findViewById<RelativeLayout>(R.id.load_more_container) searchViewModel.initialise(applicationManager!!) recyclerView.visibility = View.GONE Loading @@ -68,6 +71,7 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On } errorContainer.visibility = View.GONE view.findViewById<TextView>(R.id.error_resolve).setOnClickListener { loadMoreContainer.visibility = View.GONE progressBar.visibility = View.VISIBLE onQueryTextSubmit(searchView.query.toString()) } Loading @@ -83,11 +87,19 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On recyclerView.setHasFixedSize(true) recyclerView.layoutManager = LinearLayoutManager(context) recyclerView.adapter = ApplicationListAdapter(activity!!, applicationList) loadMoreContainer.visibility = View.GONE recyclerView.addOnScrollListener(object : RecyclerView.OnScrollListener() { override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { if (!recyclerView.canScrollVertically(1)) { loadMoreContainer.visibility = View.VISIBLE recyclerView.scrollToPosition(applicationList.size - 1) if (!isLoadingMoreApplications) { isLoadingMoreApplications = true searchViewModel.loadMore(context!!) } } else { loadMoreContainer.visibility = View.GONE } } }) Loading @@ -105,6 +117,8 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On applicationList.addAll(it) progressBar.visibility = View.GONE recyclerView.adapter.notifyDataSetChanged() loadMoreContainer.visibility = View.GONE isLoadingMoreApplications = false if (applicationList.isEmpty()) { recyclerView.visibility = View.GONE } else { Loading @@ -119,9 +133,11 @@ class SearchFragment : Fragment(), SearchView.OnQueryTextListener, SearchView.On errorDescription.text = activity!!.getString(Common.getScreenErrorDescriptionId(it)) errorContainer.visibility = View.VISIBLE progressBar.visibility = View.GONE loadMoreContainer.visibility = View.GONE } else { errorContainer.visibility = View.GONE } isLoadingMoreApplications = false }) // Handle suggestion clicks Loading
app/src/main/java/io/eelo/appinstaller/search/model/SearchModel.kt +6 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,8 @@ class SearchModel : SearchModelInterface { } else { if (pageNumber == 1) { screenError.value = Error.NO_INTERNET } else { screenError.value = null } } } Loading @@ -64,10 +66,14 @@ class SearchModel : SearchModelInterface { } if (applicationList.isEmpty() && pageNumber == 1) { screenError.value = Error.NO_RESULTS } else { screenError.value = null } } else { if (pageNumber == 1) { screenError.value = error } else { screenError.value = null } } } Loading
app/src/main/res/layout/fragment_search.xml +15 −2 Original line number Diff line number Diff line Loading @@ -61,8 +61,21 @@ android:id="@+id/app_list" android:layout_width="match_parent" android:layout_height="0dp" android:scrollbars="none" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toTopOf="@id/load_more_container" app:layout_constraintTop_toBottomOf="@id/toolbar" /> <RelativeLayout android:id="@+id/load_more_container" android:layout_width="match_parent" android:layout_height="wrap_content" android:padding="@dimen/layout_padding_medium" app:layout_constraintBottom_toBottomOf="parent"> <ProgressBar android:layout_width="@dimen/load_more_progress_bar_size" android:layout_height="@dimen/load_more_progress_bar_size" android:layout_centerInParent="true" /> </RelativeLayout> </android.support.constraint.ConstraintLayout> No newline at end of file