Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Kamila/add fragment viewmodel #348

Merged
merged 12 commits into from
May 26, 2022
Merged

Conversation

kamilababayeva
Copy link
Collaborator

@kamilababayeva kamilababayeva commented May 25, 2022

Add view model to store view and context in fragment

@kamilababayeva kamilababayeva self-assigned this May 25, 2022
}

private fun setGenreListeners(){
vmGameSetup.view.findViewById<Button>(R.id.kpopButton).setOnClickListener { chooseGenre(method = LastfmMethod.BY_TAG.method, tag = "kpop", mode = R.string.kpop) }
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 5 locations. Consider refactoring.


private fun setGenreListeners(){
vmGameSetup.view.findViewById<Button>(R.id.kpopButton).setOnClickListener { chooseGenre(method = LastfmMethod.BY_TAG.method, tag = "kpop", mode = R.string.kpop) }
vmGameSetup.view.findViewById<Button>(R.id.rockButton).setOnClickListener { chooseGenre(method = LastfmMethod.BY_TAG.method, tag = "rock", mode = R.string.rock) }
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 5 locations. Consider refactoring.

private fun setGenreListeners(){
vmGameSetup.view.findViewById<Button>(R.id.kpopButton).setOnClickListener { chooseGenre(method = LastfmMethod.BY_TAG.method, tag = "kpop", mode = R.string.kpop) }
vmGameSetup.view.findViewById<Button>(R.id.rockButton).setOnClickListener { chooseGenre(method = LastfmMethod.BY_TAG.method, tag = "rock", mode = R.string.rock) }
vmGameSetup.view.findViewById<Button>(R.id.btsButton).setOnClickListener { chooseGenre(method = LastfmMethod.BY_ARTIST.method, artist = "BTS", mode = R.string.gameGenre_bts) }
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 5 locations. Consider refactoring.

vmGameSetup.view.findViewById<Button>(R.id.rockButton).setOnClickListener { chooseGenre(method = LastfmMethod.BY_TAG.method, tag = "rock", mode = R.string.rock) }
vmGameSetup.view.findViewById<Button>(R.id.btsButton).setOnClickListener { chooseGenre(method = LastfmMethod.BY_ARTIST.method, artist = "BTS", mode = R.string.gameGenre_bts) }
vmGameSetup.view.findViewById<Button>(R.id.topTracksButton).setOnClickListener { chooseGenre(method = LastfmMethod.BY_CHART.method, mode = R.string.top_tracks) }
vmGameSetup.view.findViewById<Button>(R.id.imagDragonsButton).setOnClickListener{ chooseGenre(method = LastfmMethod.BY_ARTIST.method, artist = "Imagine Dragons", mode = R.string.gameGenre_imagine_dragons) }
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 5 locations. Consider refactoring.

vmGameSetup.view.findViewById<Button>(R.id.btsButton).setOnClickListener { chooseGenre(method = LastfmMethod.BY_ARTIST.method, artist = "BTS", mode = R.string.gameGenre_bts) }
vmGameSetup.view.findViewById<Button>(R.id.topTracksButton).setOnClickListener { chooseGenre(method = LastfmMethod.BY_CHART.method, mode = R.string.top_tracks) }
vmGameSetup.view.findViewById<Button>(R.id.imagDragonsButton).setOnClickListener{ chooseGenre(method = LastfmMethod.BY_ARTIST.method, artist = "Imagine Dragons", mode = R.string.gameGenre_imagine_dragons) }
vmGameSetup.view.findViewById<Button>(R.id.billieEilishButton).setOnClickListener { chooseGenre(method = LastfmMethod.BY_ARTIST.method, artist = "Billie Eilish", mode = R.string.gameGenre_billie_eilish) }
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 5 locations. Consider refactoring.

@MaximeZmt MaximeZmt self-requested a review May 25, 2022 22:02
Copy link
Owner

@MaximeZmt MaximeZmt left a comment

Choose a reason for hiding this comment

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

LGTM 👍 Great Job ! Hope it will improve stability!
There is one minor typo that you can correct and two refactor that you may do if you have some time.

Copy link
Collaborator

@Tsathogguaa Tsathogguaa left a comment

Choose a reason for hiding this comment

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

Good work overall! Just the intentSwitcher stuff that can be changed around, but it's not as severe to complete ASAP. If you have time, would be great to adapt them!

vmScoreBoard.view = view
vmScoreBoard.ctx = view.context

view.findViewById<Button>(R.id.scoreboard_kpopButton).setOnClickListener { setGenreListeners("Kpop") }
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 6 locations. Consider refactoring.

vmScoreBoard.ctx = view.context

view.findViewById<Button>(R.id.scoreboard_kpopButton).setOnClickListener { setGenreListeners("Kpop") }
view.findViewById<Button>(R.id.scoreboard_rockButton).setOnClickListener {setGenreListeners("Rock") }
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 6 locations. Consider refactoring.


view.findViewById<Button>(R.id.scoreboard_kpopButton).setOnClickListener { setGenreListeners("Kpop") }
view.findViewById<Button>(R.id.scoreboard_rockButton).setOnClickListener {setGenreListeners("Rock") }
view.findViewById<Button>(R.id.scoreboard_btsButton).setOnClickListener { setGenreListeners("BTS") }
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 6 locations. Consider refactoring.

view.findViewById<Button>(R.id.scoreboard_kpopButton).setOnClickListener { setGenreListeners("Kpop") }
view.findViewById<Button>(R.id.scoreboard_rockButton).setOnClickListener {setGenreListeners("Rock") }
view.findViewById<Button>(R.id.scoreboard_btsButton).setOnClickListener { setGenreListeners("BTS") }
view.findViewById<Button>(R.id.scoreboard_topTracksButton).setOnClickListener{ setGenreListeners("top tracks") }
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 6 locations. Consider refactoring.

view.findViewById<Button>(R.id.scoreboard_rockButton).setOnClickListener {setGenreListeners("Rock") }
view.findViewById<Button>(R.id.scoreboard_btsButton).setOnClickListener { setGenreListeners("BTS") }
view.findViewById<Button>(R.id.scoreboard_topTracksButton).setOnClickListener{ setGenreListeners("top tracks") }
view.findViewById<Button>(R.id.scoreboard_imagDragonsButton).setOnClickListener{ setGenreListeners("Imagine Dragons") }
Copy link

Choose a reason for hiding this comment

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

Similar blocks of code found in 6 locations. Consider refactoring.

@codeclimate
Copy link

codeclimate bot commented May 26, 2022

Code Climate has analyzed commit cb3b150 and detected 18 issues on this pull request.

Here's the issue category breakdown:

Category Count
Duplication 18

The test coverage on the diff in this pull request is 98.9% (80% is the threshold).

This pull request will bring the total coverage in the repository to 85.2% (0.7% change).

View more on Code Climate.

@kamilababayeva kamilababayeva merged commit 4e7d888 into main May 26, 2022
@kamilababayeva kamilababayeva deleted the kamila/add_fragment_viewmodel branch May 26, 2022 08:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants