mirror of
https://github.com/CappielloAntonio/tempo.git
synced 2026-01-31 14:43:36 +00:00
Added For You top bar
This commit is contained in:
@@ -23,6 +23,7 @@ import com.cappielloantonio.play.adapter.YearAdapter;
|
||||
import com.cappielloantonio.play.databinding.FragmentHomeBinding;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.Util;
|
||||
import com.cappielloantonio.play.viewmodel.HomeViewModel;
|
||||
|
||||
public class HomeFragment extends Fragment {
|
||||
@@ -50,6 +51,7 @@ public class HomeFragment extends Fragment {
|
||||
homeViewModel = new ViewModelProvider(requireActivity()).get(HomeViewModel.class);
|
||||
|
||||
init();
|
||||
initForYouBar();
|
||||
|
||||
return view;
|
||||
}
|
||||
@@ -112,6 +114,12 @@ public class HomeFragment extends Fragment {
|
||||
});
|
||||
}
|
||||
|
||||
private void initForYouBar() {
|
||||
bind.homeDateLabel.setText(Util.getDate());
|
||||
|
||||
bind.homeSettingsImageView.setOnClickListener(v -> activity.navController.navigate(R.id.action_homeFragment_to_settingsFragment));
|
||||
}
|
||||
|
||||
private void initDiscoverSongSlideView() {
|
||||
bind.discoverSongViewPager.setOrientation(ViewPager2.ORIENTATION_HORIZONTAL);
|
||||
|
||||
@@ -221,6 +229,7 @@ public class HomeFragment extends Fragment {
|
||||
public void reorder() {
|
||||
if(bind != null) {
|
||||
bind.homeLinearLayoutContainer.removeAllViews();
|
||||
bind.homeLinearLayoutContainer.addView(bind.forYouSector);
|
||||
bind.homeLinearLayoutContainer.addView(bind.homeDiscoverSector);
|
||||
bind.homeLinearLayoutContainer.addView(bind.homeRecentlyAddedTracksSector);
|
||||
bind.homeLinearLayoutContainer.addView(bind.homeFlashbackSector);
|
||||
|
||||
14
app/src/main/java/com/cappielloantonio/play/util/Util.java
Normal file
14
app/src/main/java/com/cappielloantonio/play/util/Util.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package com.cappielloantonio.play.util;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
public class Util {
|
||||
public static String getDate() {
|
||||
String pattern = "EEEE, MMMM d";
|
||||
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
|
||||
String date = simpleDateFormat.format(new Date());
|
||||
|
||||
return date;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user