remote activity java. local vars for all controls, get device name and set

This commit is contained in:
Dan Ballard 2017-09-18 08:34:54 -07:00
parent 3ee025fb23
commit 63b4a86999
1 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,55 @@
package im.ricochet.androidod;
import android.os.AsyncTask;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.TextView;
import goRicochetMobile.GoRicochetMobile;
public class RemoteActivity extends AppCompatActivity {
TextView deviceText;
TextView batteryText;
TextView statusText;
Button offButton;
Button lowButton;
Button medButton;
Button highButton;
Button disconnectButton;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_remote);
deviceText = (TextView)findViewById(R.id.deviceName);
batteryText = (TextView)findViewById(R.id.batteryLevel);
statusText = (TextView)findViewById(R.id.status);
offButton = (Button)findViewById(R.id.offButton);
lowButton = (Button)findViewById(R.id.lowButton);
medButton = (Button)findViewById(R.id.medButton);
highButton = (Button)findViewById(R.id.highButton);
disconnectButton = (Button)findViewById(R.id.disconnetButton);
GetDeviceNameTask getDeviceNameTask = new GetDeviceNameTask();
getDeviceNameTask.execute();
}
private class GetDeviceNameTask extends AsyncTask<Void, Void, String> {
@Override
protected String doInBackground(Void... params) {
String name = GoRicochetMobile.getDeviceName();
return name;
}
@Override
protected void onPostExecute(String deviceName) {
deviceText.setText(deviceName);
}
}
}