Advertisement
Ryuji89_pb

RoomInfoActivity.java

May 19th, 2011
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package elf.app;
  2.  
  3. import elf.app.comm.CommClientMod;
  4. import elf.app.comm.CommListener;
  5. import android.app.Activity;
  6. import android.os.Bundle;
  7. import android.view.View;
  8. import android.view.View.OnClickListener;
  9. import android.widget.Button;
  10. import android.widget.TextView;
  11.  
  12.     /**
  13.      * Displays details about the selected room
  14.      */
  15. public class RoomInfoActivity extends Activity implements OnClickListener, CommListener {
  16.     TextView rumInfo;
  17.     Button buttonCleaned;
  18.     TextView rumStatus;
  19.    
  20.     CommClientMod comm;
  21.     boolean cleaned = false;
  22.    
  23.  
  24.     protected void onCreate(Bundle savedInstanceState) {
  25.         super.onCreate(savedInstanceState);
  26.         setContentView(R.layout.room_info);
  27.        
  28.         comm = new CommClientMod("127.0.0.1", 62626);
  29.         rumInfo = (TextView)findViewById(R.id.textInfo);
  30.         buttonCleaned = (Button)findViewById(R.id.buttonCleaned);
  31.         rumStatus = (TextView)findViewById(R.id.textStatus);
  32.        
  33.        
  34.         rumInfo.setText(getIntent().getExtras().getString("entry"));
  35.         buttonCleaned.setText("Färdig med städningen");
  36.         rumStatus.setText("Status: "+checkStatus());
  37.     }
  38.    
  39.     public void onClick(View v) {
  40.         if(v.equals(buttonCleaned)) {
  41.             if(cleaned==false) {
  42.                 rumStatus.setText("Status: "+checkStatus());
  43.                 cleaned=true;
  44.                 buttonCleaned.setText("Ej färdig med städningen");
  45.                 // TODO comm.send("send msg that the room is cleaned");
  46.                     // redraws the Views to reflect the changes made
  47.                 redraw();
  48.             }
  49.             else {
  50.                 rumStatus.setText("Status: "+checkStatus());
  51.                 cleaned=false;
  52.                 buttonCleaned.setText("Färdig med städningen");
  53.                 // TODO comm.send("send msg that the room is not cleaned");
  54.                     // redraws the Views to reflect the changes made
  55.                 redraw();
  56.             }
  57.         }
  58.     }
  59.  
  60.     public String checkStatus() {
  61.         if(cleaned==false)
  62.             return "Ej städat";
  63.         else
  64.             return "Städat";
  65.     }
  66.    
  67.     public void redraw() {
  68.         rumInfo.invalidate();
  69.         buttonCleaned.invalidate();
  70.         rumStatus.invalidate();
  71.     }
  72.  
  73.     @Override
  74.     public void receiveMessage(String IP, String message) {
  75.         // TODO Auto-generated method stub
  76.        
  77.     }
  78.  
  79.  
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement