public void outputStatistics() { ArrayList<String> statistics = new ArrayList<String>(); int successful = 0; int errorJsonNotReadable = 0; int errorJsonFormatWrong = 0; int errorUrlNotFound = 0; int errorHtmlNotRetrieved = 0; int errorUrlNotParseable = 0; int errorArtistsNotParseable = 0; int errorExtractAlbum = 0; int errorExtractSong = 0; int errorOthers = 0; for (MusicData data : list) { if (data.getErrorMessage() == "") { successful++; } else if (data.getErrorMessage().equals("Json file not readable")) { errorJsonNotReadable++; } else if (data.getErrorMessage().equals("Json format wrong")) { errorJsonFormatWrong++; } else if (data.getErrorMessage().equals("URL not found")) { errorUrlNotFound++; } else if (data.getErrorMessage().equals("HTML not retrieved")) { errorHtmlNotRetrieved++; } else if (data.getErrorMessage().equals("URL not parseable")) { errorUrlNotParseable++; } else if (data.getErrorMessage().equals("Extracting artists not implemented")) { errorArtistsNotParseable++; } else if (data.getErrorMessage().equals("Extract album data failed")) { errorExtractAlbum++; } else if (data.getErrorMessage().equals("Extract song data failed")) { errorExtractSong++; } else { errorOthers++; } } statistics.add("Time elapsed: " + (double) (endTime - startTime) / 1000); statistics.add("Successfully Retrieved: " + successful); statistics.add("Json file not readable: " + errorJsonNotReadable); statistics.add("Json format wrong: " + errorJsonFormatWrong); statistics.add("URL not found: " + errorUrlNotFound); statistics.add("HTML not retrieved: " + errorHtmlNotRetrieved); statistics.add("URL not parseable: " + errorUrlNotParseable); statistics.add("Extracting artists not implemented: " + errorArtistsNotParseable); statistics.add("Extract album data failed: " + errorExtractAlbum); statistics.add("Extract song data failed: " + errorExtractSong); statistics.add("Other errors: " + errorOthers); statistics.add("---------------------------------"); statistics.add("Retrieved URLs: " + successURL()); statistics.add("Retrieved artists: " + successArtist()); statistics.add("Retrieved albums: " + successAlbum()); statistics.add("Retrieved songs: " + successSong()); TxtWriter writer = new TxtWriter(); String fileName = new SimpleDateFormat("'out/statistics-'yyyy-MM-dd-hh-mm'.txt'").format(new Date()); writer.overwrite(statistics, fileName); }
private void outputError() { TxtWriter writer = new TxtWriter(); ArrayList<String> errorList = new ArrayList<String>(); for (int i = 0; i < getSize(); i++) { MusicData data = list.get(i); if (!data.isSuccess()) { String error = data.getErrorMessage() + "<<" + data.getPost(); errorList.add(error); } } String fileName = new SimpleDateFormat("'out/error-'yyyy-MM-dd-hh-mm'.txt'").format(new Date()); writer.overwrite(errorList, fileName); return; }
public void updateMusicInfo() { MusicItem music = MusicData.getNowPlayingMusic(); mArtistTextView.setText(music.getArtist()); mTitleTextView.setText(music.getTitle()); mDuration.setText(setDurationFormat(Integer.parseInt(music.getDuration()))); mMusicProgress.setMax(Integer.parseInt(music.getDuration())); setMusicImg(); }
public void setMusicImg() { MusicItem music = MusicData.getNowPlayingMusic(); if (getMusicImg(music.getAlbumArtURI()) == null) { mMusicImg.setImageResource(R.drawable.phone_music_album_default); } else { mMusicImg.setImageBitmap(getMusicImg(music.getAlbumArtURI())); } }
@Override public void onClick(View v) { if (mIsDLNAConnected) { if (LocalMediaUtil.getWhichOnRemote() != LocalMediaUtil.Defs.MUSIC) { MusicItem music = MusicData.getNowPlayingMusic(); try { LocalMediaUtil.setWhichOnRemote(LocalMediaUtil.Defs.MUSIC); mPostButton.setClickable(false); mMusicPlayService.pause(); // mMusicPlayService.setPlayOnPhone(false); // mIsPlayOnLocal = false; mIsOnRemotePause = false; mMusicPlayService.postToRemote(); Log.e(TAG, music.getItemUri()); postSeek(mMusicPlayService.position() + ""); // Log.d(TAG, "isPlayOnPhone" + mIsPlayOnLocal); } catch (RemoteException e) { e.printStackTrace(); } } else { // mIsPlayOnLocal = true; poststop(); LocalMediaUtil.setWhichOnRemote(LocalMediaUtil.Defs.NOT_ANY_ONE); try { // mMusicPlayService.setPlayOnPhone(true); mMusicPlayService.play(); mMusicPlayService.seekTo(mRemotePlayPosition); } catch (RemoteException e) { e.printStackTrace(); } try { if (mMusicPlayService.isPlaying()) { mStatusButton.setImageResource(R.drawable.video_btn_pause); } else { mStatusButton.setImageResource(R.drawable.video_btn_start); } } catch (RemoteException e) { e.printStackTrace(); } } } else { Toast.makeText( getApplicationContext(), R.string.video_not_connection_toast_message, Toast.LENGTH_SHORT) .show(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_detail); ButterKnife.bind(this); mMusic = MusicData.musicList().get(getIntent().getIntExtra(EXTRA_PARAM_ID, 0)); defaultColorForRipple = getResources().getColor(R.color.colorPrimaryDark); mTextView.setText(Html.fromHtml(getString(mMusic.getTextResourceId(this)))); mMediaPlayer = MediaPlayer.create(this, R.raw.john_coltrane_equinox); loadMusic(); windowTransition(); getPhoto(); }
public void doClick(View view) throws RemoteException { switch (view.getId()) { case R.id.pause_play: if (LocalMediaUtil.getWhichOnRemote() == LocalMediaUtil.Defs.MUSIC) { if (mIsOnRemotePause) { postPauseToPlay(); mStatusButton.setImageResource(R.drawable.video_btn_pause); mIsOnRemotePause = false; } else { postpause(); mStatusButton.setImageResource(R.drawable.video_btn_start); mIsOnRemotePause = true; } } else { mMusicPlayService.pauseButtonPressed(); } break; case R.id.stop: if (LocalMediaUtil.getWhichOnRemote() == LocalMediaUtil.Defs.MUSIC) { poststop(); LocalMediaUtil.setWhichOnRemote(LocalMediaUtil.Defs.NOT_ANY_ONE); mIsOnRemotePause = true; } mMusicPlayService.stop(); MusicData.setNowPlayingMusic(null); mMusicPlayService.setInitialed(false); finish(); overridePendingTransition(R.anim.push_left_in, R.anim.push_right_out); break; case R.id.next: mMusicPlayService.next(); updateMusicInfo(); if (LocalMediaUtil.getWhichOnRemote() == LocalMediaUtil.Defs.MUSIC) { MusicItem music = MusicData.getNowPlayingMusic(); mMusicPlayService.pause(); // mMusicProgress.setMax((int) mMusicPlayService.duration()); // mArtistTextView.setText(music.getArtist()); // mTitleTextView.setText(music.getTitle()); // mDuration.setText(setDurationFormat(Integer.parseInt(music.getDuration()))); postNext(music.getItemUri(), music.metaData); } else { if (mMusicPlayService.getPreparedStatus()) { mMusicPlayService.play(); } } break; case R.id.prev: mMusicPlayService.prev(); updateMusicInfo(); if (LocalMediaUtil.getWhichOnRemote() == LocalMediaUtil.Defs.MUSIC) { MusicItem music = MusicData.getNowPlayingMusic(); mMusicPlayService.pause(); // mMusicProgress.setMax((int) mMusicPlayService.duration()); // mArtistTextView.setText(music.getArtist()); // mTitleTextView.setText(music.getTitle()); // mDuration.setText(setDurationFormat(Integer.parseInt(music.getDuration()))); postNext(music.getItemUri(), music.metaData); } else { if (mMusicPlayService.getPreparedStatus()) { mMusicPlayService.play(); } } break; case R.id.post: break; case R.id.nowplayinglist: MusicData.setMusicShowList(MusicData.getMusicPlayList()); Intent intent = new Intent(); intent.putExtra("title", getResources().getString(R.string.playing_list)); intent.putExtra("scrollto", true); intent.setClass(getApplicationContext(), MusicListActivity.class); startActivityForResult(intent, 0); overridePendingTransition(R.anim.push_left_in, R.anim.push_right_out); break; } }