Skip to content

Conversation

@nikit19
Copy link
Member

@nikit19 nikit19 commented Jun 20, 2018

fixes #159
Now events can be loaded automatically when the user opens the app
ezgif com-video-to-gif 8

private val eventsViewModel by viewModel<EventsViewModel>()
private lateinit var rootView: View
private val preference: Preference = Preference()
private val tokenKey = "LOCATION"
Copy link
Member

Choose a reason for hiding this comment

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

There's a reason to use MVVM. Please don't add logic in Views

@nikit19
Copy link
Member Author

nikit19 commented Jun 21, 2018

@iamareebjamal moved entire preference logic to ViewModel.
Please review

private val eventsRecyclerAdapter: EventsRecyclerAdapter = EventsRecyclerAdapter()
private val eventsViewModel by viewModel<EventsViewModel>()
private lateinit var rootView: View
private val preference: Preference = Preference()
Copy link
Member

Choose a reason for hiding this comment

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

No logic in fragment

Copy link
Member Author

@nikit19 nikit19 Jun 21, 2018

Choose a reason for hiding this comment

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

@iamareebjamal I moved the logic to viewmodel in this commit 0636e28
but the tests were failing so I reverted.
Was it the correct way?

Copy link
Member

Choose a reason for hiding this comment

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

Yes

@nikit19
Copy link
Member Author

nikit19 commented Jun 22, 2018

@iamareebjamal I tried to fix the failing dependency test but I wasn't able
org.koin.error.BeanInstanceCreationException: Can't create bean Factory[class=org.fossasia.openevent.general.event.EventsViewModel, binds~(android.arch.lifecycle.ViewModel)] due to error : java.lang.NullPointerException

Could you please help

val error = MutableLiveData<String>()

var locationName: String? = null
var locationName: String? = preference.getString(tokenKey)
Copy link
Member

Choose a reason for hiding this comment

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

Make this lazy, it'll work

var locationName: String? = null
var locationName: String? = preference.getString(tokenKey)

fun loadLocationEvents() {
Copy link
Member

Choose a reason for hiding this comment

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

Why not take the location name as parameter

@nikit19
Copy link
Member Author

nikit19 commented Jun 22, 2018

@iamareebjamal Did all the requested changes please review

class EventsViewModel(private val eventService: EventService, private val preference: Preference) : ViewModel() {

private val compositeDisposable = CompositeDisposable()
val tokenKey = "LOCATION"
Copy link
Member

Choose a reason for hiding this comment

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

private val

Copy link
Member

@iamareebjamal iamareebjamal left a comment

Choose a reason for hiding this comment

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

RC

@nikit19
Copy link
Member Author

nikit19 commented Jun 22, 2018

PR updated, please review

@iamareebjamal iamareebjamal merged commit e1bbe7e into fossasia:development Jun 22, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Save location name in Home Screen

2 participants