public void init(Cursor c) { if (mAdapterDestroyed) return; mAdapter.changeCursor(c); if (mQueryCursor == null) { MusicUtils.displayDatabaseError(this); setListAdapter(null); mReScanHandler.sendEmptyMessageDelayed(0, 1000); return; } MusicUtils.hideDatabaseError(this); }
@Override protected void onQueryComplete(int token, Object cookie, Cursor cursor) { if (cursor != null) { if (!isFinishing()) { /// M: when media file be empty,show the empty view MusicUtils.emptyShow(getListView(), MusicPicker.this); /// M: Only when there exist audio and has one selected by user, we need to enable ok // button. /// if user delete the last select audio, we need to check whether it exist. mOkayButton.setEnabled( cursor.getCount() > 0 && RingtoneManager.isRingtoneExist(getApplicationContext(), mSelectedUri)); // Update the adapter: we are no longer loading, and have // a new cursor for it. mAdapter.setLoading(false); mAdapter.changeCursor(cursor); /// M: when listview has item showed ,let the ProgressBar@{ if (getListView().getCount() != 0) { setProgressBarIndeterminateVisibility(false); } /// @} // Now that the cursor is populated again, it's possible to // restore the list state if (mListState != null) { getListView().onRestoreInstanceState(mListState); if (mListHasFocus) { getListView().requestFocus(); } mListHasFocus = false; mListState = null; } /// M: when query out audios, hide error ui. MusicUtils.hideDatabaseError(MusicPicker.this); MusicPicker.this.setTitle(R.string.music_picker_title); } else { cursor.close(); } } else { /// M: When can not query out result, show error to notify user. mOkayButton.setEnabled(false); MusicUtils.resetSdStatus(); MusicUtils.displayDatabaseError(MusicPicker.this, false); } }