HighscoreTrackFragment

com.j0h1.contour

## Class HighscoreTrackFragment

- java.lang.Object
- - Fragment
  - - com.j0h1.contour.HighscoreTrackFragment

-     public class HighscoreTrackFragment
      extends Fragment

  Fragment that is responsible for displaying the top 10 track sessions.
  Author:
    Johannes Riedmann

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `private ImageButton` | `btnGlobal`
    `private ImageButton` | `btnLocal`
    `private ExpandableListView` | `elvTrackPersonal`
    `private FrameLayout` | `frmGlobalHighscore`
    `private FrameLayout` | `frmLocalHighscore`
    `private java.lang.String` | `language`
    `private HighscoreExpandableListAdapter` | `listAdapter`
    `private <any>` | `listDataChild`
    `private java.util.List<Track>` | `listDataHeader`
    `private Toast` | `toast`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `HighscoreTrackFragment()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `private void` | `expandList()` Expands the headers of the ExpandableListView to show the child data.
    `private Player` | `getLocalPlayer()` Gets the locally persisted player from the database.
    `View` | `onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)`
    `void` | `onStart()`
    `private void` | `populateChildren()` For each track that serves as header data, request the top 10 track sessions.
    `private void` | `prepareToast(java.lang.String message)`
    `private void` | `refreshListData()` Refreshes the data held by the ExpandableListView and expands it afterwards.
    `private void` | `requestListHeaders()` Request track names as header data for the ExpandableListView in the default language the user has defined on his device.
    `private void` | `requestTop10GlobalForTrack(Track track)` The top10 sessions for a specific track are requested.
    `private void` | `requestTop10LocalForTrack(Track track)` The top10 sessions for a specific track and player are requested.

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

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

- - ### Field Detail

    - #### btnGlobal

          private ImageButton btnGlobal

    - #### btnLocal

          private ImageButton btnLocal

    - #### frmGlobalHighscore

          private FrameLayout frmGlobalHighscore

    - #### frmLocalHighscore

          private FrameLayout frmLocalHighscore

    - #### elvTrackPersonal

          private ExpandableListView elvTrackPersonal

    - #### listAdapter

          private HighscoreExpandableListAdapter listAdapter

    - #### listDataHeader

          private java.util.List<Track> listDataHeader

    - #### listDataChild

          private <any> listDataChild

    - #### toast

          private Toast toast

    - #### language

          private java.lang.String language

  - ### Constructor Detail

    - #### HighscoreTrackFragment

          public HighscoreTrackFragment()

  - ### Method Detail

    - #### onStart

          public void onStart()

    - #### onCreateView

          public View onCreateView(LayoutInflater inflater,
                                   ViewGroup container,
                                   Bundle savedInstanceState)

    - #### requestListHeaders

          private void requestListHeaders()

      Request track names as header data for the ExpandableListView in the default language the user has defined on his device. Populate the header data if the request was successful, provide feedback why if failed otherwise.

    - #### populateChildren

          private void populateChildren()

      For each track that serves as header data, request the top 10 track sessions. If the user selected the global button, the global high scores are shown. If the local button is selected, the users high scores are shown.

    - #### requestTop10GlobalForTrack

          private void requestTop10GlobalForTrack(Track track)

      The top10 sessions for a specific track are requested. If the request returns a valid response (SessionResponseList with List that does not equal null), the child items for the header data is set.
      Parameters:
        `track` - Track to get session highscore data from.

    - #### requestTop10LocalForTrack

          private void requestTop10LocalForTrack(Track track)

      The top10 sessions for a specific track and player are requested. If the request returns a valid response (SessionResponseList with List that does not equal null), the child items for the header data is set.
      Parameters:
        `track` - Track to get session highscore data from.

    - #### getLocalPlayer

          private Player getLocalPlayer()

      Gets the locally persisted player from the database.
      Returns:
        Locally persisted player.

    - #### refreshListData

          private void refreshListData()

      Refreshes the data held by the ExpandableListView and expands it afterwards.

    - #### expandList

          private void expandList()

      Expands the headers of the ExpandableListView to show the child data.

    - #### prepareToast

          private void prepareToast(java.lang.String message)