Skip to content

Commit

Permalink
feat: Fixed build fail
Browse files Browse the repository at this point in the history
  • Loading branch information
Aditya-gupta99 committed Dec 15, 2024
1 parent a517d06 commit af22111
Show file tree
Hide file tree
Showing 8 changed files with 64 additions and 59 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ object NetworkModule {
baseManager.createService(
usernamePassword.first,
usernamePassword.second,
prefManager.getServerConfig.getInstanceUrl(),
prefManager.getServerConfig.getInstanceUrl().dropLast(3),
prefManager.getServerConfig.tenant,
false,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -71,7 +72,7 @@ class LoginViewModel @Inject constructor(
baseApiManager.createService(
username,
password,
prefManager.getServerConfig.getInstanceUrl(),
prefManager.getServerConfig.getInstanceUrl().dropLast(3),
prefManager.getServerConfig.tenant,
true,
)
Expand All @@ -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 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -58,7 +58,7 @@ open class HomeActivity : ComponentActivity(), NavigationView.OnNavigationItemSe
} else if (binding.navView.selectedItemId == R.id.navigation_dashboard) {
doubleBackToExit()
}
supportFragmentManager.popBackStackImmediate()
// supportFragmentManager.popBackStackImmediate()
}
})
}
Expand All @@ -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 -> {
Expand Down Expand Up @@ -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()
Expand All @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@ 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

/**
* @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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import rx.Observable
*/
interface CenterListRepository {

fun getCenters(paged: Boolean, offset: Int, limit: Int): Observable<Page<Center>>
suspend fun getCenters(paged: Boolean, offset: Int, limit: Int): Page<Center>

suspend fun getCentersGroupAndMeeting(id: Int): CenterWithAssociations

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Page<Center>> {
override suspend fun getCenters(paged: Boolean, offset: Int, limit: Int): Page<Center> {
return dataManagerCenter.getCenters(paged, offset, limit)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Page<Center>>() {
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<Center>) {
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<Page<Center>>() {
// 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<Center>) {
// 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) {
Expand Down
5 changes: 3 additions & 2 deletions mifosng-android/src/main/java/com/mifos/utils/PrefManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -18,7 +18,8 @@ object PrefManager : UserPreferences<User>() {
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))
Expand Down

0 comments on commit af22111

Please sign in to comment.