mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 01:53:31 +00:00
TEST - New toolbar in HomeFragment and LibraryFragment
This commit is contained in:
parent
661899c7f7
commit
fbb9536d7e
9 changed files with 837 additions and 665 deletions
|
|
@ -1,7 +1,11 @@
|
|||
package com.cappielloantonio.play.ui.fragment;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
|
|
@ -31,10 +35,14 @@ import com.cappielloantonio.play.model.Album;
|
|||
import com.cappielloantonio.play.model.Artist;
|
||||
import com.cappielloantonio.play.model.Song;
|
||||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.util.DownloadUtil;
|
||||
import com.cappielloantonio.play.util.MappingUtil;
|
||||
import com.cappielloantonio.play.util.MusicUtil;
|
||||
import com.cappielloantonio.play.util.UIUtil;
|
||||
import com.cappielloantonio.play.viewmodel.HomeViewModel;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class HomeFragment extends Fragment {
|
||||
private static final String TAG = "CategoriesFragment";
|
||||
|
||||
|
|
@ -53,6 +61,18 @@ public class HomeFragment extends Fragment {
|
|||
private TrackAdapter dowanloadedMusicAdapter;
|
||||
private SimilarTrackAdapter similarMusicAdapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
inflater.inflate(R.menu.main_page_menu, menu);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
|
@ -71,6 +91,7 @@ public class HomeFragment extends Fragment {
|
|||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
initAppBar();
|
||||
initDiscoverSongSlideView();
|
||||
initSimilarSongView();
|
||||
initMostPlayedAlbumView();
|
||||
|
|
@ -96,6 +117,22 @@ public class HomeFragment extends Fragment {
|
|||
bind = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_search:
|
||||
activity.navController.navigate(R.id.action_homeFragment_to_searchFragment);
|
||||
return true;
|
||||
case R.id.action_settings:
|
||||
activity.navController.navigate(R.id.action_homeFragment_to_settingsFragment);
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
bind.recentlyAddedAlbumsTextViewClickable.setOnClickListener(v -> {
|
||||
Bundle bundle = new Bundle();
|
||||
|
|
@ -139,8 +176,6 @@ public class HomeFragment extends Fragment {
|
|||
activity.navController.navigate(R.id.action_homeFragment_to_songListPageFragment, bundle);
|
||||
});
|
||||
|
||||
bind.homeSettingsImageView.setOnClickListener(v -> activity.navController.navigate(R.id.action_homeFragment_to_settingsFragment));
|
||||
|
||||
bind.musicDiscoveryTextViewRefreshable.setOnLongClickListener(v -> {
|
||||
homeViewModel.refreshDiscoverySongSample(requireActivity());
|
||||
return true;
|
||||
|
|
@ -182,6 +217,11 @@ public class HomeFragment extends Fragment {
|
|||
});
|
||||
}
|
||||
|
||||
private void initAppBar() {
|
||||
activity.setSupportActionBar(bind.toolbar);
|
||||
Objects.requireNonNull(bind.toolbar.getOverflowIcon()).setTint(requireContext().getResources().getColor(R.color.titleTextColor, null));
|
||||
}
|
||||
|
||||
private void initDiscoverSongSlideView() {
|
||||
bind.discoverSongViewPager.setOrientation(ViewPager2.ORIENTATION_HORIZONTAL);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,9 @@ package com.cappielloantonio.play.ui.fragment;
|
|||
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
|
|
@ -25,6 +28,8 @@ import com.cappielloantonio.play.model.Song;
|
|||
import com.cappielloantonio.play.ui.activity.MainActivity;
|
||||
import com.cappielloantonio.play.viewmodel.LibraryViewModel;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
public class LibraryFragment extends Fragment {
|
||||
private static final String TAG = "LibraryFragment";
|
||||
|
||||
|
|
@ -37,6 +42,18 @@ public class LibraryFragment extends Fragment {
|
|||
private GenreAdapter genreAdapter;
|
||||
private PlaylistAdapter playlistAdapter;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setHasOptionsMenu(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
|
||||
super.onCreateOptionsMenu(menu, inflater);
|
||||
inflater.inflate(R.menu.main_page_menu, menu);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
|
|
@ -55,6 +72,7 @@ public class LibraryFragment extends Fragment {
|
|||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
initAppBar();
|
||||
initAlbumView();
|
||||
initArtistView();
|
||||
initGenreView();
|
||||
|
|
@ -73,6 +91,22 @@ public class LibraryFragment extends Fragment {
|
|||
bind = null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case R.id.action_search:
|
||||
activity.navController.navigate(R.id.action_libraryFragment_to_searchFragment);
|
||||
return true;
|
||||
case R.id.action_settings:
|
||||
activity.navController.navigate(R.id.action_libraryFragment_to_settingsFragment);
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private void init() {
|
||||
bind.albumCatalogueTextViewClickable.setOnClickListener(v -> activity.navController.navigate(R.id.action_libraryFragment_to_albumCatalogueFragment));
|
||||
bind.artistCatalogueTextViewClickable.setOnClickListener(v -> activity.navController.navigate(R.id.action_libraryFragment_to_artistCatalogueFragment));
|
||||
|
|
@ -97,6 +131,11 @@ public class LibraryFragment extends Fragment {
|
|||
});
|
||||
}
|
||||
|
||||
private void initAppBar() {
|
||||
activity.setSupportActionBar(bind.toolbar);
|
||||
Objects.requireNonNull(bind.toolbar.getOverflowIcon()).setTint(requireContext().getResources().getColor(R.color.titleTextColor, null));
|
||||
}
|
||||
|
||||
private void initAlbumView() {
|
||||
bind.albumRecyclerView.setLayoutManager(new LinearLayoutManager(requireContext(), LinearLayoutManager.HORIZONTAL, false));
|
||||
bind.albumRecyclerView.setHasFixedSize(true);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue