public abstract class

Screen

extends Activity
implements ScreenMethods
java.lang.Object
   ↳ android.content.Context
     ↳ android.content.ContextWrapper
       ↳ android.view.ContextThemeWrapper
         ↳ android.app.Activity
           ↳ sofia.app.Screen
Known Direct Subclasses
Known Indirect Subclasses

Class Overview

The Screen class represents a single screen in an Android application. A Screen is a subclass of Android's notion of an Activity, which manages a user interface and acts as a "controller" for the events that occur in that GUI.

Summary

[Expand]
Inherited Constants
From class android.app.Activity
From class android.content.Context
[Expand]
Inherited Fields
From class android.app.Activity
Public Constructors
Screen()
Do not directly create instances of the Screen class; They are created for you by the operating system.
Public Methods
void finish(Object result)
Call this method when the current screen is finished and should be closed.
LayoutInflater getLayoutInflater()
ScreenMixin getScreenMixin()
Not intended to be called by users; this method is public as an implementation detail.
Object getSystemService(String service)
This method is overridden to replace the default Android layout inflater with one that supports Sofia's enhancements.
void initialize()
Called when the screen has been created and is about to be displayed on the device.
void log(String message)
Prints an informational message to the system log, tagged with the "User Log" tag so that it can be easily identified in the LogCat view.
boolean onCreateOptionsMenu(Menu menu)
boolean onMenuItemSelected(int featureId, MenuItem item)
void presentActivity(Intent intent, String returnMethod)
Starts the activity with the specified intent.
void presentScreen(Class<? extends Activity> screenClass, Object... args)
Starts the activity represented by the specified Screen subclass and slides it into view.
void showAlertDialog(String title, String message)
Displays an alert dialog and waits for the user to dismiss it.
boolean showConfirmationDialog(String title, String message)
Displays a confirmation dialog and waits for the user to select an option.
Protected Methods
void afterInitialize()
Called once the screen has been created and made visible.
void afterLayoutInflated(boolean inflated)
This method is called after an attempted was made to inflate the screen's layout.
void beforeInitialize()
Called before initialize() during the screen creation process.
boolean doInitializeAfterLayout()

Determines whether the user's initialize() method should be postponed until layout of the views has already occurred.

void onActivityResult(int requestCode, int resultCode, Intent data)
Called when a sub-activity returns yielding a result.
void onCreate(Bundle savedInstanceState)
Called when the activity is created.
void onDestroy()
void onPause()
void onResume()
void onSaveInstanceState(Bundle bundle)
void onStop()
[Expand]
Inherited Methods
From class android.app.Activity
From class android.view.ContextThemeWrapper
From class android.content.ContextWrapper
From class android.content.Context
From class java.lang.Object
From interface android.content.ComponentCallbacks
From interface android.view.KeyEvent.Callback
From interface android.view.LayoutInflater.Factory
From interface android.view.View.OnCreateContextMenuListener
From interface android.view.Window.Callback
From interface sofia.app.ScreenMethods

Public Constructors

public Screen ()

Do not directly create instances of the Screen class; They are created for you by the operating system.

Public Methods

public void finish (Object result)

Call this method when the current screen is finished and should be closed. The specified value will be passed back to the previous screen and returned from the #presentScreen(Class, Object...) call that originally presented this screen.

Parameters
result the value to pass back to the previous screen

public LayoutInflater getLayoutInflater ()

public ScreenMixin getScreenMixin ()

Not intended to be called by users; this method is public as an implementation detail.

public Object getSystemService (String service)

This method is overridden to replace the default Android layout inflater with one that supports Sofia's enhancements.

public void initialize ()

Called when the screen has been created and is about to be displayed on the device.

public void log (String message)

Prints an informational message to the system log, tagged with the "User Log" tag so that it can be easily identified in the LogCat view.

Parameters
message the message to log

public boolean onCreateOptionsMenu (Menu menu)

public boolean onMenuItemSelected (int featureId, MenuItem item)

public void presentActivity (Intent intent, String returnMethod)

Starts the activity with the specified intent. This method will not return until the new activity is dismissed by the user.

Parameters
intent an Intent that describes the activity to start
returnMethod the name of the method to call when the activity returns

public void presentScreen (Class<? extends Activity> screenClass, Object... args)

Starts the activity represented by the specified Screen subclass and slides it into view. This method returns immediately even as the screen is being presented, but at that point a new screen has taken over the user's attention and the old one might be discarded from memory at any time. Therefore, users should typically not do any important computation after calling this method.

Parameters
screenClass the subclass of Screen that will be displayed
args the arguments to be sent to the new screen's initialize method

public void showAlertDialog (String title, String message)

Displays an alert dialog and waits for the user to dismiss it.

Parameters
title the title to display in the dialog
message the message to display in the dialog

public boolean showConfirmationDialog (String title, String message)

Displays a confirmation dialog and waits for the user to select an option.

Parameters
title the title to display in the dialog
message the message to display in the dialog
Returns
  • true if the user clicked the "Yes" option; false if the user clicked the "No" option or cancelled the dialog (for example, by pressing the Back button)

Protected Methods

protected void afterInitialize ()

Called once the screen has been created and made visible. Most users will not need to override this method; it is provided so that Sofia's own Screen subclasses can do additional initialization after the user's own initialize() method has executed, if necessary.

protected void afterLayoutInflated (boolean inflated)

This method is called after an attempted was made to inflate the screen's layout. Most users will not need to call or override this method; it is provided for Sofia's own subclasses of Screen to support custom behavior depending on whether a user layout was provided or not.

Returns
  • true if a layout was found and inflated, otherwise false

protected void beforeInitialize ()

Called before initialize() during the screen creation process. Most users typically will not need to override this method; it is intended for Sofia's own subclasses of Screen so that they can provide additional functionality before initialize(), and then users can override initialize() without being required to call the superclass implementation.

protected boolean doInitializeAfterLayout ()

Determines whether the user's initialize() method should be postponed until layout of the views has already occurred.

In most cases, the default behavior of false is preferred, which will cause initialize() to be called during the activity's onCreate(Bundle) method, where the view hierarchy of the activity can be created. But some specialized subclasses of Screen, like ShapeScreen, postpone the call to initialize() until later, after its ShapeView has already been laid out, so that users can access the width and height of the view in order lay out shapes using that information in calculations.

Returns
  • true if initialize() should be postponed until the screen's views are already laid out, or false to call it immediately in onCreate(Bundle)

protected void onActivityResult (int requestCode, int resultCode, Intent data)

Called when a sub-activity returns yielding a result. Subclasses can override this method if they want to handle sub-activities in the traditional way, but they must call the superclass implementation in order to make sure that Sofia's built-in methods and choosers work correctly.

protected void onCreate (Bundle savedInstanceState)

Called when the activity is created.

Parameters
savedInstanceState instance data previously saved by this activity

protected void onDestroy ()

protected void onPause ()

protected void onResume ()

protected void onSaveInstanceState (Bundle bundle)

protected void onStop ()