MainMenuActivity

com.j0h1.contour

## Class MainMenuActivity

- java.lang.Object
- - Activity
  - - com.j0h1.contour.MainMenuActivity

-     public class MainMenuActivity
      extends Activity

  Activity that is responsible for player authentification. Furthermore this activity is the entry point of the application, that requests the user to download the OpenCV Manager, that is required to play this game.
  Author:
    Johannes Riedmann

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private ImageButton` | `highscoreButton`
    `private org.opencv.android.BaseLoaderCallback` | `mLoaderCallback`
    `private ImageButton` | `playButton`
    `private Toast` | `toast`
    `private AlertDialog` | `usernamePrompt`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `MainMenuActivity()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private void` | `enableButtons()`
    `private java.lang.String` | `getAndroidId()` Gets an unique device identifier for the current device.
    `private void` | `greetPlayer(Player player)` Greets the given player and enables highscoreButton and playButton for the user to continue.
    `private void` | `handlePlayerRequestResult(Player player)` This method handles the response from the player request for a specific android device id.
    `void` | `onBackPressed()`
    `protected void` | `onCreate(Bundle savedInstanceState)`
    `void` | `onResume()`
    `private void` | `persistPlayerLocally(Player player)` Persists a player to the local SQLite database.
    `private void` | `prepareToast(java.lang.String message)`
    `private void` | `promptUsernameInput()` Prompt the user to enter a username.
    `private void` | `requestPersistPlayer(Player player)` Send a request to the server to persist a defined player.
    `private void` | `requestPlayerForAndroidId(java.lang.String androidId)` Sends a request to the server with the current android device ID and checks if there is a player persisted (server-sided) that matches the given id.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### usernamePrompt

          private AlertDialog usernamePrompt

    - #### toast

          private Toast toast

    - #### playButton

          private ImageButton playButton

    - #### highscoreButton

          private ImageButton highscoreButton

    - #### mLoaderCallback

          private org.opencv.android.BaseLoaderCallback mLoaderCallback

  - ### Constructor Detail

    - #### MainMenuActivity

          public MainMenuActivity()

  - ### Method Detail

    - #### onCreate

          protected void onCreate(Bundle savedInstanceState)

    - #### onResume

          public void onResume()

    - #### onBackPressed

          public void onBackPressed()

    - #### enableButtons

          private void enableButtons()

    - #### requestPlayerForAndroidId

          private void requestPlayerForAndroidId(java.lang.String androidId)

      Sends a request to the server with the current android device ID and checks if there is a player persisted (server-sided) that matches the given id. If so, a Player object is returned and passed on to the method handlePlayerRequestResult. If no player is found, an AlertDialog shows up that prompts the user to enter a username.
      Parameters:
        `androidId` - Unique ID that identifies the current android device.

    - #### handlePlayerRequestResult

          private void handlePlayerRequestResult(Player player)

      This method handles the response from the player request for a specific android device id.
      Parameters:
        `player` - Player object, given as response from the server.

    - #### promptUsernameInput

          private void promptUsernameInput()

      Prompt the user to enter a username. This dialog can't be canceled, since the user has to define a valid username to use the app.

    - #### requestPersistPlayer

          private void requestPersistPlayer(Player player)

      Send a request to the server to persist a defined player.
      Parameters:
        `player` - Player object that was defines by the user. (username entered by the user and androidId extracted from the device configuration)

    - #### persistPlayerLocally

          private void persistPlayerLocally(Player player)

      Persists a player to the local SQLite database.
      Parameters:
        `player` - Player to be persisted locally.

    - #### greetPlayer

          private void greetPlayer(Player player)

      Greets the given player and enables highscoreButton and playButton for the user to continue.
      Parameters:
        `player` - Player that needs to be greeted.

    - #### getAndroidId

          private java.lang.String getAndroidId()

      Gets an unique device identifier for the current device.
      Returns:
        Android device ID.

    - #### prepareToast

          private void prepareToast(java.lang.String message)