Skip to content

Commit

Permalink
Add bluetooth operator page
Browse files Browse the repository at this point in the history
  • Loading branch information
Janady committed Oct 14, 2019
1 parent 3c2e4c4 commit d2ed3f5
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 5 deletions.
12 changes: 9 additions & 3 deletions app/src/main/java/com/janady/base/JBaseSegmentFragment.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ public void onClick(View v) {
}
});

mTopBar.setTitle("添加设备");
mTopBar.setTitle(title());
}

@Override
protected View onCreateView() {
View rootView = LayoutInflater.from(getActivity()).inflate(R.layout.jfragment_tab_viewpager_layout, null);
Expand Down Expand Up @@ -98,15 +99,17 @@ private void initTabAndPager() {
@Override
public void onTabSelected(int index) {
mTabSegment.hideSignCountView(index);
tabSelected(index);
}

@Override
public void onTabUnselected(int index) {

tabUnSelected(index);
}

@Override
public void onTabReselected(int index) {
tabSelected(index);
mTabSegment.hideSignCountView(index);
}

Expand All @@ -117,7 +120,6 @@ public void onDoubleTap(int index) {
});
}

protected abstract List<View> createPageViews();
private View getPageView(int position) {
Integer page = new Integer(position);
View view = mPageMap.get(new Integer(position));
Expand All @@ -128,4 +130,8 @@ private View getPageView(int position) {
return view;
}

protected abstract String title();
protected abstract List<View> createPageViews();
protected abstract void tabSelected(int index);
protected abstract void tabUnSelected(int index);
}
49 changes: 49 additions & 0 deletions app/src/main/java/com/janady/device/BluetoothOperatorFragment.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.janady.device;

import android.view.LayoutInflater;
import android.view.View;

import com.example.funsdkdemo.MyApplication;
import com.example.funsdkdemo.R;
import com.janady.base.JBaseSegmentFragment;
import com.janady.database.model.Bluetooth;

import java.util.ArrayList;
import java.util.List;

public class BluetoothOperatorFragment extends JBaseSegmentFragment implements View.OnClickListener {
@Override
protected String title() {
return "蓝牙控制";
}

@Override
protected List<View> createPageViews() {
List<View> viewList = new ArrayList<>();
ArrayList<Bluetooth> blists = MyApplication.liteOrm.query(Bluetooth.class);
for (Bluetooth bluetooth : blists) {
View view = LayoutInflater.from(getActivity()).inflate(R.layout.jbluetooth_operator_layout, null);
view.findViewById(R.id.open).setOnClickListener(this);
view.findViewById(R.id.close).setOnClickListener(this);
view.findViewById(R.id.lock).setOnClickListener(this);
view.findViewById(R.id.unlock).setOnClickListener(this);
viewList.add(view);
}
return viewList;
}

@Override
protected void tabSelected(int index) {

}

@Override
protected void tabUnSelected(int index) {

}

@Override
public void onClick(View v) {

}
}
5 changes: 3 additions & 2 deletions app/src/main/java/com/janady/manager/DataManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.janady.device.BluetoothEditFragment;
import com.janady.device.BluetoothListFragment;
import com.janady.device.BluetoothLockFragment;
import com.janady.device.BluetoothOperatorFragment;
import com.janady.device.CameraListFragment;
import com.janady.device.DeviceCameraFragment;
import com.janady.device.DoorEditFragment;
Expand Down Expand Up @@ -82,11 +83,11 @@ public List<MainItemDescription> getDescriptions() {
}

//MainItemDescription bleDescription = new MainItemDescription(BluetoothLockFragment.class, "蓝牙门禁", R.drawable.ic_bluetooth, MainItemDescription.DeviceType.BLE);
MainItemDescription bleDescription = new MainItemDescription(BluetoothLockFragment.class, "蓝牙门禁", R.drawable.ic_bluetooth_black_24dp, MainItemDescription.DeviceType.BLE);
MainItemDescription bleDescription = new MainItemDescription(BluetoothOperatorFragment.class, "蓝牙门禁", R.drawable.ic_bluetooth_black_24dp, MainItemDescription.DeviceType.BLE);
ArrayList<Bluetooth> blists = MyApplication.liteOrm.query(Bluetooth.class);
List<Object> bitems = new ArrayList<>();
for (Bluetooth bluetooth : blists) {
ItemDescription itemDescription = new ItemDescription(BluetoothLockFragment.class, bluetooth.name, R.drawable.icon_check);
ItemDescription itemDescription = new ItemDescription(BluetoothOperatorFragment.class, bluetooth.name, R.drawable.icon_check);
itemDescription.setItem(bluetooth);
bitems.add(itemDescription);
}
Expand Down
94 changes: 94 additions & 0 deletions app/src/main/res/layout/jbluetooth_operator_layout.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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">

<RelativeLayout style="@style/button_wrapper_style">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_centerInParent="true">

<com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
android:id="@+id/open"
android:layout_width="60dp"
android:layout_height="60dp"
android:gravity="center"
android:text=""
app:qmui_radiusTopLeft="8dp"/>

<com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
android:id="@+id/close"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginLeft="64dp"
android:gravity="center"
android:text=""
app:qmui_radiusTopRight="8dp"/>

<com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
android:id="@+id/lock"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginTop="64dp"
android:gravity="center"
android:text=""
app:qmui_radiusBottomLeft="8dp"/>

<com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
android:id="@+id/unlock"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginLeft="64dp"
android:layout_marginTop="64dp"
android:gravity="center"
android:text=""
app:qmui_radiusBottomRight="8dp"/>

<com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
android:id="@+id/connect"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginTop="128dp"
android:gravity="center"
android:text="连接"
app:qmui_radiusBottomRight="8dp"
tools:visibility="gone" />

<com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
android:id="@+id/disconnect"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginLeft="64dp"
android:layout_marginTop="128dp"
android:gravity="center"
android:text="断开"
app:qmui_radiusBottomRight="8dp"
tools:visibility="gone" />

<com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
android:id="@+id/password"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginTop="192dp"
android:gravity="center"
android:text="修改密码"
app:qmui_radiusBottomRight="8dp"
tools:visibility="gone" />

<com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
android:id="@+id/scan"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_marginLeft="64dp"
android:layout_marginTop="192dp"
android:gravity="center"
android:text="搜索设备"
app:qmui_radiusBottomRight="8dp"
tools:visibility="gone" />
</FrameLayout>
</RelativeLayout>
</LinearLayout>

0 comments on commit d2ed3f5

Please sign in to comment.