mirror of
https://github.com/antebudimir/tempus.git
synced 2026-04-15 16:27:26 +00:00
feat: feat: advertise existing long press to refresh per section (#467)
* feat: advertise existing long press to refresh per section --------- Co-authored-by: eddyizm <eddyizm@gmail.com>
This commit is contained in:
parent
88c2129cd4
commit
c7f2524085
3 changed files with 159 additions and 30 deletions
|
|
@ -101,6 +101,7 @@ dependencies {
|
|||
implementation 'androidx.room:room-runtime:2.6.1'
|
||||
implementation 'androidx.core:core-splashscreen:1.0.1'
|
||||
implementation 'androidx.appcompat:appcompat:1.7.0'
|
||||
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.2.0"
|
||||
|
||||
// Android Material
|
||||
implementation 'com.google.android.material:material:1.10.0'
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@ import android.view.ViewGroup;
|
|||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.lifecycle.LifecycleOwner;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
import androidx.media3.common.util.UnstableApi;
|
||||
import androidx.media3.session.MediaBrowser;
|
||||
|
|
@ -16,8 +18,11 @@ import androidx.media3.session.SessionToken;
|
|||
import androidx.navigation.Navigation;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
|
||||
|
||||
import com.cappielloantonio.tempo.R;
|
||||
import com.cappielloantonio.tempo.databinding.FragmentLibraryBinding;
|
||||
|
|
@ -43,6 +48,7 @@ import java.util.Objects;
|
|||
@UnstableApi
|
||||
public class LibraryFragment extends Fragment implements ClickCallback {
|
||||
private static final String TAG = "LibraryFragment";
|
||||
private static final String TOAST_MSG = "Long press to refresh" ;
|
||||
|
||||
private FragmentLibraryBinding bind;
|
||||
private MainActivity activity;
|
||||
|
|
@ -81,6 +87,7 @@ public class LibraryFragment extends Fragment implements ClickCallback {
|
|||
initArtistView();
|
||||
initGenreView();
|
||||
initPlaylistView();
|
||||
initSwipeToRefresh();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -112,22 +119,41 @@ public class LibraryFragment extends Fragment implements ClickCallback {
|
|||
activity.navController.navigate(R.id.action_libraryFragment_to_playlistCatalogueFragment, bundle);
|
||||
});
|
||||
|
||||
// Album
|
||||
bind.albumCatalogueSampleTextViewRefreshable.setOnLongClickListener(view -> {
|
||||
libraryViewModel.refreshAlbumSample(getViewLifecycleOwner());
|
||||
return true;
|
||||
});
|
||||
bind.albumCatalogueSampleTextViewRefreshable.setOnClickListener( v ->
|
||||
Toast.makeText(requireContext(), TOAST_MSG, Toast.LENGTH_SHORT).show()
|
||||
);
|
||||
|
||||
// Artist
|
||||
bind.artistCatalogueSampleTextViewRefreshable.setOnLongClickListener(view -> {
|
||||
libraryViewModel.refreshArtistSample(getViewLifecycleOwner());
|
||||
return true;
|
||||
});
|
||||
bind.artistCatalogueSampleTextViewRefreshable.setOnClickListener( v ->
|
||||
Toast.makeText(requireContext(), TOAST_MSG, Toast.LENGTH_SHORT).show()
|
||||
);
|
||||
|
||||
// Genre
|
||||
bind.genreCatalogueSampleTextViewRefreshable.setOnLongClickListener(view -> {
|
||||
libraryViewModel.refreshGenreSample(getViewLifecycleOwner());
|
||||
return true;
|
||||
});
|
||||
bind.genreCatalogueSampleTextViewRefreshable.setOnClickListener(v ->
|
||||
Toast.makeText(requireContext(), TOAST_MSG, Toast.LENGTH_SHORT).show()
|
||||
);
|
||||
|
||||
// Playlist
|
||||
bind.playlistCatalogueSampleTextViewRefreshable.setOnLongClickListener(view -> {
|
||||
libraryViewModel.refreshPlaylistSample(getViewLifecycleOwner());
|
||||
return true;
|
||||
});
|
||||
bind.playlistCatalogueSampleTextViewRefreshable.setOnClickListener( v ->
|
||||
Toast.makeText(requireContext(), TOAST_MSG, Toast.LENGTH_SHORT).show()
|
||||
);
|
||||
}
|
||||
|
||||
private void initAppBar() {
|
||||
|
|
@ -304,4 +330,20 @@ public class LibraryFragment extends Fragment implements ClickCallback {
|
|||
private void initializeMediaBrowser() {
|
||||
mediaBrowserListenableFuture = new MediaBrowser.Builder(requireContext(), new SessionToken(requireContext(), new ComponentName(requireContext(), MediaService.class))).buildAsync();
|
||||
}
|
||||
|
||||
public void initSwipeToRefresh() {
|
||||
bind.swipeLibraryToRefresh.setOnRefreshListener(() -> {
|
||||
pullToRefresh();
|
||||
bind.swipeLibraryToRefresh.setRefreshing(false);
|
||||
});
|
||||
}
|
||||
|
||||
private void pullToRefresh() {
|
||||
LifecycleOwner lifecycleOwner = getViewLifecycleOwner();
|
||||
libraryViewModel.refreshAlbumSample(lifecycleOwner);
|
||||
libraryViewModel.refreshGenreSample(lifecycleOwner);
|
||||
libraryViewModel.refreshArtistSample(lifecycleOwner);
|
||||
libraryViewModel.refreshPlaylistSample(lifecycleOwner);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,12 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
|
||||
<androidx.swiperefreshlayout.widget.SwipeRefreshLayout
|
||||
android:id="@+id/swipe_library_to_refresh"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||
|
||||
<androidx.core.widget.NestedScrollView
|
||||
android:id="@+id/fragment_library_nested_scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
|
|
@ -77,21 +83,41 @@
|
|||
android:paddingEnd="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<TextView
|
||||
<!-- Refreshable area -->
|
||||
<LinearLayout
|
||||
android:id="@+id/album_catalogue_sample_text_view_refreshable"
|
||||
style="@style/TitleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<TextView
|
||||
style="@style/TitleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="@string/library_title_album" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:alpha="0.4"
|
||||
android:src="@drawable/ic_refresh"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="@string/library_title_album" />
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/album_catalogue_text_view_clickable"
|
||||
style="@style/TitleMedium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="@string/library_title_album_see_all_button" />
|
||||
|
|
@ -130,22 +156,41 @@
|
|||
android:paddingEnd="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<TextView
|
||||
<!-- Refreshable area -->
|
||||
<LinearLayout
|
||||
android:id="@+id/artist_catalogue_sample_text_view_refreshable"
|
||||
style="@style/TitleLarge"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="@string/library_title_artist" />
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<TextView
|
||||
style="@style/TitleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="@string/library_title_artist" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:alpha="0.4"
|
||||
android:src="@drawable/ic_refresh"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/artist_catalogue_text_view_clickable"
|
||||
style="@style/TitleMedium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="@string/library_title_artist_see_all_button" />
|
||||
|
|
@ -184,25 +229,45 @@
|
|||
android:paddingEnd="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<TextView
|
||||
<!-- Refreshable area -->
|
||||
<LinearLayout
|
||||
android:id="@+id/genre_catalogue_sample_text_view_refreshable"
|
||||
style="@style/TitleLarge"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="@string/library_title_genre" />
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<TextView
|
||||
style="@style/TitleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="@string/library_title_genre" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:alpha="0.4"
|
||||
android:src="@drawable/ic_refresh"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/genre_catalogue_text_view_clickable"
|
||||
style="@style/TitleMedium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="@string/library_title_genre_see_all_button" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
|
|
@ -236,21 +301,41 @@
|
|||
android:paddingEnd="8dp"
|
||||
android:paddingBottom="8dp">
|
||||
|
||||
<TextView
|
||||
<!-- Refreshable area -->
|
||||
<LinearLayout
|
||||
android:id="@+id/playlist_catalogue_sample_text_view_refreshable"
|
||||
style="@style/TitleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<TextView
|
||||
style="@style/TitleLarge"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="@string/library_title_playlist" />
|
||||
|
||||
<ImageView
|
||||
android:layout_width="28dp"
|
||||
android:layout_height="28dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_marginBottom="2dp"
|
||||
android:alpha="0.4"
|
||||
android:src="@drawable/ic_refresh"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="@string/library_title_playlist" />
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/playlist_catalogue_text_view_clickable"
|
||||
style="@style/TitleMedium"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="end|center_vertical"
|
||||
android:paddingStart="8dp"
|
||||
android:paddingEnd="8dp"
|
||||
android:text="@string/library_title_playlist_see_all_button" />
|
||||
|
|
@ -270,4 +355,5 @@
|
|||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||
Loading…
Add table
Add a link
Reference in a new issue