/** * Sets the ringtone uri in preparation for ringtone creation in makeLooper(). This uri is * defaulted to the phone-wide default ringtone. */ void setCustomRingtoneUri(Uri uri) { /// M: if the uri is not aviable(ex, ALPS00414350), use default Ringtone @{ // if (uri != null) { // log("setCustomRingtoneUri = " + uri); // mCustomRingtoneUri = uri; // } if (RingtoneManager.isRingtoneExist(mContext, uri)) { mCustomRingtoneUri = uri; log("setCustomRingtoneUri = " + uri); } else { mCustomRingtoneUri = Settings.System.DEFAULT_RINGTONE_URI; log("CustomRingtoneUri = " + uri + ", not available, use default ringtone!"); } /// @} }
@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); } }