Skip to content
This repository
Browse code

Merge pull request #69 from taconaut/generic

Use List instead of ArrayList as return type for methods in DLNAMediaInfo
  • Loading branch information...
commit b20e5b854f7fe94e748b3016ea1ce2475c3c11a9 2 parents 741e885 + 5b526aa
Philippe authored August 01, 2012
30  src/main/java/net/pms/dlna/DLNAMediaInfo.java
@@ -48,6 +48,8 @@
48 48
 import java.awt.image.BufferedImage;
49 49
 import java.io.*;
50 50
 import java.util.*;
  51
+import java.util.List;
  52
+
51 53
 
52 54
 /**
53 55
  * This class keeps track of scanned MediaInfo library information.
@@ -128,8 +130,8 @@
128 130
 	@Deprecated
129 131
 	public int bitsPerPixel;
130 132
 
131  
-	private ArrayList<DLNAMediaAudio> audioTracks = new ArrayList<DLNAMediaAudio>();
132  
-	private ArrayList<DLNAMediaSubtitle> subtitleTracks = new ArrayList<DLNAMediaSubtitle>();
  133
+	private List<DLNAMediaAudio> audioTracks = new ArrayList<DLNAMediaAudio>();
  134
+	private List<DLNAMediaSubtitle> subtitleTracks = new ArrayList<DLNAMediaSubtitle>();
133 135
 
134 136
 	/**
135 137
 	 * @deprecated Use standard getter and setter to access this variable.
@@ -1455,7 +1457,7 @@ public void setBitsPerPixel(int bitsPerPixel) {
1455 1457
 	 * @return the audioTracks
1456 1458
 	 * @since 1.60
1457 1459
 	 */
1458  
-	public ArrayList<DLNAMediaAudio> getAudioTracksList() {
  1460
+	public List<DLNAMediaAudio> getAudioTracksList() {
1459 1461
 		return audioTracks;
1460 1462
 	}
1461 1463
 
@@ -1465,14 +1467,18 @@ public void setBitsPerPixel(int bitsPerPixel) {
1465 1467
 	 */
1466 1468
 	@Deprecated
1467 1469
 	public ArrayList<DLNAMediaAudio> getAudioCodes() {
1468  
-		return getAudioTracksList();
  1470
+		if(audioTracks instanceof ArrayList) {
  1471
+			return (ArrayList<DLNAMediaAudio>) audioTracks;
  1472
+		} else {
  1473
+			return new ArrayList<DLNAMediaAudio>();
  1474
+		}
1469 1475
 	}
1470 1476
 
1471 1477
 	/**
1472 1478
 	 * @param audioTracks the audioTracks to set
1473 1479
 	 * @since 1.60
1474 1480
 	 */
1475  
-	public void setAudioTracksList(ArrayList<DLNAMediaAudio> audioTracks) {
  1481
+	public void setAudioTracksList(List<DLNAMediaAudio> audioTracks) {
1476 1482
 		this.audioTracks = audioTracks;
1477 1483
 	}
1478 1484
 
@@ -1481,7 +1487,7 @@ public void setAudioTracksList(ArrayList<DLNAMediaAudio> audioTracks) {
1481 1487
 	 * @deprecated use setAudioTracksList(ArrayList<DLNAMediaAudio> audioTracks) instead
1482 1488
 	 */
1483 1489
 	@Deprecated
1484  
-	public void setAudioCodes(ArrayList<DLNAMediaAudio> audioTracks) {
  1490
+	public void setAudioCodes(List<DLNAMediaAudio> audioTracks) {
1485 1491
 		setAudioTracksList(audioTracks);
1486 1492
 	}
1487 1493
 
@@ -1489,7 +1495,7 @@ public void setAudioCodes(ArrayList<DLNAMediaAudio> audioTracks) {
1489 1495
 	 * @return the subtitleTracks
1490 1496
 	 * @since 1.60
1491 1497
 	 */
1492  
-	public ArrayList<DLNAMediaSubtitle> getSubtitleTracksList() {
  1498
+	public List<DLNAMediaSubtitle> getSubtitleTracksList() {
1493 1499
 		return subtitleTracks;
1494 1500
 	}
1495 1501
 
@@ -1499,14 +1505,18 @@ public void setAudioCodes(ArrayList<DLNAMediaAudio> audioTracks) {
1499 1505
 	 */
1500 1506
 	@Deprecated
1501 1507
 	public ArrayList<DLNAMediaSubtitle> getSubtitlesCodes() {
1502  
-		return getSubtitleTracksList();
  1508
+		if(subtitleTracks instanceof ArrayList) {
  1509
+			return (ArrayList<DLNAMediaSubtitle>) subtitleTracks;
  1510
+		} else {
  1511
+			return new ArrayList<DLNAMediaSubtitle>();
  1512
+		}
1503 1513
 	}
1504 1514
 
1505 1515
 	/**
1506 1516
 	 * @param subtitleTracks the subtitleTracks to set
1507 1517
 	 * @since 1.60
1508 1518
 	 */
1509  
-	public void setSubtitleTracksList(ArrayList<DLNAMediaSubtitle> subtitleTracks) {
  1519
+	public void setSubtitleTracksList(List<DLNAMediaSubtitle> subtitleTracks) {
1510 1520
 		this.subtitleTracks = subtitleTracks;
1511 1521
 	}
1512 1522
 
@@ -1515,7 +1525,7 @@ public void setSubtitleTracksList(ArrayList<DLNAMediaSubtitle> subtitleTracks) {
1515 1525
 	 * @deprecated use setSubtitleTracksList(ArrayList<DLNAMediaSubtitle> subtitleTracks) instead
1516 1526
 	 */
1517 1527
 	@Deprecated
1518  
-	public void setSubtitlesCodes(ArrayList<DLNAMediaSubtitle> subtitleTracks) {
  1528
+	public void setSubtitlesCodes(List<DLNAMediaSubtitle> subtitleTracks) {
1519 1529
 		setSubtitleTracksList(subtitleTracks);
1520 1530
 	}
1521 1531
 
4  src/main/java/net/pms/dlna/FileTranscodeVirtualFolder.java
@@ -127,8 +127,8 @@ public void resolve() {
127 127
 			// List holding all combinations
128 128
 			ArrayList<DLNAResource> combos = new ArrayList<DLNAResource>();
129 129
 
130  
-			ArrayList<DLNAMediaAudio> audioTracks = child.getMedia().getAudioTracksList();
131  
-			ArrayList<DLNAMediaSubtitle> subtitles = child.getMedia().getSubtitleTracksList();
  130
+			List<DLNAMediaAudio> audioTracks = child.getMedia().getAudioTracksList();
  131
+			List<DLNAMediaSubtitle> subtitles = child.getMedia().getSubtitleTracksList();
132 132
 
133 133
 			// Make sure a combo with no subtitles will be added
134 134
 			DLNAMediaSubtitle noSubtitle = new DLNAMediaSubtitle();

0 notes on commit b20e5b8

Please sign in to comment.
Something went wrong with that request. Please try again.