@Override public void updatePage(IServiceModel model) { if (getPager() == null) { // maybe null during init return; } if (model instanceof Song) { Song song = (Song) model; if (album.getActiveSong() == null) { updateBlink(null); } if (song.isActive()) { Node container = getNodeForSong(song); updateBlink(container); } if (lastSongSelection != null) { lastSongSelection.setStyle(STYLE_INACTIVE); } if (songBox != null) { final ObservableList<Node> children = songBox.getChildren(); for (Node node : children) { String id = node.getId(); if (getPager().getActiveModel() instanceof Song) { if (id.equals(String.valueOf(((Song) getPager().getActiveModel()).getMID()))) { lastSongSelection = node; lastSongSelection.setStyle(STYLE_ACTIVE); } } } } } }
@Override public IRotaryControllable push() { Song song = (Song) getPager().getActiveModel(); album.reset(); song.setActive(true); mpdService.playAlbum(album); Node node = getNodeForSong(song); updateBlink(node); return UIStateController.getInstance().getGooglePlayerController(); }
/** Creates the album playback view. */ private void display() { scrollPos = 0; songScroller = new ScrollPane(); songScroller.setMinWidth(PaneUtil.WIDTH - GoogleUINaviController.COVER_SIZE - 10); songScroller.setStyle("-fx-background-color:transparent;"); songScroller.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); songBox = new VBox(6); songBox.setPadding(new Insets(3, 2, 2, 2)); int track = 1; for (Song song : album.getSongs()) { HBox trackBox = new HBox(); trackBox.setId(String.valueOf(song.getMID())); trackBox.setAlignment(Pos.BASELINE_LEFT); trackBox.setPadding(new Insets(2, 5, 2, 5)); if (track == 1) { trackBox.setStyle(STYLE_ACTIVE); lastSongSelection = trackBox; } else { trackBox.setStyle(STYLE_INACTIVE); } BorderPane innerTrackBox = new BorderPane(); HBox posBox = new HBox(5); posBox.setMinWidth(40); posBox.getChildren().add(createTrackText(track + ".")); innerTrackBox.setLeft(posBox); HBox nameBox = new HBox(5); nameBox.setMinWidth(385); String name = song.getName(); if (name.endsWith(".mp3")) { name = name.substring(0, name.length() - 4); } nameBox.getChildren().add(createTrackText(" " + name)); innerTrackBox.setCenter(nameBox); innerTrackBox.setRight(createTrackText(song.getDuration())); trackBox.getChildren().add(innerTrackBox); songBox.getChildren().add(trackBox); track++; } songScroller.setOpacity(0); songScroller.setContent(songBox); albumNode.getChildren().add(songScroller); }
/** * Returns the row for the given song. * * @param song * @return */ private Node getNodeForSong(Song song) { final ObservableList<Node> children = songBox.getChildren(); for (Node node : children) { String id = node.getId(); if (id.equals(String.valueOf(song.getMID()))) { return node; } } return null; }