Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d42b20c1 authored by Patrick Scott's avatar Patrick Scott
Browse files

Look up the ringtone title in the AsyncTask.

Found using strict mode.

Change-Id: I23a3398929be48f238b1389173e70d6be0833c7e
parent 2870cc9a
Loading
Loading
Loading
Loading
+11 −6
Original line number Diff line number Diff line
@@ -65,17 +65,22 @@ public class AlarmPreference extends RingtonePreference {
            if (mRingtoneTask != null) {
                mRingtoneTask.cancel(true);
            }
            mRingtoneTask = new AsyncTask<Uri, Void, Ringtone>() {
            mRingtoneTask = new AsyncTask<Uri, Void, String>() {
                @Override
                protected Ringtone doInBackground(Uri... params) {
                    return RingtoneManager.getRingtone(getContext(), params[0]);
                protected String doInBackground(Uri... params) {
                    Ringtone r = RingtoneManager.getRingtone(
                            getContext(), params[0]);
                    if (r != null) {
                        return r.getTitle(getContext());
                    }
                    return null;
                }

                @Override
                protected void onPostExecute(Ringtone r) {
                protected void onPostExecute(String title) {
                    if (!isCancelled()) {
                        if (r != null) {
                            setSummary(r.getTitle(getContext()));
                        if (title != null) {
                            setSummary(title);
                        }
                        mRingtoneTask = null;
                    }