Class ProfileController

    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.util.UUID deviceUUID
      Device UUID of the profile
      protected com.google.android.material.floatingactionbutton.FloatingActionButton followButton
      This is the follow button
      protected android.widget.TextView followersText
      This is the text that displays how many followers the user has
      protected android.widget.TextView followingText
      This is the text that displays how many users the player is following
      protected com.google.android.material.floatingactionbutton.FloatingActionButton followLoadingButton  
      protected ProfileFragment fragment
      This is the profile fragment the controller handles
      protected GameController gameController
      This is the game controller that controls the content on screen.
      protected android.widget.Spinner orderSpinner
      This is the spinner that determines the qr code display order
      protected QRCodeAdapter qrCodeAdapter
      This is the adapter for displaying the QRCode objects
      protected android.widget.GridView qrCodeList
      This is the gridview showing the qr codes of the player
      protected java.util.ArrayList<QRCode> qrCodes
      This is the array of QRCode objects that the fragment displays
      protected android.widget.TextView topScore
      This is the view showing the top score of the player's qr codes
      protected android.widget.TextView totalCodes
      This is the view showing the total number of codes the player has
      protected android.widget.TextView totalPoints
      This is the view that shows the qr codes of the player
      protected com.google.android.material.floatingactionbutton.FloatingActionButton unfollowButton  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      Modifier and Type Method Description
      void addUpdater()
      This sets up the listener for real-time database changes
      long getTopScore()
      This computes the top score of the qr codes
      int getTotalScore()
      This computes the sum of code scores
      abstract void handleContactButtonClick()
      This handles the action to take when the contact info button is clicked.
      android.widget.AdapterView.OnItemClickListener handleQRSelect()
      This is the onclicklistener for qr codes displayed in the profile
      android.widget.AdapterView.OnItemSelectedListener handleSpinnerSelect​(android.widget.Spinner orderSpinner)
      This creates a custom OnItemSelectedListener for the given spinner
      void onChange()
      This refreshes the profile upon database change
      void onRankingButtonClick()
      Calculates and renders a fragment on screen to display the percentiles of the player
      void setupFollowDetails​(android.widget.TextView followingText, android.widget.TextView followersText, com.google.android.material.floatingactionbutton.FloatingActionButton followButton, com.google.android.material.floatingactionbutton.FloatingActionButton unfollowButton, com.google.android.material.floatingactionbutton.FloatingActionButton followLoadingButton)
      Sets up the follow buttons and t ext
      void setUpQRList​(android.widget.GridView qrCodeList, android.widget.TextView totalPoints, android.widget.TextView totalCodes, android.widget.TextView topScore, android.widget.Spinner orderSpinner)
      Sets up the list view of qr codes
      void setUpUsernameAndPicture​(android.widget.TextView usernameView, android.widget.ImageView profilePic)
      This sets up the username view and profile pic view of the fragment
      protected void showMsg​(java.lang.String msg)
      This displays a Toast message
      protected abstract void updateFollowDetails()
      Updates the text and following/followers count of the follow related content in the view.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • gameController

        protected final GameController gameController
        This is the game controller that controls the content on screen.
      • fragment

        protected final ProfileFragment fragment
        This is the profile fragment the controller handles
      • qrCodes

        protected java.util.ArrayList<QRCode> qrCodes
        This is the array of QRCode objects that the fragment displays
      • qrCodeAdapter

        protected QRCodeAdapter qrCodeAdapter
        This is the adapter for displaying the QRCode objects
      • deviceUUID

        protected final java.util.UUID deviceUUID
        Device UUID of the profile
      • qrCodeList

        protected android.widget.GridView qrCodeList
        This is the gridview showing the qr codes of the player
      • totalPoints

        protected android.widget.TextView totalPoints
        This is the view that shows the qr codes of the player
      • totalCodes

        protected android.widget.TextView totalCodes
        This is the view showing the total number of codes the player has
      • topScore

        protected android.widget.TextView topScore
        This is the view showing the top score of the player's qr codes
      • orderSpinner

        protected android.widget.Spinner orderSpinner
        This is the spinner that determines the qr code display order
      • followersText

        protected android.widget.TextView followersText
        This is the text that displays how many followers the user has
      • followingText

        protected android.widget.TextView followingText
        This is the text that displays how many users the player is following
      • followButton

        protected com.google.android.material.floatingactionbutton.FloatingActionButton followButton
        This is the follow button
      • unfollowButton

        protected com.google.android.material.floatingactionbutton.FloatingActionButton unfollowButton
      • followLoadingButton

        protected com.google.android.material.floatingactionbutton.FloatingActionButton followLoadingButton
    • Constructor Detail

      • ProfileController

        public ProfileController​(ProfileFragment fragment,
                                 GameController gameController,
                                 java.util.UUID deviceUUID)
        This initializes the controller with its corresponding fragment
        Parameters:
        fragment - This is the fragment the controller manages
        gameController - The game controller that controls the global view
        deviceUUID - Device UUID of the profile.
    • Method Detail

      • setupFollowDetails

        public void setupFollowDetails​(android.widget.TextView followingText,
                                       android.widget.TextView followersText,
                                       com.google.android.material.floatingactionbutton.FloatingActionButton followButton,
                                       com.google.android.material.floatingactionbutton.FloatingActionButton unfollowButton,
                                       com.google.android.material.floatingactionbutton.FloatingActionButton followLoadingButton)
        Sets up the follow buttons and t ext
        Parameters:
        followingText - following textview
        followersText - followers textview
        followButton - follow button
        unfollowButton - unfollow button
        followLoadingButton - loading button
      • updateFollowDetails

        protected abstract void updateFollowDetails()
        Updates the text and following/followers count of the follow related content in the view.
      • setUpUsernameAndPicture

        public void setUpUsernameAndPicture​(android.widget.TextView usernameView,
                                            android.widget.ImageView profilePic)
        This sets up the username view and profile pic view of the fragment
        Parameters:
        usernameView - This is the TextView that shows the username
        profilePic - This is the ImageView that shows their profile picture
      • setUpQRList

        public void setUpQRList​(android.widget.GridView qrCodeList,
                                android.widget.TextView totalPoints,
                                android.widget.TextView totalCodes,
                                android.widget.TextView topScore,
                                android.widget.Spinner orderSpinner)
        Sets up the list view of qr codes
        Parameters:
        qrCodeList - This is the view that contains the list view of codes
        totalPoints - This is the view that displays the total points
        totalCodes - This is the view that displays the total number of codes
        topScore - This is the view that displays the top score
        orderSpinner - This is the spinner that indicates the sort order
      • handleSpinnerSelect

        public android.widget.AdapterView.OnItemSelectedListener handleSpinnerSelect​(android.widget.Spinner orderSpinner)
        This creates a custom OnItemSelectedListener for the given spinner
        Parameters:
        orderSpinner - This is the spinner for selecting the sorting order of codes
        Returns:
        Return the OnItemSelectedListener for the spinner
      • handleContactButtonClick

        public abstract void handleContactButtonClick()
        This handles the action to take when the contact info button is clicked. Either displaying the contact information or rendering the edit details fragment.
      • handleQRSelect

        public android.widget.AdapterView.OnItemClickListener handleQRSelect()
        This is the onclicklistener for qr codes displayed in the profile
        Returns:
        Return the onclicklistener
      • addUpdater

        public void addUpdater()
        This sets up the listener for real-time database changes
      • getTotalScore

        public int getTotalScore()
        This computes the sum of code scores
        Returns:
        Return the sum of code scores
      • getTopScore

        public long getTopScore()
        This computes the top score of the qr codes
        Returns:
        The top score
      • showMsg

        protected void showMsg​(java.lang.String msg)
        This displays a Toast message
        Parameters:
        msg - The message to display
      • onRankingButtonClick

        public void onRankingButtonClick()
        Calculates and renders a fragment on screen to display the percentiles of the player