Skip to content
This repository was archived by the owner on May 27, 2024. It is now read-only.

Workflow example

vreixo edited this page Sep 22, 2013 · 24 revisions

+## Application start Chain of events that occur on app loading without user interaction.

Interface initialization

On app start, the UI for the MainFragment is created inflating the correspondent XML files and setting the listeners for the buttons, gestures and map. Before adding the listeners to the map, the map should be retrieved, this can fail because [Play Services are not correctly configured in the device] (http://developer.android.com/google/play-services/setup.html#ensure).

If this fails all UI interface is disabled with setEnabled method for all button views and disabling the options menu and an intent is send to Goolge Play services that will a display a dialog to update the services. Also in the blank a map a button will appear to make the update. When the app returns to foreground (presumably coming for a successful installation of Play Services) the map is retrieved again and if this is done OK all gets re-enabled. This way the app never is in a failure state.

Set previously selected server

Selected server on last app usage is retrieved from the database and the bounds are drawn in the map. Map is centered to the center of the selected server.

Map initialization

Previously selected tiles are restored to the map and max zoom level is set to avoid problems zooming too much with custom tiles.

Restoring state

At this point the previous state of the app if is not a fresh start is restored. This is performed with [saved Instance bundle] (http://developer.android.com/training/basics/activity-lifecycle/recreating.html#RestoreState) received in onActivityCreated, if this bundle is null it means that is a fresh start and a field that allows the rest of the app to be aware of this is set.

Connection of the Location Client

Note that this part will be repeated each time the app comes from the background, because the method is triggered in onStart method, part of the [Android lifecycle] (http://developer.android.com/guide/components/fragments.html#Lifecycle).

  • A connection to LocationClient is requested in OnStart method of the fragment, setting this fragment to receive the callbacks derived from the connection.

  • OnConnectionFailed method will be activated if the connection fails, an intent to Play Services will be sent and that activity will take care of the problem.

  • OnConnected method will be triggered on a normal execution. This method can behave of several ways depending on what is the state of the app:

    • No server is selected: ServerSelector task will be always executed and will try to autodetect a server if the preference is checked and a valid user's location is obtained.

    • Server is selected and autodetect is enabled:

      • User not in server bounds and clearly changed his position or it's the first time that the server is trying to be detected, hence last position checked for servers is null: the app will try to autodetect a server.
      • Otherwise: ServerSelector task won't be triggered because will be a pointless disruption for the user.
    • Server is selected and autodetect is disabled. In this case this will be only executed at first start because if the server is not changing there is no point in changing the camera from the position set by the user. First start is detect checking if [saved Instance bundle] (http://developer.android.com/training/basics/activity-lifecycle/recreating.html#RestoreState) is null.

Parameters setting

Request

Post-request result visualization

Clone this wiki locally