Gavin Ray
03/11/2020, 5:07 PMMikael Alfredsson
03/11/2020, 5:09 PMMikael Alfredsson
03/11/2020, 5:10 PMGavin Ray
03/11/2020, 5:11 PMGavin Ray
03/11/2020, 5:11 PMMikael Alfredsson
03/11/2020, 5:13 PMGavin Ray
03/11/2020, 5:14 PMMikael Alfredsson
03/11/2020, 5:15 PMjoinGameButton() function live? (in which class)Gavin Ray
03/11/2020, 5:16 PMGameFragment though. I tried making it public, doing val gameFragment = GameFragment.newInstance() inside of DetailFragment and then gameFragment.joinGamePopup() but it breaks because of Dialog(context) inside of the joinGamePopup() method in GameFragmentGavin Ray
03/11/2020, 5:16 PMwhere does theGameFragmentfunction live? (in which class)joinGameButton()
Mikael Alfredsson
03/11/2020, 5:17 PMMikael Alfredsson
03/11/2020, 5:18 PMMikael Alfredsson
03/11/2020, 5:19 PMnullGavin Ray
03/11/2020, 5:19 PMJoinGameModel, which has some information about the game the player is trying to join, and position, which after several hours I figured out is a magic variable that gets passed into fragments denoting their index.
I was able to recreate the JoinGameModel instance because it gets gameData from the parent fragment (GameFragment), and I tried hardcoding `0`/`1` as the position to try to trigger it on the first or second fragment.Mikael Alfredsson
03/11/2020, 5:21 PMGavin Ray
03/11/2020, 5:21 PMDialog(context) is where most of the stuff happens in that method. This seems to create the pop-up window and populate it with info.
So assuming I can have the right context value in there, it should work right?Gavin Ray
03/11/2020, 5:21 PMcontextGavin Ray
03/11/2020, 5:21 PMclass GamesFragment: Fragment(), SwipeRefreshLayout.OnRefreshListener{
var context: MainActivity? = nullGavin Ray
03/11/2020, 5:21 PMprivate fun joinGamePopup(gameJoin: JoinGameModel,position:Int) {
val dialog = Dialog(context)Gavin Ray
03/11/2020, 5:23 PM2020-03-11 13:22:50.418 26091-26091/com.plei.dev E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.plei.dev, PID: 26091
java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources$Theme android.content.Context.getTheme()' on a null object reference
at android.app.Dialog.<init>(Dialog.java:175)
at android.app.Dialog.<init>(Dialog.java:149)
at com.plei.screens.games.fragment.GamesFragment.joinGamePopup(GamesFragment.kt:246)
at com.plei.screens.games.fragment.DetailFragment$_initialize$1.onClick(DetailFragment.kt:92)Mikael Alfredsson
03/11/2020, 5:23 PMMikael Alfredsson
03/11/2020, 5:24 PMjoinGamePopup(context:Context, gameJoin: JoinGameModel,position:Int)Gavin Ray
03/11/2020, 5:24 PMGameFragment into the DetailFragment function here to pass into context?Mikael Alfredsson
03/11/2020, 5:25 PMMikael Alfredsson
03/11/2020, 5:26 PMMikael Alfredsson
03/11/2020, 5:27 PMGavin Ray
03/11/2020, 5:28 PMcontext as an argument but moving it to a separate class may very well be out of the scope of my abilities with 48 hours of Android/Kotlin experience.Mikael Alfredsson
03/11/2020, 5:28 PMMikael Alfredsson
03/11/2020, 5:29 PMGamePopup or somethingMikael Alfredsson
03/11/2020, 5:29 PMMikael Alfredsson
03/11/2020, 5:30 PMGavin Ray
03/11/2020, 5:30 PMMikael Alfredsson
03/11/2020, 5:31 PMGavin Ray
03/11/2020, 5:31 PMcontext is a type-mismatch?Gavin Ray
03/11/2020, 5:31 PMbut that will be really uglyThis whole codebase is... shudder
Mikael Alfredsson
03/11/2020, 5:32 PMGavin Ray
03/11/2020, 5:32 PMMikael Alfredsson
03/11/2020, 5:33 PMcontext with requireContext (runtime you will get the same exception. but the IDE might be happier)Mikael Alfredsson
03/11/2020, 5:33 PMcontext!Gavin Ray
03/11/2020, 5:34 PMvar context: MainActivity?Gavin Ray
03/11/2020, 5:34 PMMainActivity? with context!?Mikael Alfredsson
03/11/2020, 5:34 PMMikael Alfredsson
03/11/2020, 5:35 PMGavin Ray
03/11/2020, 5:35 PMGavin Ray
03/11/2020, 5:36 PMMikael Alfredsson
03/11/2020, 5:37 PMGavin Ray
03/11/2020, 5:38 PMjoinGamePopup and refactor it to a new class?Mikael Alfredsson
03/11/2020, 5:39 PMGavin Ray
03/11/2020, 5:40 PMGavin Ray
03/11/2020, 5:40 PMMikael Alfredsson
03/11/2020, 5:40 PMGavin Ray
03/11/2020, 5:41 PMGavin Ray
03/11/2020, 5:41 PMpackage com.plei.screens.games.fragment
import androidx.fragment.app.Fragment
import com.plei.models.JoinGameModel
open class GamesFragment1 : Fragment() {
fun joinGamePopup(gameJoin: JoinGameModel, position: Int) {Mikael Alfredsson
03/11/2020, 5:42 PMMikael Alfredsson
03/11/2020, 5:42 PMclass GamePopup {
fun joinGamePopup(gameJoin: JoinGameModel, position: Int) {Gavin Ray
03/11/2020, 5:42 PMGavin Ray
03/11/2020, 5:43 PMMikael Alfredsson
03/11/2020, 5:43 PMGavin Ray
03/11/2020, 5:44 PMGavin Ray
03/11/2020, 5:44 PMGamePopup.kt anywhere and paste that method in thereGavin Ray
03/11/2020, 5:44 PMscreens/games/fragment?Mikael Alfredsson
03/11/2020, 5:44 PMGavin Ray
03/11/2020, 5:44 PMGavin Ray
03/11/2020, 5:45 PMMikael Alfredsson
03/11/2020, 5:46 PMval gamePopup = GamePopup()Mikael Alfredsson
03/11/2020, 5:46 PMGavin Ray
03/11/2020, 5:46 PMGavin Ray
03/11/2020, 5:47 PMMikael Alfredsson
03/11/2020, 5:47 PMGavin Ray
03/11/2020, 5:47 PMMikael Alfredsson
03/11/2020, 5:47 PMMikael Alfredsson
03/11/2020, 5:47 PMGavin Ray
03/11/2020, 5:49 PMUnresolved reference: paymentProcessPopup
Unresolved reference: Intent
Unresolved reference: startActivity
Unresolved reference: R
Unresolved reference: PaymentActivity
Unresolved reference: isPaymentAdded
Unresolved reference: joinGame
Unresolved reference: positiveButton
Unresolved reference: getButton
Unresolved reference: sharedPreference
Unresolved reference: AlertDialog
Unresolved reference: setBackgroundDrawable
Unresolved reference: Dialog
Unresolved reference: WindowManagerChristophe Smet
03/12/2020, 9:21 AMGavin Ray
03/12/2020, 5:01 PMChristophe Smet
03/12/2020, 7:05 PM