Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package elf.app;
- import elf.app.comm.CommClientMod;
- import elf.app.comm.CommListener;
- import android.app.Activity;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- import android.widget.TextView;
- /**
- * Displays details about the selected room
- */
- public class RoomInfoActivity extends Activity implements OnClickListener, CommListener {
- TextView rumInfo;
- Button buttonCleaned;
- TextView rumStatus;
- CommClientMod comm;
- boolean cleaned = false;
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.room_info);
- comm = new CommClientMod("127.0.0.1", 62626);
- rumInfo = (TextView)findViewById(R.id.textInfo);
- buttonCleaned = (Button)findViewById(R.id.buttonCleaned);
- rumStatus = (TextView)findViewById(R.id.textStatus);
- rumInfo.setText(getIntent().getExtras().getString("entry"));
- buttonCleaned.setText("Färdig med städningen");
- rumStatus.setText("Status: "+checkStatus());
- }
- public void onClick(View v) {
- if(v.equals(buttonCleaned)) {
- if(cleaned==false) {
- rumStatus.setText("Status: "+checkStatus());
- cleaned=true;
- buttonCleaned.setText("Ej färdig med städningen");
- // TODO comm.send("send msg that the room is cleaned");
- // redraws the Views to reflect the changes made
- redraw();
- }
- else {
- rumStatus.setText("Status: "+checkStatus());
- cleaned=false;
- buttonCleaned.setText("Färdig med städningen");
- // TODO comm.send("send msg that the room is not cleaned");
- // redraws the Views to reflect the changes made
- redraw();
- }
- }
- }
- public String checkStatus() {
- if(cleaned==false)
- return "Ej städat";
- else
- return "Städat";
- }
- public void redraw() {
- rumInfo.invalidate();
- buttonCleaned.invalidate();
- rumStatus.invalidate();
- }
- @Override
- public void receiveMessage(String IP, String message) {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment