Skip to content

Commit 45c49b2

Browse files
instance property access fix
Signed-off-by: parneet-guraya <[email protected]>
1 parent da398a1 commit 45c49b2

File tree

5 files changed

+8
-7
lines changed

5 files changed

+8
-7
lines changed

app/src/androidTest/java/fr/free/nrw/commons/AboutActivityTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ class AboutActivityTest {
105105
fun testLaunchTranslate() {
106106
Espresso.onView(ViewMatchers.withId(R.id.about_translate)).perform(ViewActions.click())
107107
Espresso.onView(ViewMatchers.withId(android.R.id.button1)).perform(ViewActions.click())
108-
val langCode = CommonsApplication.getInstance().languageLookUpTable.codes[0]
108+
val langCode = CommonsApplication.instance.languageLookUpTable!!.codes[0]
109109
Intents.intended(
110110
CoreMatchers.allOf(
111111
IntentMatchers.hasAction(Intent.ACTION_VIEW),

app/src/main/java/fr/free/nrw/commons/CommonsApplication.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ class CommonsApplication : MultiDexApplication() {
8585
@Inject
8686
lateinit var customOkHttpNetworkFetcher: CustomOkHttpNetworkFetcher
8787

88-
//TODO [parry] not being used anywhere, remove after checking
8988
var languageLookUpTable: AppLanguageLookUpTable? = null
9089
private set
9190

@@ -385,7 +384,9 @@ class CommonsApplication : MultiDexApplication() {
385384
/**
386385
* Constants End
387386
*/
388-
var instance: CommonsApplication? = null
387+
388+
@JvmStatic
389+
lateinit var instance: CommonsApplication
389390
private set
390391

391392
@JvmField

app/src/main/java/fr/free/nrw/commons/actions/ThanksClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class ThanksClient
3232
revisionId.toString(), // Rev
3333
null, // Log
3434
csrfTokenClient.getTokenBlocking(), // Token
35-
CommonsApplication.getInstance().userAgent, // Source
35+
CommonsApplication.instance.userAgent, // Source
3636
).map { mwThankPostResponse ->
3737
mwThankPostResponse.result?.success == 1
3838
}

app/src/main/java/fr/free/nrw/commons/description/DescriptionEditActivity.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ class DescriptionEditActivity :
258258
username,
259259
)
260260

261-
val commonsApplication = CommonsApplication.getInstance()
261+
val commonsApplication = CommonsApplication.instance
262262
if (commonsApplication != null) {
263263
commonsApplication.clearApplicationData(this, logoutListener)
264264
}
@@ -291,7 +291,7 @@ class DescriptionEditActivity :
291291
username,
292292
)
293293

294-
val commonsApplication = CommonsApplication.getInstance()
294+
val commonsApplication = CommonsApplication.instance
295295
if (commonsApplication != null) {
296296
commonsApplication.clearApplicationData(this, logoutListener)
297297
}

app/src/test/kotlin/fr/free/nrw/commons/actions/ThanksClientTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ThanksClientTest {
3939
fun setUp() {
4040
MockitoAnnotations.openMocks(this)
4141
mockedApplication = Mockito.mockStatic(CommonsApplication::class.java)
42-
`when`(CommonsApplication.getInstance()).thenReturn(commonsApplication)
42+
`when`(CommonsApplication.instance).thenReturn(commonsApplication)
4343
thanksClient = ThanksClient(csrfTokenClient, service)
4444
}
4545

0 commit comments

Comments
 (0)