Code example for PriorityBlockingQueue

Methods: add, contains

0
        final boolean expedited = extras.getBoolean(ContentResolver.SYNC_EXTRAS_EXPEDITED, false);
        final boolean manual = extras.getBoolean(ContentResolver.SYNC_EXTRAS_MANUAL, false);
 
        final SyncItem i = new SyncItem(uri, extras, (expedited ? 10 : 0) + (manual ? 5 : 0));
 
        if (!expedited && mPriorityQueue.contains(i)) {
            Log.d(TAG, "not adding " + i + " as it's already in the sync queue");
            return; 
        } 
 
        mPriorityQueue.add(i);
        Log.d(TAG, "enqueued " + i);
    } 
 
    @Override 
    public void onDestroy() { 
        super.onDestroy(); 
        mSyncProcessor.stop();
        mContentProviderClient.release();
        mProvider = null;
    }