Skip to content

Commit bc44b63

Browse files
committed
Extract log tag to a global variable
1 parent 1a25cf2 commit bc44b63

1 file changed

Lines changed: 24 additions & 21 deletions

File tree

app/src/main/java/ai/elimu/content_provider/provider/WordContentProvider.kt

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ import android.net.Uri
1010
import android.util.Log
1111

1212
class WordContentProvider : ContentProvider() {
13+
14+
private val TAG = "WordContentProvider"
15+
1316
override fun onCreate(): Boolean {
14-
Log.i(javaClass.name, "onCreate")
17+
Log.i(TAG, "onCreate")
1518

16-
Log.i(javaClass.name, "URI_WORD: " + URI_WORD)
19+
Log.i(TAG, "URI_WORD: " + URI_WORD)
1720

1821
return true
1922
}
@@ -28,16 +31,16 @@ class WordContentProvider : ContentProvider() {
2831
selectionArgs: Array<String>?,
2932
sortOrder: String?
3033
): Cursor? {
31-
Log.i(javaClass.name, "query")
34+
Log.i(TAG, "query")
3235

33-
Log.i(javaClass.name, "uri: $uri")
34-
Log.i(javaClass.name, "projection: $projection")
35-
Log.i(javaClass.name, "selection: $selection")
36-
Log.i(javaClass.name, "selectionArgs: $selectionArgs")
37-
Log.i(javaClass.name, "sortOrder: $sortOrder")
36+
Log.i(TAG, "uri: $uri")
37+
Log.i(TAG, "projection: $projection")
38+
Log.i(TAG, "selection: $selection")
39+
Log.i(TAG, "selectionArgs: $selectionArgs")
40+
Log.i(TAG, "sortOrder: $sortOrder")
3841

3942
val context = context
40-
Log.i(javaClass.name, "context: $context")
43+
Log.i(TAG, "context: $context")
4144
if (context == null) {
4245
return null
4346
}
@@ -46,41 +49,41 @@ class WordContentProvider : ContentProvider() {
4649
val wordDao = roomDb.wordDao()
4750

4851
val code = MATCHER.match(uri)
49-
Log.i(javaClass.name, "code: $code")
52+
Log.i(TAG, "code: $code")
5053
if (code == CODE_WORDS) {
5154
// Get the Room Cursor
5255
val cursor = wordDao.loadAllOrderedByUsageCountAsCursor()
53-
Log.i(javaClass.name, "cursor: $cursor")
56+
Log.i(TAG, "cursor: $cursor")
5457

5558
cursor.setNotificationUri(context.contentResolver, uri)
5659

5760
return cursor
5861
} else if (code == CODE_WORDS_BY_STORYBOOK_PARAGRAPH_ID) {
5962
// Extract the StoryBookParagraph ID from the URI
6063
val pathSegments = uri.pathSegments
61-
Log.i(javaClass.name, "pathSegments: $pathSegments")
64+
Log.i(TAG, "pathSegments: $pathSegments")
6265
val storyBookParagraphIdAsString = pathSegments[2]
6366
val storyBookParagraphId = storyBookParagraphIdAsString.toLong()
64-
Log.i(javaClass.name, "storyBookParagraphId: $storyBookParagraphId")
67+
Log.i(TAG, "storyBookParagraphId: $storyBookParagraphId")
6568

6669
// Get the Room Cursor
6770
val cursor = wordDao.loadAllAsCursor(storyBookParagraphId)
68-
Log.i(javaClass.name, "cursor: $cursor")
71+
Log.i(TAG, "cursor: $cursor")
6972

7073
cursor.setNotificationUri(context.contentResolver, uri)
7174

7275
return cursor
7376
} else if (code == CODE_WORD_ID) {
7477
// Extract the Word ID from the URI
7578
val pathSegments = uri.pathSegments
76-
Log.i(javaClass.name, "pathSegments: $pathSegments")
79+
Log.i(TAG, "pathSegments: $pathSegments")
7780
val wordIdAsString = pathSegments[1]
7881
val wordId = wordIdAsString.toLong()
79-
Log.i(javaClass.name, "wordId: $wordId")
82+
Log.i(TAG, "wordId: $wordId")
8083

8184
// Get the Room Cursor
8285
val cursor = wordDao.loadAsCursor(wordId)
83-
Log.i(javaClass.name, "cursor: $cursor")
86+
Log.i(TAG, "cursor: $cursor")
8487

8588
cursor.setNotificationUri(context.contentResolver, uri)
8689

@@ -94,7 +97,7 @@ class WordContentProvider : ContentProvider() {
9497
* Handles requests for the MIME type of the data at the given URI.
9598
*/
9699
override fun getType(uri: Uri): String? {
97-
Log.i(javaClass.name, "getType")
100+
Log.i(TAG, "getType")
98101

99102
throw UnsupportedOperationException("Not yet implemented")
100103
}
@@ -103,7 +106,7 @@ class WordContentProvider : ContentProvider() {
103106
* Handles requests to insert a new row.
104107
*/
105108
override fun insert(uri: Uri, values: ContentValues?): Uri? {
106-
Log.i(javaClass.name, "insert")
109+
Log.i(TAG, "insert")
107110

108111
throw UnsupportedOperationException("Not yet implemented")
109112
}
@@ -117,7 +120,7 @@ class WordContentProvider : ContentProvider() {
117120
selection: String?,
118121
selectionArgs: Array<String>?
119122
): Int {
120-
Log.i(javaClass.name, "update")
123+
Log.i(TAG, "update")
121124

122125
throw UnsupportedOperationException("Not yet implemented")
123126
}
@@ -126,7 +129,7 @@ class WordContentProvider : ContentProvider() {
126129
* Handle requests to delete one or more rows.
127130
*/
128131
override fun delete(uri: Uri, selection: String?, selectionArgs: Array<String>?): Int {
129-
Log.i(javaClass.name, "delete")
132+
Log.i(TAG, "delete")
130133

131134
throw UnsupportedOperationException("Not yet implemented")
132135
}

0 commit comments

Comments
 (0)