-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #282 from zumicts/development
Development
- Loading branch information
Showing
58 changed files
with
1,924 additions
and
326 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,68 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Collections.ObjectModel; | ||
using System.Linq; | ||
|
||
namespace Audiotica.Core.Extensions | ||
{ | ||
public static class CollectionExtensions | ||
{ | ||
private static readonly Random Random = new Random(); | ||
|
||
public static void Fill<T>(this T[] array, T value) | ||
{ | ||
for (var i = 0; i < array.Length; i++) | ||
{ | ||
array[i] = value; | ||
} | ||
} | ||
|
||
public static void Sort<T>(this ObservableCollection<T> observable, Comparison<T> comparison) | ||
{ | ||
var sorted = observable.ToList(); | ||
sorted.Sort(comparison); | ||
|
||
var ptr = 0; | ||
while (ptr < sorted.Count) | ||
{ | ||
if (!observable[ptr].Equals(sorted[ptr])) | ||
{ | ||
var t = observable[ptr]; | ||
observable.RemoveAt(ptr); | ||
observable.Insert(sorted.IndexOf(t), t); | ||
} | ||
else | ||
{ | ||
ptr++; | ||
} | ||
} | ||
} | ||
|
||
public static void AddRange<T>(this IList<T> collection, IEnumerable<T> items) | ||
{ | ||
foreach (var item in items) | ||
collection.Add(item); | ||
} | ||
|
||
public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> list) | ||
{ | ||
var arr = list.ToArray(); | ||
Shuffle(arr); | ||
return arr; | ||
} | ||
|
||
private static void Shuffle<T>(IList<T> array) | ||
{ | ||
var n = array.Count; | ||
for (var i = 0; i < n; i++) | ||
{ | ||
// NextDouble returns a random number between 0 and 1. | ||
// ... It is equivalent to Math.random() in Java. | ||
var r = i + (int) (Random.NextDouble()*(n - i)); | ||
var t = array[r]; | ||
array[r] = array[i]; | ||
array[i] = t; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 16 additions & 3 deletions
19
Windows/Audiotica.Core.Windows/Messages/AddToPlaylistMessage.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,29 @@ | ||
using Audiotica.Database.Models; | ||
using System.Collections.Generic; | ||
using Audiotica.Database.Models; | ||
using Newtonsoft.Json; | ||
|
||
namespace Audiotica.Core.Windows.Messages | ||
{ | ||
public class AddToPlaylistMessage | ||
{ | ||
public AddToPlaylistMessage() | ||
{ | ||
} | ||
|
||
public AddToPlaylistMessage(QueueTrack track, int position) | ||
{ | ||
Track = track; | ||
Tracks = new List<QueueTrack> {track}; | ||
Position = position; | ||
} | ||
|
||
public AddToPlaylistMessage(List<QueueTrack> tracks, int position) | ||
{ | ||
Tracks = tracks; | ||
Position = position; | ||
} | ||
|
||
public QueueTrack Track { get; set; } | ||
public List<QueueTrack> Tracks { get; set; } | ||
|
||
public int Position { get; set; } | ||
} | ||
} |
20 changes: 19 additions & 1 deletion
20
Windows/Audiotica.Core.Windows/Utilities/AppSettingsUtility.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,36 @@ | ||
using Windows.Storage; | ||
using Windows.UI.Xaml; | ||
using Audiotica.Core.Common; | ||
using Audiotica.Core.Utilities.Interfaces; | ||
using Audiotica.Core.Windows.Helpers; | ||
|
||
namespace Audiotica.Core.Windows.Utilities | ||
{ | ||
public class AppSettingsUtility : IAppSettingsUtility | ||
public class AppSettingsUtility : ObservableObject, IAppSettingsUtility | ||
{ | ||
private readonly ISettingsUtility _settingsUtility; | ||
private int _theme; | ||
|
||
public AppSettingsUtility(ISettingsUtility settingsUtility) | ||
{ | ||
_settingsUtility = settingsUtility; | ||
DownloadsPath = settingsUtility.Read("DownloadsPath", "virtual://Music/Audiotica/"); | ||
TempDownloadsPath = settingsUtility.Read("TempDownloadsPath", ApplicationData.Current.TemporaryFolder.Path); | ||
_theme = _settingsUtility.Read(ApplicationSettingsConstants.Theme, (int)ElementTheme.Default); | ||
} | ||
|
||
public string DownloadsPath { get; set; } | ||
|
||
public string TempDownloadsPath { get; } | ||
|
||
public int Theme | ||
{ | ||
get { return _theme; } | ||
set | ||
{ | ||
Set(ref _theme, value); | ||
_settingsUtility.Write(ApplicationSettingsConstants.Theme, value); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.