Commit 599101a5b680daf86fb26846f5731fd17637f218

Authored by wugian
1 parent 830727b9

switch contorl demo upload

@@ -10,12 +10,18 @@ @@ -10,12 +10,18 @@
10 android:label="@string/app_name" 10 android:label="@string/app_name"
11 android:supportsRtl="true" 11 android:supportsRtl="true"
12 android:theme="@style/AppTheme"> 12 android:theme="@style/AppTheme">
13 - <activity android:name=".MainActivity">  
14 - <!-- <intent-filter> 13 + <activity
  14 + android:name=".MainActivity"
  15 + android:label="@string/title_activity_main"
  16 + android:theme="@style/AppTheme.NoActionBar">
  17 +
  18 + <!--
  19 + <intent-filter>
15 <action android:name="android.intent.action.MAIN"/> 20 <action android:name="android.intent.action.MAIN"/>
16 21
17 <category android:name="android.intent.category.LAUNCHER"/> 22 <category android:name="android.intent.category.LAUNCHER"/>
18 - </intent-filter>--> 23 + </intent-filter>
  24 + -->
19 </activity> 25 </activity>
20 <activity 26 <activity
21 android:name=".SwitchControlActivity" 27 android:name=".SwitchControlActivity"
  1 +package com.qnbar.switchcontrol;
  2 +
  3 +import android.os.Bundle;
  4 +import android.support.design.widget.FloatingActionButton;
  5 +import android.support.design.widget.Snackbar;
  6 +import android.support.v7.app.AppCompatActivity;
  7 +import android.support.v7.widget.Toolbar;
  8 +import android.view.View;
  9 +
  10 +public class MainActivity extends AppCompatActivity {
  11 +
  12 + @Override
  13 + protected void onCreate(Bundle savedInstanceState) {
  14 + super.onCreate(savedInstanceState);
  15 + setContentView(R.layout.activity_main);
  16 + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  17 + setSupportActionBar(toolbar);
  18 +
  19 + FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
  20 + fab.setOnClickListener(new View.OnClickListener() {
  21 + @Override
  22 + public void onClick(View view) {
  23 + Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
  24 + .setAction("Action", null).show();
  25 + }
  26 + });
  27 + }
  28 +
  29 +}
@@ -5,6 +5,7 @@ import android.os.Bundle; @@ -5,6 +5,7 @@ import android.os.Bundle;
5 import android.support.v7.app.AppCompatActivity; 5 import android.support.v7.app.AppCompatActivity;
6 import android.support.v7.widget.GridLayoutManager; 6 import android.support.v7.widget.GridLayoutManager;
7 import android.support.v7.widget.RecyclerView; 7 import android.support.v7.widget.RecyclerView;
  8 +import android.support.v7.widget.Toolbar;
8 import android.util.Log; 9 import android.util.Log;
9 import android.view.View; 10 import android.view.View;
10 import android.widget.Toast; 11 import android.widget.Toast;
@@ -28,7 +29,9 @@ public class SwitchControlActivity extends AppCompatActivity { @@ -28,7 +29,9 @@ public class SwitchControlActivity extends AppCompatActivity {
28 @Override 29 @Override
29 protected void onCreate(Bundle savedInstanceState) { 30 protected void onCreate(Bundle savedInstanceState) {
30 super.onCreate(savedInstanceState); 31 super.onCreate(savedInstanceState);
31 - setContentView(R.layout.activity_switch_control); 32 + setContentView(R.layout.activity_main);
  33 + Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
  34 + setSupportActionBar(toolbar);
32 EventBus.getDefault().register(this); 35 EventBus.getDefault().register(this);
33 //EventBus,List of Hub,List of Lights 36 //EventBus,List of Hub,List of Lights
34 //TODO save DeviceNum,SubDeviceNum 37 //TODO save DeviceNum,SubDeviceNum
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<android.support.design.widget.CoordinatorLayout
  3 + xmlns:android="http://schemas.android.com/apk/res/android"
  4 + xmlns:app="http://schemas.android.com/apk/res-auto"
  5 + xmlns:tools="http://schemas.android.com/tools"
  6 + android:layout_width="match_parent"
  7 + android:layout_height="match_parent"
  8 + tools:context="com.qnbar.switchcontrol.MainActivity">
  9 +
  10 + <android.support.design.widget.AppBarLayout
  11 + android:layout_height="wrap_content"
  12 + android:layout_width="match_parent"
  13 + android:theme="@style/AppTheme.AppBarOverlay">
  14 +
  15 + <android.support.v7.widget.Toolbar
  16 + android:id="@+id/toolbar"
  17 + android:layout_width="match_parent"
  18 + android:layout_height="?attr/actionBarSize"
  19 + android:background="?attr/colorPrimary"
  20 + app:popupTheme="@style/AppTheme.PopupOverlay"/>
  21 +
  22 + </android.support.design.widget.AppBarLayout>
  23 +
  24 + <include layout="@layout/content_main"/>
  25 +
  26 + <android.support.design.widget.FloatingActionButton
  27 + android:id="@+id/fab"
  28 + android:layout_width="wrap_content"
  29 + android:layout_height="wrap_content"
  30 + android:layout_gravity="bottom|end"
  31 + android:layout_margin="@dimen/fab_margin"
  32 + app:srcCompat="@android:drawable/ic_dialog_email"/>
  33 +
  34 +</android.support.design.widget.CoordinatorLayout>
@@ -12,7 +12,6 @@ @@ -12,7 +12,6 @@
12 tools:showIn="@layout/activity_switch_control" 12 tools:showIn="@layout/activity_switch_control"
13 tools:context="com.qnbar.switchcontrol.SwitchControlActivity"> 13 tools:context="com.qnbar.switchcontrol.SwitchControlActivity">
14 14
15 -  
16 <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal"> 15 <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal">
17 16
18 <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="扫描主机" 17 <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="扫描主机"
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<LinearLayout
  3 + xmlns:android="http://schemas.android.com/apk/res/android"
  4 + xmlns:tools="http://schemas.android.com/tools"
  5 + xmlns:app="http://schemas.android.com/apk/res-auto"
  6 + android:background="#ac0097ca"
  7 + android:layout_width="match_parent"
  8 + android:layout_height="match_parent"
  9 + android:padding="16dp"
  10 + android:orientation="vertical"
  11 + app:layout_behavior="@string/appbar_scrolling_view_behavior"
  12 + tools:showIn="@layout/activity_switch_control"
  13 + tools:context="com.qnbar.switchcontrol.SwitchControlActivity">
  14 +
  15 + <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="horizontal">
  16 +
  17 + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="扫描主机"
  18 + android:onClick="scanHubs"/>
  19 +
  20 + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="开始添加"
  21 + android:onClick="startAdd"/>
  22 +
  23 + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="结束添加"
  24 + android:onClick="stopAdd"/>
  25 +
  26 + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="重设置密码"
  27 + android:onClick="resetPwd"/>
  28 +
  29 + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="设置路由信息"
  30 + android:onClick="setLinkMsg"/>
  31 +
  32 + <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="获取路由信息"
  33 + android:onClick="getLinkStatus"/>
  34 +
  35 +
  36 + </LinearLayout>
  37 + <TextView android:layout_width="wrap_content"
  38 + android:layout_height="wrap_content"
  39 + android:text="控制主机"
  40 + android:textSize="20sp"/>
  41 +
  42 + <android.support.v7.widget.RecyclerView
  43 + android:id="@+id/hubsRv"
  44 + android:layout_marginTop="15dp"
  45 + android:layout_width="match_parent"
  46 + android:layout_height="wrap_content"
  47 + android:layout_alignParentStart="true"
  48 + android:layout_below="@+id/button"/>
  49 +
  50 + <TextView android:layout_width="wrap_content"
  51 + android:layout_height="wrap_content"
  52 + android:layout_marginTop="30dp"
  53 + android:text="开关"
  54 + android:textSize="20sp"/>
  55 +
  56 + <android.support.v7.widget.RecyclerView
  57 + android:id="@+id/switchRv"
  58 + android:layout_marginTop="15dp"
  59 + android:layout_width="match_parent"
  60 + android:layout_height="wrap_content"
  61 + android:layout_alignParentStart="true"
  62 + android:layout_below="@+id/button"/>
  63 +
  64 +</LinearLayout>
1 <resources> 1 <resources>
2 <string name="app_name">SwitchControl</string> 2 <string name="app_name">SwitchControl</string>
3 <string name="title_activity_switch_control">SwitchControlActivity</string> 3 <string name="title_activity_switch_control">SwitchControlActivity</string>
  4 + <string name="title_activity_main">MainActivity</string>
4 </resources> 5 </resources>
Please register or login to post a comment