@@ -15,6 +15,7 @@ import android.provider.MediaStore.Audio.AudioColumns
15
15
import android.provider.MediaStore.Audio.Genres
16
16
import android.provider.Settings
17
17
import androidx.annotation.WorkerThread
18
+ import com.tencent.bugly.crashreport.CrashReport
18
19
import remix.myplayer.App
19
20
import remix.myplayer.R
20
21
import remix.myplayer.bean.mp3.Album
@@ -249,20 +250,24 @@ object MediaStoreUtil {
249
250
}
250
251
251
252
val genres: MutableList <Genre > = ArrayList ()
252
- context.contentResolver.query(
253
- Genres .EXTERNAL_CONTENT_URI ,
254
- arrayOf(Genres ._ID , Genres .NAME ),
255
- null ,
256
- null ,
257
- SPUtil .getValue(context, SETTING_KEY .NAME , SETTING_KEY .GENRE_SORT_ORDER , SortOrder .GENRE_A_Z )
258
- )?.use { cursor ->
259
- while (cursor.moveToNext()) {
260
- val genreId = cursor.getLong(0 )
261
- if (genreId > 0 ) {
262
- val songs = getSongsByGenreId(genreId)
263
- genres.add(Genre (genreId, cursor.getString(1 ) ? : " " , songs.size))
253
+ try {
254
+ context.contentResolver.query(
255
+ Genres .EXTERNAL_CONTENT_URI ,
256
+ arrayOf(Genres ._ID , Genres .NAME ),
257
+ null ,
258
+ null ,
259
+ SPUtil .getValue(context, SETTING_KEY .NAME , SETTING_KEY .GENRE_SORT_ORDER , SortOrder .GENRE_A_Z )
260
+ )?.use { cursor ->
261
+ while (cursor.moveToNext()) {
262
+ val genreId = cursor.getLong(0 )
263
+ if (genreId > 0 ) {
264
+ val songs = getSongsByGenreId(genreId)
265
+ genres.add(Genre (genreId, cursor.getString(1 ) ? : " " , songs.size))
266
+ }
264
267
}
265
268
}
269
+ } catch (e: Exception ) {
270
+ CrashReport .postCatchedException(e)
266
271
}
267
272
return genres
268
273
}
@@ -651,9 +656,15 @@ object MediaStoreUtil {
651
656
newSelectionValues, selectionValues.size,
652
657
newSelectionValues.size - selectionValues.size)
653
658
}
654
-
659
+
660
+ val uri = if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .Q ) {
661
+ Audio .Media .getContentUri(MediaStore .VOLUME_EXTERNAL )
662
+ } else {
663
+ Audio .Media .EXTERNAL_CONTENT_URI
664
+ }
665
+
655
666
return try {
656
- context.contentResolver.query(Audio . Media . EXTERNAL_CONTENT_URI ,
667
+ context.contentResolver.query(uri ,
657
668
BASE_PROJECTION , selection, newSelectionValues, sortOrder)
658
669
} catch (e: SecurityException ) {
659
670
null
0 commit comments