net.hockeyapp.android
Class UpdateActivity

java.lang.Object
  extended by Activity
      extended by net.hockeyapp.android.UpdateActivity
All Implemented Interfaces:
UpdateActivityInterface, UpdateInfoListener

public class UpdateActivity
extends Activity
implements UpdateActivityInterface, UpdateInfoListener

Description

Activity to show update information and start the download process if the user taps the corresponding button.

License

 Copyright (c) 2012 Codenauts UG
 
 Permission is hereby granted, free of charge, to any person
 obtaining a copy of this software and associated documentation
 files (the "Software"), to deal in the Software without
 restriction, including without limitation the rights to use,
 copy, modify, merge, publish, distribute, sublicense, and/or sell
 copies of the Software, and to permit persons to whom the
 Software is furnished to do so, subject to the following
 conditions:
 
 The above copyright notice and this permission notice shall be
 included in all copies or substantial portions of the Software.
 
 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 OTHER DEALINGS IN THE SOFTWARE.
 

Author:
Thomas Dohmke

Field Summary
protected  DownloadFileTask downloadTask
          Task to download the .apk file.
protected  VersionHelper versionHelper
          Helper for version management.
 
Constructor Summary
UpdateActivity()
           
 
Method Summary
protected  void configureView()
          Configures the content view by setting app name, the current version and the listener for the download button.
protected  void createDownloadTask(java.lang.String url, DownloadFileListener listener)
           
 void enableUpdateButton()
          Enables the download button.
 java.lang.String getAppName()
          Returns the app's name.
 int getCurrentVersionCode()
          Returns the current version of the app.
 ViewGroup getLayoutView()
          Creates and returns a new instance of UpdateView.
 void onClick(View v)
          Called when the download button is tapped.
 void onCreate(Bundle savedInstanceState)
          Called when the activity is starting.
 java.lang.Object onRetainNonConfigurationInstance()
          Detaches the activity from the download task and returns the task as last instance.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

downloadTask

protected DownloadFileTask downloadTask
Task to download the .apk file.


versionHelper

protected VersionHelper versionHelper
Helper for version management.

Constructor Detail

UpdateActivity

public UpdateActivity()
Method Detail

onCreate

public void onCreate(Bundle savedInstanceState)
Called when the activity is starting. Sets the title and content view. Configures the list view adapter. Attaches itself to a previously started download task.

Parameters:
savedInstanceState - Data it most recently supplied in onSaveInstanceState(Bundle)

configureView

protected void configureView()
Configures the content view by setting app name, the current version and the listener for the download button.


onRetainNonConfigurationInstance

public java.lang.Object onRetainNonConfigurationInstance()
Detaches the activity from the download task and returns the task as last instance. This way the task is restored when the activity is immediately re-created.

Returns:
The download task if present.

createDownloadTask

protected void createDownloadTask(java.lang.String url,
                                  DownloadFileListener listener)

enableUpdateButton

public void enableUpdateButton()
Enables the download button.


getCurrentVersionCode

public int getCurrentVersionCode()
Returns the current version of the app.

Specified by:
getCurrentVersionCode in interface UpdateInfoListener
Returns:
The version code as integer.

getLayoutView

public ViewGroup getLayoutView()
Creates and returns a new instance of UpdateView.

Specified by:
getLayoutView in interface UpdateActivityInterface
Returns:
Instance of UpdateView

getAppName

public java.lang.String getAppName()
Returns the app's name.

Returns:
The app's name as a String.

onClick

public void onClick(View v)
Called when the download button is tapped. Starts the download task and disables the button to avoid multiple taps.