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

Commit

Permalink
Merge pull request #375 from MaximeZmt/maximezmt/bugfix2
Browse files Browse the repository at this point in the history
bugfix
  • Loading branch information
MaximeZmt authored Jun 9, 2022
2 parents 8943952 + 8184461 commit f40ce3d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
12 changes: 9 additions & 3 deletions app/src/main/java/ch/sdp/vibester/fragment/GameSetupFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import dagger.hilt.android.AndroidEntryPoint
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
import java.io.File

/**
* Game Setup fragment with a button in the bottom navigation.
Expand Down Expand Up @@ -91,7 +92,14 @@ class GameSetupFragment : Fragment(R.layout.fragment_layout_game_setup), Adapter
val imagDragons = vmGameSetup.view.findViewById<Button>(R.id.imagDragonsButton)
val billieEilish = vmGameSetup.view.findViewById<Button>(R.id.billieEilishButton)
val validateSearch = vmGameSetup.view.findViewById<Button>(R.id.validateSearch)
offline.setOnClickListener { chooseGame("local_buzzer", GameManager(), true) }

val records = File(requireContext().getExternalFilesDir(Environment.DIRECTORY_DOWNLOADS), "records.txt")

if (!records.exists() || records.length() == 0L) {
offline.setOnClickListener { Toast.makeText(it.context, "You don't have any downloaded song", Toast.LENGTH_SHORT).show() }
}else{
offline.setOnClickListener { chooseGame("local_buzzer", GameManager(), true) }
}
kpop.setOnClickListener { chooseGenreByTag("kpop", R.string.kpop) }
rock.setOnClickListener { chooseGenreByTag("rock", R.string.rock) }
bts.setOnClickListener { chooseGenreByArtist("BTS", R.string.gameGenre_bts) }
Expand Down Expand Up @@ -258,7 +266,6 @@ class GameSetupFragment : Fragment(R.layout.fragment_layout_game_setup), Adapter
* @param mode: official game mode name
*/
private fun chooseGenre(method: String = "", artist: String = "", tag: String = "", mode: Int = 0, playOffline: Boolean = false) {
if (artist != "") {
val uri = LastfmUri()

uri.method = method
Expand All @@ -278,7 +285,6 @@ class GameSetupFragment : Fragment(R.layout.fragment_layout_game_setup), Adapter
gameManager.gameMode = getString(mode)
AppPreferences.setStr(getString(R.string.preferences_game_genre), getString(mode))
setGameSongList(uri, playOffline)
}
}


Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_download.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:backgroundTint="@color/floral_white"
tools:context=".activity.download.DownloadActivity">

<com.google.android.material.floatingactionbutton.FloatingActionButton
Expand Down

0 comments on commit f40ce3d

Please sign in to comment.