private boolean equalList(List<Music> items) { List<Music> prevItems = null; if (items == null) { return true; } try { prevItems = getPlayer().getPlayList(); } catch (Exception e) { ObiLog.e(TAG, "prevItem is NULL"); } if (prevItems == null) { return false; } if (items.size() != prevItems.size()) { return false; } for (int i = 0; i < items.size(); i++) { if (!items.get(i).mId.equals(prevItems.get(i).mId)) { return false; } } return true; }
@Override protected void onResume() { super.onResume(); try { MusicApplication.getPlayer().requestAudioFocus(); } catch (Exception e) { ObiLog.e(TAG, "onResume::getPlayer error : ", e); } }
@Override public void onCreate(Bundle savedInstanceState) { try { getPlayer().setOnPlayerListener(this); } catch (Exception e) { ObiLog.e(TAG, "onCreate() error : ", e); } super.onCreate(savedInstanceState); }
@Override public void getPlaylist() { ListDownloader.getInstance(this).setType(ListDownloader.TYPE_SEARCH); try { Intent intent = getIntent(); @SuppressWarnings("unchecked") List<Music> items = (ArrayList<Music>) intent.getSerializableExtra("ListObject"); if (!equalList(items)) { getPlayer().stop(); getPlayer().releasePlayList(); if (!isRegulation()) { mAdapter = new SongItemAdapter(this, R.layout.playlist_item, items, getListView()); getListView().setAdapter(mAdapter); } getPlayer().setPlayList(getListType(), items); play(); } else { Music music = getPlayer().getCurrentMusic(); items = getPlayer().getPlayList(); if (!isRegulation()) { mAdapter = new SongItemAdapter(this, R.layout.playlist_item, items, getListView()); getListView().setAdapter(mAdapter); getListView().setSelection(getPlayer().getCurrentPosition()); } setDetail(music); if (getPlayer().getPlayerStatus() == PlayerService.STATUS_PLAYING) { this.playAniShow(true); } else { this.playAniShow(false); } } if (items != null && items.size() == 1) { if (!isRegulation()) { getShuffleButton().setEnabled(false); } getPrevButton().setEnabled(false); getNextButton().setEnabled(false); } } catch (Exception e) { ObiLog.e(TAG, "getPlaylist : ", e); } }