Skip to content

Commit

Permalink
Fixed many issues after sort method changed
Browse files Browse the repository at this point in the history
  • Loading branch information
tsshadow committed Feb 7, 2025
1 parent 6de162b commit 7f1acf0
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ interface SubsonicAPIDefinition {

@GET("getSongs.view")
fun getSongs(
@Query("clusters") clusters: String,
@Query("clusters") clusters: String?,
@Query("ratingMin") ratingMin: Int? = null,
@Query("ratingMax") ratingMax: Int? = null,
@Query("count") count: Int = 10,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,13 @@ class Filters {
}

override fun toString(): String {
var str = "["
filters.forEach { str += "$it," }
str = str.substring(0, str.length - 1)
str += "]"
var str = "";
if (this.filters.isNotEmpty()) {
str = "["
filters.forEach { str += "$it," }
str = str.substring(0, str.length - 1)
str += "]"
}
return str
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -586,12 +586,7 @@ open class TrackCollectionFragment(
} else if(getSongsName != null) {
setTitle(getSongsName)
val filters = Filters()
if (year !== null && year.isNotEmpty()) filters.add(
Filter(
"YEAR",
year.toString()
)
)
year.ifNotNull { if(year !== "All" && year!== "") filters.add(Filter("YEAR", year.toString()))}
if (length !== null && length.isNotEmpty()) filters.add(
Filter(
"LENGTH",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ class LandingPageFragment : Fragment(), KoinComponent {
private lateinit var songsTitle: TextView
private lateinit var randomSongsButton: TextView
private lateinit var recentSongsButton: TextView
private lateinit var recentModifiedSongsButton: TextView
private lateinit var randomSongsThisYearButton: TextView

// Livesets
private lateinit var livesetsTitle: TextView
private lateinit var randomLivesetsButton: TextView
private lateinit var recentLivesetsButton: TextView
private lateinit var recentModifiedLivesetsButton: TextView
private lateinit var randomLivesetsThisYearButton: TextView

private lateinit var albumsTitle: TextView
Expand Down Expand Up @@ -98,12 +100,14 @@ class LandingPageFragment : Fragment(), KoinComponent {
randomSongsButton = binding!!.findViewById(R.id.main_songs_button)
randomSongsThisYearButton = binding!!.findViewById(R.id.main_songs_this_year_button)
recentSongsButton = binding!!.findViewById(R.id.main_songs_recent)
recentModifiedSongsButton = binding!!.findViewById(R.id.main_songs_recent_modified)

// Livesets
livesetsTitle = binding!!.findViewById(R.id.main_livesets)
randomLivesetsButton = binding!!.findViewById(R.id.main_livesets_button)
randomLivesetsThisYearButton = binding!!.findViewById(R.id.main_livesets_this_year_button)
recentLivesetsButton = binding!!.findViewById(R.id.main_livesets_recent)
recentModifiedLivesetsButton = binding!!.findViewById(R.id.main_livesets_recent_modified)

// Albums
albumsTitle = binding!!.findViewById(R.id.main_albums)
Expand Down Expand Up @@ -134,13 +138,15 @@ class LandingPageFragment : Fragment(), KoinComponent {
songsTitle.isVisible = true
randomSongsButton.isVisible = true
recentSongsButton.isVisible = true
recentModifiedSongsButton.isVisible = true
randomSongsThisYearButton.isVisible = true


// Songs
livesetsTitle.isVisible = true
randomLivesetsButton.isVisible = true
recentLivesetsButton.isVisible = true
recentModifiedLivesetsButton.isVisible = true
randomLivesetsThisYearButton.isVisible = true

// Albums
Expand Down Expand Up @@ -187,9 +193,19 @@ class LandingPageFragment : Fragment(), KoinComponent {
val action = NavigationGraphDirections.toTrackCollection(
size = maxSongs,
offset = 0,
sortMethod = "LastWritten",
sortMethod = "LastWrittenDesc",
length = "short",
getSongsName = "Recent Songs"
getSongsName = "Recent added Songs"
)
findNavController().navigate(action)
}
recentModifiedSongsButton.setOnClickListener {
val action = NavigationGraphDirections.toTrackCollection(
size = maxSongs,
offset = 0,
sortMethod = "LastWrittenDesc",
length = "short",
getSongsName = "Recent modified Songs"
)
findNavController().navigate(action)
}
Expand All @@ -204,17 +220,27 @@ class LandingPageFragment : Fragment(), KoinComponent {
findNavController().navigate(action)
}


recentLivesetsButton.setOnClickListener {
val action = NavigationGraphDirections.toTrackCollection(
size = maxSongs,
offset = 0,
sortMethod = "LastWritten",
sortMethod = "AddedDesc",
length = "long",
getSongsName = "Recent Livesets"
getSongsName = "Recent added Livesets"
)
findNavController().navigate(action)
}
recentModifiedLivesetsButton.setOnClickListener {
val action = NavigationGraphDirections.toTrackCollection(
size = maxSongs,
offset = 0,
sortMethod = "LastWrittenDesc",
length = "long",
getSongsName = "Recent modified Livesets"
)
findNavController().navigate(action)
}

randomLivesetsThisYearButton.setOnClickListener {
val action = NavigationGraphDirections.toTrackCollection(
size = maxSongs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ class SelectSongFragment : Fragment(), RefreshableFragment {
"None",
"Id",
"Random",
"LastWritten",
"AddedDesc",
"LastWrittenDesc",
"StarredDateDesc",
"Name",
"DateDescAndRelease",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,9 @@ open class RESTMusicService(
sortMethod: String?): MusicDirectory {

Timber.d(filters.toString())
val response = API.getSongs(filters.toString(), ratingMin, ratingMax, count, offset, null, sortMethod).execute().throwOnFailure()

val response = API.getSongs(if (filters.toString() == "")
null else filters.toString(), ratingMin, ratingMax, count, offset, null, sortMethod).execute().throwOnFailure()

val result = MusicDirectory()
result.addAll(response.body()!!.songsList.toDomainEntityList(activeServerId))
Expand Down
31 changes: 27 additions & 4 deletions ultrasonic/src/main/res/layout/tsshadow_landing_page.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<layout>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/main_list">
Expand Down Expand Up @@ -37,8 +37,20 @@
android:minHeight="40dip"
android:paddingStart="6dip"
android:paddingEnd="6dip"
android:text="@string/main.songs_recent"
android:text="@string/main.songs_recent_added"
android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
android:id="@+id/main_songs_recent_modified"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="40dip"
android:paddingStart="6dip"
android:paddingEnd="6dip"
android:text="@string/main.songs_recent_modified"
android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
android:id="@+id/main_songs_this_year_button"
android:layout_width="fill_parent"
Expand Down Expand Up @@ -77,8 +89,19 @@
android:minHeight="40dip"
android:paddingStart="6dip"
android:paddingEnd="6dip"
android:text="@string/main.songs_recent"
android:text="@string/main.songs_recent_added"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="@+id/main_livesets_recent_modified"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:minHeight="40dip"
android:paddingStart="6dip"
android:paddingEnd="6dip"
android:text="@string/main.songs_recent_modified"
android:textAppearance="?android:attr/textAppearanceMedium" />

<TextView
android:id="@+id/main_livesets_this_year_button"
android:layout_width="fill_parent"
Expand Down
2 changes: 2 additions & 0 deletions ultrasonic/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@
<string name="main.songs_random">Random</string>
<string name="main.songs_random_this_year">Random (2025)</string>
<string name="main.songs_recent">Recent</string>
<string name="main.songs_recent_added">Recent Added</string>
<string name="main.songs_recent_modified">Recent Modified</string>
<string name="main.songs_starred">Starred</string>
<string name="main.songs_title">Songs</string>
<string name="main.livesets_title">Livesets</string>
Expand Down

0 comments on commit 7f1acf0

Please sign in to comment.