wtanaka.praya
Class IdleTracker

java.lang.Object
  |
  +--wtanaka.praya.IdleTracker

public class IdleTracker
extends java.lang.Object

Tracker of idle time. Generates events corresponding to idle/non-idle. Does not quite function correctly, in order to avoid a synchronized block in touch(). It's possible for two unidle events to be generated at the same time. But it should tell you about at least as many transitions as there actually are.

Return to Sourceforge or the Praya Homepage

Version:
$Name: $ $Date: 2001/10/14 18:07:12 $
Author:
$Author: wtanaka $

Inner Class Summary
private  class IdleTracker.Tracker
          This runnable will sleep for one second at a time and increment a counter representing the approximate idle time.
 
Field Summary
private static IdleTracker instance
           
private  int m_definedIdleSeconds
          If idle time reaches this number of seconds, the idle tracker will generate an idle event.
private  int m_idleSeconds
           
private  boolean m_isIdle
           
private  java.util.Vector m_listeners
           
private  boolean m_resetCounter
          Internal flag used to signal the counter thread to reset the timer.
private  java.lang.Thread m_thread
           
 
Constructor Summary
IdleTracker()
           
 
Method Summary
 void addIdleListener(IdleListener l)
          Adds an idle listener to listen for idle/unidle events
 void fireIdle()
          tells listeners that user has been inactive.
 void fireUnidle()
          tells listeners that user became active.
 long getDefinedIdleSeconds()
          The time defined by the system such that the user is considered "idle" if she is idle for longer than this time.
 int getIdleSeconds()
          idle time in seconds
 java.lang.String getIdleString()
          Convenience method which returns the idle time as a string.
static IdleTracker getInstance()
           
 void removeIdleListener(IdleListener l)
          Removes an idle listener
 void setDefinedIdleLength(int seconds)
          The time defined by the system such that the user is considered "idle" if she is idle for longer than this time.
 void touch()
          The user just did something.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

m_idleSeconds

private volatile int m_idleSeconds

m_resetCounter

private boolean m_resetCounter
Internal flag used to signal the counter thread to reset the timer.

m_listeners

private java.util.Vector m_listeners

instance

private static IdleTracker instance

m_thread

private java.lang.Thread m_thread

m_isIdle

private boolean m_isIdle

m_definedIdleSeconds

private int m_definedIdleSeconds
If idle time reaches this number of seconds, the idle tracker will generate an idle event.
Constructor Detail

IdleTracker

public IdleTracker()
Method Detail

addIdleListener

public void addIdleListener(IdleListener l)
Adds an idle listener to listen for idle/unidle events

removeIdleListener

public void removeIdleListener(IdleListener l)
Removes an idle listener

fireUnidle

public void fireUnidle()
tells listeners that user became active.

fireIdle

public void fireIdle()
tells listeners that user has been inactive.

touch

public void touch()
The user just did something. Reset the idle time to 0.

getIdleSeconds

public int getIdleSeconds()
idle time in seconds

getIdleString

public java.lang.String getIdleString()
Convenience method which returns the idle time as a string. For instance, 1 second would be represented as 1s.

getDefinedIdleSeconds

public long getDefinedIdleSeconds()
The time defined by the system such that the user is considered "idle" if she is idle for longer than this time.

setDefinedIdleLength

public void setDefinedIdleLength(int seconds)
The time defined by the system such that the user is considered "idle" if she is idle for longer than this time.
Parameters:
seconds - the new length in seconds

getInstance

public static IdleTracker getInstance()