Changeset 60

Show
Ignore:
Timestamp:
05/19/07 22:23:42 (2 years ago)
Author:
chris
Message:

r7739@flan: chris
moving the history file to the iPod

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/org/lastpod/DbReader.java

    r56 r60  
    3838public class DbReader { 
    3939    /** 
     40     * The location of the iTunes path. 
     41     */ 
     42    private String iTunesPath; 
     43 
     44    /** 
    4045     * The location of the iTunes database file. 
    4146     */ 
     
    9297        } 
    9398 
     99        this.iTunesPath = itunespath; 
    94100        this.itunesfile = itunespath + "iTunesDB"; 
    95101        this.playcountsfile = itunespath + "Play Counts"; 
     
    297303                temptrack.setLastplayed(lastplayed - temptrack.getLength()); 
    298304 
    299                 if (History.getInstance().isInHistory(temptrack.getLastplayed())) { 
     305                if (History.getInstance(iTunesPath).isInHistory(temptrack.getLastplayed())) { 
    300306                    temptrack.setActive(Boolean.FALSE); 
    301307                } 
  • trunk/src/main/org/lastpod/History.java

    r53 r60  
    6464     * Singleton that reads the history file and creates this 
    6565     * <code>History</code> object. 
     66     * @param iTunesPath  The path to the iPod's iTunes DB.  LastPod's history 
     67     * data will be stored there. 
    6668     * @return  This <code>History</code> object with a List of histories. 
    6769     */ 
    68     public static History getInstance() { 
     70    public static History getInstance(String iTunesPath) { 
    6971        if (_instance == null) { 
    70             _instance = new History(new File(URL)); 
     72            if (iTunesPath == null) { 
     73                throw new RuntimeException("iTunes path was not supplied."); 
     74            } 
     75 
     76            if (!iTunesPath.endsWith(File.separator)) { 
     77                iTunesPath += File.separator; 
     78            } 
     79 
     80            _instance = new History(new File(iTunesPath + URL)); 
    7181            _instance.read(); 
    7282        } 
  • trunk/src/main/org/lastpod/Scrobbler.java

    r57 r60  
    329329        for (int i = 0; i < activeRecentPlayed.size(); i++) { 
    330330            TrackItem track = (TrackItem) activeRecentPlayed.get(i); 
    331             History.getInstance().addhistory(track.getLastplayed()); 
     331            History.getInstance(null).addhistory(track.getLastplayed()); 
    332332        } 
    333333 
     
    335335            TrackItem track = (TrackItem) inactiveRecentPlayed.get(i); 
    336336 
    337             if (History.getInstance().isInHistory(track.getLastplayed())) { 
    338                 History.getInstance().addhistory(track.getLastplayed()); 
    339             } 
    340         } 
    341  
    342         History.getInstance().write(); 
     337            if (History.getInstance(null).isInHistory(track.getLastplayed())) { 
     338                History.getInstance(null).addhistory(track.getLastplayed()); 
     339            } 
     340        } 
     341 
     342        History.getInstance(null).write(); 
    343343    } 
    344344