List of usage examples for java.util Timer Timer
public Timer()
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. co m*/ 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();//from w ww . ja va 2s.c o m 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:eu.agilejava.snoopee.scan.SnoopEERegistrationClient.java
public void init(@Observes SnoopEEConfig configEvent) { LOGGER.config("EVENT"); TimerTask health = new HealthPing(); timer = new Timer(); timer.scheduleAtFixedRate(health, 0, 10000); }
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/*from w ww.java 2s. co m*/ public void run() { channel.send().unBan(hostmask); } }, TimeUnit.SECONDS.toMillis(time)); }
From source file:com.zetcheck.SlidingStationActivity.java
License:asdf
private void setUpdateConfig() { departures = new Departures(); updateData = new UpdateData(); updateData.isRunning = true;/* w w w . ja v a2 s . c o m*/ try { uri = new URI(URL_DEPARTURES + String.valueOf(ID)); } catch (URISyntaxException e1) { // TODO:check ID !!! return; } updateData.execute((Void[]) null); isDataReady = false; refreshTimer = new Timer(); }
From source file:com.breadwallet.tools.manager.CurrencyManager.java
public void startTimer() { //set a new Timer timer = new Timer(); //initialize the TimerTask's job initializeTimerTask();// w w w .j av a 2 s . com //schedule the timer, after the first 5000ms the TimerTask will run every 10000ms timer.schedule(timerTask, 0, 60000); // }
From source file:AnimatedMetadataGraph.java
@Override public void init() { //create a graph Graph<String, String> ig = Graphs .<String, String>synchronizedDirectedGraph(new DirectedSparseMultigraph<String, String>()); ObservableGraph<String, String> og = new ObservableGraph<String, String>(ig); og.addGraphEventListener(new GraphEventListener<String, String>() { public void handleGraphEvent(GraphEvent<String, String> evt) { System.err.println("got " + evt); }/*from w ww . ja v a 2s .com*/ }); this.g = og; //create a graphdraw layout = new FRLayout<String, String>(g); layout.setSize(new Dimension(600, 600)); Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); Layout<String, String> staticLayout = new StaticLayout<String, String>(g, layout); vv = new VisualizationViewer<String, String>(staticLayout, new Dimension(600, 600)); JRootPane rp = this.getRootPane(); rp.putClientProperty("defeatSystemEventQueueCheck", Boolean.TRUE); getContentPane().setLayout(new BorderLayout()); getContentPane().setBackground(java.awt.Color.lightGray); getContentPane().setFont(new Font("Serif", Font.PLAIN, 12)); vv.setGraphMouse(new DefaultModalGraphMouse<Number, Number>()); vv.getRenderer().getVertexLabelRenderer().setPosition(Renderer.VertexLabel.Position.CNTR); vv.getRenderContext().setVertexLabelTransformer(new ToStringLabeller<String>()); vv.setForeground(Color.black); vv.addComponentListener(new ComponentAdapter() { /** * @see java.awt.event.ComponentAdapter#componentResized(java.awt.event.ComponentEvent) */ @Override public void componentResized(ComponentEvent arg0) { super.componentResized(arg0); System.err.println("resized"); layout.setSize(arg0.getComponent().getSize()); } }); getContentPane().add(vv); switchLayout = new JButton("Switch to SpringLayout"); switchLayout.addActionListener(new ActionListener() { @SuppressWarnings("unchecked") public void actionPerformed(ActionEvent ae) { Dimension d = vv.getSize();//new Dimension(600,600); if (switchLayout.getText().indexOf("Spring") > 0) { switchLayout.setText("Switch to FRLayout"); layout = new SpringLayout<String, String>(g, new ConstantTransformer(EDGE_LENGTH)); layout.setSize(d); Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); StaticLayout<String, String> staticLayout = new StaticLayout<String, String>(g, layout); LayoutTransition<String, String> lt = new LayoutTransition<String, String>(vv, vv.getGraphLayout(), staticLayout); Animator animator = new Animator(lt); animator.start(); // vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.repaint(); } else { switchLayout.setText("Switch to SpringLayout"); layout = new FRLayout<String, String>(g, d); layout.setSize(d); Relaxer relaxer = new VisRunner((IterativeContext) layout); relaxer.stop(); relaxer.prerelax(); StaticLayout<String, String> staticLayout = new StaticLayout<String, String>(g, layout); LayoutTransition<String, String> lt = new LayoutTransition<String, String>(vv, vv.getGraphLayout(), staticLayout); Animator animator = new Animator(lt); animator.start(); // vv.getRenderContext().getMultiLayerTransformer().setToIdentity(); vv.repaint(); } } }); getContentPane().add(switchLayout, BorderLayout.SOUTH); timer = new Timer(); }
From source file:com.zetcheck.LineActivity.java
@Override public void onPause() { bandwidthSaver = new Timer(); bandwidthSaver.schedule(new TimerTask() { @Override//from ww w.ja v a2 s . co m public void run() { finish(); } }, 1000 * 15); // Log.e("onpause", "a"); super.onPause(); // isPaused=true; if (adView != null) { adView.destroy(); } }
From source file:com.undatech.opaque.RemoteCanvas.java
/** * Initializes the clipboard monitor.// w ww .j a v a 2 s. c o m */ private void initializeClipboardMonitor() { clipboardMonitor = new ClipboardMonitor(getContext(), this); if (clipboardMonitor != null) { clipboardMonitorTimer = new Timer(); if (clipboardMonitorTimer != null) { clipboardMonitorTimer.schedule(clipboardMonitor, 0, 500); } } }
From source file:multiplayer.pong.client.LobbyFrame.java
private void handleSockets() { socket.on("userConnected", new Emitter.Listener() { @Override// w w w. java2s . c o m public void call(Object... arg0) { String username = (String) arg0[0]; getConnectedFriends(); if (connectedFriends.contains(username)) appendMessage("Votre ami " + username + " vient de se connecter!\n", null); refresh(); } }).on("connectedPlayers", new Emitter.Listener() { @Override public void call(Object... arg0) { JSONArray players = (JSONArray) arg0[0]; Vector<String> online = new Vector<String>(); try { for (int i = 0; i < players.length(); i++) { online.add(players.getJSONObject(i).getString("username")); } } catch (JSONException e) { } connectedPlayers = online; getConnectedFriends(); refresh(); } }).on("getMessage", new Emitter.Listener() { @Override public void call(Object... arg0) { JSONObject data = (JSONObject) arg0[0]; try { appendMessage(data.getString("from") + ": " + data.getString("message") + "\n", null); } catch (JSONException e) { } } }).on("friendRequest", new Emitter.Listener() { @Override public void call(Object... arg0) { String from = (String) arg0[0]; displayNotification("Vouz avez une demande d'ajout de " + from + "\n"); displayHelp(" >> Utilisez la commande '/accepterAmi " + from + "' pour confirmer la demande.\n"); } }).on("friendRequestAck", new Emitter.Listener() { @Override public void call(Object... arg0) { String username = (String) arg0[0]; displayNotification(username + " est maintenant votre ami.\n"); displayHelp("Invitez le une partie en tapant: '/challenge " + username + "'\n"); } }).on("challenge", new Emitter.Listener() { @Override public void call(Object... arg0) { String username = (String) arg0[0]; displayWarning(username + " vous invite une partie de Pong\n"); displayHelp("Tapez '/accepter " + username + "' pour joueur contre lui\n" + "ou '/refuser " + username + "' pour refuser\n"); } }).on("challengeAck", new Emitter.Listener() { @Override public void call(Object... arg0) { JSONObject data = (JSONObject) arg0[0]; try { String opponent = data.getString("opponent"); if (!data.getBoolean("accepted")) { displayWarning(opponent + " a refus votre dfi.\n"); } else { // Start the game daoGames.startGame(SocketHandler.username, opponent); SocketHandler.startGame(opponent); } } catch (JSONException e) { } } }).on("startGame", new Emitter.Listener() { @Override public void call(Object... arg0) { JSONObject data = (JSONObject) arg0[0]; try { String player1 = data.getString("player1"); String player2 = data.getString("player2"); if (SocketHandler.username.equals(player1) || SocketHandler.username.equals(player2)) { socket.emit("joinRoom", player1); displayWarning("La partie va commencer dans 5 secondes...\n"); Timer timer = new Timer(); timer.schedule(new TimerTask() { String opponent = SocketHandler.username.equals(player1) ? player2 : player1; String location = SocketHandler.username.equals(player1) ? "home" : "away"; public void run() { Pong game = new Pong(location, opponent); } }, 5000); } else { displayNotification("Un dfi a commenc: " + player1 + " vs " + player2 + "\n"); } } catch (JSONException e) { } } }).on("userDisconnected", new Emitter.Listener() { @Override public void call(Object... arg0) { String username = (String) arg0[0]; daoGames.cancelRequest(username, null); if (connectedFriends.contains(username)) appendMessage("Votre ami " + username + " vient de se dconnecter!\n", null); connectedPlayers.remove(username); getConnectedFriends(); refresh(); } }); }