diff --git a/app/src/main/java/ch/sdp/vibester/fragment/GameSetupFragment.kt b/app/src/main/java/ch/sdp/vibester/fragment/GameSetupFragment.kt index 1f2604143..bd960c4ad 100644 --- a/app/src/main/java/ch/sdp/vibester/fragment/GameSetupFragment.kt +++ b/app/src/main/java/ch/sdp/vibester/fragment/GameSetupFragment.kt @@ -1,16 +1,12 @@ package ch.sdp.vibester.fragment -import android.content.Context import android.content.Intent import android.os.Bundle import android.os.Environment import android.text.Editable -import android.util.Log -import android.view.LayoutInflater import android.view.View import android.view.View.GONE import android.view.View.VISIBLE -import android.view.ViewGroup import android.widget.* import androidx.appcompat.app.AppCompatActivity import androidx.constraintlayout.widget.ConstraintLayout @@ -26,6 +22,7 @@ import ch.sdp.vibester.api.LastfmMethod import ch.sdp.vibester.api.LastfmUri import ch.sdp.vibester.database.AppPreferences import ch.sdp.vibester.helper.GameManager +import ch.sdp.vibester.helper.ViewModel import com.google.android.material.floatingactionbutton.FloatingActionButton import com.google.gson.Gson import dagger.hilt.android.AndroidEntryPoint @@ -37,7 +34,7 @@ import retrofit2.Response * Game Setup fragment with a button in the bottom navigation. */ @AndroidEntryPoint -class GameSetupFragment : Fragment(), View.OnClickListener, AdapterView.OnItemSelectedListener { +class GameSetupFragment : Fragment(R.layout.fragment_layout_game_setup), AdapterView.OnItemSelectedListener { var difficulty = R.string.GameSetup_easy.toString() var game = "local_buzzer" var gameSize = R.string.one.toString() @@ -45,70 +42,77 @@ class GameSetupFragment : Fragment(), View.OnClickListener, AdapterView.OnItemSe lateinit var gameManager: GameManager // TODO: OFFLINE private var hasInternet: Boolean = true - var viewfrag: View? = null - - override fun onCreateView( - inflater: LayoutInflater, container: ViewGroup?, - savedInstanceState: Bundle? - ): View? { - viewfrag = inflater.inflate(R.layout.fragment_game_setup, container, false) - return viewfrag!!.rootView - } + private var vmGameSetup = ViewModel() override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - val ctx = view.context - - view.findViewById