public void getAndSaveSongInfo(Document doc, String mid, String id) { ArrayList<String> SongInfo = null; sInfo = new SongInfo(); sInfo.id = id; if (!crawledSongs.contains(mid)) { crawledSongs.add(mid); sInfo.mid = mid; if (doc != null) { String sname = doc.select("div.song_title").select("span").text(); sInfo.sname = sname; SongInfo = extractSongInfo(doc); } else { System.err.println("The html is not fetched!"); } if (SongInfo != null && SongInfo.size() > 0) { sInfo.singer = SongInfo.get(0); sInfo.language = SongInfo.get(1); sInfo.album = SongInfo.get(2); sInfo.date = SongInfo.get(3); } sDao.insertSongInfo(sInfo); sDao.updateSongInfo(sInfo.mid, id); } crawledSongs.add(mid); }
@Override public boolean onSingleTapUp(MotionEvent e1) { // TODO Auto-generated method stub SongInfo songInfo = new SongInfo(); if (SWITCH_VIEW != SONG_VIEW) { return false; } try { int id = lv.pointToPosition((int) e1.getX(), (int) e1.getY()); // Log.i("SONG", // "ID:"+((TextView)lv.getChildAt(id).findViewById(R.id.song_textView)).getText().toString() // ); path = songList.get(id).getData(); duration = Long.parseLong(songList.get(id).getDuration()); Log.i("SONG LIST FRAGMENT", songList.get(id).getTitle()); songInfo.setAlbum(songList.get(id).getAlbum()); songInfo.setAlbum_art(songList.get(id).getAlbum_art()); songInfo.setAlbum_id(songList.get(id).getAlbum_id()); songInfo.setArtist(songList.get(id).getArtist()); songInfo.setData(songList.get(id).getData()); songInfo.setDisplayName(songList.get(id).getDisplayName()); songInfo.setDuration(songList.get(id).getDuration()); songInfo.setId(songList.get(id).getId()); songInfo.setTitle(songList.get(id).getTitle()); StaticMusic.setSongInfo(songInfo); StaticMusic.songQueue.addLast(songInfo); } catch (NullPointerException e) { e.printStackTrace(); StaticMusic.songQueue = new LinkedList<SongInfo>(); StaticMusic.songQueue.addLast(songInfo); Log.i("SONG LIST FRAGMENT", "here ur new"); } Intent toNowPlaying = new Intent(this, Nowplaying.class); toNowPlaying.putExtra("activity", "songlist"); toNowPlaying.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(toNowPlaying); return false; }
@Override public void run() { // TODO Auto-generated method stub Log.i("DATABASE THREAD", search); switch (SWITCH_VIEW) { case SONG_VIEW: database.open(); songList = database.searchSong_byName(search); // database.close(); Log.i("DATABASE THREAD", songList.size() + ""); // TODO Auto-generated method stub if (songList.size() == 0) { songInfo.setTitle("No Songs Found"); songList.add(songInfo); removeGestureListener(); } else { addGestureListener(); } adapter = new ReadLisstAdapter(activity, songList, lv); lv.setAdapter(adapter); break; case ALBUMS_VIEW: database.open(); all_playlists = new ArrayList<ArrayList<SongInfo>>(); all_playlists = database.searchSongs_albums(search); // database.close(); if (all_playlists.size() == 0) { songInfo.setTitle("No Songs Found"); songList.clear(); songList.add(songInfo); all_playlists.add(songList); removeGestureListener(); } else { addGestureListener(); } common_list_adapter = new CommonListAdapter( activity, all_playlists, lv, SWITCH_VIEW, playlistChangedListener); lv.setAdapter(common_list_adapter); common_list_adapter.notifyDataSetChanged(); break; case ARTIST_VIEW: database.open(); all_playlists = new ArrayList<ArrayList<SongInfo>>(); all_playlists = database.searchSongs_artists(search); // database.close(); if (all_playlists.size() == 0) { songInfo.setTitle("No Songs Found"); songList.clear(); songList.add(songInfo); all_playlists.add(songList); removeGestureListener(); } else { addGestureListener(); } common_list_adapter = new CommonListAdapter( activity, all_playlists, lv, SWITCH_VIEW, playlistChangedListener); lv.setAdapter(common_list_adapter); common_list_adapter.notifyDataSetChanged(); break; case PLAYLIST_VIEW: database.open(); all_playlists = new ArrayList<ArrayList<SongInfo>>(); all_playlists = database.searchSongs_playlists(search); // database.close(); if (all_playlists.size() == 0) { songInfo.setTitle("No Songs Found"); songList.clear(); songList.add(songInfo); all_playlists.add(songList); removeGestureListener(); } else { addGestureListener(); } common_list_adapter = new CommonListAdapter( activity, all_playlists, lv, SWITCH_VIEW, playlistChangedListener); lv.setAdapter(common_list_adapter); common_list_adapter.notifyDataSetChanged(); break; } }
@Test public final void testSetTitle() { testGetTitle(); siExtended.setTitle("Hey"); assertEquals("Hey", siExtended.getTitle()); }
@Test public final void testGetTitle() { // siBasic.setInterpret("Steven"); assertEquals("I only sing in the shower", siExtended.getTitle()); }
@Test public final void testSetArtist() { testGetArtist(); siExtended.setArtist("Steven"); assertEquals("Steven", siExtended.getArtist()); }
@Test public final void testGetArtist() { assertEquals("Hendrik", siExtended.getArtist()); }
@Test public final void testSongInfo() { assertEquals(null, siBasic.getArtist()); assertEquals(null, siBasic.getTitle()); }
@Test public final void testSongInfoStringString() { assertEquals("Hendrik", siExtended.getArtist()); assertEquals("I only sing in the shower", siExtended.getTitle()); }
public void show(final SongInfo songInfo) { this.songInfo = songInfo; setTitle(songInfo.getName()); final NSURL pdfURL = NSURL.fileURLWithPath(songInfo.getPdfPath().getPath()); NSURLRequest request = requests.get(songInfo); if (request == null) { request = NSURLRequest.requestWithURL(pdfURL); requests.put(songInfo, request); } pdfView.loadRequest(request); if (UIPrintInteractionController.isPrintingAvailable()) { rightBarButtonItem = new UIBarButtonItem( UIBarButtonSystemItem.Action, new UIBarButtonItemDelegate() { public void clicked() { UIPrintInteractionController print = UIPrintInteractionController.sharedPrintController(); print.setPrintingItem(pdfURL); print.presentFromBarButtonItem( rightBarButtonItem, true, new UIPrintInteractionController.UIPrintInteractionCompletionHandler() { public void completed( UIPrintInteractionController controller, boolean b, NSError nsError) { System.out.println("finished: " + b + ", error: " + nsError); } }); } }); setHidesBottomBarWhenPushed(false); getNavigationItem().setRightBarButtonItem(rightBarButtonItem); } playButton = new UIBarButtonItem( UIBarButtonSystemItem.Play, new UIBarButtonItemDelegate() { public void clicked() { final List<MusicInfo> musicInfos = Main.library.getMusicInfos(songInfo); if (Main.getAudioPlayer() == null && musicInfos.size() > 1) { String[] titles = new String[musicInfos.size()]; for (int i = 0; i < titles.length; i++) { titles[i] = musicInfos.get(i).getName(); } // player is stopped and we have multiple music files UIActionSheet uiActionSheet = UIActionSheet.init( "Play", new UIActionSheetDelegate() { @Override public void clickedButtonAtIndex( UIActionSheet actionSheet, int buttonIndex) { Main.setAudioPlayer( AVAudioPlayer.audioPlayerWithContentsOfURL( NSURL.fileURLWithPath( musicInfos.get(buttonIndex).getMusicPath().getPath()), null)); Main.getAudioPlayer().prepareToPlay(); play(); } }, null, null, titles); uiActionSheet.showFromBarButtonItem(playButton, true); } else { play(); } } private void play() { updateRepeatMode(); Main.getAudioPlayer().play(); Main.getAudioPlayer() .setDelegate( new AVAudioPlayerDelegate() { public void audioPlayerDidFinishPlaying( AVAudioPlayer player, boolean successfully) { stop(); } public void audioPlayerDecodeErrorDidOccur( AVAudioPlayer player, NSError error) {} public void audioPlayerBeginInterruption(AVAudioPlayer player) {} public void audioPlayerEndInterruption(AVAudioPlayer player) {} }); setToolbarItems(new ArrayList<UIBarButtonItem>(buttonsPauseStop)); } }); pauseButton = new UIBarButtonItem( UIBarButtonSystemItem.Pause, new UIBarButtonItemDelegate() { public void clicked() { Main.getAudioPlayer().pause(); setToolbarItems(new ArrayList<UIBarButtonItem>(buttonsPlayStop)); } }); stopButton = new UIBarButtonItem( UIBarButtonSystemItem.Stop, new UIBarButtonItemDelegate() { public void clicked() { stop(); } }); repeat = false; repeatButton = new UIBarButtonItem( UIImage.imageNamed("repeat.png"), UIBarButtonItemStyle.Plain, new UIBarButtonItemDelegate() { public void clicked() { repeat = !repeat; if (repeat) { repeatButton.setImage(UIImage.imageNamed("no-repeat.png")); } else { repeatButton.setImage(UIImage.imageNamed("repeat.png")); } updateRepeatMode(); } }); buttonsPlay = Arrays.asList(playButton, repeatButton); buttonsPauseStop = Arrays.asList(pauseButton, stopButton, repeatButton); buttonsPlayStop = Arrays.asList(playButton, stopButton, repeatButton); setToolbarItems(new ArrayList<UIBarButtonItem>(buttonsPlay)); stop(); }