Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.bootje.stijn.bootje;
- import android.content.Context;
- import android.content.pm.ActivityInfo;
- import android.net.wifi.WifiConfiguration;
- import android.net.wifi.WifiManager;
- import android.os.Looper;
- import android.os.Message;
- import android.support.v7.app.AppCompatActivity;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.Button;
- import android.view.View.*;
- import android.view.*;
- import android.widget.Toast;
- public class Bootje extends AppCompatActivity {
- public static Bootje main;
- boolean disconnected = false;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_bootje);
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
- registerListeners();
- main = this;
- }
- void registerListeners() {
- Button button = (Button) findViewById(R.id.links);
- Button button2 = (Button) findViewById(R.id.rechts);
- Button status = (Button) findViewById(R.id.check);
- //check
- status.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- setStatus("Verbinding testen...");
- new sendTCP().execute("check");
- }
- });
- //links
- button.setOnTouchListener(new OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- if (event.getAction() == MotionEvent.ACTION_UP ||
- event.getAction() == MotionEvent.ACTION_CANCEL) {
- new sendTCP().execute("leftoff");
- } else if (event.getAction() == MotionEvent.ACTION_DOWN) {
- new sendTCP().execute("lefton");
- }
- return false;
- }
- });
- //rechts
- button2.setOnTouchListener(new OnTouchListener() {
- @Override
- public boolean onTouch(View v, MotionEvent event) {
- if (event.getAction() == MotionEvent.ACTION_UP ||
- event.getAction() == MotionEvent.ACTION_CANCEL) {
- new sendTCP().execute("rightoff");
- } else if (event.getAction() == MotionEvent.ACTION_DOWN) {
- new sendTCP().execute("righton");
- }
- return false;
- }
- });
- }
- public void setStatus(final String message) {
- Context context = Bootje.main.getApplicationContext();
- Toast.makeText(context, message, Toast.LENGTH_SHORT).show();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement