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

Mvvm/login #3

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Mvvm/login #3

wants to merge 11 commits into from

Conversation

iamsannyrai
Copy link
Contributor

I have tried to apply koin. Please go through it once

@iamsannyrai iamsannyrai requested a review from khadkarajesh July 16, 2019 04:56
@iamsannyrai iamsannyrai self-assigned this Jul 16, 2019
Copy link

@khadkarajesh khadkarajesh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion

  • Don't repeat the same mistakes
  • Review pull request by yourself before asking for a review
  • Format code properly
  • Read about clean code

): Response<BaseResponse<User>>

companion object {
operator fun invoke(networkConnectionInterceptor: NetworkConnectionInterceptor): LmsApi {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamsannyrai we have decided to create network module isn't it?

import retrofit2.Response

class UserRepository(private val lmsApi: LmsApi) {
suspend fun userLogin(username: String, password: String): Response<BaseResponse<User>> {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamsannyrai create wrapper to unwrap data rather than doing Response<BaseResponse<User>> .

authListener!!.onStarted()
when {
username.isNullOrEmpty() -> {
authListener?.onFailure(0, "Username is Empty")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamsannyrai what is zero and one. Don't use these kinds of ambiguous constants. Give a proper name for constants .

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was code to be sent in order to distinguish whether username field or password field was empty. However i have tried to give proper name now.


import com.incwelltechnology.lms.data.model.User

interface AuthListener {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamsannyrai do we need interface we have discussed to use LiveData to communicate with the view rather than interface.

else -> {
//when credential fields are not empty or null
Coroutine.main {
try {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamsannyrai is this aware of the activity life cycle? Because it may crash app once we make a network request and pressed back to the previous activity instantly. Hint: a ViewModel Scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it doesn't crash and since it is in viewmodel itself, it must be aware of activity lifecycle.

}
} catch (e: NoInternetException) {
withContext(Dispatchers.Main){
authListener?.onFailure(2, e.message!!)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamsannyrai we don't need to withContext if we use liveData to communicate

}
}

//function to translate layout from down to up

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamsannyrai name function in such a way that we don't need to write comments for further explanation.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamsannyrai proper name may be translateUp()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamsannyrai we can use animation in theme as well to make consistent over the whole application. Think about that as well. Make animation consistent for push and pop of activity if you want to keep it in theme.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this animation function is only for login page. Anyway i will think of your suggestion.

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_dashboard)
val toolbar: Toolbar = findViewById(R.id.toolbar)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamsannyrai do we need findViewById to reference element?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamsannyrai do we need findViewById to reference element?

No we don't need to. This activity was just created and left untouched. I haven't worked upon this activity :)

setSupportActionBar(toolbar)

val fab: FloatingActionButton = findViewById(R.id.fab)
fab.setOnClickListener { view ->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@iamsannyrai we are not doing anything there except a snack bar. Keep the codes only required to complete user stories otherwise, it will create confusion for a reviewer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok :)

@khadkarajesh khadkarajesh added the enhancement New feature or request label Jul 18, 2019
@khadkarajesh khadkarajesh added this to the 1.0 milestone Jul 18, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants