Removed NestedScrollView where possible to speed-up scrolling performance

This commit is contained in:
CappielloAntonio 2021-04-17 19:25:55 +02:00
parent 8d637c9452
commit 68bec3d6ec
11 changed files with 125 additions and 173 deletions

View file

@ -55,7 +55,6 @@ dependencies {
implementation "androidx.room:room-runtime:2.2.6"
implementation "androidx.cardview:cardview:1.0.0"
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.paging:paging-runtime-ktx:2.1.2'
implementation "androidx.lifecycle:lifecycle-common-java8:2.3.1"
// Android Material

View file

@ -19,7 +19,8 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class ArtistCatalogueAdapter extends RecyclerView.Adapter<ArtistCatalogueAdapter.ViewHolder> {
public class ArtistCatalogueAdapter extends
RecyclerView.Adapter<ArtistCatalogueAdapter.ViewHolder> {
private static final String TAG = "ArtistCatalogueAdapter";
private List<Artist> artists;

View file

@ -179,9 +179,7 @@ public class MainActivity extends BaseActivity {
break;
case BottomSheetBehavior.STATE_HIDDEN:
MusicPlayerRemote.quitPlaying();
mainViewModel.deleteQueue();
break;
}
}

View file

@ -58,7 +58,6 @@ public class AlbumCatalogueFragment extends Fragment {
bind.albumCatalogueRecyclerView.setAdapter(albumAdapter);
albumCatalogueViewModel.getAlbumList().observe(requireActivity(), albums -> {
bind.loadingProgressBar.setVisibility(View.GONE);
bind.albumCatalogueContainer.setVisibility(View.VISIBLE);
albumAdapter.setItems(albums);
});
}

View file

@ -1,6 +1,7 @@
package com.cappielloantonio.play.ui.fragment;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@ -56,10 +57,9 @@ public class ArtistCatalogueFragment extends Fragment {
artistAdapter = new ArtistCatalogueAdapter(requireContext());
bind.artistCatalogueRecyclerView.setAdapter(artistAdapter);
artistCatalogueViewModel.getArtistList().observe(requireActivity(), artists -> {
artistCatalogueViewModel.getArtistList().observe(requireActivity(), artistList -> {
bind.loadingProgressBar.setVisibility(View.GONE);
bind.artistCatalogueContainer.setVisibility(View.VISIBLE);
artistAdapter.setItems(artists);
artistAdapter.setItems(artistList);
});
}
}

View file

@ -138,14 +138,14 @@ public class SearchFragment extends Fragment {
}
public void search(String query) {
if (!query.trim().equals("") && query.trim().length() > 1) {
if (!query.trim().equals("") && query.trim().length() > 2) {
searchViewModel.insertNewSearch(query);
bind.persistentSearchView.collapse();
bind.persistentSearchView.setInputQuery(query);
performSearch(query.trim());
} else {
Toast.makeText(requireContext(), "Enter at least two characters", Toast.LENGTH_SHORT).show();
Toast.makeText(requireContext(), "Enter at least three characters", Toast.LENGTH_SHORT).show();
}
}

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -12,23 +11,10 @@
android:layout_height="wrap_content"
android:indeterminate="true"
android:minWidth="128dp"
android:layout_centerInParent="true"
android:visibility="visible"/>
<androidx.core.widget.NestedScrollView
android:id="@+id/album_catalogue_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/global_padding_bottom">
android:layout_centerInParent="true" />
<TextView
android:id="@+id/album_catalogue_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/open_sans_font_family"
@ -50,8 +36,7 @@
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="16dp"
android:paddingBottom="8dp" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
android:layout_below="@+id/album_catalogue_label"
android:paddingBottom="@dimen/global_padding_bottom"/>
</RelativeLayout>

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -14,20 +13,8 @@
android:minWidth="128dp"
android:layout_centerInParent="true"/>
<androidx.core.widget.NestedScrollView
android:id="@+id/artist_catalogue_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/global_padding_bottom">
<TextView
android:id="@+id/artist_catalogue_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:fontFamily="@font/open_sans_font_family"
@ -49,8 +36,7 @@
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="16dp"
android:paddingBottom="8dp" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
android:layout_below="@+id/artist_catalogue_label"
android:paddingBottom="@dimen/global_padding_bottom"/>
</RelativeLayout>

View file

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
@ -14,21 +13,9 @@
android:minWidth="128dp"
android:layout_centerInParent="true"/>
<androidx.core.widget.NestedScrollView
android:id="@+id/genre_catalogue_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="@string/hide_bottom_view_on_scroll_behavior"
android:visibility="gone">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingBottom="@dimen/global_padding_bottom">
<!-- Label and button -->
<LinearLayout
android:id="@+id/genre_catalogue_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
@ -73,8 +60,7 @@
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="16dp"
android:paddingBottom="8dp" />
</LinearLayout>
</androidx.core.widget.NestedScrollView>
android:paddingBottom="@dimen/global_padding_bottom"
android:layout_below="@+id/genre_catalogue_container"/>
</RelativeLayout>

View file

@ -97,7 +97,8 @@
android:clipToPadding="false"
android:paddingStart="8dp"
android:paddingTop="4dp"
android:paddingEnd="8dp" />
android:paddingEnd="8dp"
android:nestedScrollingEnabled="false"/>
</LinearLayout>
<!-- Search result -->
@ -142,7 +143,8 @@
android:clipToPadding="false"
android:overScrollMode="never"
android:paddingTop="8dp"
android:paddingBottom="24dp" />
android:paddingBottom="24dp"
android:nestedScrollingEnabled="false"/>
<TextView
android:layout_width="wrap_content"
@ -166,7 +168,8 @@
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="8dp"
android:paddingBottom="16dp" />
android:paddingBottom="16dp"
android:nestedScrollingEnabled="false"/>
<TextView
android:layout_width="wrap_content"
@ -190,7 +193,8 @@
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="8dp"
android:paddingBottom="56dp" />
android:paddingBottom="56dp"
android:nestedScrollingEnabled="false"/>
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>

View file

@ -1,15 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.core.widget.NestedScrollView
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:id="@+id/page_title_label"
android:layout_width="match_parent"
@ -32,5 +27,4 @@
android:clipToPadding="false"
android:paddingTop="8dp"
android:paddingBottom="@dimen/global_padding_bottom"/>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>