Search in sources :

Example 1 with NotificationSoundModel

use of com.fastaccess.data.dao.NotificationSoundModel in project FastHub by k0shk0sh.

the class FileHelper method getNotificationSounds.

public static ArrayList<NotificationSoundModel> getNotificationSounds(Context context, @Nullable String defaultValue) {
    ArrayList<NotificationSoundModel> notificationSounds = new ArrayList<>();
    RingtoneManager ringtoneManager = new RingtoneManager(context);
    ringtoneManager.setType(RingtoneManager.TYPE_NOTIFICATION);
    try (Cursor ringsCursor = ringtoneManager.getCursor()) {
        while (ringsCursor.moveToNext()) {
            String title = ringsCursor.getString(RingtoneManager.TITLE_COLUMN_INDEX);
            Uri uri = Uri.parse(ringsCursor.getString(RingtoneManager.URI_COLUMN_INDEX) + "/" + ringsCursor.getString(RingtoneManager.ID_COLUMN_INDEX));
            boolean selected = defaultValue != null && (uri.toString().contains(defaultValue) || title.equalsIgnoreCase(defaultValue) || defaultValue.contains(title));
            Logger.e(defaultValue, title, uri, selected);
            notificationSounds.add(new NotificationSoundModel(title, uri, selected));
        }
    }
    return notificationSounds;
}
Also used : NotificationSoundModel(com.fastaccess.data.dao.NotificationSoundModel) RingtoneManager(android.media.RingtoneManager) ArrayList(java.util.ArrayList) Cursor(android.database.Cursor) Uri(android.net.Uri)

Aggregations

Cursor (android.database.Cursor)1 RingtoneManager (android.media.RingtoneManager)1 Uri (android.net.Uri)1 NotificationSoundModel (com.fastaccess.data.dao.NotificationSoundModel)1 ArrayList (java.util.ArrayList)1