Class ProfileController
- java.lang.Object
-
- com.cmput301w23t09.qrhunter.profile.ProfileController
-
- All Implemented Interfaces:
DatabaseChangeListener
- Direct Known Subclasses:
MyProfileController
,OtherProfileController
public abstract class ProfileController extends java.lang.Object implements DatabaseChangeListener
This is the controller for the profile fragment of the app
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.UUID
deviceUUID
Device UUID of the profileprotected com.google.android.material.floatingactionbutton.FloatingActionButton
followButton
This is the follow buttonprotected android.widget.TextView
followersText
This is the text that displays how many followers the user hasprotected android.widget.TextView
followingText
This is the text that displays how many users the player is followingprotected com.google.android.material.floatingactionbutton.FloatingActionButton
followLoadingButton
protected ProfileFragment
fragment
This is the profile fragment the controller handlesprotected 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 orderprotected QRCodeAdapter
qrCodeAdapter
This is the adapter for displaying the QRCode objectsprotected android.widget.GridView
qrCodeList
This is the gridview showing the qr codes of the playerprotected java.util.ArrayList<QRCode>
qrCodes
This is the array of QRCode objects that the fragment displaysprotected android.widget.TextView
topScore
This is the view showing the top score of the player's qr codesprotected android.widget.TextView
totalCodes
This is the view showing the total number of codes the player hasprotected android.widget.TextView
totalPoints
This is the view that shows the qr codes of the playerprotected com.google.android.material.floatingactionbutton.FloatingActionButton
unfollowButton
-
Constructor Summary
Constructors Constructor Description ProfileController(ProfileFragment fragment, GameController gameController, java.util.UUID deviceUUID)
This initializes the controller with its corresponding fragment
-
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 changeslong
getTopScore()
This computes the top score of the qr codesint
getTotalScore()
This computes the sum of code scoresabstract 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 profileandroid.widget.AdapterView.OnItemSelectedListener
handleSpinnerSelect(android.widget.Spinner orderSpinner)
This creates a custom OnItemSelectedListener for the given spinnervoid
onChange()
This refreshes the profile upon database changevoid
onRankingButtonClick()
Calculates and renders a fragment on screen to display the percentiles of the playervoid
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 extvoid
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 codesvoid
setUpUsernameAndPicture(android.widget.TextView usernameView, android.widget.ImageView profilePic)
This sets up the username view and profile pic view of the fragmentprotected void
showMsg(java.lang.String msg)
This displays a Toast messageprotected abstract void
updateFollowDetails()
Updates the text and following/followers count of the follow related content in the view.
-
-
-
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 managesgameController
- The game controller that controls the global viewdeviceUUID
- 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 textviewfollowersText
- followers textviewfollowButton
- follow buttonunfollowButton
- unfollow buttonfollowLoadingButton
- 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 usernameprofilePic
- 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 codestotalPoints
- This is the view that displays the total pointstotalCodes
- This is the view that displays the total number of codestopScore
- This is the view that displays the top scoreorderSpinner
- 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
-
onChange
public void onChange()
This refreshes the profile upon database change- Specified by:
onChange
in interfaceDatabaseChangeListener
-
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
-
-