Android Tutorial [Newbie sample] Simple Timer Up & Down, Counter Up & Down.

Discussion in 'Tutorials & Examples' started by drachmad, Jul 9, 2013.

  1. drachmad

    drachmad Member Licensed User

    This is only a simple example for newbie to learn Wheel algorithm.
    For fully blown of wheels, see ClsWheel v 1.4 by Klaus.
    There is no intention to make it an advance Stopwatch & Timer!
    Advance Stopwatch and Timer apk can be download free from the web.

    Using scrollview in a Wheel object (simplified).
    Manipulate the scrollview native methods/properties using reflection.
    Enable/disable scrollview from scrolling manually.
    Use "smoothScrollTo" to simulate scrolling programmatically.
    Trick: to look like scrolling continuously from bottom/top.
    Displaying many variation of one class at once.
    Non-modal dialog does not stop timer in Stopwatch/Timer while running.
    Entry a new title
    Displaying the lap result
    or while displaying maximum object allowed.

    The last position when going to sleep is save in variables in a service.
    If accidentally the back button is pressed, the last postion can be recovered except the lap data.
    If it is considered the data is critical, change the algotithm to save it in a file.
    Like Statemanager but simpler.
    Note: if using the - Don't let stopwatch/timer running in the main activity if not used, it drains the battery although in sleep mode.
    ClsActionBar 1.42 for the menu.

    Sleep orange -> in sleep mode
    Sleep green -> in keep awake
    LongClick at the del button to delete.

    Library used:
    Reflection v 2.40 for Wheel simulation.
    Phone v.2.10 for WakeState
    IME v.1.05 for automatic hiding the keyboard - using phw.PartialLock - using TimeDifference (phw.PartialLock not used) see #3

    Designed & Tested on Tab 7"

    Attached Files:

    Last edited: Jul 12, 2013
    JohnD likes this.
  2. drachmad

    drachmad Member Licensed User

    Update to save the position

    The last position when going to sleep or back button is pressed is save in variables in a service.
    Can be in sleep mode or keep awake.

    I apologize, there is still bug in the timer when sleeping.
    If connected to the PC it is working correctly, but in stand alone the timer slow down.

    Above bug already corrected. Added phw.PartialLock.
    Better use reminder for long running timer (simple-task-reminder)
    Last edited: Jul 11, 2013
  3. drachmad

    drachmad Member Licensed User

    Update save method

    In sleep mode the timer is turned off.
    phw.PartialLock is not used.
    On wake up the display is get from the last save value + time difference
    I did not test for the precision! In my opinion there should be a delay.
    Last edited: Jul 13, 2013
  4. merlin2049er

    merlin2049er Well-Known Member Licensed User

    Cool, got to check this timer out. Can you use it to just display the minutes? I'd love to be able to stick a small up-counter in my app.
  5. djveleno

    djveleno Active Member Licensed User

    Hi dear, with Samsung Galaxy S3 the number into wheel counter are too large respect emulator (perfect), there is a method to change the sizes of numbers?
    Thanks for all.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice