FileDocCategorySizeDatePackage
AppWidgetShared.javaAPI DocAndroid 1.5 API4249Wed May 06 22:42:48 BST 2009com.android.providers.calendar

AppWidgetShared

public class AppWidgetShared extends Object
Set of static variables that are shared between {@link CalendarAppWidgetProvider} and {@link CalendarAppWidgetService} and guarded by {@link #sLock}.

Fields Summary
static final String
TAG
static final boolean
LOGD
static Object
sLock
static android.os.PowerManager.WakeLock
sWakeLock
static boolean
sUpdateRequested
static boolean
sUpdateRunning
static long
sLastRequest
{@link System#currentTimeMillis()} at last update request.
private static HashSet
sAppWidgetIds
private static HashSet
sChangedEventIds
Constructors Summary
Methods Summary
static voidclearLocked()
Call this at any point to release any {@link WakeLock} and reset to default state. Usually called before {@link Service#stopSelf()}.

Only call this while holding a {@link #sLock} lock.

        if (sWakeLock != null && sWakeLock.isHeld()) {
            if (LOGD) Log.d(TAG, "found held wakelock, so releasing");
            sWakeLock.release();
        }
        sWakeLock = null;
        
        sUpdateRequested = false;
        sUpdateRunning = false;
        
        sAppWidgetIds.clear();
        sChangedEventIds.clear();
    
static int[]collectAppWidgetIdsLocked()
Collect all currently requested appWidgetId filters, returning as single list. This call also clears the internal list.

Only call this while holding a {@link #sLock} lock.

        final int size = sAppWidgetIds.size();
        int[] array = new int[size];
        Iterator<Integer> iterator = sAppWidgetIds.iterator();
        for (int i = 0; i < size; i++) {
            array[i] = iterator.next();
        }
        sAppWidgetIds.clear();
        return array;
    
static java.util.SetcollectChangedEventIdsLocked()
Collect all currently requested changedEventId filters, returning as single list. This call also clears the internal list.

Only call this while holding a {@link #sLock} lock.

        Set<Long> set = new HashSet<Long>();
        for (Long value : sChangedEventIds) {
            set.add(value);
        }
        sChangedEventIds.clear();
        return set;
    
static voidmergeAppWidgetIdsLocked(int[] appWidgetIds)
Merge a set of filtering appWidgetIds with those from other pending requests. If null, then reset the filter to match all.

Only call this while holding a {@link #sLock} lock.

    
                                        
        
        if (appWidgetIds != null) {
            for (int appWidgetId : appWidgetIds) {
                sAppWidgetIds.add(appWidgetId);
            }
        } else {
            sAppWidgetIds.clear();
        }
    
static voidmergeChangedEventIdsLocked(long[] changedEventIds)
Merge a set of filtering changedEventIds with those from other pending requests. If null, then reset the filter to match all.

Only call this while holding a {@link #sLock} lock.

        if (changedEventIds != null) {
            for (long changedEventId : changedEventIds) {
                sChangedEventIds.add(changedEventId);
            }
        } else {
            sChangedEventIds.clear();
        }