Search in sources :

Example 31 with Timer

use of java.util.Timer in project android_frameworks_base by ParanoidAndroid.

the class ComprehensiveCountryDetector method scheduleLocationRefresh.

/**
     * Schedule the next location refresh. We will do nothing if the scheduled task exists.
     */
private synchronized void scheduleLocationRefresh() {
    if (mLocationRefreshTimer != null)
        return;
    if (DEBUG) {
        Slog.d(TAG, "start periodic location refresh timer. Interval: " + LOCATION_REFRESH_INTERVAL);
    }
    mLocationRefreshTimer = new Timer();
    mLocationRefreshTimer.schedule(new TimerTask() {

        @Override
        public void run() {
            if (DEBUG) {
                Slog.d(TAG, "periodic location refresh event. Starts detecting Country code");
            }
            mLocationRefreshTimer = null;
            detectCountry(false, true);
        }
    }, LOCATION_REFRESH_INTERVAL);
}
Also used : Timer(java.util.Timer) TimerTask(java.util.TimerTask)

Example 32 with Timer

use of java.util.Timer in project android_frameworks_base by ParanoidAndroid.

the class LocationBasedCountryDetectorTest method waitForTimerReset.

private void waitForTimerReset(TestCountryDetector detector) {
    int count = 5;
    long interval = 1000;
    try {
        while (count-- > 0 && detector.getTimer() != null) {
            Thread.sleep(interval);
        }
    } catch (InterruptedException e) {
    }
    Timer timer = detector.getTimer();
    assertTrue(timer == null);
}
Also used : Timer(java.util.Timer)

Example 33 with Timer

use of java.util.Timer in project simperium-android by Simperium.

the class WebSocketManager method scheduleHeartbeat.

private void scheduleHeartbeat() {
    cancelHeartbeat();
    mHeartbeatTimer = new Timer();
    mHeartbeatTimer.schedule(new TimerTask() {

        public void run() {
            sendHearbeat();
        }
    }, HEARTBEAT_INTERVAL);
}
Also used : Timer(java.util.Timer) TimerTask(java.util.TimerTask)

Example 34 with Timer

use of java.util.Timer in project storymaker by StoryMaker.

the class ProjectsProvider method setTimer.

synchronized void setTimer(long delay) {
    // if there is no pin set, do not set a timer (will force a lock and potentially cause a crash)
    SharedPreferences settings = getContext().getApplicationContext().getSharedPreferences("appPrefs", Context.MODE_PRIVATE);
    String cachewordStatus = settings.getString("cacheword_status", null);
    if (cachewordStatus == null) {
        return;
    }
    // if there is an existing timer, clear it
    if (dbTimer != null) {
        dbTimer.cancel();
        dbTimer = null;
    }
    // set timer to disconnect from cacheword service so it can timeout
    dbTimer = new Timer();
    dbTimer.schedule(new TimerTask() {

        public void run() {
            mCacheWordHandler.disconnectFromService();
            dbTimer.cancel();
            dbTimer = null;
        }
    }, // 1 min delay
    delay);
}
Also used : Timer(java.util.Timer) TimerTask(java.util.TimerTask) SharedPreferences(android.content.SharedPreferences)

Example 35 with Timer

use of java.util.Timer in project GT by Tencent.

the class DefaultParaRunEngine method runFps.

private synchronized void runFps() {
    if (Env.API >= 14) {
        fps_gather = true;
        if (!hasCheckSu) {
            thread = new Thread(new CheckSuRunnable(), "CheckSu");
            thread.setDaemon(true);
            thread.start();
        }
        // 因为这个Timer是延时执行,所以基本能赶上su判断线程出结果
        fpsTimer40 = new Timer();
        fpsTimer40.schedule(new FpsTimerTask(), 0, GTIntervalSettingActivity.msecond_FPS);
    }
}
Also used : Timer(java.util.Timer) FpsTimerTask(com.tencent.wstt.gt.api.utils.FpsTimerTask)

Aggregations

Timer (java.util.Timer)448 TimerTask (java.util.TimerTask)262 IOException (java.io.IOException)33 Date (java.util.Date)22 Test (org.junit.Test)15 File (java.io.File)11 ArrayList (java.util.ArrayList)10 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)10 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)9 JobExecutor (org.activiti.engine.impl.jobexecutor.JobExecutor)9 Intent (android.content.Intent)8 Location (android.location.Location)8 LocationListener (android.location.LocationListener)8 Bundle (android.os.Bundle)8 ActivitiException (org.activiti.engine.ActivitiException)8 View (android.view.View)7 InputMethodManager (android.view.inputmethod.InputMethodManager)7 ImageView (android.widget.ImageView)7 BufferedReader (java.io.BufferedReader)7 InputStreamReader (java.io.InputStreamReader)7