mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-29 05:43:55 +01:00
fix: use context instead of requireContext() for backward compatibility (#6403)
It fixes crash when opening certain screens like Contribution Details, Bookmark, etc. on lower Android versions Co-authored-by: Ritika Pahwa <83745993+RitikaPahwa4444@users.noreply.github.com>
This commit is contained in:
parent
718c466505
commit
4f3f7b97fd
4 changed files with 17 additions and 17 deletions
|
|
@ -36,7 +36,7 @@ class BookmarkItemsContentProvider : CommonsDaggerContentProvider() {
|
|||
requireDb(), projection, selection,
|
||||
selectionArgs, null, null, sortOrder
|
||||
).apply {
|
||||
setNotificationUri(requireContext().contentResolver, uri)
|
||||
setNotificationUri(context?.contentResolver, uri)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ class BookmarkItemsContentProvider : CommonsDaggerContentProvider() {
|
|||
)
|
||||
}
|
||||
|
||||
requireContext().contentResolver.notifyChange(uri, null)
|
||||
context?.contentResolver?.notifyChange(uri, null)
|
||||
return rowsUpdated
|
||||
}
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ class BookmarkItemsContentProvider : CommonsDaggerContentProvider() {
|
|||
*/
|
||||
override fun insert(uri: Uri, contentValues: ContentValues?): Uri? {
|
||||
val id = requireDb().insert(TABLE_NAME, null, contentValues)
|
||||
requireContext().contentResolver.notifyChange(uri, null)
|
||||
context?.contentResolver?.notifyChange(uri, null)
|
||||
return "$BASE_URI/$id".toUri()
|
||||
}
|
||||
|
||||
|
|
@ -89,7 +89,7 @@ class BookmarkItemsContentProvider : CommonsDaggerContentProvider() {
|
|||
"$COLUMN_ID = ?",
|
||||
arrayOf(uri.lastPathSegment)
|
||||
)
|
||||
requireContext().contentResolver.notifyChange(uri, null)
|
||||
context?.contentResolver?.notifyChange(uri, null)
|
||||
return rows
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class BookmarkPicturesContentProvider : CommonsDaggerContentProvider() {
|
|||
requireDb(), projection, selection,
|
||||
selectionArgs, null, null, sortOrder
|
||||
)
|
||||
cursor.setNotificationUri(requireContext().contentResolver, uri)
|
||||
cursor.setNotificationUri(context?.contentResolver, uri)
|
||||
|
||||
return cursor
|
||||
}
|
||||
|
|
@ -66,7 +66,7 @@ class BookmarkPicturesContentProvider : CommonsDaggerContentProvider() {
|
|||
"Parameter `selection` should be empty when updating an ID"
|
||||
)
|
||||
}
|
||||
requireContext().contentResolver.notifyChange(uri, null)
|
||||
context?.contentResolver?.notifyChange(uri, null)
|
||||
return rowsUpdated
|
||||
}
|
||||
|
||||
|
|
@ -75,7 +75,7 @@ class BookmarkPicturesContentProvider : CommonsDaggerContentProvider() {
|
|||
*/
|
||||
override fun insert(uri: Uri, contentValues: ContentValues?): Uri {
|
||||
val id = requireDb().insert(TABLE_NAME, null, contentValues)
|
||||
requireContext().contentResolver.notifyChange(uri, null)
|
||||
context?.contentResolver?.notifyChange(uri, null)
|
||||
return "$BASE_URI/$id".toUri()
|
||||
}
|
||||
|
||||
|
|
@ -85,7 +85,7 @@ class BookmarkPicturesContentProvider : CommonsDaggerContentProvider() {
|
|||
"media_name = ?",
|
||||
arrayOf(uri.lastPathSegment)
|
||||
)
|
||||
requireContext().contentResolver.notifyChange(uri, null)
|
||||
context?.contentResolver?.notifyChange(uri, null)
|
||||
return rows
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue