mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 09:33:33 +00:00
Merge pull request #24 from jaime-grj/fix-albumpage
fix: hide unnecessary TextViews in AlbumPageFragment when there is no data, fixed incorrect album release date
This commit is contained in:
commit
76293af038
3 changed files with 30 additions and 9 deletions
|
|
@ -14,11 +14,20 @@ open class ItemDate : Parcelable {
|
|||
var month: Int? = null
|
||||
var day: Int? = null
|
||||
|
||||
fun getFormattedDate(): String {
|
||||
val calendar = Calendar.getInstance()
|
||||
val dateFormat = SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault())
|
||||
fun getFormattedDate(): String? {
|
||||
if (year == null && month == null && day == null) return null
|
||||
|
||||
calendar.set(year ?: 0, month ?: 0, day ?: 0)
|
||||
val calendar = Calendar.getInstance()
|
||||
val dateFormat = if (month == null && day == null) {
|
||||
SimpleDateFormat("yyyy", Locale.getDefault())
|
||||
} else if (day == null) {
|
||||
SimpleDateFormat("MMMM yyyy", Locale.getDefault())
|
||||
}
|
||||
else{
|
||||
SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault())
|
||||
}
|
||||
|
||||
calendar.set(year ?: 0, month ?: 1, day ?: 1)
|
||||
|
||||
return dateFormat.format(calendar.time)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -145,17 +145,27 @@ public class AlbumPageFragment extends Fragment implements ClickCallback {
|
|||
bind.albumNameLabel.setText(album.getName());
|
||||
bind.albumArtistLabel.setText(album.getArtist());
|
||||
bind.albumReleaseYearLabel.setText(album.getYear() != 0 ? String.valueOf(album.getYear()) : "");
|
||||
bind.albumReleaseYearLabel.setVisibility(album.getYear() != 0 ? View.VISIBLE : View.GONE);
|
||||
bind.albumSongCountDurationTextview.setText(getString(R.string.album_page_tracks_count_and_duration, album.getSongCount(), album.getDuration() != null ? album.getDuration() / 60 : 0));
|
||||
bind.albumGenresTextview.setText(album.getGenre());
|
||||
if (album.getGenre() != null && !album.getGenre().isEmpty()) {
|
||||
bind.albumGenresTextview.setText(album.getGenre());
|
||||
bind.albumGenresTextview.setVisibility(View.VISIBLE);
|
||||
}
|
||||
else{
|
||||
bind.albumGenresTextview.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if (album.getReleaseDate() != null && album.getOriginalReleaseDate() != null) {
|
||||
bind.albumReleaseYearsTextview.setVisibility(View.VISIBLE);
|
||||
if (album.getReleaseDate().getFormattedDate() != null || album.getOriginalReleaseDate().getFormattedDate() != null)
|
||||
bind.albumReleaseYearsTextview.setVisibility(View.VISIBLE);
|
||||
else
|
||||
bind.albumReleaseYearsTextview.setVisibility(View.GONE);
|
||||
|
||||
if (album.getReleaseDate() == null || album.getOriginalReleaseDate() == null) {
|
||||
if (album.getReleaseDate().getFormattedDate() == null || album.getOriginalReleaseDate().getFormattedDate() == null) {
|
||||
bind.albumReleaseYearsTextview.setText(getString(R.string.album_page_release_date_label, album.getReleaseDate() != null ? album.getReleaseDate().getFormattedDate() : album.getOriginalReleaseDate().getFormattedDate()));
|
||||
}
|
||||
|
||||
if (album.getReleaseDate() != null && album.getOriginalReleaseDate() != null) {
|
||||
if (album.getReleaseDate().getFormattedDate() != null && album.getOriginalReleaseDate().getFormattedDate() != null) {
|
||||
if (Objects.equals(album.getReleaseDate().getYear(), album.getOriginalReleaseDate().getYear()) && Objects.equals(album.getReleaseDate().getMonth(), album.getOriginalReleaseDate().getMonth()) && Objects.equals(album.getReleaseDate().getDay(), album.getOriginalReleaseDate().getDay())) {
|
||||
bind.albumReleaseYearsTextview.setText(getString(R.string.album_page_release_date_label, album.getReleaseDate().getFormattedDate()));
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -126,9 +126,11 @@
|
|||
android:layout_marginEnd="18dp"
|
||||
android:text="@string/label_placeholder"
|
||||
android:textAlignment="center"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
tools:visibility="visible" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/album_song_count_duration_textview"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue