mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 02:13:33 +00:00
TEST - MediaBrowserListenableFuture passed from activity to fragment to adapter
This commit is contained in:
parent
279272a3af
commit
1926c7a696
4 changed files with 68 additions and 55 deletions
|
|
@ -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.Menu;
|
||||
import android.view.MenuInflater;
|
||||
|
|
@ -44,7 +45,7 @@ import com.cappielloantonio.play.viewmodel.HomeViewModel;
|
|||
import java.util.Objects;
|
||||
|
||||
public class HomeFragment extends Fragment {
|
||||
private static final String TAG = "CategoriesFragment";
|
||||
private static final String TAG = "HomeFragment";
|
||||
|
||||
private FragmentHomeBinding bind;
|
||||
private MainActivity activity;
|
||||
|
|
@ -106,10 +107,23 @@ public class HomeFragment extends Fragment {
|
|||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
|
||||
activity.setBottomNavigationBarVisibility(true);
|
||||
activity.setBottomSheetVisibility(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
setMediaBrowserListenableFuture();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroyView() {
|
||||
super.onDestroyView();
|
||||
|
|
@ -212,6 +226,12 @@ public class HomeFragment extends Fragment {
|
|||
Objects.requireNonNull(bind.toolbar.getOverflowIcon()).setTint(requireContext().getResources().getColor(R.color.titleTextColor, null));
|
||||
}
|
||||
|
||||
private void setMediaBrowserListenableFuture() {
|
||||
discoverSongAdapter.setMediaBrowserListenableFuture(activity.getMediaBrowserListenableFuture());
|
||||
similarMusicAdapter.setMediaBrowserListenableFuture(activity.getMediaBrowserListenableFuture());
|
||||
starredSongAdapter.setMediaBrowserListenableFuture(activity.getMediaBrowserListenableFuture());
|
||||
}
|
||||
|
||||
private void initDiscoverSongSlideView() {
|
||||
bind.discoverSongViewPager.setOrientation(ViewPager2.ORIENTATION_HORIZONTAL);
|
||||
|
||||
|
|
@ -230,6 +250,13 @@ public class HomeFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
bind.discoverSongViewPager.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Log.d(TAG, "onClick: " + view.toString());
|
||||
}
|
||||
});
|
||||
|
||||
setDiscoverSongSlideViewOffset(20, 16);
|
||||
}
|
||||
|
||||
|
|
@ -237,7 +264,7 @@ public class HomeFragment extends Fragment {
|
|||
bind.similarTracksRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||
bind.similarTracksRecyclerView.setHasFixedSize(true);
|
||||
|
||||
similarMusicAdapter = new SimilarTrackAdapter(activity, requireContext());
|
||||
similarMusicAdapter = new SimilarTrackAdapter(requireContext());
|
||||
bind.similarTracksRecyclerView.setAdapter(similarMusicAdapter);
|
||||
homeViewModel.getStarredTracksSample().observe(requireActivity(), songs -> {
|
||||
if (songs == null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue