Add better offline Support
This commit is contained in:
parent
6aa3124ee9
commit
a23e5ff794
|
@ -117,24 +117,32 @@ public class MainFragment extends Fragment {
|
|||
final MergeAdapter adapter = new MergeAdapter();
|
||||
adapter.addViews(Collections.singletonList(serverButton), true);
|
||||
|
||||
shouldUseId3 = Util.getShouldUseId3Tags();
|
||||
|
||||
if (!ActiveServerProvider.Companion.isOffline())
|
||||
{
|
||||
adapter.addView(musicTitle, false);
|
||||
adapter.addViews(asList(artistsButton, albumsButton, genresButton), true);
|
||||
|
||||
adapter.addView(songsTitle, false);
|
||||
adapter.addViews(asList(randomSongsButton, songsStarredButton), true);
|
||||
adapter.addView(albumsTitle, false);
|
||||
|
||||
if (Util.getShouldUseId3Tags())
|
||||
{
|
||||
shouldUseId3 = true;
|
||||
adapter.addViews(asList(albumsNewestButton, albumsRecentButton, albumsFrequentButton, albumsRandomButton, albumsStarredButton, albumsAlphaByNameButton, albumsAlphaByArtistButton), true);
|
||||
adapter.addView(albumsTitle, false);
|
||||
adapter.addViews(asList(albumsNewestButton, albumsRecentButton, albumsFrequentButton), true);
|
||||
if (!shouldUseId3)
|
||||
adapter.addView(albumsHighestButton, true);
|
||||
adapter.addViews(asList(albumsRandomButton, albumsStarredButton, albumsAlphaByNameButton, albumsAlphaByArtistButton), true);
|
||||
|
||||
adapter.addView(videosTitle, false);
|
||||
adapter.addViews(Collections.singletonList(videosButton), true);
|
||||
}
|
||||
else
|
||||
else // Offline supported calls
|
||||
{
|
||||
shouldUseId3 = false;
|
||||
adapter.addViews(asList(albumsNewestButton, albumsRecentButton, albumsFrequentButton, albumsHighestButton, albumsRandomButton, albumsStarredButton, albumsAlphaByNameButton, albumsAlphaByArtistButton), true);
|
||||
}
|
||||
adapter.addView(musicTitle, false);
|
||||
adapter.addViews(asList(artistsButton, genresButton), true);
|
||||
|
||||
adapter.addView(songsTitle, false);
|
||||
adapter.addView(randomSongsButton, true);
|
||||
|
||||
adapter.addView(videosTitle, false);
|
||||
adapter.addViews(Collections.singletonList(videosButton), true);
|
||||
|
@ -262,4 +270,3 @@ public class MainFragment extends Fragment {
|
|||
Navigation.findNavController(getView()).navigate(R.id.mainToServerSelector);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ import java.util.ArrayList
|
|||
import java.util.HashSet
|
||||
import java.util.LinkedList
|
||||
import java.util.Locale
|
||||
import java.util.Random
|
||||
import java.util.concurrent.TimeUnit
|
||||
import java.util.regex.Pattern
|
||||
import org.koin.core.component.KoinComponent
|
||||
|
@ -257,9 +256,9 @@ class OfflineMusicService : MusicService, KoinComponent {
|
|||
if (children.isEmpty()) {
|
||||
return result
|
||||
}
|
||||
val random = Random()
|
||||
children.shuffle()
|
||||
for (i in 0 until size) {
|
||||
val file = children[random.nextInt(children.size)]
|
||||
val file = children[i % children.size]
|
||||
result.addChild(createEntry(file, getName(file)))
|
||||
}
|
||||
return result
|
||||
|
|
Loading…
Reference in New Issue