Skip to content

Commit

Permalink
add:zTC1显示功率
Browse files Browse the repository at this point in the history
add:尝试增加ota进度显示功能
  • Loading branch information
a2633063 committed Mar 29, 2019
1 parent 86985f2 commit b3cb106
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 4 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ android {
applicationId "com.zyc.zcontrol"
minSdkVersion 19
targetSdkVersion 28
versionCode 5
versionName "0.5"
versionCode 6
versionName "0.6"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ public class TC1Fragment extends Fragment {
//region 控件
final private int PLUG_COUNT=6;
ToggleButton tbtn_all;
TextView tv_power;
ToggleButton tbtn_main_button[] = new ToggleButton[PLUG_COUNT];
TextView tv_main_button[] = new TextView[PLUG_COUNT];
//endregion

TextView log;

String device_mac = null;
Expand Down Expand Up @@ -123,6 +123,7 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
//region 控件初始化

tbtn_all = view.findViewById(R.id.tbtn_all);
tv_power = view.findViewById(R.id.tv_power);
tbtn_main_button[0] = view.findViewById(R.id.tbtn_main_button1);
tbtn_main_button[1] = view.findViewById(R.id.tbtn_main_button2);
tbtn_main_button[2] = view.findViewById(R.id.tbtn_main_button3);
Expand Down Expand Up @@ -266,6 +267,12 @@ void Receive(String topic, String message) {
if (jsonObject.has("setting")) jsonSetting = jsonObject.getJSONObject("setting");
if (mac == null || !mac.equals(device_mac)) return;

if (jsonObject.has("power")) {
String power = jsonObject.getString("power");
Log.d(Tag,"power:"+power);
tv_power.setText(power+"W");
}

//region 解析plug
for (int plug_id = 0; plug_id < 6; plug_id++) {
if (!jsonObject.has("plug_" + plug_id)) continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,10 @@ void Receive(String topic, String message) {
} else {
if (ota_flag) {
//todo 显示更新进度

if(pd!=null && pd.isShowing())
pd.setMessage("正在获取最新固件版本,请稍后....\n"+"进度:"+ota_progress+"%");
// Toast.makeText(getActivity(), "ota进度:"+ota_progress+"%", Toast.LENGTH_SHORT).show();
}
}

Expand Down
27 changes: 26 additions & 1 deletion app/src/main/res/layout/fragment_tc1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,37 @@
android:id="@+id/tbtn_all"
style="@style/TC1SwitchStyle"
app:layout_constraintBottom_toTopOf="@+id/tbtn_main_button2"
app:layout_constraintEnd_toEndOf="@+id/tbtn_main_button3"
app:layout_constraintEnd_toStartOf="@+id/ll_power"
app:layout_constraintStart_toStartOf="@+id/tbtn_main_button1"
app:layout_constraintTop_toTopOf="parent"
app:layout_goneMarginBottom="8dp" />


<LinearLayout
android:id="@+id/ll_power"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintStart_toEndOf="@+id/tbtn_all"
app:layout_constraintTop_toTopOf="@+id/tbtn_all"
android:layout_gravity="center"
app:layout_constraintEnd_toEndOf="@+id/tbtn_main_button3"
app:layout_constraintBottom_toBottomOf="@+id/tv_switch_all"
android:orientation="vertical">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="当前功率"/>

<TextView
android:id="@+id/tv_power"
android:gravity="center"
android:layout_width="match_parent"
android:textSize="35dp"
android:layout_height="wrap_content"
android:text="----"/>
</LinearLayout>

<ToggleButton
android:id="@+id/tbtn_main_button1"
style="@style/TC1SwitchStyle"
Expand Down

0 comments on commit b3cb106

Please sign in to comment.