/** * Highlight current playing item Make the playing item can be seen. * * @param position */ private void onItemPlay(int position) { // Make the the playing item can be seen. mMusicListView.smoothScrollToPosition(position); int prePlayingPosition = mMusicListAdapter.getPlayingPosition(); if (prePlayingPosition >= mMusicListView.getFirstVisiblePosition() && prePlayingPosition <= mMusicListView.getLastVisiblePosition()) { int preItem = prePlayingPosition - mMusicListView.getFirstVisiblePosition(); ((ViewGroup) mMusicListView.getChildAt(preItem)).getChildAt(0).setVisibility(View.INVISIBLE); } mMusicListAdapter.setPlayingPosition(position); if (mMusicListView.getLastVisiblePosition() < position || mMusicListView.getFirstVisiblePosition() > position) return; int currentItem = position - mMusicListView.getFirstVisiblePosition(); ((ViewGroup) mMusicListView.getChildAt(currentItem)).getChildAt(0).setVisibility(View.VISIBLE); }
/** Called by UI Thread MainActivity.java */ public void onMusicListChanged() { mMusicListAdapter.notifyDataSetChanged(); }