Skip to content
This repository has been archived by the owner on Jan 11, 2024. It is now read-only.

Feat: Convert Retrofit Model Java classes to Kotlin. #104

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
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
10 changes: 7 additions & 3 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,18 @@
android:resource="@xml/filepaths" />
</provider>

<activity android:name=".ui.online.SplashActivity" android:theme="@style/SplashTheme">
<activity
android:name=".ui.online.SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>

<activity android:name=".ui.online.launcher.LauncherActivity"/>
<activity android:name=".ui.online.launcher.LauncherActivity" />

<activity android:name=".ui.online.PassCodeActivity" />

<activity
android:name=".ui.online.login.LoginActivity"
Expand All @@ -50,7 +54,7 @@

<activity android:name=".ui.online.customers.customerpayroll.PayrollActivity" />

<activity android:name=".ui.online.customers.customerpayroll.editcustomerpayroll.EditPayrollActivity"/>
<activity android:name=".ui.online.customers.customerpayroll.editcustomerpayroll.EditPayrollActivity" />

<activity android:name=".ui.online.depositaccounts.depositaccountslist.DepositAccountsActivity" />

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import com.crashlytics.android.Crashlytics;
import com.evernote.android.job.JobManager;
import com.mifos.mobile.passcode.utils.ForegroundChecker;
import com.raizlabs.android.dbflow.config.FlowManager;

import org.apache.fineract.injection.component.ApplicationComponent;
Expand Down Expand Up @@ -35,6 +36,7 @@ public void onCreate() {
instance = this;
Fabric.with(this, new Crashlytics());
FlowManager.init(this);
ForegroundChecker.init(this);
}

public static Context getContext() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public DataManagerRoles(BaseApiManager baseApiManager,

public Observable<List<Role>> getRoles() {
return authenticatedObservableApi(
baseApiManager.getRolesAndPermissionsService().getRoles())
baseApiManager.rolesService.getRoles())
.onErrorResumeNext(
new Function<Throwable, ObservableSource<List<Role>>>() {
@Override
Expand Down
145 changes: 0 additions & 145 deletions app/src/main/java/org/apache/fineract/data/remote/BaseApiManager.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
package org.apache.fineract.data.remote

import android.content.Context
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import org.apache.fineract.data.services.*
import retrofit2.Retrofit
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory
import retrofit2.converter.gson.GsonConverterFactory
import retrofit2.converter.scalars.ScalarsConverterFactory

/**
* Created by Ahmad Jawid Muhammadi on 1/6/20
*/

class BaseApiManager(context: Context) {

companion object {
lateinit var retrofit: Retrofit
}

lateinit var anonyMousRetrofit: Retrofit
lateinit var authApi: AuthService
lateinit var customerApi: CustomerService
lateinit var depositApi: DepositService
lateinit var loanApi: LoanService
lateinit var individualLendingService: IndividualLendingService
lateinit var anonymousService: AnonymousService
lateinit var rolesService: RolesService
lateinit var accountingService: AccountingService
lateinit var tellerService: TellersService
lateinit var productService: ProductService
lateinit var payrollService: PayrollService

init {
createService(context)
createAnonymousService()
}

private fun init() {
authApi = createApi(AuthService::class.java)
customerApi = createApi(CustomerService::class.java)
depositApi = createApi(DepositService::class.java)
loanApi = createApi(LoanService::class.java)
individualLendingService = createApi(IndividualLendingService::class.java)
rolesService = createApi(RolesService::class.java)
accountingService = createApi(AccountingService::class.java)
tellerService = createApi(TellersService::class.java)
productService = createApi(ProductService::class.java)
payrollService = createApi(PayrollService::class.java)
}

private fun initAnonymous() {
anonymousService = anonyMousRetrofit!!.create(AnonymousService::class.java)
}

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

private fun createService(context: Context) {
retrofit = Retrofit.Builder()
.baseUrl(BaseUrl.getDefaultBaseUrl())
.addConverterFactory(NullOnEmptyConverterFactory())
.addConverterFactory(ScalarsConverterFactory.create())
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.client(FineractOkHttpClient.getFineractOkHttpClient(context))
.build()
init()
}

private fun createAnonymousService() {
val interceptor = HttpLoggingInterceptor()
interceptor.level = HttpLoggingInterceptor.Level.BODY
val okHttpClient = OkHttpClient.Builder()
.addInterceptor(interceptor)
.build()
anonyMousRetrofit = Retrofit.Builder()
.baseUrl(BaseUrl.getDefaultBaseUrl())
.addConverterFactory(GsonConverterFactory.create())
.addCallAdapterFactory(RxJava2CallAdapterFactory.create())
.client(okHttpClient)
.build()
initAnonymous()
}
}
25 changes: 0 additions & 25 deletions app/src/main/java/org/apache/fineract/data/remote/BaseUrl.java

This file was deleted.

22 changes: 22 additions & 0 deletions app/src/main/java/org/apache/fineract/data/remote/BaseUrl.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.apache.fineract.data.remote

/**
* Created by Ahmad Jawid Muhammadi on 1/6/20
*/

object BaseUrl {
private const val PROTOCOL_HTTPS = "https://"
private const val API_ENDPOINT = "pilot.kuelap.io"
val PORT = "80"
// "/" in the last of the base url always

// "/" in the last of the base url always
fun getName(): String? {
return "fineract"
}

@JvmStatic
fun getDefaultBaseUrl(): String? {
return PROTOCOL_HTTPS + API_ENDPOINT
}
}

This file was deleted.

Loading