Skip to content

Conversation

@liveHarshit
Copy link
Member

Fixes #644

Changes: Set search fragment without the saved state.

@liveHarshit
Copy link
Member Author

@iamareebjamal Please review it.

private fun checkAndLoadFragment(fragment: Fragment) {
val savedFragment = supportFragmentManager.findFragmentByTag(fragment::class.java.name)
if (savedFragment != null) {
if (savedFragment != null && fragment !is SearchFragment) {
Copy link
Member

Choose a reason for hiding this comment

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

This is not a fix. This is a workaround

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not a fix. This is a workaround

But as in Eventbright everytime open search section, it opens with a new fragment so, I think no saved state is required for search fragment. That's why I direct load with new fragment if the search fragment is open. Should I fix this issue in another 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, the special case should be handled in a generic way while opening search fragment, not a special case in a method which should not even know about the existence of search fragment

@liveHarshit
Copy link
Member Author

@iamareebjamal Updated.

@trancenoid
Copy link
Member

Are you still working on it ? @liveHarshit I will be happy to solve this issue

@liveHarshit
Copy link
Member Author

Are you still working on it? @liveHarshit I will be happy to solve this issue

Yes.

@simarsingh24
Copy link
Member

@liveHarshit please finish this!

@liveHarshit
Copy link
Member Author

Updated. Now I check the saved state for search fragment. If yes, then hide the search layout for no overlapping with saved data.
Please review.

@iamareebjamal
Copy link
Member

No changes in Activity are needed. Only changes should be in the fragment as it is the buggy component. Use fragment lifecycles or ViewModel to fix the bug

@liveHarshit
Copy link
Member Author

Updated.

private lateinit var rootView: View
private var loadEventsAgain = false
private lateinit var searchView: SearchView
private var isSearched = false
Copy link
Member

Choose a reason for hiding this comment

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

Remove this variable from here, react to changes from viewmodel only

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated

})

searchViewModel.isSearched.observe(this, Observer {
showSearchLayout(false)
Copy link
Member

Choose a reason for hiding this comment

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

This is always sending false, it should send the value received from the LiveData instead

searchViewModel.searchEvent = query
rootView.searchLinearLayout.visibility = View.GONE
rootView.fabSearch.visibility = View.GONE
showSearchLayout(false)
Copy link
Member

Choose a reason for hiding this comment

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

No explicit calls from view, all calls should be from ViewModel

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated.

@iamareebjamal
Copy link
Member

I request you to look at the first solution you submitted and this one and realize which one was elegant and maintainable. 😄 Good work

@iamareebjamal iamareebjamal merged commit 8da62a2 into fossasia:development Dec 8, 2018
@liveHarshit liveHarshit deleted the issue644 branch December 8, 2018 14:06
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.

4 participants