[banshee] AppleDeviceSource: refactoring, decrease indentation in two blocks of code
- From: AndrÃs Aragoneses <aaragoneses src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [banshee] AppleDeviceSource: refactoring, decrease indentation in two blocks of code
- Date: Sun, 23 Sep 2012 15:44:39 +0000 (UTC)
commit e8ad429a3b87076fe5a85c2ca5e87fd27e001653
Author: Andres G. Aragoneses <knocte gmail com>
Date: Sun Sep 23 15:27:32 2012 +0100
AppleDeviceSource: refactoring, decrease indentation in two blocks of code
Thanks to previous refactoring, we can now bail early from this method that
syncs playlists, so we decrease one level of indentation and makes the code
a bit more readable.
.../Banshee.Dap.AppleDevice/AppleDeviceSource.cs | 42 ++++++++++---------
1 files changed, 22 insertions(+), 20 deletions(-)
---
diff --git a/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs b/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs
index b448fce..2b11f15 100644
--- a/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs
+++ b/src/Dap/Banshee.Dap.AppleDevice/Banshee.Dap.AppleDevice/AppleDeviceSource.cs
@@ -660,28 +660,30 @@ namespace Banshee.Dap.AppleDevice
void SyncTracksToPlaylists ()
{
- if (SupportsPlaylists) {
- // Remove playlists on the device
- var device_playlists = new List<GPod.Playlist> (MediaDatabase.Playlists);
- foreach (var playlist in device_playlists) {
- if (!playlist.IsMaster && !playlist.IsPodcast) {
- MediaDatabase.Playlists.Remove (playlist);
- }
+ if (!SupportsPlaylists) {
+ return;
+ }
+
+ // Remove playlists on the device
+ var device_playlists = new List<GPod.Playlist> (MediaDatabase.Playlists);
+ foreach (var playlist in device_playlists) {
+ if (!playlist.IsMaster && !playlist.IsPodcast) {
+ MediaDatabase.Playlists.Remove (playlist);
}
+ }
- // Add playlists from Banshee to the device
- foreach (Source child in Children) {
- PlaylistSource from = child as PlaylistSource;
- if (from != null && from.Count > 0) {
- var playlist = new GPod.Playlist (from.Name);
- MediaDatabase.Playlists.Add (playlist);
- foreach (int track_id in ServiceManager.DbConnection.QueryEnumerable<int> (String.Format (
- "SELECT CoreTracks.TrackID FROM {0} WHERE {1}",
- from.DatabaseTrackModel.ConditionFromFragment, from.DatabaseTrackModel.Condition)))
- {
- if (tracks_map.ContainsKey (track_id)) {
- playlist.Tracks.Add (tracks_map[track_id].IpodTrack);
- }
+ // Add playlists from Banshee to the device
+ foreach (Source child in Children) {
+ PlaylistSource from = child as PlaylistSource;
+ if (from != null && from.Count > 0) {
+ var playlist = new GPod.Playlist (from.Name);
+ MediaDatabase.Playlists.Add (playlist);
+ foreach (int track_id in ServiceManager.DbConnection.QueryEnumerable<int> (String.Format (
+ "SELECT CoreTracks.TrackID FROM {0} WHERE {1}",
+ from.DatabaseTrackModel.ConditionFromFragment, from.DatabaseTrackModel.Condition)))
+ {
+ if (tracks_map.ContainsKey (track_id)) {
+ playlist.Tracks.Add (tracks_map[track_id].IpodTrack);
}
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]