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

Commit

Permalink
Scoreboard fragment: fix the layout
Browse files Browse the repository at this point in the history
  • Loading branch information
kamilababayeva committed May 20, 2022
1 parent eac0181 commit 147126b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
24 changes: 13 additions & 11 deletions app/src/main/java/ch/sdp/vibester/fragment/ScoreBoardFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import android.view.View.VISIBLE
import android.view.ViewGroup
import android.widget.Button
import android.widget.LinearLayout
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.core.widget.NestedScrollView
import androidx.fragment.app.Fragment
import androidx.recyclerview.widget.LinearLayoutManager
Expand Down Expand Up @@ -53,11 +54,11 @@ class ScoreBoardFragment : Fragment(), OnItemClickListener, View.OnClickListener
return view
}

private fun selectScoreboard(view:View) {
private fun selectScoreboard() {
val sortedBy = "scores/" + genre

view.findViewById<LinearLayout>(R.id.genrePerScoreboard).visibility = GONE
view.findViewById<NestedScrollView>(R.id.scoreboard_content_scrolling).visibility = VISIBLE
requireView().findViewById<ConstraintLayout>(R.id.genrePerScoreboard).visibility = GONE
requireView().findViewById<NestedScrollView>(R.id.scoreboard_content_scrolling).visibility = VISIBLE

loadPlayersSortedBy(sortedBy)
}
Expand Down Expand Up @@ -102,7 +103,7 @@ class ScoreBoardFragment : Fragment(), OnItemClickListener, View.OnClickListener

private fun showPlayersPosition(players: MutableList<User>?) {
userScoreboardAdapter = UserScoreboardAdapter(players!!, genre, this)
view?.findViewById<RecyclerView>(R.id.recycler_view)!!.adapter = userScoreboardAdapter
requireView().findViewById<RecyclerView>(R.id.recycler_view)!!.adapter = userScoreboardAdapter
}

/**
Expand All @@ -119,24 +120,25 @@ class ScoreBoardFragment : Fragment(), OnItemClickListener, View.OnClickListener
override fun onClick(v: View?) {
when(v!!.getId()) {
R.id.btsButton -> {
genre = "BTS"
genre = "BTS"; selectScoreboard()
}
R.id.kpopButton -> {
genre = "kpop"
genre = "kpop"; selectScoreboard()
}
R.id.imagDragonsButton -> {
genre = "Imagine Dragons"
genre = "Imagine Dragons"; selectScoreboard()
}
R.id.billieEilishButton -> {
genre = "Billie Eilish"
genre = "Billie Eilish"; selectScoreboard()
}
R.id.rockButton -> {
genre = "rock"
genre = "rock";selectScoreboard()
}
R.id.topTracksButton -> {
genre = "top tracks"
genre = "top tracks";selectScoreboard()
}

}
selectScoreboard(v)

}
}
4 changes: 2 additions & 2 deletions app/src/main/res/layout/genre_for_scoreboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/genrePerScoreboard"
android:visibility="visible"
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:id="@+id/genrePerScoreboard"
android:layout_width="0dp"
android:layout_height="0dp"
android:orientation="vertical"
android:visibility="visible"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down

0 comments on commit 147126b

Please sign in to comment.