private void setAdapter() { mPathList = MusicUtils.getPathList(this); String[] folderPathinDB = MusicUtils.getFolderPath(this); mFolderPathInDB.clear(); if (mPathList != null && folderPathinDB != null) { if (folderPathinDB.length > 0) { for (int i = 0; i < folderPathinDB.length; i++) { if (mPathList.contains(folderPathinDB[i])) { mFolderPathInDB.add(folderPathinDB[i]); } else { MusicUtils.deleteFolderPath(getApplicationContext(), folderPathinDB[i]); } } } else { for (int i = 0; i < mPathList.size(); i++) { mFolderPathInDB.add(mPathList.get(i)); } } mAdapter = new MusicFolderAdapter( this, mPathList, mFolderPathInDB, mIsOuter, getApplicationContext()); if (mAdapter != null) { mList.setAdapter(mAdapter); mList.setOnItemClickListener(SelectFolderActivity.this); } } }
@Override public void handleMessage(Message msg) { if (msg.what == 1) { mAdapter = new MusicFolderAdapter( SelectFolderActivity.this, mPathList, mFolderPathInDB, 2, getApplicationContext()); } else { mPathList = MusicUtils.getPathList(SelectFolderActivity.this); String[] folderPathinDB = MusicUtils.getFolderPath(SelectFolderActivity.this); if (mFolderPathInDB != null && mFolderPathInDB.size() != 0) { mFolderPathInDB.clear(); } if (mPathList != null && folderPathinDB != null) { if (folderPathinDB.length > 0) { for (int i = 0; i < folderPathinDB.length; i++) { mFolderPathInDB.add(folderPathinDB[i]); } } else { for (int i = 0; i < mPathList.size(); i++) { mFolderPathInDB.add(mPathList.get(i)); } } mAdapter = new MusicFolderAdapter( SelectFolderActivity.this, mPathList, mFolderPathInDB, mIsOuter, getApplicationContext()); } } if (mAdapter != null) { mList.setAdapter(mAdapter); mAdapter.notifyDataSetChanged(); } setupNoSongsView(); if (MusicUtils.sService != null && Artistactionbar != null) { Artistactionbar.setMediaService(MusicUtils.sService); } }