Package unify.data

Examples of unify.data.Show


    }   
  }

  private void createAllShowsMenu(Menu allShows) {
    for(int i=0;i<ShowLibrary.getInstance().shows.size();i++) {
      final Show s1 = ShowLibrary.getInstance().shows.get(i);
      int numSeasons = s1.seasons.size();
      if(numSeasons>0) {
        final String title = s1.getTitle();
        final Menu showMenu = new Menu(title);
        allShows.add(showMenu);
        for(Season mySeason : s1.seasons) {
          final int mySeasonNum = mySeason.getNumber();
          int numEpisodes = mySeason.getEpisodes().size();

          for(Episode myEpisode : mySeason.getEpisodes()) {
            //Var setup
            final int myEpisodeNum = myEpisode.getNumber();
            final String myLink;
            final String myLabel;
            String formattedSeasonEp = mySeason.formatSeasonEp(myEpisodeNum);
            myLink = myEpisode.getLink();
            myLabel = myEpisode.getLinkLabel();

            //Menu setup
            MenuItem remove = new MenuItem("Remove");
            MenuItem linkItem = new MenuItem(myLabel);

            //Link menu item functionality
            if(!myLink.equals(" ")) {
              final URI myURL = URI.create(myLink);
              linkItem.addActionListener(new ActionListener() {
                public void actionPerformed(ActionEvent e) {
                  try {
                    Desktop.getDesktop().browse(myURL);
                  } catch (IOException e1) {
                    LOGGER.warning("IO error " + e1.toString());
                  }
                }
              });
            }

            //Remove menu item functionality
            final Season season = mySeason;
            final Episode episode = myEpisode;
            remove.addActionListener(new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                int result = JOptionPane.showConfirmDialog(null,"Are you sure you want to remove " + title + " season " + mySeasonNum + " episode " + myEpisodeNum, "Remove Episode?", JOptionPane.YES_NO_OPTION);
                if(result==0) {
                  season.removeEpisode(episode);
                  LOGGER.fine("Removed episode " + episode.getNumber() + " from " + title);
                  if (season.getEpisodes().size()==0) {
                    Show show = ShowLibrary.getInstance().getShow(title);
                    show.removeSeason(season);
                    LOGGER.fine("Season " + season.getNumber() + " of " + title + " is removed because it was empty.");
                  }
                  showLib.doUpdates();
                }
              }
View Full Code Here


    return getShow(this.shows, myTitle);
  }

  public Show getShow(ArrayList<Show> shows, String myTitle) {
    for (int i = 0; i < shows.size(); i++) {
      Show show = shows.get(i);
      if (show.isThisMyTitle(myTitle)) {
        return show;
      }
    }
    return null;
  }
View Full Code Here

  public Show addShow(Show show) {
    return addShow(show.getTitle(), show.getCurSeason(), show.getLastEpisode());
  }

  public Show addShow(String myTitle, int mySeason, int myEpisode) {
    Show show = new Show(myTitle);
    show.setCurSeason(mySeason);
    show.setLastEpisode(myEpisode);
    shows.add(show);
    return show;
  }
View Full Code Here

  private void populateList(ArrayList<Show> showList, Feed feed) {
    showList.clear();
    RSSParser parser = new RSSParser(feed);
    ArrayList<Show> rssShows = parser.parseFeed();
    for(int i=0;i<rssShows.size();i++) {
      Show show = rssShows.get(i);
      if(getShow(show.getTitle())!=null) {
        showList.add(show);
        this.pendingUpdates = true;
      }
    }
  }
View Full Code Here

    }
  }

  private void checkShows(ArrayList<Show> rssShows) {
    for(int i=0;i<rssShows.size();i++) {
      Show rssShow = rssShows.get(i);
      Show show = getShow(rssShow.getTitle());
      if(show!=null) {
        for(Season rssSeason : rssShow.seasons) {
          int seasonInt = rssSeason.getNumber();
          Season season = show.findSeason(seasonInt);
          if(show.getCurSeason()<=seasonInt) {
            if(show.getCurSeason()<seasonInt) {
              season = show.addSeason(seasonInt);
              show.setLastEpisode(0);
              LOGGER.info("Found new season (" + seasonInt + ") of " + show.getTitle());
              show.setCurSeason(seasonInt);
            }
            for(Episode rssEpisode : rssSeason.getEpisodes()) {
              int episodeInt = rssEpisode.getNumber();
              Episode episode = null;
              if(season!=null) {
                episode = season.findEpisode(episodeInt);
              }
              if(show.getLastEpisode()<episodeInt && episode==null) {
                if(season==null) {
                  season = show.addSeason(seasonInt);
                }
                for(int m=show.getLastEpisode()+1;m<episodeInt;m++) {
                  LOGGER.info("Found new episode (" + m + ") of " + show.getTitle() + " in season " + seasonInt);
                  season.addEpisode(m, " ", " ");
                  pendingNotice(show.getTitle() + " (" + seasonInt + "x" + m + ") is now available.");              
                }
                LOGGER.info("Found new episode (" + episodeInt + ") of " + show.getTitle() + " in season " + seasonInt);
                season.addEpisode(episodeInt, rssEpisode.getLink(), rssEpisode.getLinkLabel());
                pendingNotice(show.getTitle() + " (" + seasonInt + "x" + episodeInt + ") is now available.");
                show.setLastEpisode(episodeInt);
              }
              if(episode!=null) {
                int newPriority = Settings.getInstance().getFeedPriority(rssEpisode.getLinkLabel());
                int oldPriority = Settings.getInstance().getFeedPriority(episode.getLinkLabel());
                if (newPriority>oldPriority) {
                  LOGGER.info("Found higher priority link for " + show.getTitle() + " (" + seasonInt + "x" + episodeInt + "), updating from " + episode.getLinkLabel() + " to " + rssEpisode.getLinkLabel());         
                  episode.setLink(rssEpisode.getLink());
                  episode.setLinkLabel(rssEpisode.getLinkLabel());
                  pendingNotice(show.getTitle() + " (" + seasonInt + "x" + episode.getNumber() + ") is now available on " + rssEpisode.getLinkLabel() + ".");
                }
              }
            }
          }
        }
View Full Code Here

    }
  }

  private void checkNewShows(ArrayList<Show> rssShows) {
    for(int i=0;i<rssShows.size();i++) {
      Show rssShow = rssShows.get(i);
      if(getShow(this.shows, rssShow.getTitle())==null && getShow(this.newShows, rssShow.getTitle())==null && getShow(this.ignoredShows, rssShow.getTitle())==null) {
        Season season = rssShow.getSeason();
        Episode episode = season.getEpisode();
        if(season.getNumber()==1 && episode.getNumber() == 1) {
          Show show = new Show(rssShow.getTitle());
          Season newSeason = show.addSeason(1);
          newSeason.addEpisode(1, episode.getLink(), episode.getLinkLabel());
          show.setCurSeason(1);
          show.setLastEpisode(1);
          this.newShows.add(show);
          this.ignoredShows.add(show);
          LOGGER.info("Found new show: " + show.getTitle());
          pendingNotice("Found new show: " + show.getTitle());
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of unify.data.Show

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.