mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-26 20:33:53 +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,
|
requireDb(), projection, selection,
|
||||||
selectionArgs, null, null, sortOrder
|
selectionArgs, null, null, sortOrder
|
||||||
).apply {
|
).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
|
return rowsUpdated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ class BookmarkItemsContentProvider : CommonsDaggerContentProvider() {
|
||||||
*/
|
*/
|
||||||
override fun insert(uri: Uri, contentValues: ContentValues?): Uri? {
|
override fun insert(uri: Uri, contentValues: ContentValues?): Uri? {
|
||||||
val id = requireDb().insert(TABLE_NAME, null, contentValues)
|
val id = requireDb().insert(TABLE_NAME, null, contentValues)
|
||||||
requireContext().contentResolver.notifyChange(uri, null)
|
context?.contentResolver?.notifyChange(uri, null)
|
||||||
return "$BASE_URI/$id".toUri()
|
return "$BASE_URI/$id".toUri()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@ class BookmarkItemsContentProvider : CommonsDaggerContentProvider() {
|
||||||
"$COLUMN_ID = ?",
|
"$COLUMN_ID = ?",
|
||||||
arrayOf(uri.lastPathSegment)
|
arrayOf(uri.lastPathSegment)
|
||||||
)
|
)
|
||||||
requireContext().contentResolver.notifyChange(uri, null)
|
context?.contentResolver?.notifyChange(uri, null)
|
||||||
return rows
|
return rows
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ class BookmarkPicturesContentProvider : CommonsDaggerContentProvider() {
|
||||||
requireDb(), projection, selection,
|
requireDb(), projection, selection,
|
||||||
selectionArgs, null, null, sortOrder
|
selectionArgs, null, null, sortOrder
|
||||||
)
|
)
|
||||||
cursor.setNotificationUri(requireContext().contentResolver, uri)
|
cursor.setNotificationUri(context?.contentResolver, uri)
|
||||||
|
|
||||||
return cursor
|
return cursor
|
||||||
}
|
}
|
||||||
|
|
@ -66,7 +66,7 @@ class BookmarkPicturesContentProvider : CommonsDaggerContentProvider() {
|
||||||
"Parameter `selection` should be empty when updating an ID"
|
"Parameter `selection` should be empty when updating an ID"
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
requireContext().contentResolver.notifyChange(uri, null)
|
context?.contentResolver?.notifyChange(uri, null)
|
||||||
return rowsUpdated
|
return rowsUpdated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -75,7 +75,7 @@ class BookmarkPicturesContentProvider : CommonsDaggerContentProvider() {
|
||||||
*/
|
*/
|
||||||
override fun insert(uri: Uri, contentValues: ContentValues?): Uri {
|
override fun insert(uri: Uri, contentValues: ContentValues?): Uri {
|
||||||
val id = requireDb().insert(TABLE_NAME, null, contentValues)
|
val id = requireDb().insert(TABLE_NAME, null, contentValues)
|
||||||
requireContext().contentResolver.notifyChange(uri, null)
|
context?.contentResolver?.notifyChange(uri, null)
|
||||||
return "$BASE_URI/$id".toUri()
|
return "$BASE_URI/$id".toUri()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -85,7 +85,7 @@ class BookmarkPicturesContentProvider : CommonsDaggerContentProvider() {
|
||||||
"media_name = ?",
|
"media_name = ?",
|
||||||
arrayOf(uri.lastPathSegment)
|
arrayOf(uri.lastPathSegment)
|
||||||
)
|
)
|
||||||
requireContext().contentResolver.notifyChange(uri, null)
|
context?.contentResolver?.notifyChange(uri, null)
|
||||||
return rows
|
return rows
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -50,7 +50,7 @@ class RecentSearchesContentProvider : CommonsDaggerContentProvider() {
|
||||||
else -> throw IllegalArgumentException("Unknown URI$uri")
|
else -> throw IllegalArgumentException("Unknown URI$uri")
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor.setNotificationUri(requireContext().contentResolver, uri)
|
cursor.setNotificationUri(context?.contentResolver, uri)
|
||||||
|
|
||||||
return cursor
|
return cursor
|
||||||
}
|
}
|
||||||
|
|
@ -67,7 +67,7 @@ class RecentSearchesContentProvider : CommonsDaggerContentProvider() {
|
||||||
|
|
||||||
else -> throw IllegalArgumentException("Unknown URI: $uri")
|
else -> throw IllegalArgumentException("Unknown URI: $uri")
|
||||||
}
|
}
|
||||||
requireContext().contentResolver.notifyChange(uri, null)
|
context?.contentResolver?.notifyChange(uri, null)
|
||||||
return "$BASE_URI/$id".toUri()
|
return "$BASE_URI/$id".toUri()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,7 +88,7 @@ class RecentSearchesContentProvider : CommonsDaggerContentProvider() {
|
||||||
|
|
||||||
else -> throw IllegalArgumentException("Unknown URI - $uri")
|
else -> throw IllegalArgumentException("Unknown URI - $uri")
|
||||||
}
|
}
|
||||||
requireContext().contentResolver.notifyChange(uri, null)
|
context?.contentResolver?.notifyChange(uri, null)
|
||||||
return rows
|
return rows
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -108,7 +108,7 @@ class RecentSearchesContentProvider : CommonsDaggerContentProvider() {
|
||||||
}
|
}
|
||||||
sqlDB.setTransactionSuccessful()
|
sqlDB.setTransactionSuccessful()
|
||||||
sqlDB.endTransaction()
|
sqlDB.endTransaction()
|
||||||
requireContext().contentResolver.notifyChange(uri, null)
|
context?.contentResolver?.notifyChange(uri, null)
|
||||||
return values.size
|
return values.size
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -147,7 +147,7 @@ class RecentSearchesContentProvider : CommonsDaggerContentProvider() {
|
||||||
|
|
||||||
else -> throw IllegalArgumentException("Unknown URI: $uri with type $uriType")
|
else -> throw IllegalArgumentException("Unknown URI: $uri with type $uriType")
|
||||||
}
|
}
|
||||||
requireContext().contentResolver.notifyChange(uri, null)
|
context?.contentResolver?.notifyChange(uri, null)
|
||||||
return rowsUpdated
|
return rowsUpdated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ class RecentLanguagesContentProvider : CommonsDaggerContentProvider() {
|
||||||
null,
|
null,
|
||||||
sortOrder
|
sortOrder
|
||||||
)
|
)
|
||||||
cursor.setNotificationUri(requireContext().contentResolver, uri)
|
cursor.setNotificationUri(context?.contentResolver, uri)
|
||||||
return cursor
|
return cursor
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -90,7 +90,7 @@ class RecentLanguagesContentProvider : CommonsDaggerContentProvider() {
|
||||||
throw IllegalArgumentException("Parameter `selection` should be empty when updating an ID")
|
throw IllegalArgumentException("Parameter `selection` should be empty when updating an ID")
|
||||||
}
|
}
|
||||||
|
|
||||||
requireContext().contentResolver?.notifyChange(uri, null)
|
context?.contentResolver?.notifyChange(uri, null)
|
||||||
return rowsUpdated
|
return rowsUpdated
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -105,7 +105,7 @@ class RecentLanguagesContentProvider : CommonsDaggerContentProvider() {
|
||||||
null,
|
null,
|
||||||
contentValues
|
contentValues
|
||||||
)
|
)
|
||||||
requireContext().contentResolver?.notifyChange(uri, null)
|
context?.contentResolver?.notifyChange(uri, null)
|
||||||
return "$BASE_URI/$id".toUri()
|
return "$BASE_URI/$id".toUri()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -119,7 +119,7 @@ class RecentLanguagesContentProvider : CommonsDaggerContentProvider() {
|
||||||
"language_code = ?",
|
"language_code = ?",
|
||||||
arrayOf(uri.lastPathSegment)
|
arrayOf(uri.lastPathSegment)
|
||||||
)
|
)
|
||||||
requireContext().contentResolver?.notifyChange(uri, null)
|
context?.contentResolver?.notifyChange(uri, null)
|
||||||
return rows
|
return rows
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue