Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ##### Java code for Common_washroom
- package com.example.shikhadwivedi.homeautomation;
- import android.content.Intent;
- import android.net.Uri;
- import android.os.Bundle;
- import android.support.v7.app.AppCompatActivity;
- import android.view.View;
- import android.widget.Button;
- import android.widget.CompoundButton;
- import android.widget.ToggleButton;
- public class Washroom extends AppCompatActivity {
- ToggleButton w1lt,geyser;
- Button washroom2;
- Intent intent;
- Thread thread;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.washroom);
- w1lt = findViewById(R.id.w1lightt);
- washroom2 = findViewById(R.id.w2);
- washroom2.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- startActivity(new Intent(Washroom.this, Washroom2.class));
- }
- });
- /* geyser = findViewById(R.id.w1geyser);
- geyser.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- startActivity(new Intent(Washroom.this, Geyser.class));
- }
- });*/
- geyser = findViewById(R.id.geyser);
- geyser.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if (isChecked) {
- Url_run xyz = new Url_run("http://192.168.0.14/gayseron");
- thread = new Thread(xyz);
- thread.start();
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://192.168.0.14/gayseron"));
- //startActivity(intent);
- } else {
- Url_run xyz = new Url_run("http://192.168.0.14/gayseroff");
- thread = new Thread(xyz);
- thread.start();
- Intent intent1 = new Intent(Intent.ACTION_VIEW, Uri.parse("http://192.168.0.14/gayseroff"));
- //startActivity(intent1);
- }
- }
- });
- w1lt.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
- @Override
- public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
- if (isChecked) {
- Url_run xyz = new Url_run("http://192.168.0.15/wr1_lighton");
- thread = new Thread(xyz);
- thread.start();
- Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://192.168.0.15/wr1_lighton"));
- } else {
- Url_run xyz = new Url_run("http://192.168.0.15/wr1_lightoff");
- thread = new Thread(xyz);
- thread.start();
- Intent intent1 = new Intent(Intent.ACTION_VIEW, Uri.parse("http://192.168.0.15/wr1_lightoff"));
- }
- }
- });
- }
- }
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- #### Xml code for Common_washroom
- <?xml version="1.0" encoding="utf-8"?>
- <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:background="@drawable/washroom"
- android:padding="10sp"
- >
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="150sp"
- android:layout_marginTop="20sp"
- android:id="@+id/wl1"
- android:background="@drawable/headings"
- android:layout_margin="10sp">
- <TextView
- android:layout_width="fill_parent"
- android:layout_height="match_parent"
- android:text="Washroom Devices"
- android:textAlignment="center"
- android:textSize="30sp"
- android:layout_margin="20sp"
- android:id="@+id/washroomdevice"
- android:textColor="#f8f9f8"
- android:gravity="center"
- android:drawableLeft="@drawable/device"
- />
- </LinearLayout>
- <LinearLayout
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_marginBottom="10sp"
- android:layout_weight="0.4"
- android:orientation="vertical"
- android:paddingTop="20sp"
- android:layout_below="@id/wl1"
- android:gravity="center">
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="80sp"
- android:layout_margin="10sp"
- android:orientation="horizontal"
- android:background="@drawable/oval">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_marginLeft="10sp"
- android:textSize="25sp"
- android:textColor="#3c0660"
- android:text=" Light"
- android:id="@+id/Washroom1lighttext"
- android:gravity="left"
- android:drawableLeft="@drawable/light"
- android:padding="10sp"
- android:layout_marginTop="10sp"/>
- <ToggleButton
- android:layout_width="60sp"
- android:layout_height="wrap_content"
- android:id="@+id/w1lightt"
- android:background="@drawable/headings"
- android:textSize="20sp"
- android:textColor="#ffffff"
- android:layout_alignParentRight="true"
- android:layout_marginTop="10sp"
- android:layout_marginRight="30sp"
- android:layout_marginBottom="10sp"/>
- </RelativeLayout>
- <!--<Button
- android:id="@+id/w1geyser"
- android:layout_width="match_parent"
- android:layout_height="80sp"
- android:background="@drawable/oval"
- android:drawableLeft="@drawable/geyser"
- android:text="Geyser"
- android:textColor="@color/text_color"
- android:textSize="25sp"
- android:paddingLeft="30sp"
- android:layout_margin="10sp"/>-->
- <RelativeLayout
- android:layout_width="match_parent"
- android:layout_height="70sp"
- android:layout_margin="20sp"
- android:orientation="horizontal"
- android:background="@drawable/oval"
- android:layout_gravity="center">
- <TextView
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- android:layout_marginLeft="10sp"
- android:textSize="25sp"
- android:textColor="#3c0660"
- android:text=" Geyser"
- android:id="@+id/geysertext"
- android:gravity="left"
- android:drawableLeft="@drawable/geyser"
- android:padding="10sp"/>
- <ToggleButton
- android:layout_width="60sp"
- android:layout_height="wrap_content"
- android:id="@+id/geyser"
- android:background="@drawable/headings"
- android:textSize="20sp"
- android:textColor="#ffffff"
- android:layout_alignParentRight="true"
- android:layout_marginTop="10sp"
- android:layout_marginRight="30sp"
- android:layout_marginBottom="10sp"/>
- </RelativeLayout>
- <Button
- android:id="@+id/w2"
- android:layout_width="match_parent"
- android:layout_height="80sp"
- android:background="@drawable/oval"
- android:drawableLeft="@drawable/toilet32"
- android:text="WashRoom 2"
- android:textColor="#3c0660"
- android:textSize="25sp"
- android:paddingLeft="40sp"
- android:layout_margin="10sp"/>
- </LinearLayout>
- </RelativeLayout>
Add Comment
Please, Sign In to add comment