Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #1968 : Java to Kotlin and ButterKnife to Viewbinding Migration : Authentication #1970

Merged
merged 3 commits into from
Jun 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,7 @@ ext {
butterKnifeVersion = '8.0.1'
mifosPasscodeVersion = '1.0.0'
preference = '1.1.0'
jUnitVersion = '4.13.2'
mockitoVersion = '5.3.1'

}
9 changes: 7 additions & 2 deletions mifosng-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,13 @@ dependencies {
}
androidTestImplementation 'androidx.test.espresso:espresso-intents:3.1.0'

testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-core:1.10.19'
testImplementation "junit:junit:$rootProject.jUnitVersion"
testImplementation "org.mockito:mockito-core:$rootProject.mockitoVersion"

androidTestImplementation "junit:junit:$rootProject.jUnitVersion"
androidTestImplementation "org.mockito:mockito-core:$rootProject.mockitoVersion"
androidTestImplementation "org.mockito:mockito-android:$rootProject.mockitoVersion"
testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2'

//Android-Jobs
implementation 'com.evernote:android-job:1.2.6'
Expand Down
179 changes: 0 additions & 179 deletions mifosng-android/src/main/java/com/mifos/api/BaseApiManager.java

This file was deleted.

174 changes: 174 additions & 0 deletions mifosng-android/src/main/java/com/mifos/api/BaseApiManager.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,174 @@
/*
* This project is licensed under the open source MPL V2.
* See https://github.com/openMF/android-client/blob/master/LICENSE.md
*/
package com.mifos.api

import com.google.gson.GsonBuilder
import com.mifos.api.services.AuthService
import com.mifos.api.services.CenterService
import com.mifos.api.services.ChargeService
import com.mifos.api.services.CheckerInboxService
import com.mifos.api.services.ClientAccountsService
import com.mifos.api.services.ClientService
import com.mifos.api.services.CollectionSheetService
import com.mifos.api.services.DataTableService
import com.mifos.api.services.DocumentService
import com.mifos.api.services.GroupService
import com.mifos.api.services.LoanService
import com.mifos.api.services.NoteService
import com.mifos.api.services.OfficeService
import com.mifos.api.services.RunReportsService
import com.mifos.api.services.SavingsAccountService
import com.mifos.api.services.SearchService
import com.mifos.api.services.StaffService
import com.mifos.api.services.SurveyService
import com.mifos.utils.JsonDateSerializer
import com.mifos.utils.PrefManager.instanceUrl
import retrofit2.Retrofit
import retrofit2.adapter.rxjava.RxJavaCallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.converter.scalars.ScalarsConverterFactory
import java.util.Date

/**
* @author fomenkoo
*/
class BaseApiManager {
init {
createService()
}

val authApi: AuthService
get() = Companion.authApi
val centerApi: CenterService
get() = Companion.centerApi
val accountsApi: ClientAccountsService
get() = Companion.accountsApi
val clientsApi: ClientService
get() = Companion.clientsApi
val dataTableApi: DataTableService
get() = Companion.dataTableApi
val loanApi: LoanService
get() = Companion.loanApi
val savingsApi: SavingsAccountService
get() = Companion.savingsApi
val searchApi: SearchService
get() = Companion.searchApi
val groupApi: GroupService
get() = Companion.groupApi
val documentApi: DocumentService
get() = Companion.documentApi
val officeApi: OfficeService
get() = Companion.officeApi
val staffApi: StaffService
get() = Companion.staffApi
val surveyApi: SurveyService
get() = Companion.surveyApi
val chargeApi: ChargeService
get() = Companion.chargeApi
val checkerInboxApi: CheckerInboxService
get() = Companion.checkerInboxApi
val collectionSheetApi: CollectionSheetService
get() = Companion.collectionSheetApi
val noteApi: NoteService
get() = Companion.noteApi
val runReportsService: RunReportsService
get() = Companion.runReportsService

companion object {
private var mRetrofit: Retrofit? = null
private lateinit var authApi: AuthService
private lateinit var centerApi: CenterService
private lateinit var accountsApi: ClientAccountsService
private lateinit var clientsApi: ClientService
private lateinit var dataTableApi: DataTableService
private lateinit var loanApi: LoanService
private lateinit var savingsApi: SavingsAccountService
private lateinit var chargeApi: ChargeService
private lateinit var searchApi: SearchService
private lateinit var groupApi: GroupService
private lateinit var documentApi: DocumentService
private lateinit var officeApi: OfficeService
private lateinit var staffApi: StaffService
private lateinit var surveyApi: SurveyService
private lateinit var runReportsService: RunReportsService
private lateinit var noteApi: NoteService
private lateinit var collectionSheetApi: CollectionSheetService
private lateinit var checkerInboxApi: CheckerInboxService

fun init() {
authApi = createApi(
AuthService::class.java
)
centerApi = createApi(
CenterService::class.java
)
accountsApi = createApi(
ClientAccountsService::class.java
)
clientsApi = createApi(
ClientService::class.java
)
dataTableApi = createApi(
DataTableService::class.java
)
loanApi = createApi(
LoanService::class.java
)
savingsApi = createApi(
SavingsAccountService::class.java
)
searchApi = createApi(
SearchService::class.java
)
groupApi = createApi(
GroupService::class.java
)
documentApi = createApi(
DocumentService::class.java
)
officeApi = createApi(
OfficeService::class.java
)
staffApi = createApi(
StaffService::class.java
)
surveyApi = createApi(
SurveyService::class.java
)
chargeApi = createApi(
ChargeService::class.java
)
runReportsService = createApi(
RunReportsService::class.java
)
noteApi = createApi(
NoteService::class.java
)
collectionSheetApi = createApi(
CollectionSheetService::class.java
)
checkerInboxApi = createApi(
CheckerInboxService::class.java
)
}

private fun <T> createApi(clazz: Class<T>): T {
return mRetrofit!!.create(clazz)
}

fun createService() {
val gson = GsonBuilder()
.registerTypeAdapter(Date::class.java, JsonDateSerializer()).create()
mRetrofit = Retrofit.Builder()
.baseUrl(instanceUrl)
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create(gson))
.addCallAdapterFactory(RxJavaCallAdapterFactory.create())
.client(MifosOkHttpClient().mifosOkHttpClient)
.build()
init()
}
}
}
Loading