mansi_singhal

java and xml code for Common_Washroom

Jul 11th, 2018
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.45 KB | None | 0 0
  1. ##### Java code for Common_washroom
  2.  
  3. package com.example.shikhadwivedi.homeautomation;
  4.  
  5. import android.content.Intent;
  6. import android.net.Uri;
  7. import android.os.Bundle;
  8. import android.support.v7.app.AppCompatActivity;
  9. import android.view.View;
  10. import android.widget.Button;
  11. import android.widget.CompoundButton;
  12. import android.widget.ToggleButton;
  13.  
  14. public class Washroom extends AppCompatActivity {
  15. ToggleButton w1lt,geyser;
  16. Button washroom2;
  17. Intent intent;
  18. Thread thread;
  19. @Override
  20. protected void onCreate(Bundle savedInstanceState) {
  21. super.onCreate(savedInstanceState);
  22. setContentView(R.layout.washroom);
  23. w1lt = findViewById(R.id.w1lightt);
  24. washroom2 = findViewById(R.id.w2);
  25. washroom2.setOnClickListener(new View.OnClickListener() {
  26. @Override
  27. public void onClick(View v) {
  28.  
  29. startActivity(new Intent(Washroom.this, Washroom2.class));
  30. }
  31. });
  32.  
  33. /* geyser = findViewById(R.id.w1geyser);
  34. geyser.setOnClickListener(new View.OnClickListener() {
  35. @Override
  36. public void onClick(View v) {
  37.  
  38. startActivity(new Intent(Washroom.this, Geyser.class));
  39. }
  40. });*/
  41. geyser = findViewById(R.id.geyser);
  42. geyser.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  43. @Override
  44. public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  45. if (isChecked) {
  46. Url_run xyz = new Url_run("http://192.168.0.14/gayseron");
  47. thread = new Thread(xyz);
  48. thread.start();
  49. Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://192.168.0.14/gayseron"));
  50.  
  51. //startActivity(intent);
  52. } else {
  53. Url_run xyz = new Url_run("http://192.168.0.14/gayseroff");
  54. thread = new Thread(xyz);
  55. thread.start();
  56. Intent intent1 = new Intent(Intent.ACTION_VIEW, Uri.parse("http://192.168.0.14/gayseroff"));
  57.  
  58. //startActivity(intent1);
  59. }
  60.  
  61. }
  62. });
  63. w1lt.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
  64. @Override
  65. public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
  66. if (isChecked) {
  67. Url_run xyz = new Url_run("http://192.168.0.15/wr1_lighton");
  68. thread = new Thread(xyz);
  69. thread.start();
  70. Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://192.168.0.15/wr1_lighton"));
  71.  
  72. } else {
  73. Url_run xyz = new Url_run("http://192.168.0.15/wr1_lightoff");
  74. thread = new Thread(xyz);
  75. thread.start();
  76. Intent intent1 = new Intent(Intent.ACTION_VIEW, Uri.parse("http://192.168.0.15/wr1_lightoff"));
  77.  
  78. }
  79.  
  80. }
  81. });
  82. }
  83.  
  84. }
  85.  
  86. ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  87.  
  88. #### Xml code for Common_washroom
  89.  
  90.  
  91. <?xml version="1.0" encoding="utf-8"?>
  92. <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  93. xmlns:app="http://schemas.android.com/apk/res-auto"
  94. xmlns:tools="http://schemas.android.com/tools"
  95. android:layout_width="match_parent"
  96. android:layout_height="match_parent"
  97. android:background="@drawable/washroom"
  98. android:padding="10sp"
  99. >
  100.  
  101. <LinearLayout
  102. android:layout_width="match_parent"
  103. android:layout_height="150sp"
  104. android:layout_marginTop="20sp"
  105. android:id="@+id/wl1"
  106. android:background="@drawable/headings"
  107. android:layout_margin="10sp">
  108.  
  109. <TextView
  110. android:layout_width="fill_parent"
  111. android:layout_height="match_parent"
  112. android:text="Washroom Devices"
  113. android:textAlignment="center"
  114. android:textSize="30sp"
  115. android:layout_margin="20sp"
  116. android:id="@+id/washroomdevice"
  117. android:textColor="#f8f9f8"
  118. android:gravity="center"
  119. android:drawableLeft="@drawable/device"
  120. />
  121. </LinearLayout>
  122.  
  123. <LinearLayout
  124. android:layout_width="match_parent"
  125. android:layout_height="match_parent"
  126. android:layout_marginBottom="10sp"
  127. android:layout_weight="0.4"
  128. android:orientation="vertical"
  129. android:paddingTop="20sp"
  130. android:layout_below="@id/wl1"
  131. android:gravity="center">
  132.  
  133. <RelativeLayout
  134. android:layout_width="match_parent"
  135. android:layout_height="80sp"
  136. android:layout_margin="10sp"
  137. android:orientation="horizontal"
  138. android:background="@drawable/oval">
  139. <TextView
  140. android:layout_width="match_parent"
  141. android:layout_height="match_parent"
  142. android:layout_marginLeft="10sp"
  143. android:textSize="25sp"
  144. android:textColor="#3c0660"
  145. android:text=" Light"
  146. android:id="@+id/Washroom1lighttext"
  147. android:gravity="left"
  148. android:drawableLeft="@drawable/light"
  149. android:padding="10sp"
  150. android:layout_marginTop="10sp"/>
  151.  
  152. <ToggleButton
  153. android:layout_width="60sp"
  154. android:layout_height="wrap_content"
  155. android:id="@+id/w1lightt"
  156. android:background="@drawable/headings"
  157. android:textSize="20sp"
  158. android:textColor="#ffffff"
  159. android:layout_alignParentRight="true"
  160. android:layout_marginTop="10sp"
  161. android:layout_marginRight="30sp"
  162. android:layout_marginBottom="10sp"/>
  163. </RelativeLayout>
  164. <!--<Button
  165. android:id="@+id/w1geyser"
  166. android:layout_width="match_parent"
  167. android:layout_height="80sp"
  168. android:background="@drawable/oval"
  169. android:drawableLeft="@drawable/geyser"
  170. android:text="Geyser"
  171. android:textColor="@color/text_color"
  172. android:textSize="25sp"
  173. android:paddingLeft="30sp"
  174. android:layout_margin="10sp"/>-->
  175.  
  176. <RelativeLayout
  177. android:layout_width="match_parent"
  178. android:layout_height="70sp"
  179. android:layout_margin="20sp"
  180. android:orientation="horizontal"
  181. android:background="@drawable/oval"
  182. android:layout_gravity="center">
  183. <TextView
  184. android:layout_width="match_parent"
  185. android:layout_height="match_parent"
  186. android:layout_marginLeft="10sp"
  187. android:textSize="25sp"
  188. android:textColor="#3c0660"
  189. android:text=" Geyser"
  190. android:id="@+id/geysertext"
  191. android:gravity="left"
  192. android:drawableLeft="@drawable/geyser"
  193. android:padding="10sp"/>
  194.  
  195. <ToggleButton
  196. android:layout_width="60sp"
  197. android:layout_height="wrap_content"
  198. android:id="@+id/geyser"
  199. android:background="@drawable/headings"
  200. android:textSize="20sp"
  201. android:textColor="#ffffff"
  202. android:layout_alignParentRight="true"
  203. android:layout_marginTop="10sp"
  204. android:layout_marginRight="30sp"
  205. android:layout_marginBottom="10sp"/>
  206. </RelativeLayout>
  207. <Button
  208. android:id="@+id/w2"
  209. android:layout_width="match_parent"
  210. android:layout_height="80sp"
  211. android:background="@drawable/oval"
  212. android:drawableLeft="@drawable/toilet32"
  213. android:text="WashRoom 2"
  214. android:textColor="#3c0660"
  215. android:textSize="25sp"
  216. android:paddingLeft="40sp"
  217. android:layout_margin="10sp"/>
  218.  
  219. </LinearLayout>
  220.  
  221. </RelativeLayout>
Add Comment
Please, Sign In to add comment