mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-02 02:13:33 +00:00
Fix bug in image visualization
This commit is contained in:
parent
a0f417fa94
commit
18fae806a6
36 changed files with 431 additions and 150 deletions
|
|
@ -81,6 +81,16 @@ public class MainActivity extends BaseActivity {
|
|||
});
|
||||
}
|
||||
|
||||
// True: VISIBLE
|
||||
// False: GONE
|
||||
public void setBottomNavigationBarVisibility(boolean visibility) {
|
||||
if (visibility) {
|
||||
bottomNavigationView.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
bottomNavigationView.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void goToLogin() {
|
||||
if (Objects.requireNonNull(navController.getCurrentDestination()).getId() == R.id.landingFragment)
|
||||
navController.navigate(R.id.action_landingFragment_to_loginFragment);
|
||||
|
|
@ -89,10 +99,7 @@ public class MainActivity extends BaseActivity {
|
|||
public void goToSync() {
|
||||
bottomNavigationView.setVisibility(View.GONE);
|
||||
|
||||
if (Objects.requireNonNull(navController.getCurrentDestination()).getId() == R.id.landingFragment) {
|
||||
Bundle bundle = SyncUtil.getSyncBundle(true, true, true, true, true, false);
|
||||
navController.navigate(R.id.action_landingFragment_to_syncFragment, bundle);
|
||||
} else if (Objects.requireNonNull(navController.getCurrentDestination()).getId() == R.id.loginFragment) {
|
||||
if (Objects.requireNonNull(navController.getCurrentDestination()).getId() == R.id.loginFragment) {
|
||||
Bundle bundle = SyncUtil.getSyncBundle(true, true, true, true, true, false);
|
||||
navController.navigate(R.id.action_loginFragment_to_syncFragment, bundle);
|
||||
} else if (Objects.requireNonNull(navController.getCurrentDestination()).getId() == R.id.homeFragment) {
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ public class AlbumPageFragment extends Fragment {
|
|||
|
||||
private void initBackCover() {
|
||||
CustomGlideRequest.Builder
|
||||
.from(requireContext(), albumPageViewModel.getAlbum().getPrimary(), albumPageViewModel.getAlbum().getBlurHash(), CustomGlideRequest.PRIMARY)
|
||||
.from(requireContext(), albumPageViewModel.getAlbum().getPrimary(), albumPageViewModel.getAlbum().getBlurHash(), CustomGlideRequest.PRIMARY, CustomGlideRequest.TOP_QUALITY)
|
||||
.build()
|
||||
.into(bind.albumBackCoverImageView);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,20 +55,17 @@ public class ArtistPageFragment extends Fragment {
|
|||
artistPageViewModel.setArtist(getArguments().getParcelable("artist_object"));
|
||||
bind.artistNameLabel.setText(artistPageViewModel.getArtist().getName());
|
||||
|
||||
bind.mostStreamedSongTextViewClickable.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Song.BY_ARTIST, Song.BY_ARTIST);
|
||||
bundle.putParcelable("artist_object", artistPageViewModel.getArtist());
|
||||
activity.navController.navigate(R.id.action_artistPageFragment_to_songListPageFragment, bundle);
|
||||
}
|
||||
bind.mostStreamedSongTextViewClickable.setOnClickListener(v -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Song.BY_ARTIST, Song.BY_ARTIST);
|
||||
bundle.putParcelable("artist_object", artistPageViewModel.getArtist());
|
||||
activity.navController.navigate(R.id.action_artistPageFragment_to_songListPageFragment, bundle);
|
||||
});
|
||||
}
|
||||
|
||||
private void initBackdrop() {
|
||||
CustomGlideRequest.Builder
|
||||
.from(requireContext(), artistPageViewModel.getArtist().getBackdrop(), artistPageViewModel.getArtist().getBackdropBlurHash(), CustomGlideRequest.BACKDROP)
|
||||
.from(requireContext(), artistPageViewModel.getArtist().getBackdrop(), artistPageViewModel.getArtist().getBackdropBlurHash(), CustomGlideRequest.BACKDROP, CustomGlideRequest.TOP_QUALITY)
|
||||
.build()
|
||||
.into(bind.artistBackdropImageView);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,14 +58,11 @@ public class GenreCatalogueFragment extends Fragment {
|
|||
bind.genreCatalogueRecyclerView.setHasFixedSize(true);
|
||||
|
||||
genreCatalogueAdapter = new GenreCatalogueAdapter(requireContext(), new ArrayList<>());
|
||||
genreCatalogueAdapter.setClickListener(new GenreCatalogueAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Song.BY_GENRE, Song.BY_GENRE);
|
||||
bundle.putParcelable("genre_object", genreCatalogueAdapter.getItem(position));
|
||||
activity.navController.navigate(R.id.action_genreCatalogueFragment_to_songListPageFragment, bundle);
|
||||
}
|
||||
genreCatalogueAdapter.setClickListener((view, position) -> {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString(Song.BY_GENRE, Song.BY_GENRE);
|
||||
bundle.putParcelable("genre_object", genreCatalogueAdapter.getItem(position));
|
||||
activity.navController.navigate(R.id.action_genreCatalogueFragment_to_songListPageFragment, bundle);
|
||||
});
|
||||
bind.genreCatalogueRecyclerView.setAdapter(genreCatalogueAdapter);
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
package com.cappielloantonio.play.ui.fragment;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
|
@ -11,12 +9,10 @@ import android.widget.Toast;
|
|||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.lifecycle.ViewModelProvider;
|
||||
|
||||
import com.cappielloantonio.play.App;
|
||||
import com.cappielloantonio.play.R;
|
||||
import com.cappielloantonio.play.databinding.FragmentSyncBinding;
|
||||
import com.cappielloantonio.play.interfaces.MediaCallback;
|
||||
import com.cappielloantonio.play.model.Album;
|
||||
|
|
@ -34,8 +30,6 @@ import com.cappielloantonio.play.ui.activities.MainActivity;
|
|||
import com.cappielloantonio.play.util.PreferenceUtil;
|
||||
import com.cappielloantonio.play.util.SyncUtil;
|
||||
import com.cappielloantonio.play.viewmodel.SyncViewModel;
|
||||
import com.google.android.material.snackbar.BaseTransientBottomBar;
|
||||
import com.google.android.material.snackbar.Snackbar;
|
||||
|
||||
import org.jellyfin.apiclient.model.dto.BaseItemDto;
|
||||
|
||||
|
|
@ -181,7 +175,7 @@ public class SyncFragment extends Fragment {
|
|||
|
||||
private void syncSongs() {
|
||||
Log.d(TAG, "syncSongs");
|
||||
SyncUtil.getSongs(requireContext(), new MediaCallback() {
|
||||
SyncUtil.getSongs(requireContext(), syncViewModel.getCatalogue(), new MediaCallback() {
|
||||
@Override
|
||||
public void onError(Exception exception) {
|
||||
Log.e(TAG, "onError: " + exception.getMessage());
|
||||
|
|
@ -191,6 +185,7 @@ public class SyncFragment extends Fragment {
|
|||
@Override
|
||||
public void onLoadMedia(List<?> media) {
|
||||
SongRepository repository = new SongRepository(activity.getApplication());
|
||||
repository.deleteAllSongGenreCross();
|
||||
repository.insertAll((ArrayList<Song>) media);
|
||||
animateProgressBar(true);
|
||||
}
|
||||
|
|
@ -198,6 +193,8 @@ public class SyncFragment extends Fragment {
|
|||
}
|
||||
|
||||
private void syncSongsPerGenre(List<Genre> genres) {
|
||||
Log.d(TAG, "syncSongsPerGenre");
|
||||
|
||||
for (Genre genre : genres) {
|
||||
SyncUtil.getSongsPerGenre(requireContext(), new MediaCallback() {
|
||||
@Override
|
||||
|
|
@ -207,24 +204,30 @@ public class SyncFragment extends Fragment {
|
|||
|
||||
@Override
|
||||
public void onLoadMedia(List<?> media) {
|
||||
GenreRepository repository = new GenreRepository(App.getInstance());
|
||||
repository.insertPerGenre((ArrayList<SongGenreCross>) media);
|
||||
SongRepository repository = new SongRepository(App.getInstance());
|
||||
repository.insertSongPerGenre((ArrayList<SongGenreCross>) media);
|
||||
}
|
||||
}, genre.id);
|
||||
}
|
||||
|
||||
Log.d(TAG, "syncSongsPerGenre: set progress");
|
||||
|
||||
animateProgressBar(true);
|
||||
PreferenceUtil.getInstance(requireContext()).setSongGenreSync(true);
|
||||
}
|
||||
|
||||
|
||||
private void animateProgressBar(boolean step) {
|
||||
Log.d(TAG, "animateProgressBar: PROGRESS " + step);
|
||||
syncViewModel.setProgress(step);
|
||||
bind.loadingProgressBar.setProgress(syncViewModel.getProgressBarInfo(), true);
|
||||
countProgress();
|
||||
}
|
||||
|
||||
private void countProgress() {
|
||||
Log.d(TAG, "countProgress = " + syncViewModel.getProgress());
|
||||
Log.d(TAG, "progressbar = " + syncViewModel.getProgressBarInfo());
|
||||
|
||||
if (syncViewModel.getProgress() == syncViewModel.getStep()) {
|
||||
if (syncViewModel.getProgressBarInfo() >= 100)
|
||||
terminate();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue