Simplified layout hierarchy in fragment_album_page

This commit is contained in:
CappielloAntonio 2021-05-01 19:17:51 +02:00
parent 9312d0e203
commit 76a1bc6541
2 changed files with 44 additions and 50 deletions

View file

@ -122,18 +122,12 @@ public class AlbumPageFragment extends Fragment {
activity.getSupportActionBar().setDisplayShowHomeEnabled(true);
}
bind.animToolbar.setTitle(albumPageViewModel.getAlbum().getTitle());
bind.albumNameLabel.setText(albumPageViewModel.getAlbum().getTitle());
bind.albumArtistLabel.setText(albumPageViewModel.getAlbum().getArtistName());
bind.albumReleaseYearLabel.setText(albumPageViewModel.getAlbum().getYear() != 0 ? String.valueOf(albumPageViewModel.getAlbum().getYear()) : "");
bind.appBarLayout.addOnOffsetChangedListener((appBarLayout, verticalOffset) -> {
if ((bind.albumInfoSector.getHeight() + verticalOffset) < (2 * ViewCompat.getMinimumHeight(bind.animToolbar))) {
bind.animToolbar.setTitle(albumPageViewModel.getAlbum().getTitle());
} else {
bind.animToolbar.setTitle("Album");
}
});
bind.animToolbar.setNavigationOnClickListener(v -> activity.navController.navigateUp());
}

View file

@ -14,23 +14,21 @@
app:popupTheme="@style/ThemeOverlay.MaterialComponents.Light"
app:titleTextColor="@color/titleTextColor" />
<androidx.coordinatorlayout.widget.CoordinatorLayout
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingTop="8dp">
android:layout_height="wrap_content">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:elevation="0dp">
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/album_info_sector"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false"
app:layout_scrollFlags="scroll|exitUntilCollapsed|snap">
android:paddingTop="8dp">
<ImageView
android:id="@+id/album_cover_image_view"
@ -144,51 +142,53 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/album_page_button_layout" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.appbar.AppBarLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingBottom="@dimen/global_padding_bottom"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/song_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingTop="8dp" />
<LinearLayout
android:id="@+id/similar_album_sector"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<TextView
style="@style/HeadlineTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingTop="32dp"
android:paddingEnd="20dp"
android:text="More like this" />
android:paddingBottom="@dimen/global_padding_bottom"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/similar_albums_recycler_view"
android:id="@+id/song_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="8dp"
android:paddingBottom="8dp" />
android:nestedScrollingEnabled="false"
android:paddingTop="8dp" />
<LinearLayout
android:id="@+id/similar_album_sector"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<TextView
style="@style/HeadlineTextView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingStart="16dp"
android:paddingTop="32dp"
android:paddingEnd="20dp"
android:text="More like this" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/similar_albums_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:clipToPadding="false"
android:nestedScrollingEnabled="false"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="8dp"
android:paddingBottom="8dp" />
</LinearLayout>
</LinearLayout>
</LinearLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
</androidx.core.widget.NestedScrollView>
</LinearLayout>