Example #1
0
 def __init__(self, clock, handler):
     """
     on_tick: function called per tick
     handler: Android os Handler, tied to application's main thread.
     """
     self.clock = clock
     self.handler = handler
     Log.i('TimeUpdateTask', 'initialized')
Example #2
0
 def _start_timer(self):
     """
     Starts the timer
     """
     Log.i('BaseClock', 'called _start_timer()')
     self.start_time_millis = SystemClock.uptimeMillis()
     self.time_handler.removeCallbacks(self.time_update_task)
     self.time_handler.postDelayed(self.time_update_task, TIMER_DELAY)
Example #3
0
    def restart(self):
        Log.i('BaseClock', 'called restart()')
        self.time_handler.removeCallbacks(self.time_update_task)
        self.state = 'new'
        self.turn = None
        self._reset_timers()

        # Update UI
        self._application.update_ui_state()
Example #4
0
    def on_switch_click(self, player):
        Log.i(
            'BaseClock',
            'called on_switch_player(%s), self.state:%s, self.turn:%s' %
            (player, self.state, self.turn))
        # Starts the clock if game hasn't started yet.
        if self.state == 'new':
            self.turn = 'w' if player == 'b' else 'b'
            self.state = 'active'
            self._start_timer()
            self._turn_switch(-1, self._turn_ind())

            # Update UI
            self._application.update_ui_state()

        # Switches the active clock
        elif self.state == 'active':
            Log.i('BaseClock', 'in active branch')
            if player == 'w' and self.turn == 'w':
                Log.i('BaseClock', 'switching to black')
                self.turn = 'b'
                self._turn_switch(1 - self._turn_ind(), self._turn_ind())
            elif player == 'b' and self.turn == 'b':
                Log.i('BaseClock', 'switching to white')
                self.turn = 'w'
                self._turn_switch(1 - self._turn_ind(), self._turn_ind())

            # Update UI
            self._application.update_ui_state()
Example #5
0
    def __init__(self, application):

        # call for updating ui
        self._application = application

        # possible values of state = ['new', 'active', 'paused', 'finished']
        self.state = 'new'

        self.turn = None

        # time control
        self.time = [None, None]
        self.delay = [None, None]

        # timer task
        self.start_time_millis = None
        self.time_handler = Handler()
        self.time_update_task = TimeUpdateTask(self, self.time_handler)

        Log.i('BaseClock', 'initialized')
Example #6
0
 def setUp(self):
     from android.util import Log
     Log.i(*self.get_marker())
     self.expected_log = []
Example #7
0
 def restart_clicked(self):
     Log.i('MyApplication', 'called restart_clicked()')
     self.clock.restart()
Example #8
0
 def pause_or_resume_clicked(self):
     Log.i('MyApplication', 'called pause_clicked()')
     self.clock.pause_or_resume()
Example #9
0
 def onClick(self, v: android.view.View) -> void:
     Log.i("TESTAPP", "Push the button")
     self.text_view.setText(self.text_view.getText().toString() +
                            "\nStop touching me!\n")
     Log.i("TESTAPP", "Text updated")
Example #10
0
		task.execute();

	}

	public String getLeaderData() {
		String response = "";
		try {
			HttpClient httpclient = new DefaultHttpClient();
			String connect = MyConsts.NETWORK_FOLDER + "getallusers.php";
			HttpPost httppost = new HttpPost(connect);
			HttpResponse httpResponse = httpclient.execute(httppost);
			HttpEntity resEntityGet = httpResponse.getEntity();
			if (resEntityGet != null) {
				// do something with the response
				response = EntityUtils.toString(resEntityGet);
				Log.i("GET RESPONSE", response);
				// Log.d(
				response = response.trim();

			}
		} catch (Exception e) {
			// Log.d(
			e.printStackTrace();
			// finish();
		}
		return response;
	}

	public void postLeaderData(String result) {
		getDataFromJSON();