mirror of
https://github.com/antebudimir/tempus.git
synced 2026-01-01 18:03:33 +00:00
fix: fixed incorrect album release date, hid release date TextView when there is no data
This commit is contained in:
parent
bfd6f28d7a
commit
44f8160e21
2 changed files with 19 additions and 7 deletions
|
|
@ -14,11 +14,20 @@ open class ItemDate : Parcelable {
|
||||||
var month: Int? = null
|
var month: Int? = null
|
||||||
var day: Int? = null
|
var day: Int? = null
|
||||||
|
|
||||||
fun getFormattedDate(): String {
|
fun getFormattedDate(): String? {
|
||||||
val calendar = Calendar.getInstance()
|
if (year == null && month == null && day == null) return null
|
||||||
val dateFormat = SimpleDateFormat("MMMM dd, yyyy", Locale.getDefault())
|
|
||||||
|
|
||||||
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) // Default to 1 if day is null
|
||||||
|
|
||||||
return dateFormat.format(calendar.time)
|
return dateFormat.format(calendar.time)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -149,13 +149,16 @@ public class AlbumPageFragment extends Fragment implements ClickCallback {
|
||||||
bind.albumGenresTextview.setText(album.getGenre());
|
bind.albumGenresTextview.setText(album.getGenre());
|
||||||
|
|
||||||
if (album.getReleaseDate() != null && album.getOriginalReleaseDate() != null) {
|
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()));
|
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())) {
|
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()));
|
bind.albumReleaseYearsTextview.setText(getString(R.string.album_page_release_date_label, album.getReleaseDate().getFormattedDate()));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue