Advertisement
Guest User

Untitled

a guest
Aug 18th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.63 KB | None | 0 0
  1. package elf.app;
  2.  
  3. import elf.app.comm.CommClientMod;
  4. import android.app.Activity;
  5. import android.os.Bundle;
  6. import android.view.View;
  7. import android.view.View.OnClickListener;
  8. import android.widget.Button;
  9. import android.widget.TextView;
  10.  
  11.     /**
  12.      * displays details about the selected room
  13.      */
  14. public class RoomInfoActivity extends Activity implements OnClickListener {
  15.     TextView rumInfo;
  16.     CharSequence rumInfoText;
  17.     Button buttonCleaned;
  18.     CharSequence buttonCleanedText;
  19.     TextView rumStatus;
  20.     CharSequence rumStatusText;
  21.    
  22.     CommClientMod comm;
  23.     boolean cleaned = false;
  24.    
  25.  
  26.     protected void onCreate(Bundle savedInstanceState) {
  27.         super.onCreate(savedInstanceState);
  28.         setContentView(R.layout.room_info);
  29.        
  30.         comm = new CommClientMod("127.0.0.1", 62626);
  31.         rumInfo = (TextView)findViewById(R.id.textInfo);
  32.         buttonCleaned = (Button)findViewById(R.id.buttonCleaned);
  33.         rumStatus = (TextView)findViewById(R.id.textStatus);
  34.        
  35.        
  36.         rumInfoText = (CharSequence)getIntent().getExtras().getString("entry");
  37.         rumInfo.setText(rumInfoText);
  38.         buttonCleanedText = "Färdig med städningen";
  39.         buttonCleaned.setText(buttonCleanedText);
  40.         rumStatusText = (CharSequence)"Status: "+checkStatus();
  41.         rumStatus.setText(rumStatusText);
  42.     }
  43.    
  44.     public void onClick(View v) {
  45.         if(v.equals(buttonCleaned)) {
  46.             if(cleaned==false) {
  47.                 cleaned=true;
  48.                 comm.send("skicka meddelande rummet är städat");
  49.             }
  50.             else {
  51.                 cleaned=false;
  52.                 comm.send("skicka meddelande rummet är inte städat");
  53.             }
  54.         }
  55.     }
  56.    
  57.     public String checkStatus() {
  58.         if(cleaned==false)
  59.             return "Ej städat";
  60.         else
  61.             return "Städat";
  62.     }
  63.  
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement