List of usage examples for java.util TimerTask TimerTask
protected TimerTask()
From source file:com.andrada.sitracker.ui.fragment.AuthorsFragment.java
/** * Crouton click handler/*from w w w . j a va 2 s . com*/ * * @param view being clicked */ @Override public void onClick(@NotNull View view) { if (view.getId() == R.id.retryUpdateButton) { if (this.mNoNetworkCrouton != null) { Crouton.hide(this.mNoNetworkCrouton); this.mNoNetworkCrouton = null; } Timer timer = new Timer(); timer.schedule(new TimerTask() { @Override public void run() { FragmentActivity activity = getActivity(); if (activity != null) { activity.runOnUiThread(new Runnable() { @Override public void run() { menuRefreshSelected(); } }); } } }, 1500); } }
From source file:com.zetcheck.LineActivity_low.java
@Override public void onPause() { bandwidthSaver = new Timer(); bandwidthSaver.schedule(new TimerTask() { @Override//ww w.j a v a 2 s .c om public void run() { finish(); } }, 1000 * 15); // Log.e("onpause", "a"); super.onPause(); // isPaused=true; }
From source file:io.radio.streamer.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Allow keys to change volume without playing setVolumeControlStream(AudioManager.STREAM_MUSIC); audioManager = (AudioManager) getApplicationContext().getSystemService(Context.AUDIO_SERVICE); // Initialize Remote Controls if SDK Version >=14 initializeRemoteControls();/* w ww . ja v a 2 s .c om*/ initializeVariables(); initializeSideBar(); updateApiData(); // first page in the menu (homepage) on first load if (savedInstanceState == null) { selectItem(0); } // Get the fxView fxView = (FXView) findViewById(R.id.audioFxView); apiTimer = new Timer(); apiTimer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { try { updateApiData(); } catch (Exception e) { Log.e("api", "exception", e); } } }, 0, 10000); progressTimer = new Timer(); progressTimer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { try { Message m = new Message(); m.what = Util.PROGRESSUPDATE; mMessenger.send(m); } catch (Exception e) { Log.e("api", "exception", e); } } }, 0, 1000); }
From source file:com.irccloud.android.Notifications.java
@TargetApi(9) private void save() { if (mSaveTimerTask != null) mSaveTimerTask.cancel();// w ww .jav a 2 s . c o m mSaveTimerTask = new TimerTask() { @Override public void run() { saveNow(); } }; try { mSaveTimer.schedule(mSaveTimerTask, 100); } catch (IllegalStateException e) { //Timer is already cancelled } }
From source file:co.foxdev.foxbot.utils.Utils.java
public static void scheduleUnban(final Channel channel, final String hostmask, final int time) { new Timer().schedule(new TimerTask() { @Override/* ww w .ja va2 s . co m*/ public void run() { channel.send().unBan(hostmask); } }, TimeUnit.SECONDS.toMillis(time)); }
From source file:dk.itst.oiosaml.sp.metadata.CRLChecker.java
public void startChecker(long period, final IdpMetadata metadata, final Configuration conf) { if (timer != null) return;// w w w. j a v a2 s .c o m log.info("Starting CRL checker, running with " + period + " seconds interval. Checking " + metadata.getEntityIDs().size() + " certificates"); timer = new Timer("CRLChecker"); timer.schedule(new TimerTask() { public void run() { log.debug("Running CRL checker task"); try { checkCertificates(metadata, conf); } catch (Exception e) { log.error("Unable to run CRL checker", e); } } }, 1000L, 1000L * period); }
From source file:com.predic8.membrane.core.exchangestore.FileExchangeStore.java
public void initializeTimer() { if (this.maxDays < 0) { return; // don't do anything if this feature is deactivated }// ww w . ja v a2 s.c o m oldFilesCleanupTimer = new Timer("Clean up old log files", true); // schedule first run for the night Calendar firstRun = Calendar.getInstance(); firstRun.set(Calendar.HOUR_OF_DAY, 3); firstRun.set(Calendar.MINUTE, 14); // schedule for the next day if the scheduled execution time is before now if (firstRun.before(Calendar.getInstance())) firstRun.add(Calendar.DAY_OF_MONTH, 1); oldFilesCleanupTimer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { try { deleteOldFolders(); } catch (IOException e) { log.error("", e); } } }, firstRun.getTime(), 24 * 60 * 60 * 1000 // one day ); }
From source file:de.chaosfisch.google.youtube.upload.Uploader.java
public void runStarttimeChecker() { logger.debug("Running starttime checker"); final long delay = uploadService.getStarttimeDelay(); logger.debug("Delay to upload is {}", delay); final TimerTask timerTask = new TimerTask() { @Override/*from w w w .j a va 2s . c o m*/ public void run() { if (0 < uploadService.countReadyStarttime()) { Uploader.this.run(); } runStarttimeChecker(); } }; if (-1 != delay && (0 == runningUploads || canAddJob())) { task = timer.schedule(timerTask, delay, TimeUnit.MILLISECONDS); } }
From source file:de.ufinke.cubaja.sort.SortManager.java
private void initTimer(final Log logger, final String prefix, final String key, final AtomicLong counter) { TimerTask task = new TimerTask() { public void run() { logger.trace(prefix + text.get(key, counter.get())); }//from w w w . j a v a 2 s. c o m }; timer = new Timer(); timer.schedule(task, logInterval, logInterval); }
From source file:com.zetcheck.LineActivity.java
@Override public void onPause() { bandwidthSaver = new Timer(); bandwidthSaver.schedule(new TimerTask() { @Override/*from w ww . ja v a 2s.c o m*/ public void run() { finish(); } }, 1000 * 15); // Log.e("onpause", "a"); super.onPause(); // isPaused=true; if (adView != null) { adView.destroy(); } }