From af221110923ff02c9dacda5457a4cffe711fc4e0 Mon Sep 17 00:00:00 2001 From: Aditya-gupta99 Date: Sun, 8 Dec 2024 15:53:12 +0530 Subject: [PATCH] feat: Fixed build fail --- .../mifos/core/network/di/NetworkModule.kt | 2 +- .../feature/auth/login/LoginViewModel.kt | 4 +- .../mifosxdroid/activity/home/HomeActivity.kt | 42 ++++++------- .../mifosxdroid/core/MifosBaseActivity.kt | 3 +- .../online/centerlist/CenterListRepository.kt | 2 +- .../centerlist/CenterListRepositoryImp.kt | 2 +- .../online/centerlist/CenterListViewModel.kt | 63 ++++++++++--------- .../main/java/com/mifos/utils/PrefManager.kt | 5 +- 8 files changed, 64 insertions(+), 59 deletions(-) diff --git a/core/network/src/main/java/com/mifos/core/network/di/NetworkModule.kt b/core/network/src/main/java/com/mifos/core/network/di/NetworkModule.kt index e99129c9dd4..2b9db1561d3 100644 --- a/core/network/src/main/java/com/mifos/core/network/di/NetworkModule.kt +++ b/core/network/src/main/java/com/mifos/core/network/di/NetworkModule.kt @@ -42,7 +42,7 @@ object NetworkModule { baseManager.createService( usernamePassword.first, usernamePassword.second, - prefManager.getServerConfig.getInstanceUrl(), + prefManager.getServerConfig.getInstanceUrl().dropLast(3), prefManager.getServerConfig.tenant, false, ) diff --git a/feature/auth/src/main/java/com/mifos/feature/auth/login/LoginViewModel.kt b/feature/auth/src/main/java/com/mifos/feature/auth/login/LoginViewModel.kt index cc096ca644b..6e6fa2f0787 100644 --- a/feature/auth/src/main/java/com/mifos/feature/auth/login/LoginViewModel.kt +++ b/feature/auth/src/main/java/com/mifos/feature/auth/login/LoginViewModel.kt @@ -10,6 +10,7 @@ package com.mifos.feature.auth.login import android.content.Context +import android.util.Log import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import com.mifos.core.common.utils.Network @@ -71,7 +72,7 @@ class LoginViewModel @Inject constructor( baseApiManager.createService( username, password, - prefManager.getServerConfig.getInstanceUrl(), + prefManager.getServerConfig.getInstanceUrl().dropLast(3), prefManager.getServerConfig.tenant, true, ) @@ -90,6 +91,7 @@ class LoginViewModel @Inject constructor( is Resource.Error -> { _loginUiState.value = LoginUiState.ShowError(R.string.feature_auth_error_login_failed) + Log.e("@@@", "login: ${result.message}") } is Resource.Loading -> { diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/home/HomeActivity.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/home/HomeActivity.kt index 869f920726f..d1452d6920c 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/home/HomeActivity.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/activity/home/HomeActivity.kt @@ -44,7 +44,7 @@ open class HomeActivity : ComponentActivity(), NavigationView.OnNavigationItemSe super.onCreate(savedInstanceState) binding = ActivityHomeBinding.inflate(layoutInflater) setContentView(binding.root) - setSupportActionBar(toolbar) +// setSupportActionBar(toolbar) appBarConfiguration = AppBarConfiguration.Builder() .setDrawerLayout(binding.drawer) .build() @@ -58,7 +58,7 @@ open class HomeActivity : ComponentActivity(), NavigationView.OnNavigationItemSe } else if (binding.navView.selectedItemId == R.id.navigation_dashboard) { doubleBackToExit() } - supportFragmentManager.popBackStackImmediate() +// supportFragmentManager.popBackStackImmediate() } }) } @@ -74,7 +74,7 @@ open class HomeActivity : ComponentActivity(), NavigationView.OnNavigationItemSe mDrawerLayout.closeDrawer(Gravity.LEFT); return false; }*/ - clearFragmentBackStack() +// clearFragmentBackStack() when (item.itemId) { R.id.individual_collection_sheet -> { @@ -155,23 +155,23 @@ open class HomeActivity : ComponentActivity(), NavigationView.OnNavigationItemSe binding.navigationView.setNavigationItemSelectedListener(this as NavigationView.OnNavigationItemSelectedListener) // setup drawer layout and sync to toolbar - val actionBarDrawerToggle: ActionBarDrawerToggle = object : ActionBarDrawerToggle( - this, - binding.drawer, toolbar, R.string.open_drawer, R.string.close_drawer - ) { - - override fun onDrawerOpened(drawerView: View) { - super.onDrawerOpened(drawerView) - setUserStatus(userStatusToggle) - hideKeyboard(binding.drawer) - } - - override fun onDrawerSlide(drawerView: View, slideOffset: Float) { - if (slideOffset != 0f) super.onDrawerSlide(drawerView, slideOffset) - } - } - binding.drawer.addDrawerListener(actionBarDrawerToggle) - actionBarDrawerToggle.syncState() +// val actionBarDrawerToggle: ActionBarDrawerToggle = object : ActionBarDrawerToggle( +// this, +// binding.drawer, toolbar, R.string.open_drawer, R.string.close_drawer +// ) { +// +// override fun onDrawerOpened(drawerView: View) { +// super.onDrawerOpened(drawerView) +// setUserStatus(userStatusToggle) +// hideKeyboard(binding.drawer) +// } +// +// override fun onDrawerSlide(drawerView: View, slideOffset: Float) { +// if (slideOffset != 0f) super.onDrawerSlide(drawerView, slideOffset) +// } +// } +// binding.drawer.addDrawerListener(actionBarDrawerToggle) +// actionBarDrawerToggle.syncState() // make an API call to fetch logged in client's details loadClientDetails() @@ -185,7 +185,7 @@ open class HomeActivity : ComponentActivity(), NavigationView.OnNavigationItemSe override fun onOptionsItemSelected(item: MenuItem): Boolean { if (item.itemId == R.id.logout) { - logout() +// logout() } return super.onOptionsItemSelected(item) } diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/core/MifosBaseActivity.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/core/MifosBaseActivity.kt index b19ac341bd9..a1c9e2e1c6b 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/core/MifosBaseActivity.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/core/MifosBaseActivity.kt @@ -18,6 +18,7 @@ import androidx.fragment.app.Fragment import androidx.fragment.app.FragmentManager import com.mifos.mifosxdroid.AndroidClientActivity import com.mifos.mifosxdroid.R +import com.mifos.mifosxdroid.passcode.PassCodeActivity import com.mifos.utils.Constants import com.mifos.utils.LanguageHelper import com.mifos.utils.PrefManager @@ -25,7 +26,7 @@ import com.mifos.utils.PrefManager /** * @author fomenkoo */ -open class MifosBaseActivity : BaseActivityCallback, AppCompatActivity() { +open class MifosBaseActivity : AppCompatActivity(), BaseActivityCallback { var toolbar: Toolbar? = null private var progress: ProgressDialog? = null override fun setContentView(layoutResID: Int) { diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListRepository.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListRepository.kt index e0c9448df7d..f9b62a99019 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListRepository.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListRepository.kt @@ -10,7 +10,7 @@ import rx.Observable */ interface CenterListRepository { - fun getCenters(paged: Boolean, offset: Int, limit: Int): Observable> + suspend fun getCenters(paged: Boolean, offset: Int, limit: Int): Page
suspend fun getCentersGroupAndMeeting(id: Int): CenterWithAssociations diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListRepositoryImp.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListRepositoryImp.kt index 2d757b565b1..126e8c3847e 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListRepositoryImp.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListRepositoryImp.kt @@ -13,7 +13,7 @@ import javax.inject.Inject class CenterListRepositoryImp @Inject constructor(private val dataManagerCenter: DataManagerCenter) : CenterListRepository { - override fun getCenters(paged: Boolean, offset: Int, limit: Int): Observable> { + override suspend fun getCenters(paged: Boolean, offset: Int, limit: Int): Page
{ return dataManagerCenter.getCenters(paged, offset, limit) } diff --git a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListViewModel.kt b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListViewModel.kt index fbdcc39efa9..dfd8713840d 100644 --- a/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListViewModel.kt +++ b/mifosng-android/src/main/java/com/mifos/mifosxdroid/online/centerlist/CenterListViewModel.kt @@ -74,37 +74,38 @@ class CenterListViewModel @Inject constructor(private val repository: CenterList */ private fun loadCenters(paged: Boolean, offset: Int, limit: Int) { _centerListUiState.value = CenterListUiState.ShowProgressbar(true) - repository.getCenters(paged, offset, limit) - .observeOn(AndroidSchedulers.mainThread()) - .subscribeOn(Schedulers.io()) - .subscribe(object : Subscriber>() { - override fun onCompleted() {} - override fun onError(e: Throwable) { - if (loadmore) { - _centerListUiState.value = - CenterListUiState.ShowMessage(R.string.failed_to_fetch_centers) - } else { - _centerListUiState.value = CenterListUiState.ShowFetchingError - } - } - - override fun onNext(centerPage: Page
) { - mSyncCenterList = centerPage.pageItems - if (mSyncCenterList.isEmpty() && !loadmore) { - _centerListUiState.value = - CenterListUiState.ShowEmptyCenters(R.string.center) - _centerListUiState.value = - CenterListUiState.UnregisterSwipeAndScrollListener - } else if (mSyncCenterList.isEmpty() && loadmore) { - _centerListUiState.value = - CenterListUiState.ShowMessage(R.string.no_more_centers_available) - } else { - showCenters(mSyncCenterList) - mRestApiCenterSyncStatus = true - setAlreadyCenterSyncStatus() - } - } - }) +// val response = repository.getCenters() +// repository.getCenters(paged, offset, limit) +// .observeOn(AndroidSchedulers.mainThread()) +// .subscribeOn(Schedulers.io()) +// .subscribe(object : Subscriber>() { +// override fun onCompleted() {} +// override fun onError(e: Throwable) { +// if (loadmore) { +// _centerListUiState.value = +// CenterListUiState.ShowMessage(R.string.failed_to_fetch_centers) +// } else { +// _centerListUiState.value = CenterListUiState.ShowFetchingError +// } +// } +// +// override fun onNext(centerPage: Page
) { +// mSyncCenterList = centerPage.pageItems +// if (mSyncCenterList.isEmpty() && !loadmore) { +// _centerListUiState.value = +// CenterListUiState.ShowEmptyCenters(R.string.center) +// _centerListUiState.value = +// CenterListUiState.UnregisterSwipeAndScrollListener +// } else if (mSyncCenterList.isEmpty() && loadmore) { +// _centerListUiState.value = +// CenterListUiState.ShowMessage(R.string.no_more_centers_available) +// } else { +// showCenters(mSyncCenterList) +// mRestApiCenterSyncStatus = true +// setAlreadyCenterSyncStatus() +// } +// } +// }) } fun loadCentersGroupAndMeeting(id: Int) = viewModelScope.launch(Dispatchers.IO) { diff --git a/mifosng-android/src/main/java/com/mifos/utils/PrefManager.kt b/mifosng-android/src/main/java/com/mifos/utils/PrefManager.kt index c573d8edb2f..b5d904355d1 100644 --- a/mifosng-android/src/main/java/com/mifos/utils/PrefManager.kt +++ b/mifosng-android/src/main/java/com/mifos/utils/PrefManager.kt @@ -4,9 +4,9 @@ import android.content.SharedPreferences import android.preference.PreferenceManager import com.mifos.application.App import com.mifos.core.objects.user.User -import org.apache.fineract.client.models.PostAuthenticationResponse import org.mifos.core.sharedpreference.Key import org.mifos.core.sharedpreference.UserPreferences +import org.openapitools.client.models.PostAuthenticationResponse /** * Created by Aditya Gupta on 19/08/23. @@ -18,7 +18,8 @@ object PrefManager : UserPreferences() { private const val AUTH_USERNAME = "auth_username" private const val AUTH_PASSWORD = "auth_password" - override val preference: SharedPreferences = PreferenceManager.getDefaultSharedPreferences(App.instance?.applicationContext) + override val preference: SharedPreferences = + PreferenceManager.getDefaultSharedPreferences(App.instance?.applicationContext) override fun getUser(): User { return get(Key.Custom(USER_DETAILS))