uk.ac.stir.cs.android.easter
Class EasterActivity

java.lang.Object
  extended by Activity
      extended by uk.ac.stir.cs.android.easter.EasterActivity

public class EasterActivity
extends Activity

Calculate the date of Easter Sunday for a range of years in the Gregorian calendar. The algorithm is taken from "Puzzles and Paradoxes", T. H. O'Beirne, 1965 (p. 180).

Version:
1.0 (5th August 2011)
Author:
Kenneth J. Turner

Field Summary
private static int ABOUT_PADDING
          Padding for "About Easter" popup
private static int ABOUT_TEXT_SIZE
          Text size for "About Easter" popup
private  java.util.Calendar currentCalendar
          Current calendar
private  int currentYear
          Current year
private  java.text.DateFormat dateFormat
          Date format
private  TextView dateList
          Date list
private static int DATES_MAX
          Maximum difference between start and end years
private  WheelView endYear1
          End year digitis
private  WheelView endYear2
          End year digitis
private  WheelView endYear3
          End year digitis
private  WheelView endYear4
          End year digitis
private  WheelView startYear1
          Start year digitis
private  WheelView startYear2
          Start year digitis
private  WheelView startYear3
          Start year digitis
private  WheelView startYear4
          Start year digitis
private static int WHEEL_TEXT_SIZE
          Size of text in wheel
private static int WHEEL_VISIBLE
          Number of visible items in wheel
private static int YEAR_MAX
          Maximum start year
private static int YEAR_MIN
          Minimum start year (first Easter of the Gregorian calendar)
 
Constructor Summary
EasterActivity()
           
 
Method Summary
private  WheelView createWheel(int identifier)
          Create a wheel with digits 0..9.
private  java.lang.String getEaster(int year)
          Return Easter Sunday date in localised form for the given year.
 void listDates(View view)
          Display list of Easter dates from start to end year.
 void onCreate(Bundle savedInstanceState)
          React to activity creation by setting up key variables.
 boolean onCreateOptionsMenu(Menu menu)
          Create options menu.
 boolean onOptionsItemSelected(MenuItem item)
          Handle menu selection.
 void resetYears(View view)
          Reset start and end years to current year.
private  void setYears(int start, int end, boolean animate)
          Set start and end year dates.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ABOUT_PADDING

private static final int ABOUT_PADDING
Padding for "About Easter" popup

See Also:
Constant Field Values

ABOUT_TEXT_SIZE

private static final int ABOUT_TEXT_SIZE
Text size for "About Easter" popup

See Also:
Constant Field Values

DATES_MAX

private static final int DATES_MAX
Maximum difference between start and end years

See Also:
Constant Field Values

WHEEL_TEXT_SIZE

private static final int WHEEL_TEXT_SIZE
Size of text in wheel

See Also:
Constant Field Values

WHEEL_VISIBLE

private static final int WHEEL_VISIBLE
Number of visible items in wheel

See Also:
Constant Field Values

YEAR_MIN

private static final int YEAR_MIN
Minimum start year (first Easter of the Gregorian calendar)

See Also:
Constant Field Values

YEAR_MAX

private static final int YEAR_MAX
Maximum start year

See Also:
Constant Field Values

currentCalendar

private java.util.Calendar currentCalendar
Current calendar


currentYear

private int currentYear
Current year


dateFormat

private java.text.DateFormat dateFormat
Date format


dateList

private TextView dateList
Date list


endYear1

private WheelView endYear1
End year digitis


endYear2

private WheelView endYear2
End year digitis


endYear3

private WheelView endYear3
End year digitis


endYear4

private WheelView endYear4
End year digitis


startYear1

private WheelView startYear1
Start year digitis


startYear2

private WheelView startYear2
Start year digitis


startYear3

private WheelView startYear3
Start year digitis


startYear4

private WheelView startYear4
Start year digitis

Constructor Detail

EasterActivity

public EasterActivity()
Method Detail

createWheel

private WheelView createWheel(int identifier)
Create a wheel with digits 0..9.

Parameters:
identifier - wheel widget identifier
Returns:
created wheel

getEaster

private java.lang.String getEaster(int year)
Return Easter Sunday date in localised form for the given year. The algorithm is by T. H. O'Beirne.

Parameters:
year - year for Easter
Returns:
Easter Sunday date in localised form

listDates

public void listDates(View view)
Display list of Easter dates from start to end year. One or other will be set to the current year if incorrect (start empty or before first year, end empty or before start).

Parameters:
view - current view

onCreate

public void onCreate(Bundle savedInstanceState)
React to activity creation by setting up key variables.

Parameters:
savedInstanceState - saved state

onCreateOptionsMenu

public boolean onCreateOptionsMenu(Menu menu)
Create options menu.

Parameters:
item - menu item

onOptionsItemSelected

public boolean onOptionsItemSelected(MenuItem item)
Handle menu selection.

Parameters:
item - menu item

resetYears

public void resetYears(View view)
Reset start and end years to current year.

Parameters:
view - current view

setYears

private void setYears(int start,
                      int end,
                      boolean animate)
Set start and end year dates.

Parameters:
start - start year
end - end year
animate - whether to animate the change