From 2eb6e4732e35c5cfa656075ab7e3d75cc6b7ffbc Mon Sep 17 00:00:00 2001
From: kerwincui <164770707@qq.com>
Date: Sat, 19 Jun 2021 17:16:47 +0800
Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90Android=E7=AB=AF=E5=BC=80?=
=?UTF-8?q?=E5=8F=91?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
android/app/build.gradle | 4 +
android/app/src/main/assets/tips.json | 10 +-
.../src/main/java/com/kerwin/wumei/MyApp.java | 19 +-
.../wumei/activity/AddDeviceActivity.java | 90 ++--
.../kerwin/wumei/activity/LoginActivity.java | 1 +
.../kerwin/wumei/activity/MainActivity.java | 116 +++--
.../kerwin/wumei/activity/SplashActivity.java | 19 +-
.../adapter/entity/EspTouchViewModel.java | 3 +-
.../kerwin/wumei/adapter/entity/NewInfo.java | 16 -
.../wumei/core/http/api/ApiService.java | 2 +-
.../java/com/kerwin/wumei/entity/Dept.java | 121 +++++
.../com/kerwin/wumei/entity/DictData.java | 65 +++
.../com/kerwin/wumei/entity/IotCategory.java | 39 ++
.../com/kerwin/wumei/entity/IotDevice.java | 126 ++++++
.../com/kerwin/wumei/entity/IotDeviceSet.java | 282 ++++++++++++
.../kerwin/wumei/entity/IotDeviceStatus.java | 234 ++++++++++
.../com/kerwin/wumei/entity/IotGroup.java | 63 +++
.../java/com/kerwin/wumei/entity/Roles.java | 119 +++++
.../java/com/kerwin/wumei/entity/User.java | 162 +++++++
.../kerwin/wumei/entity/bo/CaptureImage.java | 33 ++
.../kerwin/wumei/entity/vo/IotDeviceVo.java | 222 ++++++++++
.../kerwin/wumei/fragment/AboutFragment.java | 41 +-
.../wumei/fragment/FeedbackFragment.java | 10 +
.../kerwin/wumei/fragment/LoginFragment.java | 190 ++++----
.../wumei/fragment/MessageFragment.java | 31 +-
.../wumei/fragment/SettingsFragment.java | 50 ++-
.../fragment/device/AddDeviceFragment.java | 180 +++++++-
.../fragment/device/AddDeviceTwoFragment.java | 10 +
.../fragment/device/DeviceDetailFragment.java | 78 ++++
.../fragment/device/DeviceEditFragment.java | 238 ++++++++++
.../wumei/fragment/device/DeviceFragment.java | 264 +++++++++--
.../fragment/device/DeviceSetFragment.java | 268 +++++++++++
.../fragment/device/DeviceStatusFragment.java | 307 +++++++++++++
.../FragmentStateViewPager2Adapter.java | 10 +
.../wumei/fragment/device/GroupFragment.java | 10 +
.../wumei/fragment/device/SceneFragment.java | 147 +++++-
.../fragment/device/ShareDeviceFragment.java | 10 +
.../fragment/device/SimpleTabFragment.java | 418 ++++++++++++------
.../wumei/fragment/news/HomePageFragment.java | 122 +++++
.../wumei/fragment/news/NewsFragment.java | 10 +
.../fragment/profile/AccountFragment.java | 133 ++++++
.../fragment/profile/ProfileFragment.java | 96 +++-
.../http/callback/NoTipRequestCallBack.java | 55 +++
.../http/callback/TipRequestCallBack.java | 60 +++
.../interceptor/CustomLoggingInterceptor.java | 100 +++++
.../http/request/CaptchaImageApiResult.java | 61 +++
.../wumei/http/request/CustomApiResult.java | 97 ++++
.../wumei/http/request/CustomGetRequest.java | 53 +++
.../wumei/http/request/ListApiResult.java | 52 +++
.../wumei/http/request/NoDataApiResult.java | 36 ++
.../wumei/http/request/TokenApiResult.java | 48 ++
.../wumei/http/request/UserInfoApiResult.java | 48 ++
.../subscriber/NoTipRequestSubscriber.java | 58 +++
.../http/subscriber/TipRequestSubscriber.java | 63 +++
.../kerwin/wumei/utils/DemoDataProvider.java | 2 +-
.../com/kerwin/wumei/utils/DialogUtils.java | 42 ++
.../wumei/utils/HProgressDialogUtils.java | 105 +++++
.../com/kerwin/wumei/utils/RouterUtils.java | 50 +++
.../kerwin/wumei/utils/SettingSPUtils.java | 65 +++
.../com/kerwin/wumei/utils/SettingUtils.java | 103 ++++-
.../com/kerwin/wumei/utils/TokenUtils.java | 8 +-
.../wumei/utils/sdkinit/XUpdateInit.java | 18 +-
.../kerwin/wumei/widget/GuideTipsDialog.java | 1 +
.../app/src/main/res/drawable-hdpi/alarm.png | Bin 0 -> 5665 bytes
.../src/main/res/drawable-hdpi/category.png | Bin 6520 -> 5129 bytes
.../app/src/main/res/drawable-hdpi/image.png | Bin 0 -> 4571 bytes
.../src/main/res/drawable-hdpi/light_on.png | Bin 0 -> 5541 bytes
.../app/src/main/res/drawable-hdpi/lock.png | Bin 0 -> 3370 bytes
.../app/src/main/res/drawable-hdpi/logo.png | Bin 3329 -> 2911 bytes
.../app/src/main/res/drawable-hdpi/radar.png | Bin 0 -> 7200 bytes
.../src/main/res/drawable-hdpi/radar_bg.png | Bin 0 -> 9148 bytes
.../app/src/main/res/drawable-hdpi/relay.png | Bin 0 -> 2705 bytes
.../app/src/main/res/drawable-hdpi/set.png | Bin 0 -> 17516 bytes
.../src/main/res/drawable-hdpi/switch_c.png | Bin 0 -> 7244 bytes
.../app/src/main/res/drawable-hdpi/title.png | Bin 0 -> 2734 bytes
.../app/src/main/res/drawable-hdpi/update.png | Bin 0 -> 6028 bytes
.../app/src/main/res/drawable-hdpi/user.png | Bin 0 -> 21499 bytes
.../app/src/main/res/drawable-hdpi/wifi_0.png | Bin 0 -> 6302 bytes
.../app/src/main/res/drawable-hdpi/wifi_1.png | Bin 0 -> 6360 bytes
.../app/src/main/res/drawable-hdpi/wifi_2.png | Bin 0 -> 6438 bytes
.../app/src/main/res/drawable-hdpi/wifi_3.png | Bin 0 -> 6562 bytes
.../app/src/main/res/drawable-hdpi/wifi_4.png | Bin 0 -> 6585 bytes
.../src/main/res/drawable/ic_default_head.xml | 2 +-
.../adapter_device_card_view_list_item.xml | 248 +++++++----
.../src/main/res/layout/dialog_guide_tips.xml | 6 +-
.../src/main/res/layout/fragment_about.xml | 55 ++-
.../src/main/res/layout/fragment_account.xml | 194 ++++++++
.../main/res/layout/fragment_add_device.xml | 177 ++++++--
.../res/layout/fragment_add_device_two.xml | 10 +
.../src/main/res/layout/fragment_device.xml | 10 +
.../res/layout/fragment_device_detail.xml | 41 ++
.../main/res/layout/fragment_device_edit.xml | 224 ++++++++++
.../main/res/layout/fragment_device_set.xml | 337 ++++++++++++++
.../res/layout/fragment_device_status.xml | 389 ++++++++++++++++
.../src/main/res/layout/fragment_group.xml | 11 +-
.../main/res/layout/fragment_home_page.xml | 53 +++
.../src/main/res/layout/fragment_login.xml | 122 ++---
.../src/main/res/layout/fragment_message.xml | 18 +-
.../src/main/res/layout/fragment_profile.xml | 74 ++--
.../src/main/res/layout/fragment_scene.xml | 240 +++++++++-
.../main/res/layout/fragment_share_device.xml | 11 +-
.../main/res/layout/fragment_simple_tab.xml | 14 -
android/app/src/main/res/menu/menu_drawer.xml | 16 +-
.../main/res/menu/menu_navigation_bottom.xml | 8 +-
android/app/src/main/res/values/dimens.xml | 30 +-
android/app/src/main/res/values/strings.xml | 22 +-
android/app/src/main/res/values/styles.xml | 8 +-
.../app/src/main/res/values/styles_widget.xml | 30 ++
android/app/x-library.gradle | 2 +-
109 files changed, 7018 insertions(+), 828 deletions(-)
create mode 100644 android/app/src/main/java/com/kerwin/wumei/entity/Dept.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/entity/DictData.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/entity/IotCategory.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/entity/IotDevice.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/entity/IotDeviceSet.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/entity/IotDeviceStatus.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/entity/IotGroup.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/entity/Roles.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/entity/User.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/entity/bo/CaptureImage.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/entity/vo/IotDeviceVo.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceDetailFragment.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceEditFragment.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceSetFragment.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceStatusFragment.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/fragment/news/HomePageFragment.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/fragment/profile/AccountFragment.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/http/callback/NoTipRequestCallBack.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/http/callback/TipRequestCallBack.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/http/interceptor/CustomLoggingInterceptor.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/http/request/CaptchaImageApiResult.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/http/request/CustomApiResult.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/http/request/CustomGetRequest.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/http/request/ListApiResult.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/http/request/NoDataApiResult.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/http/request/TokenApiResult.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/http/request/UserInfoApiResult.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/http/subscriber/NoTipRequestSubscriber.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/http/subscriber/TipRequestSubscriber.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/utils/DialogUtils.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/utils/HProgressDialogUtils.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/utils/RouterUtils.java
create mode 100644 android/app/src/main/java/com/kerwin/wumei/utils/SettingSPUtils.java
create mode 100644 android/app/src/main/res/drawable-hdpi/alarm.png
create mode 100644 android/app/src/main/res/drawable-hdpi/image.png
create mode 100644 android/app/src/main/res/drawable-hdpi/light_on.png
create mode 100644 android/app/src/main/res/drawable-hdpi/lock.png
create mode 100644 android/app/src/main/res/drawable-hdpi/radar.png
create mode 100644 android/app/src/main/res/drawable-hdpi/radar_bg.png
create mode 100644 android/app/src/main/res/drawable-hdpi/relay.png
create mode 100644 android/app/src/main/res/drawable-hdpi/set.png
create mode 100644 android/app/src/main/res/drawable-hdpi/switch_c.png
create mode 100644 android/app/src/main/res/drawable-hdpi/title.png
create mode 100644 android/app/src/main/res/drawable-hdpi/update.png
create mode 100644 android/app/src/main/res/drawable-hdpi/user.png
create mode 100644 android/app/src/main/res/drawable-hdpi/wifi_0.png
create mode 100644 android/app/src/main/res/drawable-hdpi/wifi_1.png
create mode 100644 android/app/src/main/res/drawable-hdpi/wifi_2.png
create mode 100644 android/app/src/main/res/drawable-hdpi/wifi_3.png
create mode 100644 android/app/src/main/res/drawable-hdpi/wifi_4.png
create mode 100644 android/app/src/main/res/layout/fragment_account.xml
create mode 100644 android/app/src/main/res/layout/fragment_device_detail.xml
create mode 100644 android/app/src/main/res/layout/fragment_device_edit.xml
create mode 100644 android/app/src/main/res/layout/fragment_device_set.xml
create mode 100644 android/app/src/main/res/layout/fragment_device_status.xml
create mode 100644 android/app/src/main/res/layout/fragment_home_page.xml
diff --git a/android/app/build.gradle b/android/app/build.gradle
index 603984ae..4653cf2e 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -122,6 +122,10 @@ dependencies {
//美团多渠道打包
implementation 'com.meituan.android.walle:library:1.1.6'
+
+ //rxutil2
+ implementation deps.rxbinding
+ implementation 'com.github.xuexiangjys:rxutil2:1.2.0'
}
//自动添加X-Library依赖
apply from: 'x-library.gradle'
diff --git a/android/app/src/main/assets/tips.json b/android/app/src/main/assets/tips.json
index 969a4c43..a85c1806 100644
--- a/android/app/src/main/assets/tips.json
+++ b/android/app/src/main/assets/tips.json
@@ -3,19 +3,15 @@
"Data": [
{
"title": "微信公众号",
- "content": "获取更多资讯内容,欢迎微信搜索公众号:「我的Android开源之旅」"
+ "content": "获取更多资讯内容,欢迎微信搜索公众号:「我的Android开源之旅」"
},
{
"title": "关于作者",
- "content": "点击关注作者,了解最新动态!
Github
\n知乎
\n掘金
简书
\n思否
\n哔哩哔哩
\n今日头条"
- },
- {
- "title": "赞助作者",
- "content": "你的打赏是我维护的动力,点击此处支持我吧!"
+ "content": "点击关注作者,了解最新动态!
Gitee
"
},
{
"title": "QQ交流群",
- "content": "XUI开源交流1号群
XUI开源交流2号群
AndroidGitHub开源交流群
XUpdate官方交流群"
+ "content": "物美智能交流群
"
}
]
}
diff --git a/android/app/src/main/java/com/kerwin/wumei/MyApp.java b/android/app/src/main/java/com/kerwin/wumei/MyApp.java
index 6cbf244e..4da8dfcd 100644
--- a/android/app/src/main/java/com/kerwin/wumei/MyApp.java
+++ b/android/app/src/main/java/com/kerwin/wumei/MyApp.java
@@ -14,14 +14,15 @@ import androidx.lifecycle.MutableLiveData;
import androidx.lifecycle.Observer;
import androidx.multidex.MultiDex;
-import com.kerwin.wumei.BuildConfig;
+import com.kerwin.wumei.http.interceptor.CustomLoggingInterceptor;
+import com.kerwin.wumei.utils.SettingSPUtils;
import com.kerwin.wumei.utils.sdkinit.ANRWatchDogInit;
import com.kerwin.wumei.utils.sdkinit.UMengInit;
import com.kerwin.wumei.utils.sdkinit.XBasicLibInit;
import com.kerwin.wumei.utils.sdkinit.XUpdateInit;
+import com.xuexiang.xhttp2.XHttpSDK;
-import java.util.HashMap;
-import java.util.Map;
+import static com.kerwin.wumei.utils.SettingUtils.getServeUrl;
/**
* @author xuexiang
@@ -60,7 +61,7 @@ public class MyApp extends Application {
public void onCreate() {
super.onCreate();
initLibs();
-
+ initHttp();
app = this;
mBroadcastData = new MutableLiveData<>();
IntentFilter filter = new IntentFilter(WifiManager.NETWORK_STATE_CHANGED_ACTION);
@@ -102,6 +103,16 @@ public class MyApp extends Application {
ANRWatchDogInit.init();
}
+ private void initHttp() {
+ XHttpSDK.init(this); //初始化网络请求框架,必须首先执行
+ XHttpSDK.setSuccessCode(200);
+ XHttpSDK.debug(); //需要调试的时候执行
+ XHttpSDK.debug(new CustomLoggingInterceptor()); //设置自定义的日志打印拦截器
+ XHttpSDK.setBaseUrl(getServeUrl()); //设置网络请求的基础地址
+// XHttpSDK.addInterceptor(new CustomDynamicInterceptor()); //设置动态参数添加拦截器
+// XHttpSDK.addInterceptor(new CustomExpiredInterceptor()); //请求失效校验拦截器
+ }
+
/**
* @return 当前app是否是调试开发模式
diff --git a/android/app/src/main/java/com/kerwin/wumei/activity/AddDeviceActivity.java b/android/app/src/main/java/com/kerwin/wumei/activity/AddDeviceActivity.java
index 9b89c562..c4ec7fdd 100644
--- a/android/app/src/main/java/com/kerwin/wumei/activity/AddDeviceActivity.java
+++ b/android/app/src/main/java/com/kerwin/wumei/activity/AddDeviceActivity.java
@@ -14,6 +14,7 @@ import android.net.wifi.WifiManager;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
+import android.os.Handler;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.SpannableStringBuilder;
@@ -35,9 +36,11 @@ import com.kerwin.wumei.R;
import com.kerwin.wumei.adapter.entity.EspTouchViewModel;
import com.kerwin.wumei.core.BaseActivity;
import com.kerwin.wumei.fragment.LoginFragment;
+import com.kerwin.wumei.fragment.device.AddDeviceFragment;
import com.kerwin.wumei.utils.NetUtils;
import com.xuexiang.xui.utils.KeyboardUtils;
import com.xuexiang.xui.utils.StatusBarUtils;
+import com.xuexiang.xui.widget.progress.CircleProgressView;
import com.xuexiang.xutil.display.Colors;
import java.lang.ref.WeakReference;
@@ -68,6 +71,10 @@ public class AddDeviceActivity extends BaseActivity {
return mViewModel;
}
+ private AddDeviceFragment addDeviceFragment;
+ private IEsptouchTask mEsptouchTask;
+
+
public void executeEsptouch() {
EspTouchViewModel viewModel = mViewModel;
// byte[] ssid = viewModel.ssidBytes == null ? ByteUtil.getBytesByString(viewModel.ssid): viewModel.ssidBytes;
@@ -77,7 +84,8 @@ public class AddDeviceActivity extends BaseActivity {
byte[] password = pwdStr == null ? null : ByteUtil.getBytesByString(pwdStr.toString());
byte[] bssid = TouchNetUtil.parseBssid2bytes(viewModel.bssid);
byte[] broadcast = {(byte) (mViewModel.packageModeGroup.getCheckedRadioButtonId() == R.id.packageBroadcast? 1 : 0)};
- byte[] deviceCount = "1".getBytes();
+ int count = mViewModel.xsbDeviceCount.getSelectedNumber();
+ byte[] deviceCount = String.valueOf(count).getBytes();
if (mTask != null) {
mTask.cancelEsptouch();
}
@@ -259,12 +267,19 @@ public class AddDeviceActivity extends BaseActivity {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
- public static class EsptouchAsyncTask4 extends AsyncTask> {
+ /**
+ * 中断配网任务
+ */
+ public void interruptEspTouchTask(){
+ if (mEsptouchTask != null) {
+ mEsptouchTask.interrupt();
+ }
+ }
+
+ public class EsptouchAsyncTask4 extends AsyncTask> {
private WeakReference mActivity;
private final Object mLock = new Object();
- private ProgressDialog mProgressDialog;
- private AlertDialog mResultDialog;
- private IEsptouchTask mEsptouchTask;
+
EsptouchAsyncTask4(AddDeviceActivity activity) {
mActivity = new WeakReference<>(activity);
@@ -272,12 +287,6 @@ public class AddDeviceActivity extends BaseActivity {
public void cancelEsptouch() {
cancel(true);
- if (mProgressDialog != null) {
- mProgressDialog.dismiss();
- }
- if (mResultDialog != null) {
- mResultDialog.dismiss();
- }
if (mEsptouchTask != null) {
mEsptouchTask.interrupt();
}
@@ -285,26 +294,8 @@ public class AddDeviceActivity extends BaseActivity {
@Override
protected void onPreExecute() {
- Activity activity = mActivity.get();
- mProgressDialog = new ProgressDialog(activity);
- mProgressDialog.setMessage(activity.getString(R.string.esptouch1_configuring_message));
- mProgressDialog.setCanceledOnTouchOutside(false);
- mProgressDialog.setOnCancelListener(dialog -> {
- synchronized (mLock) {
- if (mEsptouchTask != null) {
- mEsptouchTask.interrupt();
- }
- }
- });
- mProgressDialog.setButton(DialogInterface.BUTTON_NEGATIVE, activity.getText(android.R.string.cancel),
- (dialog, which) -> {
- synchronized (mLock) {
- if (mEsptouchTask != null) {
- mEsptouchTask.interrupt();
- }
- }
- });
- mProgressDialog.show();
+ addDeviceFragment = (AddDeviceFragment) getSupportFragmentManager().getFragments().get(0);
+ addDeviceFragment.beginCounter();
}
@Override
@@ -341,13 +332,9 @@ public class AddDeviceActivity extends BaseActivity {
protected void onPostExecute(List result) {
AddDeviceActivity activity = mActivity.get();
activity.mTask = null;
- mProgressDialog.dismiss();
if (result == null) {
- mResultDialog = new AlertDialog.Builder(activity)
- .setMessage(R.string.esptouch1_configure_result_failed_port)
- .setPositiveButton(android.R.string.ok, null)
- .show();
- mResultDialog.setCanceledOnTouchOutside(false);
+ addDeviceFragment.showMessage("建立 EspTouch 任务失败, 端口可能被其他程序占用",false);
+ addDeviceFragment.endCounter();
return;
}
@@ -356,31 +343,20 @@ public class AddDeviceActivity extends BaseActivity {
if (firstResult.isCancelled()) {
return;
}
- // the task received some results including cancelled while
- // executing before receiving enough results
if (!firstResult.isSuc()) {
- mResultDialog = new AlertDialog.Builder(activity)
- .setMessage(R.string.esptouch1_configure_result_failed)
- .setPositiveButton(android.R.string.ok, null)
- .show();
- mResultDialog.setCanceledOnTouchOutside(false);
+ addDeviceFragment.showMessage("配网失败",false);
+ addDeviceFragment.endCounter();
return;
}
- ArrayList resultMsgList = new ArrayList<>(result.size());
+ String message="";
for (IEsptouchResult touchResult : result) {
- String message = activity.getString(R.string.esptouch1_configure_result_success_item,
- touchResult.getBssid(), touchResult.getInetAddress().getHostAddress());
- resultMsgList.add(message);
+ message += "BSSID: "+touchResult.getBssid()+", 地址: "+touchResult.getInetAddress().getHostAddress()+"\n";
}
- CharSequence[] items = new CharSequence[resultMsgList.size()];
- mResultDialog = new AlertDialog.Builder(activity)
- .setTitle(R.string.esptouch1_configure_result_success)
- .setItems(resultMsgList.toArray(items), null)
- .setPositiveButton(android.R.string.ok, null)
- .show();
- mResultDialog.setCanceledOnTouchOutside(false);
+
+ addDeviceFragment.endCounter();
+ addDeviceFragment.showMessage("完成配网\n"+message,true);
}
}
@@ -391,6 +367,8 @@ public class AddDeviceActivity extends BaseActivity {
super.onCreate(savedInstanceState);
mWifiManager = (WifiManager) getApplicationContext().getSystemService(WIFI_SERVICE);
mViewModel = new EspTouchViewModel();
+
+
}
@Override
@@ -407,4 +385,6 @@ public class AddDeviceActivity extends BaseActivity {
public boolean onKeyDown(int keyCode, KeyEvent event) {
return KeyboardUtils.onDisableBackKeyDown(keyCode) && super.onKeyDown(keyCode, event);
}
+
+
}
diff --git a/android/app/src/main/java/com/kerwin/wumei/activity/LoginActivity.java b/android/app/src/main/java/com/kerwin/wumei/activity/LoginActivity.java
index bab79c1c..88d8c584 100644
--- a/android/app/src/main/java/com/kerwin/wumei/activity/LoginActivity.java
+++ b/android/app/src/main/java/com/kerwin/wumei/activity/LoginActivity.java
@@ -6,6 +6,7 @@ import android.view.KeyEvent;
import com.kerwin.wumei.core.BaseActivity;
import com.kerwin.wumei.fragment.LoginFragment;
+import com.kerwin.wumei.fragment.device.DeviceDetailFragment;
import com.xuexiang.xui.utils.KeyboardUtils;
import com.xuexiang.xui.utils.StatusBarUtils;
import com.xuexiang.xutil.display.Colors;
diff --git a/android/app/src/main/java/com/kerwin/wumei/activity/MainActivity.java b/android/app/src/main/java/com/kerwin/wumei/activity/MainActivity.java
index 9c05b48f..6f8bc317 100644
--- a/android/app/src/main/java/com/kerwin/wumei/activity/MainActivity.java
+++ b/android/app/src/main/java/com/kerwin/wumei/activity/MainActivity.java
@@ -51,6 +51,12 @@ import androidx.core.location.LocationManagerCompat;
import androidx.drawerlayout.widget.DrawerLayout;
import androidx.viewpager.widget.ViewPager;
+import com.kerwin.wumei.entity.User;
+import com.kerwin.wumei.fragment.profile.AccountFragment;
+import com.kerwin.wumei.http.callback.TipRequestCallBack;
+import com.kerwin.wumei.http.request.UserInfoApiResult;
+import com.kerwin.wumei.utils.sdkinit.XUpdateInit;
+
import com.espressif.iot.esptouch.EsptouchTask;
import com.espressif.iot.esptouch.IEsptouchResult;
import com.espressif.iot.esptouch.IEsptouchTask;
@@ -70,6 +76,7 @@ import com.kerwin.wumei.fragment.device.AddDeviceFragment;
import com.kerwin.wumei.fragment.device.GroupFragment;
import com.kerwin.wumei.fragment.device.SceneFragment;
import com.kerwin.wumei.fragment.device.ShareDeviceFragment;
+import com.kerwin.wumei.fragment.news.HomePageFragment;
import com.kerwin.wumei.fragment.news.NewsFragment;
import com.kerwin.wumei.fragment.profile.ProfileFragment;
import com.kerwin.wumei.fragment.device.DeviceFragment;
@@ -78,6 +85,9 @@ import com.kerwin.wumei.utils.Utils;
import com.kerwin.wumei.utils.XToastUtils;
import com.kerwin.wumei.widget.GuideTipsDialog;
import com.xuexiang.xaop.annotation.SingleClick;
+import com.xuexiang.xhttp2.XHttp;
+import com.xuexiang.xhttp2.callback.CallBackProxy;
+import com.xuexiang.xhttp2.exception.ApiException;
import com.xuexiang.xpage.core.PageOption;
import com.xuexiang.xpage.enums.CoreAnim;
import com.xuexiang.xui.adapter.FragmentAdapter;
@@ -99,6 +109,10 @@ import java.util.List;
import butterknife.BindView;
+import static com.kerwin.wumei.utils.TokenUtils.clearToken;
+import static com.kerwin.wumei.utils.TokenUtils.getToken;
+import static com.kerwin.wumei.utils.TokenUtils.hasToken;
+
public class MainActivity extends BaseActivity implements View.OnClickListener, ViewPager.OnPageChangeListener, BottomNavigationView.OnNavigationItemSelectedListener, ClickUtils.OnClick2ExitListener, Toolbar.OnMenuItemClickListener {
@BindView(R.id.toolbar)
@@ -129,6 +143,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
initViews();
+// initData();
initListeners();
}
@@ -148,14 +163,20 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
BaseFragment[] fragments = new BaseFragment[]{
new DeviceFragment(),
new SceneFragment(),
- new NewsFragment(),
+ new HomePageFragment(),
new ProfileFragment(),
};
FragmentAdapter adapter = new FragmentAdapter<>(getSupportFragmentManager(), fragments);
viewPager.setOffscreenPageLimit(mTitles.length - 1);
viewPager.setAdapter(adapter);
+ //显示提示
+// GuideTipsDialog.showTips(this);
+ }
+
+ private void initData() {
GuideTipsDialog.showTips(this);
+ XUpdateInit.checkUpdate(this, false);
}
/**
@@ -183,10 +204,11 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
}
}
- // TODO: 2019-10-09 初始化数据
+ // 绑定数据
ivAvatar.setImageResource(R.drawable.ic_default_head);
- tvAvatar.setText("15208747707");
- tvSign.setText("物美点亮智慧生活...");
+ tvAvatar.setText("匿名用户");
+ tvSign.setText("物美智能点亮智慧生活...");
+ getUserInfo(tvAvatar,tvSign );
navHeader.setOnClickListener(this);
}
@@ -197,34 +219,31 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
//侧边栏点击事件
navView.setNavigationItemSelectedListener(menuItem -> {
- switch (menuItem.getItemId()) {
- case R.id.nav_add_device:
- PageOption.to(AddDeviceFragment.class) //跳转的fragment
- .setAnim(CoreAnim.slide) //页面转场动画
- .setRequestCode(100) //请求码,用于返回结果
- .setAddToBackStack(true) //是否加入堆栈
- .setNewActivity(true,AddDeviceActivity.class) //是否使用新的Activity打开
- .open(this); //打开页面进行跳转
- break;
- case R.id.nav_settings:
- openNewPage(SettingsFragment.class);
- break;
- case R.id.nav_about:
- openNewPage(AboutFragment.class);
- break;
- case R.id.nav_message:
- openNewPage(MessageFragment.class);
- break;
- case R.id.nav_share_device:
- openNewPage(ShareDeviceFragment.class);
- break;
- case R.id.nav_group:
- openNewPage(GroupFragment.class);
- break;
- default:
- XToastUtils.toast("点击了:" + menuItem.getTitle());
- break;
- }
+
+ switch (menuItem.getItemId()) {
+ case R.id.nav_add_device:
+ PageOption.to(AddDeviceFragment.class) //跳转的fragment
+ .setAnim(CoreAnim.slide) //页面转场动画
+ .setRequestCode(100) //请求码,用于返回结果
+ .setAddToBackStack(true) //是否加入堆栈
+ .setNewActivity(true, AddDeviceActivity.class) //是否使用新的Activity打开
+ .open(this); //打开页面进行跳转
+ break;
+ case R.id.nav_about:
+ openNewPage(AboutFragment.class);
+ break;
+ case R.id.nav_serve_config:
+ drawerLayout.closeDrawers();
+ toolbar.setTitle(menuItem.getTitle());
+ viewPager.setCurrentItem(1, false);
+ break;
+ case R.id.nav_message:
+ openNewPage(MessageFragment.class);
+ break;
+ default:
+ XToastUtils.toast("点击了:" + menuItem.getTitle());
+ break;
+ }
return true;
});
@@ -258,7 +277,7 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
public void onClick(View v) {
switch (v.getId()) {
case R.id.nav_header:
- XToastUtils.toast("功能完善中...");
+ openNewPage(AccountFragment.class);
break;
default:
break;
@@ -325,5 +344,36 @@ public class MainActivity extends BaseActivity implements View.OnClickListener,
XUtil.exitApp();
}
+ /**
+ * HTTP获取用户信息
+ */
+ private void getUserInfo(TextView avatar,TextView sign){
+ if(!hasToken()) return;
+ XHttp.get("/prod-api/getInfo")
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new CallBackProxy, User>(new TipRequestCallBack() {
+ @Override
+ public void onSuccess(User user) throws Throwable {
+ Log.d("user:",user.getNickName());
+ if(user.getNickName()!=null && user.getNickName().length()!=0)
+ {
+ avatar.setText(user.getNickName());
+ }else{
+ avatar.setText(user.getUserName());
+ }
+ sign.setText("物美智能开源项目(wumei-smart)");
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ }){});
+ }
+
}
diff --git a/android/app/src/main/java/com/kerwin/wumei/activity/SplashActivity.java b/android/app/src/main/java/com/kerwin/wumei/activity/SplashActivity.java
index 9f9328e5..4a789743 100644
--- a/android/app/src/main/java/com/kerwin/wumei/activity/SplashActivity.java
+++ b/android/app/src/main/java/com/kerwin/wumei/activity/SplashActivity.java
@@ -38,15 +38,16 @@ public class SplashActivity extends BaseSplashActivity implements CancelAdapt {
*/
@Override
protected void onSplashFinished() {
- if (SettingUtils.isAgreePrivacy()) {
- loginOrGoMainPage();
- } else {
- Utils.showPrivacyDialog(this, (dialog, which) -> {
- dialog.dismiss();
- SettingUtils.setIsAgreePrivacy(true);
- loginOrGoMainPage();
- });
- }
+ loginOrGoMainPage();
+// if (SettingUtils.isAgreePrivacy()) {
+// loginOrGoMainPage();
+// } else {
+// Utils.showPrivacyDialog(this, (dialog, which) -> {
+// dialog.dismiss();
+// SettingUtils.setIsAgreePrivacy(true);
+// loginOrGoMainPage();
+// });
+// }
}
private void loginOrGoMainPage() {
diff --git a/android/app/src/main/java/com/kerwin/wumei/adapter/entity/EspTouchViewModel.java b/android/app/src/main/java/com/kerwin/wumei/adapter/entity/EspTouchViewModel.java
index fb4a2429..074708fe 100644
--- a/android/app/src/main/java/com/kerwin/wumei/adapter/entity/EspTouchViewModel.java
+++ b/android/app/src/main/java/com/kerwin/wumei/adapter/entity/EspTouchViewModel.java
@@ -5,12 +5,13 @@ import android.widget.EditText;
import android.widget.RadioGroup;
import android.widget.TextView;
+import com.xuexiang.xui.widget.picker.XSeekBar;
import com.xuexiang.xui.widget.spinner.materialspinner.MaterialSpinner;
public class EspTouchViewModel {
public MaterialSpinner ssidSpinner;
public EditText apPasswordEdit;
- public EditText deviceCountEdit;
+ public XSeekBar xsbDeviceCount;
public RadioGroup packageModeGroup;
public TextView messageView;
public Button confirmBtn;
diff --git a/android/app/src/main/java/com/kerwin/wumei/adapter/entity/NewInfo.java b/android/app/src/main/java/com/kerwin/wumei/adapter/entity/NewInfo.java
index 165ed133..14bdd448 100644
--- a/android/app/src/main/java/com/kerwin/wumei/adapter/entity/NewInfo.java
+++ b/android/app/src/main/java/com/kerwin/wumei/adapter/entity/NewInfo.java
@@ -1,19 +1,3 @@
-/*
- * Copyright (C) 2021 xuexiangjys(xuexiangjys@163.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
package com.kerwin.wumei.adapter.entity;
diff --git a/android/app/src/main/java/com/kerwin/wumei/core/http/api/ApiService.java b/android/app/src/main/java/com/kerwin/wumei/core/http/api/ApiService.java
index efda7d0a..b1dcf95c 100644
--- a/android/app/src/main/java/com/kerwin/wumei/core/http/api/ApiService.java
+++ b/android/app/src/main/java/com/kerwin/wumei/core/http/api/ApiService.java
@@ -39,7 +39,7 @@ public class ApiService {
/**
* 获得小贴士
*/
- @GET("/xuexiangjys/Resource/raw/master/jsonapi/tips.json")
+ @GET("http://wumei.live/tips.json")
Observable>> getTips();
}
diff --git a/android/app/src/main/java/com/kerwin/wumei/entity/Dept.java b/android/app/src/main/java/com/kerwin/wumei/entity/Dept.java
new file mode 100644
index 00000000..90e651b5
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/entity/Dept.java
@@ -0,0 +1,121 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.entity;
+
+import java.util.List;
+
+public class Dept {
+ private String remark;
+
+ private int deptId;
+
+ private int parentId;
+
+ private String ancestors;
+
+ private String deptName;
+
+ private String orderNum;
+
+ private String leader;
+
+ private String phone;
+
+ private String email;
+
+ private String status;
+
+ private String delFlag;
+
+ private String parentName;
+
+ private List children ;
+
+ public void setRemark(String remark){
+ this.remark = remark;
+ }
+ public String getRemark(){
+ return this.remark;
+ }
+ public void setDeptId(int deptId){
+ this.deptId = deptId;
+ }
+ public int getDeptId(){
+ return this.deptId;
+ }
+ public void setParentId(int parentId){
+ this.parentId = parentId;
+ }
+ public int getParentId(){
+ return this.parentId;
+ }
+ public void setAncestors(String ancestors){
+ this.ancestors = ancestors;
+ }
+ public String getAncestors(){
+ return this.ancestors;
+ }
+ public void setDeptName(String deptName){
+ this.deptName = deptName;
+ }
+ public String getDeptName(){
+ return this.deptName;
+ }
+ public void setOrderNum(String orderNum){
+ this.orderNum = orderNum;
+ }
+ public String getOrderNum(){
+ return this.orderNum;
+ }
+ public void setLeader(String leader){
+ this.leader = leader;
+ }
+ public String getLeader(){
+ return this.leader;
+ }
+ public void setPhone(String phone){
+ this.phone = phone;
+ }
+ public String getPhone(){
+ return this.phone;
+ }
+ public void setEmail(String email){
+ this.email = email;
+ }
+ public String getEmail(){
+ return this.email;
+ }
+ public void setStatus(String status){
+ this.status = status;
+ }
+ public String getStatus(){
+ return this.status;
+ }
+ public void setDelFlag(String delFlag){
+ this.delFlag = delFlag;
+ }
+ public String getDelFlag(){
+ return this.delFlag;
+ }
+ public void setParentName(String parentName){
+ this.parentName = parentName;
+ }
+ public String getParentName(){
+ return this.parentName;
+ }
+ public void setChildren(List children){
+ this.children = children;
+ }
+ public List getChildren(){
+ return this.children;
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/entity/DictData.java b/android/app/src/main/java/com/kerwin/wumei/entity/DictData.java
new file mode 100644
index 00000000..c35b0f65
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/entity/DictData.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.entity;
+
+public class DictData {
+
+ /** 字典标签 */
+ private String dictLabel;
+
+ /** 字典键值 */
+ private Integer dictValue;
+
+ /** 字典编码 */
+ private Long dictCode;
+
+ /** 字典类型 */
+ private String dictType;
+
+
+ public Long getDictCode()
+ {
+ return dictCode;
+ }
+ public void setDictCode(Long dictCode)
+ {
+ this.dictCode = dictCode;
+ }
+
+ public String getDictLabel()
+ {
+ return dictLabel;
+ }
+ public void setDictLabel(String dictLabel)
+ {
+ this.dictLabel = dictLabel;
+ }
+
+ public Integer getDictValue()
+ {
+ return dictValue;
+ }
+ public void setDictValue(Integer dictValue)
+ {
+ this.dictValue = dictValue;
+ }
+
+ public String getDictType()
+ {
+ return dictType;
+ }
+ public void setDictType(String dictType)
+ {
+ this.dictType = dictType;
+ }
+
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/entity/IotCategory.java b/android/app/src/main/java/com/kerwin/wumei/entity/IotCategory.java
new file mode 100644
index 00000000..1bee7422
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/entity/IotCategory.java
@@ -0,0 +1,39 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.entity;
+
+public class IotCategory {
+ /** 序号 */
+ private Long categoryId;
+
+ /** 分类名称 */
+ private String categoryName;
+
+ public void setCategoryId(Long categoryId)
+ {
+ this.categoryId = categoryId;
+ }
+ public Long getCategoryId()
+ {
+ return categoryId;
+ }
+
+ public void setCategoryName(String categoryName)
+ {
+ this.categoryName = categoryName;
+ }
+ public String getCategoryName()
+ {
+ return categoryName;
+ }
+
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/entity/IotDevice.java b/android/app/src/main/java/com/kerwin/wumei/entity/IotDevice.java
new file mode 100644
index 00000000..a6d4634b
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/entity/IotDevice.java
@@ -0,0 +1,126 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.entity;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+public class IotDevice {
+ /** 序号 */
+ private Long deviceId;
+
+ /** 编号 */
+ private String deviceNum;
+
+ /** 分类 */
+ private String categoryName;
+
+ /** 名称 */
+ private String deviceName;
+
+ /** 固件版本 */
+ private String firmwareVersion;
+
+ /** 用户 */
+ private String ownerId;
+
+ /** 备注 */
+ private String remark;
+
+ /** 设备温度 */
+ private String deviceTemp;
+
+ /** 创建时间 */
+ private String createTime;
+
+ public void setDeviceId(Long deviceId)
+ {
+ this.deviceId = deviceId;
+ }
+
+ public Long getDeviceId()
+ {
+ return deviceId;
+ }
+ public void setDeviceNum(String deviceNum)
+ {
+ this.deviceNum = deviceNum;
+ }
+
+ public String getDeviceNum()
+ {
+ return deviceNum;
+ }
+ public void setCategoryId(String categoryId)
+ {
+ this.categoryName = categoryName;
+ }
+
+ public String getCategoryName()
+ {
+ return categoryName;
+ }
+ public void setDeviceName(String deviceName)
+ {
+ this.deviceName = deviceName;
+ }
+
+ public String getDeviceName()
+ {
+ return deviceName;
+ }
+ public void setFirmwareVersion(String firmwareVersion)
+ {
+ this.firmwareVersion = firmwareVersion;
+ }
+
+ public String getFirmwareVersion()
+ {
+ return firmwareVersion;
+ }
+ public void setOwnerId(String ownerId)
+ {
+ this.ownerId = ownerId;
+ }
+
+ public String getOwnerId()
+ {
+ return ownerId;
+ }
+
+ public void setRemark(String remark)
+ {
+ this.remark = remark;
+ }
+ public String getRemark()
+ {
+ return remark;
+ }
+
+ public void setDeviceTemp(String deviceTemperature)
+ {
+ this.deviceTemp = deviceTemperature;
+ }
+ public String getDeviceTemp()
+ {
+ return deviceTemp;
+ }
+
+ public void setCreateTime(String createTime)
+ {
+ this.createTime = createTime;
+ }
+ public String getCreateTime()
+ {
+ return createTime;
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/entity/IotDeviceSet.java b/android/app/src/main/java/com/kerwin/wumei/entity/IotDeviceSet.java
new file mode 100644
index 00000000..6b2247cc
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/entity/IotDeviceSet.java
@@ -0,0 +1,282 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.entity;
+
+public class IotDeviceSet {
+ /** 序号 */
+ private Long deviceSetId;
+
+ /** 设备 */
+ private Long deviceId;
+
+ /** 设备编号 */
+ private String deviceNum;
+
+ /** 报警 */
+ private Integer isAlarm;
+
+ /** 雷达感应 */
+ private Integer isRadar;
+
+ /** 托管 */
+ private Integer isHost;
+
+ /** 重启 */
+ private Integer isReset;
+
+ /** 打开AP */
+ private Integer isAp;
+
+ /** 是否离线使用 */
+ private Integer isWifiOffline;
+
+ /** 是否使用证书 */
+ private Integer isOpenCertifi;
+
+ /** 智能配网 */
+ private Integer isSmartConfig;
+
+ /** 射频遥控 */
+ private Integer isRfControl;
+
+ /** 遥控配对 */
+ private Integer isRfLearn;
+
+ /** 遥控清码 */
+ private Integer isRfClear;
+
+ /** 按键一 */
+ private Integer rfOneFunc;
+
+ /** 按键二 */
+ private Integer rfTwoFunc;
+
+ /** 按键三 */
+ private Integer rfThreeFunc;
+
+ /** 按键四 */
+ private Integer rfFourFunc;
+
+ /** 用户 */
+ private String ownerId;
+
+ /** 配网地址 */
+ private String networkAddress;
+
+ /** 配网IP */
+ private String networkIp;
+
+ /** 雷达感应间隔 */
+ private Integer radarInterval;
+
+ public void setDeviceSetId(Long deviceSetId)
+ {
+ this.deviceSetId = deviceSetId;
+ }
+
+ public Long getDeviceSetId()
+ {
+ return deviceSetId;
+ }
+ public void setDeviceId(Long deviceId)
+ {
+ this.deviceId = deviceId;
+ }
+
+ public Long getDeviceId()
+ {
+ return deviceId;
+ }
+ public void setDeviceNum(String deviceNum)
+ {
+ this.deviceNum = deviceNum;
+ }
+
+ public String getDeviceNum()
+ {
+ return deviceNum;
+ }
+ public void setIsAlarm(Integer isAlarm)
+ {
+ this.isAlarm = isAlarm;
+ }
+
+ public Integer getIsAlarm()
+ {
+ return isAlarm;
+ }
+ public void setIsRadar(Integer isRadar)
+ {
+ this.isRadar = isRadar;
+ }
+
+ public Integer getIsRadar()
+ {
+ return isRadar;
+ }
+ public void setIsHost(Integer isHost)
+ {
+ this.isHost = isHost;
+ }
+
+ public Integer getIsHost()
+ {
+ return isHost;
+ }
+ public void setIsReset(Integer isReset)
+ {
+ this.isReset = isReset;
+ }
+
+ public Integer getIsReset()
+ {
+ return isReset;
+ }
+
+ public void setIsAp(Integer isAp)
+ {
+ this.isAp = isAp;
+ }
+ public Integer getIsAp()
+ {
+ return isAp;
+ }
+
+ public void setIsWifiOffline(Integer isWifiOffline)
+ {
+ this.isWifiOffline = isWifiOffline;
+ }
+ public Integer getIsWifiOffline()
+ {
+ return isWifiOffline;
+ }
+
+ public void setIsOpenCertifi(Integer isOpenCertifi)
+ {
+ this.isOpenCertifi = isOpenCertifi;
+ }
+ public Integer getIsOpenCertifi()
+ {
+ return isOpenCertifi;
+ }
+
+ public void setIsSmartConfig(Integer isSmartConfig)
+ {
+ this.isSmartConfig = isSmartConfig;
+ }
+
+ public Integer getIsSmartConfig()
+ {
+ return isSmartConfig;
+ }
+ public void setIsRfControl(Integer isRfControl)
+ {
+ this.isRfControl = isRfControl;
+ }
+
+ public Integer getIsRfControl()
+ {
+ return isRfControl;
+ }
+ public void setIsRfLearn(Integer isRfLearn)
+ {
+ this.isRfLearn = isRfLearn;
+ }
+
+ public Integer getIsRfLearn()
+ {
+ return isRfLearn;
+ }
+ public void setIsRfClear(Integer isRfClear)
+ {
+ this.isRfClear = isRfClear;
+ }
+
+ public Integer getIsRfClear()
+ {
+ return isRfClear;
+ }
+ public void setRfOneFunc(Integer rfOneFunc)
+ {
+ this.rfOneFunc = rfOneFunc;
+ }
+
+ public Integer getRfOneFunc()
+ {
+ return rfOneFunc;
+ }
+ public void setRfTwoFunc(Integer rfTwoFunc)
+ {
+ this.rfTwoFunc = rfTwoFunc;
+ }
+
+ public Integer getRfTwoFunc()
+ {
+ return rfTwoFunc;
+ }
+ public void setRfThreeFunc(Integer rfThreeFunc)
+ {
+ this.rfThreeFunc = rfThreeFunc;
+ }
+
+ public Integer getRfThreeFunc()
+ {
+ return rfThreeFunc;
+ }
+ public void setRfFourFunc(Integer rfFourFunc)
+ {
+ this.rfFourFunc = rfFourFunc;
+ }
+
+ public Integer getRfFourFunc()
+ {
+ return rfFourFunc;
+ }
+ public void setOwnerId(String ownerId)
+ {
+ this.ownerId = ownerId;
+ }
+
+ public String getOwnerId()
+ {
+ return ownerId;
+ }
+ public void setNetworkAddress(String networkAddress)
+ {
+ this.networkAddress = networkAddress;
+ }
+
+ public String getNetworkAddress()
+ {
+ return networkAddress;
+ }
+ public void setNetworkIp(String networkIp)
+ {
+ this.networkIp = networkIp;
+ }
+
+ public String getNetworkIp()
+ {
+ return networkIp;
+ }
+
+ public void setRadarInterval(Integer radarInterval)
+ {
+ this.radarInterval = radarInterval;
+ }
+
+ public Integer getRadarInterval()
+ {
+ return radarInterval;
+ }
+
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/entity/IotDeviceStatus.java b/android/app/src/main/java/com/kerwin/wumei/entity/IotDeviceStatus.java
new file mode 100644
index 00000000..cdd70040
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/entity/IotDeviceStatus.java
@@ -0,0 +1,234 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.entity;
+
+import java.math.BigDecimal;
+
+public class IotDeviceStatus {
+ /** 序号 */
+ private Long deviceStatusId;
+
+ /** 设备 */
+ private Long deviceId;
+
+ /** 设备编号 */
+ private String deviceNum;
+
+ /** 继电器 */
+ private Integer relayStatus;
+
+ /** 灯状态 */
+ private Integer lightStatus;
+
+ /** 在线 */
+ private Integer isOnline;
+
+ /** 设备温度 */
+ private BigDecimal deviceTemperature;
+
+ /** 设备湿度 */
+ private Integer rssi;
+
+ /** 空气温度 */
+ private BigDecimal airTemperature;
+
+ /** 空气湿度 */
+ private BigDecimal airHumidity;
+
+ /** 触发源 */
+ private Integer triggerSource;
+
+ /** 彩灯亮度 */
+ private Integer brightness;
+
+ /** 渐变间隔 */
+ private Integer lightInterval;
+
+ /** 彩灯模式 */
+ private Integer lightMode;
+
+ /** 灯渐变时间 */
+ private Integer fadeTime;
+
+ /** 红灯 */
+ private Integer red;
+
+ /** 绿灯 */
+ private Integer green;
+
+ /** 蓝灯 */
+ private Integer blue;
+
+ public void setDeviceStatusId(Long deviceStatusId)
+ {
+ this.deviceStatusId = deviceStatusId;
+ }
+
+ public Long getDeviceStatusId()
+ {
+ return deviceStatusId;
+ }
+ public void setDeviceId(Long deviceId)
+ {
+ this.deviceId = deviceId;
+ }
+
+ public Long getDeviceId()
+ {
+ return deviceId;
+ }
+ public void setDeviceNum(String deviceNum)
+ {
+ this.deviceNum = deviceNum;
+ }
+
+ public String getDeviceNum()
+ {
+ return deviceNum;
+ }
+ public void setRelayStatus(Integer relayStatus)
+ {
+ this.relayStatus = relayStatus;
+ }
+
+ public Integer getRelayStatus()
+ {
+ return relayStatus;
+ }
+ public void setLightStatus(Integer lightStatus)
+ {
+ this.lightStatus = lightStatus;
+ }
+
+ public Integer getLightStatus()
+ {
+ return lightStatus;
+ }
+ public void setIsOnline(Integer isOnline)
+ {
+ this.isOnline = isOnline;
+ }
+
+ public Integer getIsOnline()
+ {
+ return isOnline;
+ }
+ public void setDeviceTemperature(BigDecimal deviceTemperature)
+ {
+ this.deviceTemperature = deviceTemperature;
+ }
+
+ public BigDecimal getDeviceTemperature()
+ {
+ return deviceTemperature;
+ }
+ public void setRssi(Integer rssi)
+ {
+ this.rssi = rssi;
+ }
+
+ public Integer getRssi()
+ {
+ return rssi;
+ }
+ public void setAirTemperature(BigDecimal airTemperature)
+ {
+ this.airTemperature = airTemperature;
+ }
+
+ public BigDecimal getAirTemperature()
+ {
+ return airTemperature;
+ }
+ public void setAirHumidity(BigDecimal airHumidity)
+ {
+ this.airHumidity = airHumidity;
+ }
+
+ public BigDecimal getAirHumidity()
+ {
+ return airHumidity;
+ }
+ public void setTriggerSource(Integer triggerSource)
+ {
+ this.triggerSource = triggerSource;
+ }
+
+ public Integer getTriggerSource()
+ {
+ return triggerSource;
+ }
+ public void setBrightness(Integer brightness)
+ {
+ this.brightness = brightness;
+ }
+
+ public Integer getBrightness()
+ {
+ return brightness;
+ }
+ public void setLightInterval(Integer lightInterval)
+ {
+ this.lightInterval = lightInterval;
+ }
+
+ public Integer getLightInterval()
+ {
+ return lightInterval;
+ }
+ public void setLightMode(Integer lightMode)
+ {
+ this.lightMode = lightMode;
+ }
+
+ public Integer getLightMode()
+ {
+ return lightMode;
+ }
+ public void setRed(Integer red)
+ {
+ this.red = red;
+ }
+
+ public Integer getRed()
+ {
+ return red;
+ }
+ public void setGreen(Integer green)
+ {
+ this.green = green;
+ }
+
+ public Integer getGreen()
+ {
+ return green;
+ }
+ public void setBlue(Integer blue)
+ {
+ this.blue = blue;
+ }
+
+ public Integer getBlue()
+ {
+ return blue;
+ }
+
+ public void setFadeTime(Integer fadeTime)
+ {
+ this.fadeTime = fadeTime;
+ }
+ public Integer getFadeTime()
+ {
+ return fadeTime;
+ }
+
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/entity/IotGroup.java b/android/app/src/main/java/com/kerwin/wumei/entity/IotGroup.java
new file mode 100644
index 00000000..b15b9e4c
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/entity/IotGroup.java
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.entity;
+
+public class IotGroup {
+ /** 设备分组 */
+ private Long groupId;
+
+ /** 用户 */
+ private Long userId;
+
+ /** 分组名称 */
+ private String groupName;
+
+ /** 排序 */
+ private Integer groupOrder;
+
+ public void setGroupId(Long groupId)
+ {
+ this.groupId = groupId;
+ }
+
+ public Long getGroupId()
+ {
+ return groupId;
+ }
+ public void setUserId(Long userId)
+ {
+ this.userId = userId;
+ }
+
+ public Long getUserId()
+ {
+ return userId;
+ }
+ public void setGroupName(String groupName)
+ {
+ this.groupName = groupName;
+ }
+
+ public String getGroupName()
+ {
+ return groupName;
+ }
+ public void setGroupOrder(Integer groupOrder)
+ {
+ this.groupOrder = groupOrder;
+ }
+
+ public Integer getGroupOrder()
+ {
+ return groupOrder;
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/entity/Roles.java b/android/app/src/main/java/com/kerwin/wumei/entity/Roles.java
new file mode 100644
index 00000000..c089b1da
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/entity/Roles.java
@@ -0,0 +1,119 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.entity;
+
+public class Roles {
+ private String remark;
+
+ private int roleId;
+
+ private String roleName;
+
+ private String roleKey;
+
+ private String roleSort;
+
+ private String dataScope;
+
+ private boolean menuCheckStrictly;
+
+ private boolean deptCheckStrictly;
+
+ private String status;
+
+ private boolean flag;
+
+ private String menuIds;
+
+ private String deptIds;
+
+ private boolean admin;
+
+ public void setRemark(String remark){
+ this.remark = remark;
+ }
+ public String getRemark(){
+ return this.remark;
+ }
+ public void setRoleId(int roleId){
+ this.roleId = roleId;
+ }
+ public int getRoleId(){
+ return this.roleId;
+ }
+ public void setRoleName(String roleName){
+ this.roleName = roleName;
+ }
+ public String getRoleName(){
+ return this.roleName;
+ }
+ public void setRoleKey(String roleKey){
+ this.roleKey = roleKey;
+ }
+ public String getRoleKey(){
+ return this.roleKey;
+ }
+ public void setRoleSort(String roleSort){
+ this.roleSort = roleSort;
+ }
+ public String getRoleSort(){
+ return this.roleSort;
+ }
+ public void setDataScope(String dataScope){
+ this.dataScope = dataScope;
+ }
+ public String getDataScope(){
+ return this.dataScope;
+ }
+ public void setMenuCheckStrictly(boolean menuCheckStrictly){
+ this.menuCheckStrictly = menuCheckStrictly;
+ }
+ public boolean getMenuCheckStrictly(){
+ return this.menuCheckStrictly;
+ }
+ public void setDeptCheckStrictly(boolean deptCheckStrictly){
+ this.deptCheckStrictly = deptCheckStrictly;
+ }
+ public boolean getDeptCheckStrictly(){
+ return this.deptCheckStrictly;
+ }
+ public void setStatus(String status){
+ this.status = status;
+ }
+ public String getStatus(){
+ return this.status;
+ }
+ public void setFlag(boolean flag){
+ this.flag = flag;
+ }
+ public boolean getFlag(){
+ return this.flag;
+ }
+ public void setMenuIds(String menuIds){
+ this.menuIds = menuIds;
+ }
+ public String getMenuIds(){
+ return this.menuIds;
+ }
+ public void setDeptIds(String deptIds){
+ this.deptIds = deptIds;
+ }
+ public String getDeptIds(){
+ return this.deptIds;
+ }
+ public void setAdmin(boolean admin){
+ this.admin = admin;
+ }
+ public boolean getAdmin(){
+ return this.admin;
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/entity/User.java b/android/app/src/main/java/com/kerwin/wumei/entity/User.java
new file mode 100644
index 00000000..86a4f78d
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/entity/User.java
@@ -0,0 +1,162 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.entity;
+
+import java.util.List;
+
+public class User {
+
+ private String remark;
+
+ private int userId;
+
+ private int deptId;
+
+ private String userName;
+
+ private String nickName;
+
+ private String email;
+
+ private String phonenumber;
+
+ private String sex;
+
+ private String avatar;
+
+ private String status;
+
+ private String loginIp;
+
+ private String loginDate;
+
+ private Dept dept;
+
+ private List roles ;
+
+ private String roleIds;
+
+ private String postIds;
+
+ private boolean admin;
+
+ private String createTime;
+
+ public void setRemark(String remark){
+ this.remark = remark;
+ }
+ public String getRemark(){
+ return this.remark;
+ }
+ public void setUserId(int userId){
+ this.userId = userId;
+ }
+ public int getUserId(){
+ return this.userId;
+ }
+ public void setDeptId(int deptId){
+ this.deptId = deptId;
+ }
+ public int getDeptId(){
+ return this.deptId;
+ }
+ public void setUserName(String userName){
+ this.userName = userName;
+ }
+ public String getUserName(){
+ return this.userName;
+ }
+ public void setNickName(String nickName){
+ this.nickName = nickName;
+ }
+ public String getNickName(){
+ return this.nickName;
+ }
+ public void setEmail(String email){
+ this.email = email;
+ }
+ public String getEmail(){
+ return this.email;
+ }
+ public void setPhonenumber(String phonenumber){
+ this.phonenumber = phonenumber;
+ }
+ public String getPhonenumber(){
+ return this.phonenumber;
+ }
+ public void setSex(String sex){
+ this.sex = sex;
+ }
+ public String getSex(){
+ return this.sex;
+ }
+ public void setAvatar(String avatar){
+ this.avatar = avatar;
+ }
+ public String getAvatar(){
+ return this.avatar;
+ }
+ public void setStatus(String status){
+ this.status = status;
+ }
+ public String getStatus(){
+ return this.status;
+ }
+ public void setLoginIp(String loginIp){
+ this.loginIp = loginIp;
+ }
+ public String getLoginIp(){
+ return this.loginIp;
+ }
+ public void setLoginDate(String loginDate){
+ this.loginDate = loginDate;
+ }
+ public String getLoginDate(){
+ return this.loginDate;
+ }
+ public void setDept(Dept dept){
+ this.dept = dept;
+ }
+ public Dept getDept(){
+ return this.dept;
+ }
+ public void setRoles(List roles){
+ this.roles = roles;
+ }
+ public List getRoles(){
+ return this.roles;
+ }
+ public void setRoleIds(String roleIds){
+ this.roleIds = roleIds;
+ }
+ public String getRoleIds(){
+ return this.roleIds;
+ }
+ public void setPostIds(String postIds){
+ this.postIds = postIds;
+ }
+ public String getPostIds(){
+ return this.postIds;
+ }
+ public void setAdmin(boolean admin){
+ this.admin = admin;
+ }
+ public boolean getAdmin(){
+ return this.admin;
+ }
+ public void setCreateTime(String createTime){
+ this.createTime = createTime;
+ }
+ public String getCreateTime(){
+ return this.createTime;
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/entity/bo/CaptureImage.java b/android/app/src/main/java/com/kerwin/wumei/entity/bo/CaptureImage.java
new file mode 100644
index 00000000..a26fa2cc
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/entity/bo/CaptureImage.java
@@ -0,0 +1,33 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.entity.bo;
+
+public class CaptureImage {
+ private String uuid;
+
+ private String img;
+
+ public String getUuid() {
+ return uuid;
+ }
+ public void setUuid(String uuid) {
+ this.uuid = uuid ;
+ }
+
+ public String getImg() {
+ return img;
+ }
+ public void setImg(String img) {
+ this.img = img ;
+ }
+
+}
\ No newline at end of file
diff --git a/android/app/src/main/java/com/kerwin/wumei/entity/vo/IotDeviceVo.java b/android/app/src/main/java/com/kerwin/wumei/entity/vo/IotDeviceVo.java
new file mode 100644
index 00000000..0bb945ac
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/entity/vo/IotDeviceVo.java
@@ -0,0 +1,222 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.entity.vo;
+
+import java.math.BigDecimal;
+
+public class IotDeviceVo {
+ private Long deviceId;
+
+ /** 编号 */
+ private String deviceNum;
+
+ /** 分类 */
+ private Long categoryId;
+
+ /** 分类名称 */
+ private String categoryName;
+
+ /** 名称 */
+ private String deviceName;
+
+ /** 固件版本 */
+ private String firmwareVersion;
+
+ /** 用户 */
+ private String ownerId;
+
+ private String nickName;
+
+ /** 删除标志(0代表存在 2代表删除) */
+ private String delFlag;
+
+ /** 报警 */
+ private Integer isAlarm;
+
+ /** 雷达感应 */
+ private Integer isRadar;
+
+ /** 射频遥控 */
+ private Integer isRfControl;
+
+ /** 配网地址 */
+ private String networkAddress;
+
+ /** 配网IP */
+ private String networkIp;
+
+ /** 继电器 */
+ private Integer relayStatus;
+
+ /** 灯状态 */
+ private Integer lightStatus;
+
+ /** 在线 */
+ private Integer isOnline;
+
+ /** 设备温度 */
+ private BigDecimal deviceTemperature;
+
+ /** 设备湿度 */
+ private Integer rssi;
+
+
+
+ public void setDeviceId(Long deviceId)
+ {
+ this.deviceId = deviceId;
+ }
+ public Long getDeviceId()
+ {
+ return deviceId;
+ }
+ public void setDeviceNum(String deviceNum)
+ {
+ this.deviceNum = deviceNum;
+ }
+ public String getDeviceNum()
+ {
+ return deviceNum;
+ }
+ public void setCategoryId(Long categoryId)
+ {
+ this.categoryId = categoryId;
+ }
+ public Long getCategoryId()
+ {
+ return categoryId;
+ }
+ public void setCategoryName(String categoryName)
+ {
+ this.categoryName = categoryName;
+ }
+ public String getCategoryName()
+ {
+ return categoryName;
+ }
+ public void setDeviceName(String deviceName)
+ {
+ this.deviceName = deviceName;
+ }
+ public String getDeviceName()
+ {
+ return deviceName;
+ }
+ public void setFirmwareVersion(String firmwareVersion) { this.firmwareVersion = firmwareVersion; }
+ public String getFirmwareVersion()
+ {
+ return firmwareVersion;
+ }
+ public void setOwnerId(String ownerId)
+ {
+ this.ownerId = ownerId;
+ }
+ public String getOwnerId()
+ {
+ return ownerId;
+ }
+ public void setNickName(String nickName)
+ {
+ this.nickName = nickName;
+ }
+ public String getNickName()
+ {
+ return nickName;
+ }
+ public void setDelFlag(String delFlag)
+ {
+ this.delFlag = delFlag;
+ }
+ public String getDelFlag()
+ {
+ return delFlag;
+ }
+
+ public void setIsAlarm(Integer isAlarm)
+ {
+ this.isAlarm = isAlarm;
+ }
+ public Integer getIsAlarm()
+ {
+ return isAlarm;
+ }
+ public void setIsRadar(Integer isRadar)
+ {
+ this.isRadar = isRadar;
+ }
+ public Integer getIsRadar()
+ {
+ return isRadar;
+ }
+ public void setIsRfControl(Integer isRfControl)
+ {
+ this.isRfControl = isRfControl;
+ }
+ public Integer getIsRfControl()
+ {
+ return isRfControl;
+ }
+ public void setNetworkAddress(String networkAddress)
+ {
+ this.networkAddress = networkAddress;
+ }
+ public String getNetworkAddress()
+ {
+ return networkAddress;
+ }
+ public void setNetworkIp(String networkIp)
+ {
+ this.networkIp = networkIp;
+ }
+ public String getNetworkIp()
+ {
+ return networkIp;
+ }
+
+ public void setRelayStatus(Integer relayStatus)
+ {
+ this.relayStatus = relayStatus;
+ }
+ public Integer getRelayStatus()
+ {
+ return relayStatus;
+ }
+ public void setLightStatus(Integer lightStatus)
+ {
+ this.lightStatus = lightStatus;
+ }
+ public Integer getLightStatus()
+ {
+ return lightStatus;
+ }
+ public void setIsOnline(Integer isOnline)
+ {
+ this.isOnline = isOnline;
+ }
+ public Integer getIsOnline()
+ {
+ return isOnline;
+ }
+ public void setDeviceTemperature(BigDecimal deviceTemperature) { this.deviceTemperature = deviceTemperature; }
+ public BigDecimal getDeviceTemperature()
+ {
+ return deviceTemperature;
+ }
+ public void setRssi(Integer rssi)
+ {
+ this.rssi = rssi;
+ }
+ public Integer getRssi()
+ {
+ return rssi;
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/AboutFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/AboutFragment.java
index 0ea94321..6e327927 100644
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/AboutFragment.java
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/AboutFragment.java
@@ -1,19 +1,13 @@
-/*
- * Copyright (C) 2021 xuexiangjys(xuexiangjys@163.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
package com.kerwin.wumei.fragment;
@@ -24,6 +18,7 @@ import com.kerwin.wumei.core.webview.AgentWebActivity;
import com.kerwin.wumei.R;
import com.kerwin.wumei.utils.XToastUtils;
import com.xuexiang.xpage.annotation.Page;
+import com.xuexiang.xui.widget.actionbar.TitleBar;
import com.xuexiang.xui.widget.grouplist.XUIGroupListView;
import com.xuexiang.xutil.app.AppUtils;
@@ -36,6 +31,8 @@ import butterknife.BindView;
@Page(name = "关于")
public class AboutFragment extends BaseFragment {
+ @BindView(R.id.titlebar_min)
+ TitleBar titleBarMin;
@BindView(R.id.tv_version)
TextView mVersionTextView;
@@ -43,6 +40,13 @@ public class AboutFragment extends BaseFragment {
XUIGroupListView mAboutGroupListView;
@BindView(R.id.tv_copyright)
TextView mCopyrightTextView;
+ @BindView(R.id.tv_autho)
+ TextView tvAutho;
+
+ @Override
+ protected TitleBar initTitle() {
+ return null;
+ }
@Override
protected int getLayoutId() {
@@ -51,12 +55,15 @@ public class AboutFragment extends BaseFragment {
@Override
protected void initViews() {
+ titleBarMin.setLeftClickListener(v -> popToBack());
+
mVersionTextView.setText(String.format("版本号:%s", AppUtils.getAppVersionName()));
+ tvAutho.setText("Author:kerwinci Website:www.wumei.live");
XUIGroupListView.newSection(getContext())
.addItemView(mAboutGroupListView.createItemView(getResources().getString(R.string.about_item_homepage)), v -> AgentWebActivity.goWeb(getContext(), getString(R.string.url_project_github)))
.addItemView(mAboutGroupListView.createItemView(getResources().getString(R.string.about_item_author_github)), v -> AgentWebActivity.goWeb(getContext(), getString(R.string.url_author_github)))
- .addItemView(mAboutGroupListView.createItemView("版本"), v -> XToastUtils.toast("版本升级"))
+ .addItemView(mAboutGroupListView.createItemView(getResources().getString(R.string.about_item_add_qq_group)), v -> AgentWebActivity.goWeb(getContext(), getString(R.string.url_add_qq_group)))
.addTo(mAboutGroupListView);
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy", Locale.CHINA);
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/FeedbackFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/FeedbackFragment.java
index fec81e94..2ff25e34 100644
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/FeedbackFragment.java
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/FeedbackFragment.java
@@ -1,3 +1,13 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
package com.kerwin.wumei.fragment;
import android.widget.TextView;
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/LoginFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/LoginFragment.java
index 683c09f9..fbe3606c 100644
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/LoginFragment.java
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/LoginFragment.java
@@ -1,37 +1,47 @@
-/*
- * Copyright (C) 2021 xuexiangjys(xuexiangjys@163.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
package com.kerwin.wumei.fragment;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.graphics.Color;
+import android.util.Base64;
+import android.util.Log;
import android.view.View;
+import android.widget.ImageView;
+import com.kerwin.wumei.activity.LoginActivity;
import com.kerwin.wumei.activity.MainActivity;
import com.kerwin.wumei.core.BaseFragment;
import com.kerwin.wumei.R;
-import com.kerwin.wumei.utils.RandomUtils;
+import com.kerwin.wumei.entity.IotGroup;
+import com.kerwin.wumei.entity.bo.CaptureImage;
+import com.kerwin.wumei.entity.User;
+import com.kerwin.wumei.http.callback.TipRequestCallBack;
+import com.kerwin.wumei.http.request.CaptchaImageApiResult;
+import com.kerwin.wumei.http.request.ListApiResult;
+import com.kerwin.wumei.http.request.TokenApiResult;
+import com.kerwin.wumei.http.request.UserInfoApiResult;
+import com.kerwin.wumei.utils.MMKVUtils;
import com.kerwin.wumei.utils.SettingUtils;
import com.kerwin.wumei.utils.TokenUtils;
import com.kerwin.wumei.utils.Utils;
import com.kerwin.wumei.utils.XToastUtils;
import com.xuexiang.xaop.annotation.SingleClick;
+import com.xuexiang.xhttp2.XHttp;
+import com.xuexiang.xhttp2.callback.CallBackProxy;
+import com.xuexiang.xhttp2.exception.ApiException;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xpage.enums.CoreAnim;
-import com.xuexiang.xui.utils.CountDownButtonHelper;
import com.xuexiang.xui.utils.ResUtils;
import com.xuexiang.xui.utils.ThemeUtils;
import com.xuexiang.xui.widget.actionbar.TitleBar;
@@ -39,9 +49,15 @@ import com.xuexiang.xui.widget.button.roundbutton.RoundButton;
import com.xuexiang.xui.widget.edittext.materialedittext.MaterialEditText;
import com.xuexiang.xutil.app.ActivityUtils;
+import java.util.List;
+
import butterknife.BindView;
import butterknife.OnClick;
+import static com.kerwin.wumei.utils.TokenUtils.clearToken;
+import static com.kerwin.wumei.utils.TokenUtils.getToken;
+import static com.kerwin.wumei.utils.TokenUtils.hasToken;
+
/**
* 登录页面
@@ -54,12 +70,17 @@ public class LoginFragment extends BaseFragment {
@BindView(R.id.et_phone_number)
MaterialEditText etPhoneNumber;
+ @BindView(R.id.et_password)
+ MaterialEditText etPassword;
@BindView(R.id.et_verify_code)
MaterialEditText etVerifyCode;
- @BindView(R.id.btn_get_verify_code)
- RoundButton btnGetVerifyCode;
+ @BindView(R.id.iv_code)
+ ImageView imgVertifyCode;
+ @BindView(R.id.btn_clear)
+ RoundButton btnClear;
- private CountDownButtonHelper mCountDownHelper;
+ private String uuid="";
+ private String token="";
@Override
protected int getLayoutId() {
@@ -77,6 +98,7 @@ public class LoginFragment extends BaseFragment {
titleBar.addAction(new TitleBar.TextAction(R.string.title_jump_login) {
@Override
public void performAction(View view) {
+ clearToken();
onLoginSuccess();
}
});
@@ -85,87 +107,103 @@ public class LoginFragment extends BaseFragment {
@Override
protected void initViews() {
- mCountDownHelper = new CountDownButtonHelper(btnGetVerifyCode, 60);
-
//隐私政策弹窗
- if (!SettingUtils.isAgreePrivacy()) {
- Utils.showPrivacyDialog(getContext(), (dialog, which) -> {
- dialog.dismiss();
- SettingUtils.setIsAgreePrivacy(true);
- });
- }
+// if (!SettingUtils.isAgreePrivacy()) {
+// Utils.showPrivacyDialog(getContext(), (dialog, which) -> {
+// dialog.dismiss();
+// SettingUtils.setIsAgreePrivacy(true);
+// });
+// }
+ getCatpureImage();
+ getLocalAccount();
}
@SingleClick
- @OnClick({R.id.btn_get_verify_code, R.id.btn_login, R.id.tv_other_login, R.id.tv_forget_password, R.id.tv_user_protocol, R.id.tv_privacy_protocol})
+ @OnClick({ R.id.btn_login,R.id.iv_code,R.id.btn_clear})
public void onViewClicked(View view) {
switch (view.getId()) {
- case R.id.btn_get_verify_code:
- if (etPhoneNumber.validate()) {
- getVerifyCode(etPhoneNumber.getEditValue());
- }
+ case R.id.btn_clear:
+ SettingUtils.clearPassword();
+ etPassword.clear();
+ break;
+ case R.id.iv_code:
+ getCatpureImage();
break;
case R.id.btn_login:
if (etPhoneNumber.validate()) {
if (etVerifyCode.validate()) {
- loginByVerifyCode(etPhoneNumber.getEditValue(), etVerifyCode.getEditValue());
+ loginByVerifyCode(etPhoneNumber.getEditValue(), etPassword.getEditValue(), etVerifyCode.getEditValue());
}
}
break;
- case R.id.tv_other_login:
- XToastUtils.info("其他登录方式");
- break;
- case R.id.tv_forget_password:
- XToastUtils.info("忘记密码");
- break;
- case R.id.tv_user_protocol:
- XToastUtils.info("用户协议");
- break;
- case R.id.tv_privacy_protocol:
- XToastUtils.info("隐私政策");
- break;
default:
break;
}
}
- /**
- * 获取验证码
- */
- private void getVerifyCode(String phoneNumber) {
- // TODO: 2020/8/29 这里只是界面演示而已
- XToastUtils.warning("只是演示,验证码请随便输");
- mCountDownHelper.start();
- }
-
- /**
- * 根据验证码登录
- *
- * @param phoneNumber 手机号
- * @param verifyCode 验证码
- */
- private void loginByVerifyCode(String phoneNumber, String verifyCode) {
- // TODO: 2020/8/29 这里只是界面演示而已
- onLoginSuccess();
+ @Override
+ public void onDestroyView() {
+ super.onDestroyView();
}
/**
* 登录成功的处理
*/
private void onLoginSuccess() {
- String token = RandomUtils.getRandomNumbersAndLetters(16);
- if (TokenUtils.handleLoginSuccess(token)) {
- popToBack();
- ActivityUtils.startActivity(MainActivity.class);
- }
+ TokenUtils.handleLoginSuccess(token);
+ popToBack();
+ ActivityUtils.startActivity(MainActivity.class);
}
- @Override
- public void onDestroyView() {
- if (mCountDownHelper != null) {
- mCountDownHelper.recycle();
- }
- super.onDestroyView();
+ /**
+ * 获取本地存储的账号
+ */
+ private void getLocalAccount(){
+ etPhoneNumber.setText(SettingUtils.getUserName());
+ etPassword.setText(SettingUtils.getPassword());
}
+
+ /**
+ * HTTP获取验证码
+ */
+ private void getCatpureImage(){
+ XHttp.get("/prod-api/captchaImage")
+ .execute(new CallBackProxy, CaptureImage>(new TipRequestCallBack() {
+ @Override
+ public void onSuccess(CaptureImage image) throws Throwable {
+ uuid=image.getUuid();
+ byte[] decode = Base64.decode(image.getImg(), Base64.DEFAULT);
+ Bitmap bitmap = BitmapFactory.decodeByteArray(decode, 0, decode.length);
+ imgVertifyCode.setImageBitmap(bitmap);
+ }
+ }){});
+ }
+
+ /**
+ * HTTP登录
+ *
+ * @param phoneNumber 手机号
+ * @param verifyCode 验证码
+ */
+ private void loginByVerifyCode(String phoneNumber,String password, String verifyCode) {
+ XHttp.post("/prod-api/login")
+ .upJson("{\"username\":\""+phoneNumber+"\",\"password\":\""+password+"\",\"code\":\""+verifyCode+"\",\"uuid\":\""+uuid+"\"}")
+ .execute(new CallBackProxy, String>(new TipRequestCallBack() {
+ @Override
+ public void onSuccess(String tokenResult) throws Throwable {
+ SettingUtils.setAccount(etPhoneNumber.getEditValue(),etPassword.getEditValue());
+ token=tokenResult;
+ onLoginSuccess();
+ }
+ @Override
+ public void onError(ApiException e) {
+ clearToken();
+ }
+ }){});
+ }
+
+
+
+
}
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/MessageFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/MessageFragment.java
index d5fecd09..7ea2744b 100644
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/MessageFragment.java
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/MessageFragment.java
@@ -1,3 +1,13 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
package com.kerwin.wumei.fragment;
import android.view.View;
@@ -6,6 +16,7 @@ import android.widget.TextView;
import com.kerwin.wumei.R;
import com.kerwin.wumei.core.BaseFragment;
import com.kerwin.wumei.core.webview.AgentWebActivity;
+import com.kerwin.wumei.utils.XToastUtils;
import com.xuexiang.xaop.annotation.SingleClick;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xui.widget.actionbar.TitleBar;
@@ -21,6 +32,8 @@ import butterknife.BindView;
@Page(name = "消息")
public class MessageFragment extends BaseFragment {
+ @BindView(R.id.titlebar_min)
+ TitleBar titleBarMin;
@Override
protected int getLayoutId() {
@@ -29,26 +42,12 @@ public class MessageFragment extends BaseFragment {
@Override
protected TitleBar initTitle() {
- com.xuexiang.xui.widget.actionbar.TitleBar titleBar = super.initTitle();
- titleBar.setCenterClickListener(new View.OnClickListener() {
- @SingleClick
- @Override
- public void onClick(View view) {
-
- }
- });
- titleBar.addAction(new com.xuexiang.xui.widget.actionbar.TitleBar.TextAction("菜单") {
- @SingleClick
- @Override
- public void performAction(View view) {
-
- }
- });
- return titleBar;
+ return null;
}
@Override
protected void initViews() {
+ titleBarMin.setLeftClickListener(v -> popToBack());
}
}
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/SettingsFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/SettingsFragment.java
index 0e3ccd6c..661bdede 100644
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/SettingsFragment.java
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/SettingsFragment.java
@@ -1,27 +1,27 @@
-/*
- * Copyright (C) 2021 xuexiangjys(xuexiangjys@163.com)
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- *
- */
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
package com.kerwin.wumei.fragment;
import com.kerwin.wumei.core.BaseFragment;
import com.kerwin.wumei.R;
+import com.kerwin.wumei.http.callback.TipRequestCallBack;
+import com.kerwin.wumei.http.request.NoDataApiResult;
+import com.kerwin.wumei.http.request.TokenApiResult;
import com.kerwin.wumei.utils.TokenUtils;
import com.kerwin.wumei.utils.XToastUtils;
import com.xuexiang.xaop.annotation.SingleClick;
+import com.xuexiang.xhttp2.XHttp;
+import com.xuexiang.xhttp2.callback.CallBackProxy;
+import com.xuexiang.xhttp2.exception.ApiException;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xui.widget.dialog.DialogLoader;
import com.xuexiang.xui.widget.textview.supertextview.SuperTextView;
@@ -64,6 +64,23 @@ public class SettingsFragment extends BaseFragment implements SuperTextView.OnSu
menuLogout.setOnSuperTextViewClickListener(this);
}
+ /**
+ * HTTP退出登录
+ */
+ private void logout(){
+ XHttp.post("/prod-api/logout")
+ .execute(new CallBackProxy, String>(new TipRequestCallBack() {
+ @Override
+ public void onSuccess(String tokenResult) throws Throwable {
+ XToastUtils.success("登出成功" );
+ }
+ @Override
+ public void onError(ApiException e) {
+
+ }
+ }){});
+ }
+
@SingleClick
@Override
public void onClick(SuperTextView superTextView) {
@@ -83,6 +100,7 @@ public class SettingsFragment extends BaseFragment implements SuperTextView.OnSu
getString(R.string.lab_logout_confirm),
getString(R.string.lab_yes),
(dialog, which) -> {
+ logout();
dialog.dismiss();
XUtil.getActivityLifecycleHelper().exit();
TokenUtils.handleLogoutSuccess();
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/device/AddDeviceFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/device/AddDeviceFragment.java
index 8c9af48d..e02cc600 100644
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/AddDeviceFragment.java
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/device/AddDeviceFragment.java
@@ -1,34 +1,45 @@
+/*****************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ *****************************************************************************/
package com.kerwin.wumei.fragment.device;
import android.Manifest;
+import android.graphics.Color;
import android.os.Build;
+import android.os.Handler;
import android.text.method.HideReturnsTransformationMethod;
import android.text.method.PasswordTransformationMethod;
import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
+import android.widget.TextView;
import androidx.appcompat.widget.AppCompatImageView;
import com.kerwin.wumei.MyApp;
import com.kerwin.wumei.R;
import com.kerwin.wumei.activity.AddDeviceActivity;
-import com.kerwin.wumei.activity.MainActivity;
import com.kerwin.wumei.adapter.entity.EspTouchViewModel;
import com.kerwin.wumei.core.BaseFragment;
import com.xuexiang.xpage.annotation.Page;
-import com.xuexiang.xpage.core.PageOption;
-import com.xuexiang.xpage.enums.CoreAnim;
-import com.xuexiang.xui.widget.spinner.materialspinner.MaterialSpinner;
+import com.xuexiang.xui.widget.progress.CircleProgressView;
+import com.xuexiang.xui.widget.textview.supertextview.SuperButton;
import java.util.List;
import butterknife.BindView;
-@Page(name = "WIFI网络配置")
-public class AddDeviceFragment extends BaseFragment {
+@Page(name = "智能配网")
+public class AddDeviceFragment extends BaseFragment implements CircleProgressView.CircleProgressUpdateListener {
@BindView(R.id.advance_frame_layout)
FrameLayout advanceFrameLayout;
@BindView(R.id.advance_linear_layout)
@@ -37,11 +48,24 @@ public class AddDeviceFragment extends BaseFragment {
AppCompatImageView advanceIcon;
@BindView(R.id.wifi_password_icon)
AppCompatImageView wifiPasswordIcon;
+ @BindView(R.id.progressView_circle_main)
+ CircleProgressView progressViewCircleMain;
+ @BindView(R.id.progress_text_main)
+ TextView progressTextMain;
+ @BindView(R.id.btn_config_cancle)
+ SuperButton btnConfigCancle;
+ @BindView(R.id.btn_return)
+ SuperButton btnReturn;
private static final String TAG = AddDeviceFragment.class.getSimpleName();
private static final int REQUEST_PERMISSION = 0x01;
private EspTouchViewModel mViewModel;
+ private boolean bStart=false;
+
+ private Handler mHander=new Handler();
+ private int mCount=0;
+
/**
* 布局的资源id
*
@@ -57,23 +81,30 @@ public class AddDeviceFragment extends BaseFragment {
*/
@Override
protected void initViews() {
+ progressViewCircleMain.setGraduatedEnabled(true);
+ progressViewCircleMain.setProgressViewUpdateListener(this);
//智能配网
mViewModel = ((AddDeviceActivity)this.getActivity()).GetMViewModel();
mViewModel.ssidSpinner = findViewById(R.id.ssid_spinner);
mViewModel.apPasswordEdit = findViewById(R.id.wifi_password_txt);
mViewModel.packageModeGroup = findViewById(R.id.packageModeGroup);
- mViewModel.messageView = findViewById(R.id.messageView);
- mViewModel.confirmBtn = findViewById(R.id.add_device_next_btn);
+ mViewModel.messageView = findViewById(R.id.txt_config_message);
+ mViewModel.messageView.setText("");
+ mViewModel.xsbDeviceCount = findViewById(R.id.xsb_device_count);
+ mViewModel.xsbDeviceCount.setDefaultValue(1);
+ mViewModel.confirmBtn = findViewById(R.id.btn_begin);
mViewModel.confirmBtn.setOnClickListener(v ->
{
- // ((AddDeviceActivity)this.getActivity()).executeEsptouch();
- PageOption.to(AddDeviceTwoFragment.class) //跳转的fragment
- .setAnim(CoreAnim.slide) //页面转场动画
- .setRequestCode(100) //请求码,用于返回结果
- .setAddToBackStack(true) //是否加入堆栈
- .putString("device_mac","0908070605040306")
- .open(this); //打开页面进行跳转
+
+ ((AddDeviceActivity)this.getActivity()).executeEsptouch();
+
+// PageOption.to(AddDeviceTwoFragment.class) //跳转的fragment
+// .setAnim(CoreAnim.slide) //页面转场动画
+// .setRequestCode(100) //请求码,用于返回结果
+// .setAddToBackStack(true) //是否加入堆栈
+// .putString("device_mac","0908070605040306")
+// .open(this); //打开页面进行跳转
});
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@@ -98,6 +129,41 @@ public class AddDeviceFragment extends BaseFragment {
}
});
+ }
+
+
+ /**
+ * 进度条开始更新
+ *
+ * @param view
+ */
+ @Override
+ public void onCircleProgressStart(View view) {
+
+ }
+
+ /**
+ * 进度条更新结束
+ *
+ * @param view
+ */
+ @Override
+ public void onCircleProgressFinished(View view) {
+ progressViewCircleMain.startProgressAnimation();
+ }
+
+
+
+ /**
+ * 进度条更新中
+ *
+ * @param view
+ * @param progress
+ */
+ @Override
+ public void onCircleProgressUpdate(View view, float progress) {
+
+// progressTextMain.setText("10");
}
@@ -135,8 +201,92 @@ public class AddDeviceFragment extends BaseFragment {
}
});
+ btnConfigCancle.setOnClickListener(new View.OnClickListener(){
+ @Override
+ public void onClick(View view){
+ ((AddDeviceActivity)getActivity()).interruptEspTouchTask();
+ endCounter();
+ }
+ });
+ btnReturn.setOnClickListener(new View.OnClickListener(){
+ @Override
+ public void onClick(View view){
+ popToBack();
+ endCounter();
+ }
+ });
}
+ @Override
+ public void onDestroyView() {
+ endCounter();
+ super.onDestroyView();
+ }
+
+ /**
+ * 打开计时器
+ */
+ public void beginCounter(){
+ progressViewCircleMain.startProgressAnimation();
+ mHander.post(mCounter);
+ showMessage("配网中...",true);
+ mViewModel.confirmBtn.setEnabled(false);
+ btnConfigCancle.setEnabled(true);
+ }
+
+ /**
+ * 关闭计时器
+ */
+ public void endCounter(){
+ mHander.removeCallbacks(mCounter);
+ mViewModel.confirmBtn.setEnabled(true);
+ btnConfigCancle.setEnabled(false);
+ progressViewCircleMain.stopProgressAnimation();
+ progressViewCircleMain.setProgressViewUpdateListener(null);
+ }
+
+ /**
+ * 计时器
+ */
+ private Runnable mCounter=new Runnable() {
+ @Override
+ public void run() {
+ int delay=300;
+ if(mCount<30){
+ mCount++;
+ }else if(mCount<50){
+ mCount++;
+ delay=500;
+ }else if(mCount<80){
+ mCount++;
+ delay=1000;
+ }else if(mCount<90){
+ mCount++;
+ delay=3000;
+ }else if(mCount<98){
+ mCount++;
+ delay=10000;
+ }
+ progressTextMain.setText(mCount + "");
+ mHander.postDelayed(this, delay);
+ }
+ };
+
+ /**
+ * 消息提示
+ * @param message
+ * @param isSuccess
+ */
+ public void showMessage(String message,boolean isSuccess){
+ if(isSuccess){
+ mViewModel.messageView.setTextColor(Color.argb(255, 103, 194, 58)); // 绿色
+ }else{
+ mViewModel.messageView.setTextColor(Color.argb(255, 245, 108, 108)); //红色
+ }
+ mViewModel.messageView.setText(message);
+ mViewModel.messageView.setVisibility(View.VISIBLE);
+ }
+
}
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/device/AddDeviceTwoFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/device/AddDeviceTwoFragment.java
index 9003ba42..3193bb90 100644
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/AddDeviceTwoFragment.java
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/device/AddDeviceTwoFragment.java
@@ -1,3 +1,13 @@
+/***************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ***************************************************************************/
package com.kerwin.wumei.fragment.device;
import android.Manifest;
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceDetailFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceDetailFragment.java
new file mode 100644
index 00000000..90acf3b0
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceDetailFragment.java
@@ -0,0 +1,78 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.fragment.device;
+
+import android.os.Bundle;
+import android.util.Log;
+import android.widget.TextView;
+
+import androidx.viewpager.widget.ViewPager;
+
+import com.kerwin.wumei.R;
+import com.kerwin.wumei.core.BaseFragment;
+import com.kerwin.wumei.core.webview.AgentWebActivity;
+import com.kerwin.wumei.utils.XToastUtils;
+import com.xuexiang.xpage.annotation.Page;
+import com.xuexiang.xui.adapter.FragmentAdapter;
+import com.xuexiang.xui.widget.actionbar.TitleBar;
+import com.xuexiang.xui.widget.grouplist.XUIGroupListView;
+import com.xuexiang.xui.widget.tabbar.TabSegment;
+import com.xuexiang.xutil.app.AppUtils;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
+import butterknife.BindView;
+
+
+@Page(name = "设备详情")
+public class DeviceDetailFragment extends BaseFragment {
+ @BindView(R.id.titlebar_min)
+ TitleBar titleBarMin;
+ @BindView(R.id.tabSegment)
+ TabSegment tabSegment;
+ @BindView(R.id.contentViewPager)
+ ViewPager contentViewPager;
+
+ @Override
+ protected TitleBar initTitle() {
+ return null;
+ }
+
+ @Override
+ protected int getLayoutId() {
+ return R.layout.fragment_device_detail;
+ }
+
+ @Override
+ protected void initViews() {
+ titleBarMin.setLeftClickListener(v -> popToBack());
+
+ Bundle arguments = getArguments();
+ Long device_id = arguments.getLong("device_id");
+ String device_num=arguments.getString("device_num");
+ tabSegment.addTab(new TabSegment.Tab("设备"));
+ tabSegment.addTab(new TabSegment.Tab("状态"));
+ tabSegment.addTab(new TabSegment.Tab("配置"));
+
+ FragmentAdapter adapter = new FragmentAdapter<>(getChildFragmentManager());
+ adapter.addFragment(new DeviceEditFragment(device_id,device_num), "");
+ adapter.addFragment(new DeviceStatusFragment(device_id,device_num), "");
+ adapter.addFragment(new DeviceSetFragment(device_id,device_num), "");
+
+ contentViewPager.setAdapter(adapter);
+ contentViewPager.setCurrentItem(0, false);
+ tabSegment.setupWithViewPager(contentViewPager, false);
+ tabSegment.setMode(TabSegment.MODE_FIXED);
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceEditFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceEditFragment.java
new file mode 100644
index 00000000..c1f7bcee
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceEditFragment.java
@@ -0,0 +1,238 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+package com.kerwin.wumei.fragment.device;
+
+import android.util.Log;
+import android.view.View;
+import android.widget.TextView;
+
+import androidx.appcompat.widget.AppCompatImageView;
+
+import com.kerwin.wumei.R;
+import com.kerwin.wumei.core.BaseFragment;
+import com.kerwin.wumei.entity.DictData;
+import com.kerwin.wumei.entity.IotDevice;
+import com.kerwin.wumei.entity.IotDeviceStatus;
+import com.kerwin.wumei.http.callback.TipRequestCallBack;
+import com.kerwin.wumei.http.request.NoDataApiResult;
+import com.kerwin.wumei.utils.XToastUtils;
+import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
+import com.xuexiang.xaop.annotation.SingleClick;
+import com.xuexiang.xhttp2.XHttp;
+import com.xuexiang.xhttp2.callback.CallBackProxy;
+import com.xuexiang.xhttp2.callback.SimpleCallBack;
+import com.xuexiang.xhttp2.exception.ApiException;
+import com.xuexiang.xpage.annotation.Page;
+import com.xuexiang.xui.widget.actionbar.TitleBar;
+import com.xuexiang.xui.widget.edittext.materialedittext.MaterialEditText;
+import com.xuexiang.xui.widget.textview.supertextview.SuperButton;
+import com.xuexiang.xutil.net.JsonUtil;
+
+import java.util.List;
+
+import butterknife.BindView;
+import butterknife.OnClick;
+
+import static com.kerwin.wumei.utils.TokenUtils.clearToken;
+import static com.kerwin.wumei.utils.TokenUtils.getToken;
+import static com.kerwin.wumei.utils.TokenUtils.hasToken;
+
+@Page(name = "编辑设备")
+public class DeviceEditFragment extends BaseFragment {
+
+ @BindView(R.id.et_device_name)
+ MaterialEditText et_device_name;
+ @BindView(R.id.et_device_remark)
+ MaterialEditText et_device_remark;
+ @BindView(R.id.txt_device_num)
+ TextView txt_device_num;
+ @BindView(R.id.txt_device_category)
+ TextView txt_device_category;
+ @BindView(R.id.txt_firmware_version)
+ TextView txt_firmware_version;
+ @BindView(R.id.txt_create_time)
+ TextView txt_create_time;
+ @BindView(R.id.sp_device_temperature)
+ SuperButton sp_device_temperature;
+ @BindView(R.id.update_device_temp_icon)
+ AppCompatImageView update_temp_icon;
+
+ private Long deviceId=0L;
+ private String deviceNum="";
+
+ public DeviceEditFragment(Long device_id,String device_num){
+ deviceId=device_id;
+ deviceNum=device_num;
+ }
+
+ /**
+ * @return 返回为 null意为不需要导航栏
+ */
+ @Override
+ protected TitleBar initTitle() {
+ return null;
+ }
+
+ /**
+ * 布局的资源id
+ *
+ * @return
+ */
+ @Override
+ protected int getLayoutId() {
+ return R.layout.fragment_device_edit;
+ }
+
+ /**
+ * 初始化控件
+ */
+ @Override
+ protected void initViews() {
+ getDevice(deviceId);
+ }
+
+ @SingleClick
+ @OnClick({ R.id.btn_save,R.id.btn_cancle_edit,R.id.update_device_temp_icon})
+ public void onViewClicked(View view) {
+ switch (view.getId()) {
+ case R.id.btn_save:
+ updateDevice(buildDevice());
+ break;
+ case R.id.btn_cancle_edit:
+ popToBack();
+ break;
+ case R.id.update_device_temp_icon:
+ getNewStatusData();
+ update_temp_icon.setVisibility(View.GONE);
+ break;
+ default:
+ break;
+ }
+ }
+
+
+ /**
+ * 构建设备数据
+ */
+ private IotDevice buildDevice(){
+ IotDevice device=new IotDevice();
+ device.setDeviceId(deviceId);
+ device.setDeviceNum((String) txt_device_num.getText());
+ device.setDeviceName(et_device_name.getEditValue());
+ device.setRemark(et_device_remark.getEditValue());
+ return device;
+ }
+
+ /**
+ * HTTP获取最新设备信息
+ */
+ private void getNewStatusData(){
+ XHttp.get("/prod-api/system/status/getStatus/"+deviceNum)
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new CallBackProxy, String>(new TipRequestCallBack() {
+ @Override
+ public void onSuccess(String response) {
+ getDeviceStatus(deviceId);
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ }){});
+ }
+
+ /**
+ * HTTP获取设备状态
+ */
+ private void getDeviceStatus(Long device_id){
+ XHttp.get("/prod-api/system/status/new/"+device_id)
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new SimpleCallBack() {
+ @Override
+ public void onSuccess(IotDeviceStatus status) throws Throwable {
+ //更新温度
+ sp_device_temperature.setText(status.getDeviceTemperature()+"℃");
+ update_temp_icon.setVisibility(View.VISIBLE);
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ });
+ }
+
+ /**
+ * HTTP获取设备信息
+ */
+ private void getDevice(Long device_id){
+ XHttp.get("/prod-api/system/device/"+device_id)
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new SimpleCallBack() {
+ @Override
+ public void onSuccess(IotDevice device) throws Throwable {
+ //绑定数据
+ Log.d("deviceName:",device.getDeviceName());
+ et_device_name.setText(device.getDeviceName());
+ et_device_remark.setText(device.getRemark());
+ txt_device_num.setText(device.getDeviceNum());
+ txt_device_category.setText(device.getCategoryName());
+ txt_firmware_version.setText("v"+device.getFirmwareVersion());
+ txt_create_time.setText(device.getCreateTime());
+ sp_device_temperature.setText(device.getDeviceTemp()+"℃");
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ });
+ }
+
+ /**
+ * HTTP更新设备信息
+ */
+ private void updateDevice(IotDevice device){
+ if(!hasToken()) return;
+ XHttp.put("/prod-api/system/device")
+ .upJson(JsonUtil.toJson(device))
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new CallBackProxy, String>(new TipRequestCallBack() {
+ @Override
+ public void onSuccess(String response) throws Throwable {
+ Log.d("response:",response);
+ XToastUtils.success("数据保存成功");
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ }){});
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceFragment.java
index 84b2a353..0237d400 100644
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceFragment.java
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceFragment.java
@@ -1,35 +1,61 @@
+/****************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ****************************************************************************/
package com.kerwin.wumei.fragment.device;
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.animation.AnimatorSet;
-import android.animation.ObjectAnimator;
-import android.view.View;
-import android.widget.TextView;
+import android.util.Log;
-import androidx.appcompat.widget.AppCompatImageView;
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
import androidx.viewpager2.widget.ViewPager2;
import com.google.android.material.tabs.TabLayout;
import com.google.android.material.tabs.TabLayoutMediator;
+import com.kerwin.wumei.activity.LoginActivity;
import com.kerwin.wumei.core.BaseFragment;
import com.kerwin.wumei.R;
+import com.kerwin.wumei.entity.DictData;
+import com.kerwin.wumei.entity.IotCategory;
+import com.kerwin.wumei.entity.IotDevice;
+import com.kerwin.wumei.entity.IotDeviceSet;
+import com.kerwin.wumei.entity.IotDeviceStatus;
+import com.kerwin.wumei.entity.IotGroup;
+import com.kerwin.wumei.fragment.LoginFragment;
+import com.kerwin.wumei.http.callback.TipRequestCallBack;
+import com.kerwin.wumei.http.request.ListApiResult;
+import com.kerwin.wumei.http.request.NoDataApiResult;
import com.kerwin.wumei.utils.XToastUtils;
-import com.xuexiang.xaop.annotation.SingleClick;
+import com.xuexiang.xhttp2.XHttp;
+import com.xuexiang.xhttp2.callback.CallBackProxy;
+import com.xuexiang.xhttp2.callback.SimpleCallBack;
+import com.xuexiang.xhttp2.exception.ApiException;
import com.xuexiang.xpage.annotation.Page;
-import com.xuexiang.xui.adapter.simple.AdapterItem;
import com.xuexiang.xui.utils.WidgetUtils;
import com.xuexiang.xui.widget.actionbar.TitleBar;
-import com.xuexiang.xui.widget.popupwindow.popup.XUISimplePopup;
-import com.xuexiang.xutil.display.ViewUtils;
+import com.xuexiang.xui.widget.toast.XToast;
+import com.xuexiang.xutil.app.ActivityUtils;
+import com.xuexiang.xutil.net.JsonUtil;
+
+import java.util.ArrayList;
+import java.util.List;
import butterknife.BindView;
-import butterknife.OnClick;
import static com.google.android.material.tabs.TabLayout.MODE_SCROLLABLE;
+import static com.kerwin.wumei.utils.TokenUtils.clearToken;
+import static com.kerwin.wumei.utils.TokenUtils.getToken;
+import static com.kerwin.wumei.utils.TokenUtils.hasToken;
@Page(name = "设备")
public class DeviceFragment extends BaseFragment implements TabLayout.OnTabSelectedListener{
+
@BindView(R.id.tab_layout)
TabLayout tabLayout;
@BindView(R.id.view_pager)
@@ -46,7 +72,6 @@ public class DeviceFragment extends BaseFragment implements TabLayout.OnTabSelec
// mAdapter.addFragment(2, SimpleTabFragment.newInstance("动态加入"), "动态加入");
// mAdapter.removeFragment(2);
// mAdapter.notifyDataSetChanged();
-
return null;
}
@@ -65,27 +90,14 @@ public class DeviceFragment extends BaseFragment implements TabLayout.OnTabSelec
*/
@Override
protected void initViews() {
- mAdapter = new FragmentStateViewPager2Adapter(this);
- tabLayout.setTabMode(MODE_SCROLLABLE);
- tabLayout.addOnTabSelectedListener(this);
- viewPager.setAdapter(mAdapter);
- // 设置缓存的数量
- viewPager.setOffscreenPageLimit(1);
- new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> tab.setText(mAdapter.getPageTitle(position))).attach();
-
- // 动态加载选项卡内容
- for (String page : MultiPage.getPageNames()) {
- mAdapter.addFragment(SimpleTabFragment.newInstance(page), page);
- }
- mAdapter.notifyDataSetChanged();
- viewPager.setCurrentItem(0, false);
- WidgetUtils.setTabLayoutTextFont(tabLayout);
+ //获取分组列表
+ getGroupList(this);
}
@Override
public void onTabSelected(TabLayout.Tab tab) {
- XToastUtils.toast("选中了:" + tab.getText());
+
}
@Override
@@ -97,4 +109,198 @@ public class DeviceFragment extends BaseFragment implements TabLayout.OnTabSelec
public void onTabReselected(TabLayout.Tab tab) {
}
+
+ /**
+ * 初始化设备列表
+ * @param listener
+ * @param groupList
+ */
+ private void initDeviceListView(@NonNull TabLayout.OnTabSelectedListener listener,List groupList){
+ mAdapter = new FragmentStateViewPager2Adapter((Fragment) listener);
+ tabLayout.setTabMode(MODE_SCROLLABLE);
+ tabLayout.addOnTabSelectedListener(listener);
+ viewPager.setAdapter(mAdapter);
+ // 设置缓存的数量
+ viewPager.setOffscreenPageLimit(10);
+ new TabLayoutMediator(tabLayout, viewPager, (tab, position) -> tab.setText(mAdapter.getPageTitle(position))).attach();
+
+ // 动态加载选项卡内容
+ for (IotGroup group: groupList) {
+ mAdapter.addFragment(SimpleTabFragment.newInstance(group.getGroupId()), group.getGroupName());
+ }
+ mAdapter.notifyDataSetChanged();
+ viewPager.setCurrentItem(0, false);
+ WidgetUtils.setTabLayoutTextFont(tabLayout);
+ }
+
+ /**
+ * HTTP获取分组列表
+ */
+ private void getGroupList(@NonNull TabLayout.OnTabSelectedListener listener){
+ XHttp.get("/prod-api/system/group/list?pageNum=1&pageSize=100")
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new CallBackProxy>, List>(new TipRequestCallBack>() {
+ @Override
+ public void onSuccess(List list) throws Throwable {
+ List groupList=list;
+ IotGroup iotGroup=new IotGroup();
+ iotGroup.setGroupId(0L);
+ iotGroup.setGroupName("全部");
+ iotGroup.setGroupOrder(0);
+ groupList.add(0,iotGroup);
+
+ initDeviceListView(listener,groupList);
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ List groupList=new ArrayList();
+ IotGroup group=new IotGroup();
+ group.setGroupId(0L);
+ group.setGroupName("全部");
+ groupList.add(group);
+ initDeviceListView(listener,groupList);
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ }){});
+ }
+
+
+
+
+
+ /**
+ * HTTP获取触发源字典列表
+ */
+ private void getTriggerSourceDic(){
+ XHttp.get("/prod-api/system/dict/data/type/iot_trigger_source")
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new SimpleCallBack>() {
+ @Override
+ public void onSuccess(List response) {
+ Log.d("group name:",response.get(0).getDictLabel());
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+
+ });
+ }
+
+
+ /**
+ * HTTP获取分组详情
+ */
+ private void getGroup(Long groupId){
+ if(!hasToken()) return;
+ XHttp.get("/prod-api/system/group/"+groupId)
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new SimpleCallBack(){
+ @Override
+ public void onSuccess(IotGroup response) throws Throwable {
+
+ Log.d("response:","response");
+ XToastUtils.info("response");
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ });
+ }
+
+ /**
+ * HTTP新增分组
+ */
+ private void addGroup(IotGroup group){
+ if(!hasToken()) return;
+ XHttp.post("/prod-api/system/group")
+ .upJson(JsonUtil.toJson(group))
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new CallBackProxy, String>(new TipRequestCallBack() {
+ @Override
+ public void onSuccess(String response) throws Throwable {
+
+ Log.d("response:","response");
+ XToastUtils.info("response");
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ }){});
+ }
+
+ /**
+ * HTTP编辑分组
+ */
+ private void editGroup(IotGroup group){
+ if(!hasToken()) return;
+ XHttp.put("/prod-api/system/group")
+ .upJson(JsonUtil.toJson(group))
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new CallBackProxy, String>(new TipRequestCallBack() {
+ @Override
+ public void onSuccess(String response) throws Throwable {
+ Log.d("response:","response");
+ XToastUtils.info("response");
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ }){});
+ }
+
+ /**
+ * HTTP删除分组
+ */
+ private void deleteGroup(Long groupId){
+ if(!hasToken()) return;
+ XHttp.delete("/prod-api/system/group/"+groupId)
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new CallBackProxy, String>(new TipRequestCallBack() {
+ @Override
+ public void onSuccess(String response) throws Throwable {
+ Log.d("response:","response");
+ XToastUtils.info("response");
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ }){});
+ }
+
+
}
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceSetFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceSetFragment.java
new file mode 100644
index 00000000..a7c2a10e
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceSetFragment.java
@@ -0,0 +1,268 @@
+/***************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ***************************************************************************/
+package com.kerwin.wumei.fragment.device;
+
+import android.util.Log;
+import android.view.View;
+import android.widget.Spinner;
+
+import com.kerwin.wumei.R;
+import com.kerwin.wumei.core.BaseFragment;
+import com.kerwin.wumei.entity.DictData;
+import com.kerwin.wumei.entity.IotDevice;
+import com.kerwin.wumei.entity.IotDeviceSet;
+import com.kerwin.wumei.http.callback.TipRequestCallBack;
+import com.kerwin.wumei.http.request.ListApiResult;
+import com.kerwin.wumei.http.request.NoDataApiResult;
+import com.kerwin.wumei.utils.XToastUtils;
+import com.xuexiang.xaop.annotation.SingleClick;
+import com.xuexiang.xhttp2.XHttp;
+import com.xuexiang.xhttp2.callback.CallBackProxy;
+import com.xuexiang.xhttp2.callback.SimpleCallBack;
+import com.xuexiang.xhttp2.exception.ApiException;
+import com.xuexiang.xpage.annotation.Page;
+import com.xuexiang.xui.utils.WidgetUtils;
+import com.xuexiang.xui.widget.actionbar.TitleBar;
+import com.xuexiang.xui.widget.button.switchbutton.SwitchButton;
+import com.xuexiang.xui.widget.picker.XSeekBar;
+import com.xuexiang.xutil.net.JsonUtil;
+import java.util.List;
+
+import butterknife.BindView;
+import butterknife.OnClick;
+
+import static com.kerwin.wumei.utils.TokenUtils.clearToken;
+import static com.kerwin.wumei.utils.TokenUtils.getToken;
+import static com.kerwin.wumei.utils.TokenUtils.hasToken;
+
+@Page(name = "编辑设备配置")
+public class DeviceSetFragment extends BaseFragment {
+
+ @BindView(R.id.sb_radar)
+ SwitchButton sb_radar;
+ @BindView(R.id.sb_alarm)
+ SwitchButton sb_alarm;
+ @BindView(R.id.sb_rf_control)
+ SwitchButton sb_rf_control;
+ @BindView(R.id.sb_rf_learn)
+ SwitchButton sb_rf_learn;
+ @BindView(R.id.sb_rf_clear)
+ SwitchButton sb_rf_clear;
+ @BindView(R.id.sb_reset)
+ SwitchButton sb_reset;
+ @BindView(R.id.sb_open_ap)
+ SwitchButton sb_open_ap;
+
+ @BindView(R.id.spinner_rf_func_one)
+ Spinner spinner_rf_func_one;
+ @BindView(R.id.spinner_rf_func_two)
+ Spinner spinner_rf_func_two;
+ @BindView(R.id.spinner_rf_func_three)
+ Spinner spinner_rf_func_three;
+ @BindView(R.id.spinner_rf_func_four)
+ Spinner spinner_rf_func_four;
+
+ @BindView(R.id.xsb_radar_interval)
+ XSeekBar xsb_radar_interval;
+
+ private Long deviceId=0L;
+ private String deviceNum="";
+ private List rfFunctionList;
+ private String[] rfFunctionStrings;
+
+ public DeviceSetFragment(Long device_id,String device_num){
+ deviceId=device_id;
+ deviceNum=device_num;
+ }
+
+ /**
+ * @return 返回为 null意为不需要导航栏
+ */
+ @Override
+ protected TitleBar initTitle() {
+ return null;
+ }
+
+ /**
+ * 布局的资源id
+ *
+ * @return
+ */
+ @Override
+ protected int getLayoutId() {
+ return R.layout.fragment_device_set;
+ }
+
+ /**
+ * 初始化控件
+ */
+ @Override
+ protected void initViews() {
+ getRFFunctionDic();
+
+ }
+
+ @SingleClick
+ @OnClick({ R.id.btn_apply_set,R.id.btn_cancle_set})
+ public void onViewClicked(View view) {
+ switch (view.getId()) {
+ case R.id.btn_apply_set:
+ updateDeviceSet(buildDeviceSet());
+ break;
+ case R.id.btn_cancle_set:
+ popToBack();
+ default:
+ break;
+ }
+ }
+
+ /**
+ * 构建设备配置数据
+ */
+ private IotDeviceSet buildDeviceSet(){
+ IotDeviceSet deviceSet=new IotDeviceSet();
+ deviceSet.setDeviceId(deviceId);
+ deviceSet.setDeviceNum(deviceNum);
+ deviceSet.setIsHost(0); //不托管
+ deviceSet.setIsRadar(sb_radar.isChecked()==true?1:0);
+ deviceSet.setIsAlarm(sb_alarm.isChecked()==true?1:0);
+ deviceSet.setIsRfLearn(sb_rf_learn.isChecked()==true?1:0);
+ deviceSet.setIsRfClear(sb_rf_clear.isChecked()==true?1:0);
+ deviceSet.setIsAp(sb_open_ap.isChecked()==true?1:0);
+ deviceSet.setIsReset(sb_reset.isChecked()==true?1:0);
+ deviceSet.setIsRfControl(sb_rf_control.isChecked()==true?1:0);
+ deviceSet.setRadarInterval(xsb_radar_interval.getSelectedNumber());
+ deviceSet.setRfOneFunc(getValueByDicString(spinner_rf_func_one.getSelectedItem().toString()));
+ deviceSet.setRfTwoFunc(getValueByDicString(spinner_rf_func_two.getSelectedItem().toString()));
+ deviceSet.setRfThreeFunc(getValueByDicString(spinner_rf_func_three.getSelectedItem().toString()));
+ deviceSet.setRfFourFunc(getValueByDicString(spinner_rf_func_four.getSelectedItem().toString()));
+ return deviceSet;
+ }
+
+ /**
+ * 根据字典标签获取字典值
+ * @param label
+ * @return
+ */
+ private int getValueByDicString(String label){
+ for(DictData dict:rfFunctionList){
+ if(dict.getDictLabel().equals(label)){
+ return dict.getDictValue();
+ }
+ }
+ return 0;
+ }
+
+ /**
+ * 根据字典值获取索引
+ */
+ private int getIndexByDicValue(int value){
+ for(int i=0;i>() {
+ @Override
+ public void onSuccess(List list) {
+ //绑定数据
+ rfFunctionList=list;
+ rfFunctionStrings=new String[rfFunctionList.size()];
+ for(int i=0;i() {
+ @Override
+ public void onSuccess(IotDeviceSet set) throws Throwable {
+ //绑定数据
+ Log.d("device num:",set.getDeviceNum());
+ sb_radar.setChecked(set.getIsRadar()==1);
+ sb_alarm.setChecked(set.getIsAlarm()==1);
+ sb_rf_control.setChecked(set.getIsRfControl()==1);
+ xsb_radar_interval.setDefaultValue(set.getRadarInterval());
+ spinner_rf_func_one.setSelection(getIndexByDicValue(set.getRfOneFunc()));
+ spinner_rf_func_two.setSelection(getIndexByDicValue(set.getRfTwoFunc()));
+ spinner_rf_func_three.setSelection(getIndexByDicValue(set.getRfThreeFunc()));
+ spinner_rf_func_four.setSelection(getIndexByDicValue(set.getRfFourFunc()));
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ });
+ }
+
+ /**
+ * HTTP更新设备配置
+ */
+ private void updateDeviceSet(IotDeviceSet deviceSet){
+ if(!hasToken()) return;
+ XHttp.put("/prod-api/system/set")
+ .upJson(JsonUtil.toJson(deviceSet))
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new CallBackProxy, String>(new TipRequestCallBack() {
+ @Override
+ public void onSuccess(String response) throws Throwable {
+ Log.d("response:",response);
+ XToastUtils.success("设备配置更新成功");
+ sb_reset.setChecked(false);
+ sb_open_ap.setChecked(false);
+ sb_rf_clear.setChecked(false);
+ sb_rf_learn.setChecked(false);
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ }){});
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceStatusFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceStatusFragment.java
new file mode 100644
index 00000000..c02598d0
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceStatusFragment.java
@@ -0,0 +1,307 @@
+/*****************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ *****************************************************************************/
+package com.kerwin.wumei.fragment.device;
+
+import android.util.Log;
+import android.view.View;
+import android.widget.ArrayAdapter;
+import android.widget.CompoundButton;
+import android.widget.FrameLayout;
+import android.widget.Spinner;
+
+import androidx.appcompat.widget.AppCompatImageView;
+
+import com.kerwin.wumei.R;
+import com.kerwin.wumei.core.BaseFragment;
+import com.kerwin.wumei.entity.DictData;
+import com.kerwin.wumei.entity.IotDeviceStatus;
+import com.kerwin.wumei.http.callback.TipRequestCallBack;
+import com.kerwin.wumei.http.request.NoDataApiResult;
+import com.kerwin.wumei.utils.XToastUtils;
+import com.xuexiang.rxutil2.rxjava.RxJavaUtils;
+import com.xuexiang.xaop.annotation.SingleClick;
+import com.xuexiang.xhttp2.XHttp;
+import com.xuexiang.xhttp2.callback.CallBackProxy;
+import com.xuexiang.xhttp2.callback.SimpleCallBack;
+import com.xuexiang.xhttp2.exception.ApiException;
+import com.xuexiang.xpage.annotation.Page;
+import com.xuexiang.xui.utils.WidgetUtils;
+import com.xuexiang.xui.widget.actionbar.TitleBar;
+import com.xuexiang.xui.widget.button.switchbutton.SwitchButton;
+import com.xuexiang.xui.widget.dialog.MiniLoadingDialog;
+import com.xuexiang.xui.widget.picker.XSeekBar;
+import com.xuexiang.xui.widget.textview.supertextview.SuperButton;
+import com.xuexiang.xutil.net.JsonUtil;
+
+import java.util.ArrayList;
+import java.util.List;
+import butterknife.BindView;
+import butterknife.OnClick;
+
+import static android.R.layout.simple_spinner_item;
+import static com.kerwin.wumei.utils.TokenUtils.clearToken;
+import static com.kerwin.wumei.utils.TokenUtils.getToken;
+import static com.kerwin.wumei.utils.TokenUtils.hasToken;
+
+@Page(name = "编辑设备状态")
+public class DeviceStatusFragment extends BaseFragment implements CompoundButton.OnCheckedChangeListener {
+
+ @BindView(R.id.sb_relay)
+ SwitchButton sb_relay;
+ @BindView(R.id.sb_light)
+ SwitchButton sb_light;
+ @BindView(R.id.spinner_light_mode)
+ Spinner spinner_light_mode;
+ @BindView(R.id.xsb_fade_interval)
+ XSeekBar xsb_fade_interval;
+ @BindView(R.id.xsb_fade_time)
+ XSeekBar xsb_fade_time;
+ @BindView(R.id.xsb_brightness)
+ XSeekBar xsb_brightness;
+ @BindView(R.id.xsb_red)
+ XSeekBar xsb_red;
+ @BindView(R.id.xsb_green)
+ XSeekBar xsb_green;
+ @BindView(R.id.xsb_blue)
+ XSeekBar xsb_blue;
+ @BindView(R.id.sp_temperature)
+ SuperButton sp_temperature;
+ @BindView(R.id.sp_humidity)
+ SuperButton sp_humidity;
+ @BindView(R.id.frame_layout_loading_status)
+ FrameLayout frame_layout_loading_status;
+
+ private Long deviceId=0L;
+ private String deviceNum="";
+ private List lightModeList;
+ private String[] lightModeStrings;
+
+ public DeviceStatusFragment(Long device_id,String device_num){
+ deviceId=device_id;
+ deviceNum=device_num;
+ }
+
+ /**
+ * @return 返回为 null意为不需要导航栏
+ */
+ @Override
+ protected TitleBar initTitle() {
+ return null;
+ }
+
+ /**
+ * 布局的资源id
+ *
+ * @return
+ */
+ @Override
+ protected int getLayoutId() {
+ return R.layout.fragment_device_status;
+ }
+
+ /**
+ * 初始化控件
+ */
+ @Override
+ protected void initViews() {
+ getLightModeDic();
+
+ }
+
+ /**
+ * 初始化监听
+ */
+ @Override
+ protected void initListeners() {
+
+ }
+
+ @Override
+ public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+ XToastUtils.toast("isChecked:" + isChecked);
+ }
+
+ @SingleClick
+ @OnClick({ R.id.btn_apply_status,R.id.btn_cancle_status,R.id.frame_layout_loading_status})
+ public void onViewClicked(View view) {
+ switch (view.getId()) {
+ case R.id.btn_apply_status:
+ updateDeviceStatus(buildDeviceStatus());
+ break;
+ case R.id.btn_cancle_status:
+ popToBack();
+ break;
+ case R.id.frame_layout_loading_status:
+ getNewStatusData();
+ frame_layout_loading_status.setVisibility(View.INVISIBLE);
+ break;
+ default:
+ break;
+ }
+ }
+
+ /**
+ * 构建设备状态数据
+ */
+ private IotDeviceStatus buildDeviceStatus(){
+ IotDeviceStatus deviceStatus=new IotDeviceStatus();
+ deviceStatus.setDeviceId(deviceId);
+ deviceStatus.setDeviceNum(deviceNum);
+ deviceStatus.setRelayStatus(sb_relay.isChecked()==true?1:0);
+ deviceStatus.setLightStatus(sb_light.isChecked()==true?1:0);
+ deviceStatus.setLightMode(getValueByDicString(spinner_light_mode.getSelectedItem().toString()));
+ deviceStatus.setLightInterval(xsb_fade_interval.getSelectedNumber());
+ deviceStatus.setFadeTime(xsb_fade_time.getSelectedNumber());
+ deviceStatus.setBrightness(xsb_brightness.getSelectedNumber());
+ deviceStatus.setRed(xsb_red.getSelectedNumber());
+ deviceStatus.setBlue(xsb_blue.getSelectedNumber());
+ deviceStatus.setGreen(xsb_green.getSelectedNumber());
+ deviceStatus.setTriggerSource(1); //0-无、1-按键、2.手机、3-浏览器、4-射频遥控、5-雷达、6-报警、7-定时
+ return deviceStatus;
+ }
+
+ /**
+ * 根据字典标签获取字典值
+ */
+ private int getValueByDicString(String label){
+ for(DictData dict:lightModeList){
+ if(dict.getDictLabel().equals(label)){
+ return dict.getDictValue();
+ }
+ }
+ return 0;
+ }
+
+ /**
+ * 根据字典值获取索引
+ */
+ private int getIndexByDicValue(int value){
+ for(int i=0;i, String>(new TipRequestCallBack() {
+ @Override
+ public void onSuccess(String response) {
+ getDeviceStatus(deviceId);
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ }){});
+ }
+
+ /**
+ * HTTP获取灯模式字典列表
+ */
+ private void getLightModeDic(){
+ XHttp.get("/prod-api/system/dict/data/type/light_mode")
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new SimpleCallBack>() {
+ @Override
+ public void onSuccess(List list) {
+ lightModeList=list;
+ lightModeStrings=new String[lightModeList.size()];
+ for (int i=0;i() {
+ @Override
+ public void onSuccess(IotDeviceStatus status) throws Throwable {
+ //绑定数据
+ Log.d("device num:",status.getDeviceNum());
+ sb_relay.setChecked(status.getRelayStatus()==1);
+ sb_light.setChecked(status.getLightStatus()==1);
+ xsb_fade_interval.setDefaultValue(status.getLightInterval());
+ xsb_fade_time.setDefaultValue(status.getFadeTime());
+ xsb_red.setDefaultValue(status.getRed());
+ xsb_green.setDefaultValue(status.getGreen());
+ xsb_blue.setDefaultValue(status.getBlue());
+ xsb_blue.setDefaultValue(status.getBrightness());
+ sp_temperature.setText(status.getAirTemperature()+"℃");
+ sp_humidity.setText(status.getAirHumidity()+"RH%");
+ spinner_light_mode.setSelection(getIndexByDicValue(status.getLightMode()));
+ frame_layout_loading_status.setVisibility(View.VISIBLE);
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ });
+ }
+
+ /**
+ * HTTP更新设备状态
+ */
+ private void updateDeviceStatus(IotDeviceStatus deviceStatus){
+ if(!hasToken()) return;
+ XHttp.put("/prod-api/system/status")
+ .upJson(JsonUtil.toJson(deviceStatus))
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new CallBackProxy, String>(new TipRequestCallBack() {
+ @Override
+ public void onSuccess(String response) throws Throwable {
+ Log.d("response:",response);
+ XToastUtils.success("设备状态更新成功");
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+
+ }
+ }){});
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/device/FragmentStateViewPager2Adapter.java b/android/app/src/main/java/com/kerwin/wumei/fragment/device/FragmentStateViewPager2Adapter.java
index b0a75892..3ad33696 100644
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/FragmentStateViewPager2Adapter.java
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/device/FragmentStateViewPager2Adapter.java
@@ -1,3 +1,13 @@
+/*****************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ *****************************************************************************/
package com.kerwin.wumei.fragment.device;
import androidx.annotation.NonNull;
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/device/GroupFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/device/GroupFragment.java
index d85115e1..d4e9c9f2 100644
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/GroupFragment.java
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/device/GroupFragment.java
@@ -1,3 +1,13 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
package com.kerwin.wumei.fragment.device;
import com.kerwin.wumei.R;
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/device/SceneFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/device/SceneFragment.java
index b07a69b8..9b79316d 100644
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/SceneFragment.java
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/device/SceneFragment.java
@@ -1,34 +1,67 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
package com.kerwin.wumei.fragment.device;
-import android.Manifest;
-import android.os.Build;
-import android.text.method.HideReturnsTransformationMethod;
-import android.text.method.PasswordTransformationMethod;
-import android.util.Log;
+import android.graphics.Color;
import android.view.View;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
+import android.widget.TextView;
-import androidx.appcompat.widget.AppCompatImageView;
-
-import com.kerwin.wumei.MyApp;
import com.kerwin.wumei.R;
-import com.kerwin.wumei.activity.MainActivity;
-import com.kerwin.wumei.adapter.entity.EspTouchViewModel;
import com.kerwin.wumei.core.BaseFragment;
+import com.kerwin.wumei.core.webview.AgentWebActivity;
+import com.kerwin.wumei.entity.bo.CaptureImage;
+import com.kerwin.wumei.http.callback.TipRequestCallBack;
+import com.kerwin.wumei.http.request.CaptchaImageApiResult;
+import com.kerwin.wumei.utils.XToastUtils;
+import com.xuexiang.xaop.annotation.SingleClick;
+import com.xuexiang.xhttp2.XHttp;
+import com.xuexiang.xhttp2.callback.CallBackProxy;
+import com.xuexiang.xhttp2.exception.ApiException;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xpage.enums.CoreAnim;
import com.xuexiang.xui.widget.actionbar.TitleBar;
-import com.xuexiang.xui.widget.spinner.materialspinner.MaterialSpinner;
-
-import java.util.List;
+import com.xuexiang.xui.widget.button.switchbutton.SwitchButton;
+import com.xuexiang.xui.widget.edittext.materialedittext.MaterialEditText;
+import com.xuexiang.xui.widget.textview.supertextview.SuperButton;
import butterknife.BindView;
+import butterknife.OnClick;
+
+import static com.kerwin.wumei.utils.SettingUtils.getApIp;
+import static com.kerwin.wumei.utils.SettingUtils.getIsHttps;
+import static com.kerwin.wumei.utils.SettingUtils.getServerPort;
+import static com.kerwin.wumei.utils.SettingUtils.getServerip;
+import static com.kerwin.wumei.utils.SettingUtils.setApIp;
+import static com.kerwin.wumei.utils.SettingUtils.setServeUrl;
+import static com.kerwin.wumei.utils.TokenUtils.clearToken;
-@Page(anim = CoreAnim.none)
+@Page(name = "用户信息")
public class SceneFragment extends BaseFragment {
+ @BindView(R.id.btn_connect_test)
+ SuperButton btn_connect_test;
+ @BindView(R.id.btn_save_serve)
+ SuperButton btn_save_serve;
+ @BindView(R.id.txt_message)
+ TextView txt_message;
+ @BindView(R.id.et_serve)
+ MaterialEditText et_serve_ip;
+ @BindView(R.id.et_port)
+ MaterialEditText et_port;
+ @BindView(R.id.sb_https)
+ SwitchButton sb_https;
+ @BindView(R.id.et_ap_address)
+ MaterialEditText et_ap_address;
+
/**
* @return 返回为 null意为不需要导航栏
*/
@@ -51,9 +84,89 @@ public class SceneFragment extends BaseFragment {
* 初始化控件
*/
@Override
- protected void initViews() { }
+ protected void initViews() {
+ et_serve_ip.setText(getServerip());
+ et_port.setText(getServerPort());
+ sb_https.setChecked(getIsHttps());
+ et_ap_address.setText(getApIp());
+ }
@Override
protected void initListeners() { }
+ @SingleClick
+ @OnClick({ R.id.btn_save_serve,R.id.btn_connect_test,R.id.btn_open_ap})
+ public void onViewClicked(View view) {
+ if(!et_port.validate()) return;
+ if(et_serve_ip.getEditValue().length()==0)
+ {
+ showMessage("服务端地址不能为空",false);
+ return;
+ }
+
+ switch (view.getId()) {
+ case R.id.btn_save_serve:
+ setServeUrl(et_serve_ip.getEditValue(),et_port.getEditValue(),sb_https.isChecked());
+ clearToken();
+ showMessage("服务端地址信息存储成功,请重新启动APP!",true);
+ break;
+ case R.id.btn_connect_test:
+ getCatpureImage();
+ break;
+ case R.id.btn_open_ap:
+ if(et_ap_address.getEditValue()==null || et_ap_address.getEditValue().length()==0){
+ XToastUtils.error("AP的地址不能为空");
+ }else {
+ AgentWebActivity.goWeb(getContext(), et_ap_address.getEditValue());
+ setApIp(et_ap_address.getEditValue());
+ }
+ default:
+ break;
+ }
+ }
+
+ private String buildServeString(){
+ String address="";
+ if(sb_https.isChecked()){
+ address="https://";
+ }else{
+ address="http://";
+ }
+ return address+et_serve_ip.getEditValue()+":"+et_port.getEditValue();
+ }
+
+
+ /**
+ * HTTP获取验证码(用于连接测试)
+ */
+ private void getCatpureImage(){
+ XHttp.get(buildServeString() + "/prod-api/captchaImage")
+ .execute(new CallBackProxy, CaptureImage>(new TipRequestCallBack() {
+ @Override
+ public void onSuccess(CaptureImage image) throws Throwable {
+ String uuid=image.getUuid();
+ showMessage("服务端连接成功",true);
+ }
+ @Override
+ public void onError(ApiException e) {
+ showMessage("服务端连接失败\n"+"连接地址:"+buildServeString()+"\n错误提示:"+e.getMessage(),false);
+ }
+ }){});
+ }
+
+ /**
+ * 显示提示
+ * @param message
+ * @param isSuccess
+ */
+ private void showMessage(String message,boolean isSuccess){
+ if(isSuccess){
+ txt_message.setTextColor(Color.argb(255, 103, 194, 58)); // 绿色
+ }else{
+ txt_message.setTextColor(Color.argb(255, 245, 108, 108)); //红色
+ }
+ txt_message.setText(message);
+ txt_message.setVisibility(View.VISIBLE);
+ }
+
}
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/device/ShareDeviceFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/device/ShareDeviceFragment.java
index 964c66e2..553a25e6 100644
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/ShareDeviceFragment.java
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/device/ShareDeviceFragment.java
@@ -1,3 +1,13 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
package com.kerwin.wumei.fragment.device;
import com.kerwin.wumei.R;
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/device/SimpleTabFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/device/SimpleTabFragment.java
index 965e7d08..67779605 100644
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/SimpleTabFragment.java
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/device/SimpleTabFragment.java
@@ -1,151 +1,141 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
package com.kerwin.wumei.fragment.device;
+import android.annotation.SuppressLint;
import android.content.Context;
-import android.graphics.Point;
-import android.graphics.drawable.Drawable;
-import android.os.Bundle;
+import android.graphics.Color;
import android.os.Vibrator;
-import android.text.method.HideReturnsTransformationMethod;
-import android.text.method.PasswordTransformationMethod;
-import android.util.DisplayMetrics;
import android.util.Log;
-import android.view.Display;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.WindowManager;
-import android.widget.TextView;
+import android.widget.FrameLayout;
import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;
-import androidx.cardview.widget.CardView;
-import androidx.core.content.ContextCompat;
-import androidx.core.graphics.drawable.DrawableCompat;
-import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.recyclerview.widget.RecyclerView;
import com.alibaba.android.vlayout.DelegateAdapter;
-import com.alibaba.android.vlayout.LayoutHelper;
import com.alibaba.android.vlayout.VirtualLayoutManager;
-import com.alibaba.android.vlayout.layout.GridLayoutHelper;
-import com.alibaba.android.vlayout.layout.LinearLayoutHelper;
import com.alibaba.android.vlayout.layout.StaggeredGridLayoutHelper;
-import com.alibaba.android.vlayout.layout.StickyLayoutHelper;
import com.kerwin.wumei.R;
import com.kerwin.wumei.adapter.base.broccoli.BroccoliSimpleDelegateAdapter;
import com.kerwin.wumei.adapter.base.delegate.SimpleDelegateAdapter;
-import com.kerwin.wumei.adapter.base.delegate.SingleDelegateAdapter;
-import com.kerwin.wumei.adapter.entity.NewInfo;
-import com.kerwin.wumei.utils.DemoDataProvider;
-import com.kerwin.wumei.utils.RandomUtils;
-import com.kerwin.wumei.utils.Utils;
+import com.kerwin.wumei.core.BaseFragment;
+import com.kerwin.wumei.entity.IotCategory;
+import com.kerwin.wumei.entity.IotDeviceStatus;
+import com.kerwin.wumei.entity.vo.IotDeviceVo;
+import com.kerwin.wumei.http.callback.TipRequestCallBack;
+import com.kerwin.wumei.http.request.ListApiResult;
+import com.kerwin.wumei.http.request.NoDataApiResult;
import com.kerwin.wumei.utils.XToastUtils;
import com.scwang.smartrefresh.layout.SmartRefreshLayout;
-import com.xuexiang.xrouter.annotation.AutoWired;
-import com.xuexiang.xrouter.launcher.XRouter;
+import com.xuexiang.xhttp2.XHttp;
+import com.xuexiang.xhttp2.callback.CallBackProxy;
+import com.xuexiang.xhttp2.exception.ApiException;
+import com.xuexiang.xpage.annotation.Page;
+import com.xuexiang.xpage.base.XPageFragment;
+import com.xuexiang.xpage.core.PageOption;
import com.xuexiang.xui.adapter.recyclerview.RecyclerViewHolder;
-import com.xuexiang.xui.adapter.simple.AdapterItem;
-import com.xuexiang.xui.widget.banner.widget.banner.SimpleImageBanner;
+import com.xuexiang.xui.widget.actionbar.TitleBar;
import com.xuexiang.xui.widget.button.SwitchIconView;
-import com.xuexiang.xui.widget.imageview.ImageLoader;
-import com.xuexiang.xui.widget.imageview.RadiusImageView;
-import com.xuexiang.xui.widget.textview.supertextview.SuperButton;
+import com.xuexiang.xutil.net.JsonUtil;
import java.util.ArrayList;
-import java.util.Collection;
+import java.util.List;
import butterknife.BindView;
-import butterknife.ButterKnife;
-import butterknife.Unbinder;
import me.samlss.broccoli.Broccoli;
-import static com.xuexiang.xui.utils.Utils.getScreenWidth;
+import static com.kerwin.wumei.utils.TokenUtils.clearToken;
+import static com.kerwin.wumei.utils.TokenUtils.getToken;
+import static com.kerwin.wumei.utils.TokenUtils.hasToken;
import static com.xuexiang.xutil.display.DensityUtils.dip2px;
-/**
- * @author xuexiang
- * @since 2020/4/21 12:24 AM
- */
-public class SimpleTabFragment extends Fragment {
+@Page(name = "设备")
+public class SimpleTabFragment extends BaseFragment {
private static final String TAG = "SimpleTabFragment";
- private static final String KEY_TITLE = "title";
-
-// @BindView(R.id.tv_title)
-// TextView tvTitle;
-// @BindView(R.id.tv_explain)
-// TextView tvExplain;
@BindView(R.id.recyclerView)
RecyclerView recyclerView;
@BindView(R.id.refreshLayout)
SmartRefreshLayout refreshLayout;
-// @BindView(R.id.item_card_view)
-// CardView itemCardView;
- private Unbinder mUnbinder;
-
- private SimpleDelegateAdapter mNewsAdapter;
-
- @AutoWired(name = KEY_TITLE)
- String title;
+ private SimpleDelegateAdapter deviceAdapter;
+ private List devices=new ArrayList() {};
+ private int pageNum=1;
+ private int pageSize=10;
+ private Long groupId=0L;
- public static SimpleTabFragment newInstance(String title) {
- Bundle args = new Bundle();
- args.putString(KEY_TITLE, title);
+ public static SimpleTabFragment newInstance(Long groupId) {
SimpleTabFragment fragment = new SimpleTabFragment();
- fragment.setArguments(args);
+ fragment.groupId=groupId;
return fragment;
}
+ /**
+ * 布局的资源id
+ *
+ * @return
+ */
+ @Override
+ protected int getLayoutId() {
+ return R.layout.fragment_simple_tab;
+ }
+
+ /**
+ * @return 返回为 null意为不需要导航栏
+ */
+ @Override
+ protected TitleBar initTitle() {
+ return null;
+ }
+
+ /**
+ * 初始化控件
+ */
+ @Override
+ protected void initViews() {
+ initView();
+ //Http获取设备列表
+ getDeviceList();
+ }
+
@Override
public void onAttach(@NonNull Context context) {
super.onAttach(context);
- Log.e(TAG, "onAttach:" + title);
+ Log.e(TAG, "onAttach:" + groupId);
}
@Override
public void onDetach() {
super.onDetach();
- Log.e(TAG, "onDetach:" + title);
+ Log.e(TAG, "onDetach:" + groupId);
}
@Override
public void onResume() {
super.onResume();
- Log.e(TAG, "onResume:" + title);
+ Log.e(TAG, "onResume:" + groupId);
}
@Override
public void onStop() {
super.onStop();
- Log.e(TAG, "onStop:" + title);
+ Log.e(TAG, "onStop:" + groupId);
}
- @Override
- public void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- XRouter.getInstance().inject(this);
- }
-
- @Nullable
- @Override
- public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
- View view = inflater.inflate(R.layout.fragment_simple_tab, container, false);
- mUnbinder = ButterKnife.bind(this, view);
- initView();
- return view;
- }
private void initView() {
-// int randomNumber = RandomUtils.getRandom(10, 100);
-// Log.e(TAG, "initView, random number:" + randomNumber + ", " + title);
-// tvTitle.setText(String.format("这个是%s页面的内容", title));
-// tvExplain.setText(String.format("这个是页面随机生成的数字:%d", randomNumber));
-
VirtualLayoutManager virtualLayoutManager = new VirtualLayoutManager(getContext());
recyclerView.setLayoutManager(virtualLayoutManager);
@@ -153,19 +143,14 @@ public class SimpleTabFragment extends Fragment {
recyclerView.setRecycledViewPool(viewPool);
viewPool.setMaxRecycledViews(0, 10);
- //顶部按钮
-// SingleDelegateAdapter buttonAdapter = new SingleDelegateAdapter(R.layout.adapter_button_top_item) {
-// @Override
-// public void onBindViewHolder(@NonNull RecyclerViewHolder holder, int position) {
-// SuperButton superButton = holder.findViewById(R.id.device_item_all_open);
-// }
-// };
-
// 设备
FragmentActivity activity=this.getActivity();
- mNewsAdapter = new BroccoliSimpleDelegateAdapter(R.layout.adapter_device_card_view_list_item, new StaggeredGridLayoutHelper(2,0), DemoDataProvider.getEmptyNewInfo()) {
+ XPageFragment fragment= this;
+ deviceAdapter = new BroccoliSimpleDelegateAdapter(R.layout.adapter_device_card_view_list_item, new StaggeredGridLayoutHelper(2,0), devices) {
+ @SuppressLint("ResourceType")
@Override
- protected void onBindData(RecyclerViewHolder holder, NewInfo model, int position) {
+ protected void onBindData(RecyclerViewHolder holder, IotDeviceVo device, int position) {
+ if (device == null) {return;}
//设置item宽度,适配屏幕分辨率
// CardView view=holder.findViewById(R.id.device_item_card_view);
@@ -174,82 +159,229 @@ public class SimpleTabFragment extends Fragment {
// ViewGroup.LayoutParams cardViewParams=view.getLayoutParams();
// cardViewParams.width=(widthPixels-space)/2;
- //设置开关按钮
+ holder.text(R.id.device_item_title, device.getDeviceName());
+ holder.text(R.id.device_item_temp, device.getDeviceTemperature()+"℃");
+ holder.text(R.id.device_item_category, device.getCategoryName());
+
+ //图标设置状态
+ SwitchIconView radarView=holder.findViewById(R.id.device_item_radar_icon);
+ SwitchIconView alarmView=holder.findViewById(R.id.device_item_alarm_icon);
SwitchIconView switchIconView=holder.findViewById(R.id.device_item_switch_button);
- holder.click(R.id.device_item_switch_button, v -> {
+ SwitchIconView lightIconView=holder.findViewById(R.id.device_item_light_button);
+ if(device.getIsRadar()!=1){ radarView.setIconEnabled(false);}
+ if(device.getIsAlarm()!=1){ alarmView.setIconEnabled(false);}
+ switchIconView.setIconEnabled(device.getRelayStatus()==1?true:false);
+ lightIconView.setIconEnabled(device.getLightStatus()==1?true:false);
+
+ //根据分类显示图标
+ AppCompatImageView stateView=holder.findViewById(R.id.device_item_category_icon);
+ stateView.setImageDrawable(getResources().getDrawable((R.drawable.category)));
+
+ //显示网络信号:wifi信号强度(信号极好4格[-55—— 0],信号好3格[-70—— -55),信号一般2格[-85—— -70),信号差1格[-100—— -85))
+ AppCompatImageView wifiView=holder.findViewById(R.id.device_item_wifi_icon);
+ if(device.getRssi()>=-55){
+ wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_4)));
+ }else if(device.getRssi()>=70){
+ wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_3)));
+ }else if(device.getRssi()>=-85){
+ wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_2)));
+ }else if(device.getRssi()>=-100){
+ wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_1)));
+ }else{
+ wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_0)));
+ }
+
+ //设置状态
+ FrameLayout flTitle=holder.findViewById(R.id.device_item_fl_title);
+ if(device.getIsOnline()==1){
+ holder.text(R.id.device_item_wifi, "在线");
+ flTitle.setBackgroundColor(Color.argb(255, 201, 243, 218));
+ }else{
+ holder.text(R.id.device_item_wifi, "离线");
+ flTitle.setBackgroundColor(Color.argb(255, 230, 230, 230));
+ }
+
+ holder.click(R.id.device_item_light_button, v -> {
+ if(device.getIsOnline()==0) return;
+ // 更新灯状态
+ updateDeviceStatus(buildDeviceLightStatus(device.getDeviceId(),
+ device.getDeviceNum(),
+ lightIconView.isIconEnabled()==true?0:1));
+ //震动
Vibrator vibrator = (Vibrator) activity.getSystemService(activity.VIBRATOR_SERVICE);
vibrator.vibrate(100);
- switchIconView.switchState();
+ lightIconView.switchState(true);
+
+ });
+ holder.click(R.id.device_item_switch_button, v -> {
+ if(device.getIsOnline()==0) return;
+ // 更新继电器状态
+ updateDeviceStatus(buildDeviceRelayStatus(device.getDeviceId(),
+ device.getDeviceNum(),
+ switchIconView.isIconEnabled()==true?0:1));
+ //震动
+ Vibrator vibrator = (Vibrator) activity.getSystemService(activity.VIBRATOR_SERVICE);
+ vibrator.vibrate(100);
+ switchIconView.switchState(true);
+
+ });
+ holder.click(R.id.device_item_card_view, v -> {
+
+ PageOption.to(DeviceDetailFragment.class) //跳转的fragment
+ .setAddToBackStack(true) //是否加入堆栈
+ .putLong("device_id", device.getDeviceId()) //传递的参数
+ .putString("device_num",device.getDeviceNum())
+ .setNewActivity(true)
+ .open(fragment); //打开页面进行跳转
+
});
- AppCompatImageView stateView=holder.findViewById(R.id.device_item_state_icon);
- stateView.setImageDrawable(getResources().getDrawable((R.drawable.state_a)));
-
-
- if (model != null) {
-// holder.text(R.id.tv_user_name, model.getUserName());
-// holder.text(R.id.tv_tag, model.getTag());
-// holder.text(R.id.tv_title, model.getTitle());
-// holder.text(R.id.tv_summary, model.getSummary());
-// holder.text(R.id.tv_praise, model.getPraise() == 0 ? "点赞" : String.valueOf(model.getPraise()));
-// holder.text(R.id.tv_comment, model.getComment() == 0 ? "评论" : String.valueOf(model.getComment()));
-// holder.text(R.id.tv_read, "阅读量 " + model.getRead());
-// holder.image(R.id.iv_image, model.getImageUrl());
-//
-// holder.click(R.id.card_view, v -> Utils.goWeb(getContext(), model.getDetailUrl()));
- }
}
@Override
protected void onBindBroccoli(RecyclerViewHolder holder, Broccoli broccoli) {
-// broccoli.addPlaceholders(
-// holder.findView(R.id.device_item_title),
-// holder.findView(R.id.device_item_title_icon),
-// holder.findView(R.id.device_item_time),
-// holder.findView(R.id.device_item_time_icon),
-// holder.findView(R.id.device_item_temperature),
-// holder.findView(R.id.device_item_humidity),
-// holder.findView(R.id.device_item_wifi),
-// holder.findView(R.id.device_item_wifi_icon),
-// holder.findView(R.id.device_item_state),
-// holder.findView(R.id.device_item_state_icon),
-// holder.findView(R.id.device_item_switch_button)
-// );
+ broccoli.addPlaceholders(
+ holder.findView(R.id.device_item_title),
+ holder.findView(R.id.update_device_temp_icon),
+ holder.findView(R.id.device_item_category),
+ holder.findView(R.id.device_item_category_icon),
+ holder.findView(R.id.device_item_wifi),
+ holder.findView(R.id.device_item_wifi_icon),
+ holder.findView(R.id.device_item_temp),
+ holder.findView(R.id.device_item_temp_icon),
+ holder.findView(R.id.device_item_alarm_icon),
+ holder.findView(R.id.device_item_alarm),
+ holder.findView(R.id.device_item_radar),
+ holder.findView(R.id.device_item_radar_icon),
+ holder.findView(R.id.device_item_switch_button),
+ holder.findView(R.id.device_item_light_button)
+ );
}
};
DelegateAdapter delegateAdapter = new DelegateAdapter(virtualLayoutManager);
- delegateAdapter.addAdapter(mNewsAdapter);
+ delegateAdapter.addAdapter(deviceAdapter);
recyclerView.setAdapter(delegateAdapter);
-
//下拉刷新
refreshLayout.setOnRefreshListener(refreshLayout -> {
- // TODO: 2020-02-25 这里只是模拟了网络请求
refreshLayout.getLayout().postDelayed(() -> {
- mNewsAdapter.refresh(DemoDataProvider.getDemoNewInfos());
- refreshLayout.finishRefresh();
+ pageNum=1;
+ getDeviceList();
}, 1000);
});
//上拉加载
refreshLayout.setOnLoadMoreListener(refreshLayout -> {
- // TODO: 2020-02-25 这里只是模拟了网络请求
refreshLayout.getLayout().postDelayed(() -> {
- mNewsAdapter.loadMore(DemoDataProvider.getDemoNewInfos());
- refreshLayout.finishLoadMore();
+ pageNum=pageNum+1;
+ getDeviceList();
}, 1000);
});
- refreshLayout.autoRefresh();//第一次进入触发自动刷新,演示效果
+// refreshLayout.autoRefresh();//第一次进入触发自动刷新
+ }
+
+ /**
+ * 构建设备状态数据
+ */
+ private IotDeviceStatus buildDeviceLightStatus(Long deviceId,String deviceNum,int lightStatus){
+ IotDeviceStatus deviceStatus=new IotDeviceStatus();
+ deviceStatus.setDeviceId(deviceId);
+ deviceStatus.setDeviceNum(deviceNum);
+ deviceStatus.setLightStatus(lightStatus);
+ deviceStatus.setTriggerSource(1); //0-无、1-按键、2.手机、3-浏览器、4-射频遥控、5-雷达、6-报警、7-定时
+ return deviceStatus;
+ }
+
+ /**
+ * 构建设备状态数据
+ */
+ private IotDeviceStatus buildDeviceRelayStatus(Long deviceId,String deviceNum,int relayStatus){
+ IotDeviceStatus deviceStatus=new IotDeviceStatus();
+ deviceStatus.setDeviceId(deviceId);
+ deviceStatus.setDeviceNum(deviceNum);
+ deviceStatus.setRelayStatus(relayStatus);
+ deviceStatus.setTriggerSource(1); //0-无、1-按键、2.手机、3-浏览器、4-射频遥控、5-雷达、6-报警、7-定时
+ return deviceStatus;
+ }
+
+ /**
+ * HTTP更新设备状态
+ */
+ private void updateDeviceStatus(IotDeviceStatus deviceStatus){
+ if(!hasToken()) return;
+ XHttp.put("/prod-api/system/status")
+ .upJson(JsonUtil.toJson(deviceStatus))
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new CallBackProxy, String>(new TipRequestCallBack() {
+ @Override
+ public void onSuccess(String response) throws Throwable {
+ Log.d("response:",response);
+ XToastUtils.success("设备状态更新成功");
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+
+ }
+ }){});
+ }
+
+ /**
+ * HTTP获取设备列表
+ */
+ private void getDeviceList(){
+ XHttp.get("/prod-api/system/device/list?"+"pageNum="+pageNum+"&pageSize="+pageSize+"&groupId="+groupId)
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new CallBackProxy>, List>(new TipRequestCallBack>() {
+ @Override
+ public void onSuccess(List list) throws Throwable {
+ if(pageNum==1) {
+ deviceAdapter.refresh(list);
+ refreshLayout.finishRefresh();
+ }else {
+ deviceAdapter.loadMore(list);
+ refreshLayout.finishLoadMore();
+ }
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ }){});
+ }
+
+ /**
+ * HTTP获取分类列表
+ */
+ private void getCategoryList(){
+ XHttp.get("/prod-api/system/category/list?pageNum=1&pageSize=100")
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new CallBackProxy>, List>(new TipRequestCallBack>() {
+ @Override
+ public void onSuccess(List list) throws Throwable {
+
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ }){});
}
- @Override
- public void onDestroyView() {
- if (mUnbinder != null) {
- mUnbinder.unbind();
- }
- super.onDestroyView();
- Log.e(TAG, "onDestroyView:" + title);
-
- }
}
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/news/HomePageFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/news/HomePageFragment.java
new file mode 100644
index 00000000..f3d625a3
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/news/HomePageFragment.java
@@ -0,0 +1,122 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+package com.kerwin.wumei.fragment.news;
+
+import android.webkit.WebChromeClient;
+import android.webkit.WebSettings;
+import android.webkit.WebView;
+import android.webkit.WebViewClient;
+
+import androidx.annotation.NonNull;
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.alibaba.android.vlayout.DelegateAdapter;
+import com.alibaba.android.vlayout.VirtualLayoutManager;
+import com.alibaba.android.vlayout.layout.GridLayoutHelper;
+import com.alibaba.android.vlayout.layout.LinearLayoutHelper;
+import com.kerwin.wumei.R;
+import com.kerwin.wumei.adapter.base.broccoli.BroccoliSimpleDelegateAdapter;
+import com.kerwin.wumei.adapter.base.delegate.SimpleDelegateAdapter;
+import com.kerwin.wumei.adapter.base.delegate.SingleDelegateAdapter;
+import com.kerwin.wumei.adapter.entity.NewInfo;
+import com.kerwin.wumei.core.BaseFragment;
+import com.kerwin.wumei.utils.DemoDataProvider;
+import com.kerwin.wumei.utils.Utils;
+import com.kerwin.wumei.utils.XToastUtils;
+import com.scwang.smartrefresh.layout.SmartRefreshLayout;
+import com.xuexiang.xpage.annotation.Page;
+import com.xuexiang.xpage.enums.CoreAnim;
+import com.xuexiang.xui.adapter.recyclerview.RecyclerViewHolder;
+import com.xuexiang.xui.adapter.simple.AdapterItem;
+import com.xuexiang.xui.widget.actionbar.TitleBar;
+import com.xuexiang.xui.widget.banner.widget.banner.SimpleImageBanner;
+import com.xuexiang.xui.widget.imageview.ImageLoader;
+import com.xuexiang.xui.widget.imageview.RadiusImageView;
+
+import butterknife.BindView;
+import me.samlss.broccoli.Broccoli;
+
+@Page(anim = CoreAnim.none)
+public class HomePageFragment extends BaseFragment {
+
+ @BindView(R.id.webview_home)
+ WebView webView;
+ @BindView(R.id.refreshLayout)
+ SmartRefreshLayout refreshLayout;
+
+ private SimpleDelegateAdapter mNewsAdapter;
+
+ /**
+ * @return 返回为 null意为不需要导航栏
+ */
+ @Override
+ protected TitleBar initTitle() {
+ return null;
+ }
+
+ /**
+ * 布局的资源id
+ *
+ * @return
+ */
+ @Override
+ protected int getLayoutId() {
+ return R.layout.fragment_home_page;
+ }
+
+ /**
+ * 初始化控件
+ */
+ @Override
+ protected void initViews() {
+ webView.loadUrl("http://wumei.live");
+ //系统默认会通过手机浏览器打开网页,为了能够直接通过WebView显示网页,则必须设置
+ webView.setWebViewClient(new WebViewClient(){
+ @Override
+ public boolean shouldOverrideUrlLoading(WebView view, String url) {
+ //使用WebView加载显示url
+ view.loadUrl(url);
+ //返回true
+ return true;
+ }
+ });
+ // 支持js中alert弹窗提示
+ webView.setWebChromeClient(new WebChromeClient());
+
+ //声明WebSettings子类
+ WebSettings webSettings = webView.getSettings();
+ //如果访问的页面中要与Javascript交互,则webview必须设置支持Javascript
+ webSettings.setJavaScriptEnabled(true);
+ webSettings.setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); //关闭webview中缓存
+ webSettings.setLoadsImagesAutomatically(true); //支持自动加载图片
+ webSettings.setDefaultTextEncodingName("utf-8");//设置编码格式
+ }
+
+ @Override
+ protected void initListeners() {
+ //下拉刷新
+ refreshLayout.setOnRefreshListener(refreshLayout -> {
+ refreshLayout.getLayout().postDelayed(() -> {
+ webView.reload();
+ refreshLayout.finishRefresh();
+ }, 1000);
+ });
+ //上拉加载
+ refreshLayout.setOnLoadMoreListener(refreshLayout -> {
+ // TODO: 2020-02-25 这里只是模拟了网络请求
+ refreshLayout.getLayout().postDelayed(() -> {
+ webView.reload();
+ refreshLayout.finishLoadMore();
+ }, 1000);
+ });
+ refreshLayout.autoRefresh();//第一次进入触发自动刷新,演示效果
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/news/NewsFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/news/NewsFragment.java
index 21358614..03ef3381 100644
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/news/NewsFragment.java
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/news/NewsFragment.java
@@ -1,3 +1,13 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
package com.kerwin.wumei.fragment.news;
import androidx.annotation.NonNull;
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/profile/AccountFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/profile/AccountFragment.java
new file mode 100644
index 00000000..9d251778
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/profile/AccountFragment.java
@@ -0,0 +1,133 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+package com.kerwin.wumei.fragment.profile;
+
+import android.graphics.Color;
+import android.util.Log;
+import android.view.View;
+import android.widget.TextView;
+
+import androidx.appcompat.widget.AppCompatImageView;
+
+import com.kerwin.wumei.R;
+import com.kerwin.wumei.core.BaseFragment;
+import com.kerwin.wumei.entity.User;
+import com.kerwin.wumei.entity.bo.CaptureImage;
+import com.kerwin.wumei.http.callback.TipRequestCallBack;
+import com.kerwin.wumei.http.request.CaptchaImageApiResult;
+import com.kerwin.wumei.http.request.UserInfoApiResult;
+import com.kerwin.wumei.utils.XToastUtils;
+import com.xuexiang.xaop.annotation.SingleClick;
+import com.xuexiang.xhttp2.XHttp;
+import com.xuexiang.xhttp2.callback.CallBackProxy;
+import com.xuexiang.xhttp2.exception.ApiException;
+import com.xuexiang.xpage.annotation.Page;
+import com.xuexiang.xpage.enums.CoreAnim;
+import com.xuexiang.xui.utils.ResUtils;
+import com.xuexiang.xui.widget.actionbar.TitleBar;
+import com.xuexiang.xui.widget.button.switchbutton.SwitchButton;
+import com.xuexiang.xui.widget.edittext.materialedittext.MaterialEditText;
+import com.xuexiang.xui.widget.imageview.RadiusImageView;
+import com.xuexiang.xui.widget.textview.supertextview.SuperButton;
+
+import butterknife.BindView;
+import butterknife.OnClick;
+
+import static com.kerwin.wumei.utils.SettingUtils.getIsHttps;
+import static com.kerwin.wumei.utils.SettingUtils.getServerPort;
+import static com.kerwin.wumei.utils.SettingUtils.getServerip;
+import static com.kerwin.wumei.utils.SettingUtils.setServeUrl;
+import static com.kerwin.wumei.utils.TokenUtils.clearToken;
+import static com.kerwin.wumei.utils.TokenUtils.getToken;
+import static com.kerwin.wumei.utils.TokenUtils.hasToken;
+
+
+@Page(name = "账户信息")
+public class AccountFragment extends BaseFragment {
+ @BindView(R.id.titlebar_min)
+ TitleBar titleBarMin;
+
+ @BindView(R.id.txt_user_name)
+ TextView txt_user_name;
+ @BindView(R.id.txt_nick_name)
+ TextView txt_nick_name;
+ @BindView(R.id.txt_email)
+ TextView txt_email;
+ @BindView(R.id.txt_phone_num)
+ TextView txt_phone_num;
+ @BindView(R.id.txt_create_time)
+ TextView txt_create_time;
+ @BindView(R.id.txt_remark)
+ TextView txt_remark;
+
+ @Override
+ protected TitleBar initTitle() {
+ return null;
+ }
+
+ /**
+ * 布局的资源id
+ *
+ * @return
+ */
+ @Override
+ protected int getLayoutId() {
+ return R.layout.fragment_account;
+ }
+
+ /**
+ * 初始化控件
+ */
+ @Override
+ protected void initViews() {
+ titleBarMin.setLeftClickListener(v -> popToBack());
+ getUserInfo();
+ }
+
+ @Override
+ protected void initListeners() { }
+
+ @SingleClick
+ @OnClick({ R.id.btn_confirm})
+ public void onViewClicked(View view) {
+ popToBack();
+ }
+
+ /**
+ * HTTP获取用户信息
+ */
+ private void getUserInfo(){
+ if(!hasToken()) return;
+ XHttp.get("/prod-api/getInfo")
+ .headers("Authorization","Bearer "+getToken())
+ .execute(new CallBackProxy, User>(new TipRequestCallBack() {
+ @Override
+ public void onSuccess(User user) throws Throwable {
+ txt_user_name.setText(user.getUserName());
+ txt_nick_name.setText(user.getNickName());
+ txt_email.setText(user.getEmail());
+ txt_phone_num.setText(user.getPhonenumber());
+ txt_remark.setText(user.getRemark());
+ txt_create_time.setText(user.getCreateTime());
+ }
+ @Override
+ public void onError(ApiException e) {
+ if(e.getCode()==401){
+ XToastUtils.info("匿名登录状态,功能受限");
+ clearToken();
+ }else{
+ XToastUtils.error(e.getMessage());
+ }
+ }
+ }){});
+ }
+
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/profile/ProfileFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/profile/ProfileFragment.java
index 50a7bc22..8bc85429 100644
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/profile/ProfileFragment.java
+++ b/android/app/src/main/java/com/kerwin/wumei/fragment/profile/ProfileFragment.java
@@ -1,20 +1,47 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
package com.kerwin.wumei.fragment.profile;
import android.graphics.drawable.ColorDrawable;
+import android.widget.TextView;
import com.kerwin.wumei.core.BaseFragment;
import com.kerwin.wumei.R;
+import com.kerwin.wumei.core.webview.AgentWebActivity;
import com.kerwin.wumei.fragment.AboutFragment;
import com.kerwin.wumei.fragment.FeedbackFragment;
import com.kerwin.wumei.fragment.MessageFragment;
import com.kerwin.wumei.fragment.SettingsFragment;
+import com.kerwin.wumei.http.callback.TipRequestCallBack;
+import com.kerwin.wumei.http.request.NoDataApiResult;
+import com.kerwin.wumei.utils.TokenUtils;
+import com.kerwin.wumei.utils.XToastUtils;
import com.xuexiang.xaop.annotation.SingleClick;
+import com.xuexiang.xhttp2.XHttp;
+import com.xuexiang.xhttp2.callback.CallBackProxy;
+import com.xuexiang.xhttp2.exception.ApiException;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xpage.enums.CoreAnim;
import com.xuexiang.xpage.utils.Utils;
import com.xuexiang.xui.widget.actionbar.TitleBar;
+import com.xuexiang.xui.widget.dialog.DialogLoader;
+import com.xuexiang.xui.widget.grouplist.XUIGroupListView;
import com.xuexiang.xui.widget.imageview.RadiusImageView;
import com.xuexiang.xui.widget.textview.supertextview.SuperTextView;
+import com.xuexiang.xutil.XUtil;
+import com.xuexiang.xutil.app.AppUtils;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
import butterknife.BindView;
@@ -22,14 +49,16 @@ import butterknife.BindView;
public class ProfileFragment extends BaseFragment implements SuperTextView.OnSuperTextViewClickListener {
@BindView(R.id.riv_head_pic)
RadiusImageView rivHeadPic;
- @BindView(R.id.menu_settings)
- SuperTextView menuSettings;
- @BindView(R.id.menu_about)
- SuperTextView menuAbout;
- @BindView(R.id.menu_feedback)
- SuperTextView menuFeedback;
@BindView(R.id.menu_message)
SuperTextView menuMessage;
+ @BindView(R.id.menu_logout)
+ SuperTextView menuLogout;
+ @BindView(R.id.about_list)
+ XUIGroupListView mAboutGroupListView;
+ @BindView(R.id.tv_copyright)
+ TextView mCopyrightTextView;
+ @BindView(R.id.menu_account)
+ SuperTextView menuAccount;
/**
* @return 返回为 null意为不需要导航栏
@@ -54,32 +83,65 @@ public class ProfileFragment extends BaseFragment implements SuperTextView.OnSup
*/
@Override
protected void initViews() {
+ XUIGroupListView.newSection(getContext())
+ .addItemView(mAboutGroupListView.createItemView(getResources().getString(R.string.about_item_author_github)), v -> AgentWebActivity.goWeb(getContext(), getString(R.string.url_author_github)))
+ .addItemView(mAboutGroupListView.createItemView(getResources().getString(R.string.about_item_add_qq_group)), v -> AgentWebActivity.goWeb(getContext(), getString(R.string.url_add_qq_group)))
+ .addItemView(mAboutGroupListView.createItemView("版本:v"+AppUtils.getAppVersionName()), v -> XToastUtils.toast("官网下载最新版本"))
+ .addTo(mAboutGroupListView);
+ SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy", Locale.CHINA);
+ String currentYear = dateFormat.format(new Date());
+ mCopyrightTextView.setText(String.format(getResources().getString(R.string.about_copyright), currentYear));
}
@Override
protected void initListeners() {
- menuSettings.setOnSuperTextViewClickListener(this);
- menuAbout.setOnSuperTextViewClickListener(this);
- menuFeedback.setOnSuperTextViewClickListener(this);
menuMessage.setOnSuperTextViewClickListener(this);
+ menuLogout.setOnSuperTextViewClickListener(this);
+ menuAccount.setOnSuperTextViewClickListener(this);
+ }
+
+ /**
+ * HTTP退出登录
+ */
+ private void logout(){
+ XHttp.post("/prod-api/logout")
+ .execute(new CallBackProxy, String>(new TipRequestCallBack() {
+ @Override
+ public void onSuccess(String tokenResult) throws Throwable {
+ XToastUtils.success("登出成功" );
+ }
+ @Override
+ public void onError(ApiException e) {
+
+ }
+ }){});
}
@SingleClick
@Override
public void onClick(SuperTextView view) {
switch(view.getId()) {
- case R.id.menu_settings:
- openNewPage(SettingsFragment.class);
- break;
- case R.id.menu_about:
- openNewPage(AboutFragment.class);
- break;
case R.id.menu_message:
openNewPage(MessageFragment.class);
break;
- case R.id.menu_feedback:
- openNewPage(FeedbackFragment.class);
+ case R.id.menu_account:
+ openNewPage(AccountFragment.class);
+ break;
+ case R.id.menu_logout:
+ DialogLoader.getInstance().showConfirmDialog(
+ getContext(),
+ getString(R.string.lab_logout_confirm),
+ getString(R.string.lab_yes),
+ (dialog, which) -> {
+ logout();
+ dialog.dismiss();
+ XUtil.getActivityLifecycleHelper().exit();
+ TokenUtils.handleLogoutSuccess();
+ },
+ getString(R.string.lab_no),
+ (dialog, which) -> dialog.dismiss()
+ );
break;
default:
break;
diff --git a/android/app/src/main/java/com/kerwin/wumei/http/callback/NoTipRequestCallBack.java b/android/app/src/main/java/com/kerwin/wumei/http/callback/NoTipRequestCallBack.java
new file mode 100644
index 00000000..285b9827
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/http/callback/NoTipRequestCallBack.java
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2018 xuexiangjys(xuexiangjys@163.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.kerwin.wumei.http.callback;
+
+import com.xuexiang.xhttp2.callback.SimpleCallBack;
+import com.xuexiang.xhttp2.exception.ApiException;
+import com.xuexiang.xhttp2.model.XHttpRequest;
+import com.xuexiang.xutil.common.StringUtils;
+import com.xuexiang.xutil.common.logger.Logger;
+
+/**
+ * @author xuexiang
+ * @since 2018/8/8 上午10:23
+ */
+public abstract class NoTipRequestCallBack extends SimpleCallBack {
+ /**
+ * 记录一下请求的url,确定出错的请求是哪个请求
+ */
+ private String mUrl;
+
+ public NoTipRequestCallBack() {
+
+ }
+
+ public NoTipRequestCallBack(XHttpRequest req) {
+ this(req.getUrl());
+ }
+
+ public NoTipRequestCallBack(String url) {
+ mUrl = url;
+ }
+
+ @Override
+ public void onError(ApiException e) {
+ if (!StringUtils.isEmpty(mUrl)) {
+ Logger.e("网络请求的url:" + mUrl, e);
+ } else {
+ Logger.e(e);
+ }
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/http/callback/TipRequestCallBack.java b/android/app/src/main/java/com/kerwin/wumei/http/callback/TipRequestCallBack.java
new file mode 100644
index 00000000..5620f1a0
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/http/callback/TipRequestCallBack.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2018 xuexiangjys(xuexiangjys@163.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.kerwin.wumei.http.callback;
+
+import androidx.annotation.NonNull;
+
+import com.xuexiang.xhttp2.callback.SimpleCallBack;
+import com.xuexiang.xhttp2.exception.ApiException;
+import com.xuexiang.xhttp2.model.XHttpRequest;
+import com.xuexiang.xutil.common.StringUtils;
+import com.xuexiang.xutil.common.logger.Logger;
+import com.xuexiang.xutil.tip.ToastUtils;
+
+/**
+ * @author xuexiang
+ * @since 2018/8/8 上午10:20
+ */
+public abstract class TipRequestCallBack extends SimpleCallBack {
+
+ /**
+ * 记录一下请求的url,确定出错的请求是哪个请求
+ */
+ private String mUrl;
+
+ public TipRequestCallBack() {
+
+ }
+
+ public TipRequestCallBack(@NonNull XHttpRequest req) {
+ this(req.getUrl());
+ }
+
+ public TipRequestCallBack(String url) {
+ mUrl = url;
+ }
+
+ @Override
+ public void onError(ApiException e) {
+ ToastUtils.toast(e.getDisplayMessage());
+ if (!StringUtils.isEmpty(mUrl)) {
+ Logger.e("网络请求的url:" + mUrl, e);
+ } else {
+ Logger.e(e);
+ }
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/http/interceptor/CustomLoggingInterceptor.java b/android/app/src/main/java/com/kerwin/wumei/http/interceptor/CustomLoggingInterceptor.java
new file mode 100644
index 00000000..178a4035
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/http/interceptor/CustomLoggingInterceptor.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2018 xuexiangjys(xuexiangjys@163.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.kerwin.wumei.http.interceptor;
+
+import com.xuexiang.xhttp2.interceptor.HttpLoggingInterceptor;
+import com.xuexiang.xhttp2.utils.HttpUtils;
+
+import java.io.IOException;
+
+import okhttp3.Connection;
+import okhttp3.Protocol;
+import okhttp3.Request;
+import okhttp3.RequestBody;
+import okhttp3.Response;
+import okhttp3.ResponseBody;
+import okhttp3.internal.http.HttpHeaders;
+
+/**
+ * 自定义日志拦截器【简单打印入参和出参】
+ *
+ * @author xuexiang
+ * @since 2018/8/6 上午11:53
+ */
+public class CustomLoggingInterceptor extends HttpLoggingInterceptor {
+
+ public CustomLoggingInterceptor() {
+ super("custom");
+ setLevel(Level.PARAM);
+ }
+
+ @Override
+ protected void logForRequest(Request request, Connection connection) throws IOException {
+ RequestBody requestBody = request.body();
+ boolean hasRequestBody = requestBody != null;
+ Protocol protocol = connection != null ? connection.protocol() : Protocol.HTTP_1_1;
+
+ StringBuilder logBuilder = new StringBuilder();
+ try {
+ logBuilder.append("--> ")
+ .append(request.method())
+ .append(' ')
+ .append(request.url())
+ .append(' ')
+ .append(protocol)
+ .append("\r\n");
+ if (hasRequestBody) {
+ logBuilder.append("入参:");
+ if (HttpUtils.isPlaintext(requestBody.contentType())) {
+ logBuilder.append(bodyToString(request));
+ } else {
+ logBuilder.append("maybe [file part] , too large too print , ignored!");
+ }
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+
+ log(logBuilder.toString());
+ }
+
+ @Override
+ protected Response logForResponse(Response response, long tookMs) {
+ Response clone = response.newBuilder().build();
+ ResponseBody responseBody = clone.body();
+ log("<-- " + clone.code() + ' ' + clone.message() + ' ' + clone.request().url() + " (" + tookMs + "ms)");
+ try {
+ if (HttpHeaders.hasBody(clone)) {
+ if (responseBody == null) {
+ return response;
+ }
+ if (HttpUtils.isPlaintext(responseBody.contentType())) {
+ String body = responseBody.string();
+ log("\t出参:" + body);
+ responseBody = ResponseBody.create(responseBody.contentType(), body);
+ return response.newBuilder().body(responseBody).build();
+ } else {
+ log("\t出参: maybe [file part] , too large too print , ignored!");
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return response;
+ }
+
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/http/request/CaptchaImageApiResult.java b/android/app/src/main/java/com/kerwin/wumei/http/request/CaptchaImageApiResult.java
new file mode 100644
index 00000000..5390c95e
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/http/request/CaptchaImageApiResult.java
@@ -0,0 +1,61 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.http.request;
+
+import com.kerwin.wumei.entity.bo.CaptureImage;
+import com.xuexiang.xhttp2.model.ApiResult;
+
+
+public class CaptchaImageApiResult extends ApiResult {
+ private String uuid;
+ private String img;
+
+ public String getUuid() {
+ return uuid;
+ }
+ public CaptchaImageApiResult setUuid(String uuid) {
+ this.uuid = uuid;
+ return this;
+ }
+
+ public String getImg() {
+ return img;
+ }
+ public CaptchaImageApiResult setImg(String img) {
+ this.img = img;
+ return this;
+ }
+
+
+ @Override
+ public boolean isSuccess() {
+ return getCode()==200;
+ }
+
+ @Override
+ public T getData() {
+ CaptureImage image=new CaptureImage();
+ image.setImg(getImg());
+ image.setUuid(getUuid());
+ return (T) image;
+ }
+
+ @Override
+ public String toString() {
+ return "ApiResult{" +
+ "code='" + CODE + '\'' +
+ ", msg='" + MSG + '\'' +
+ ", uuid='" + uuid + '\'' +
+ ", img=" + img +
+ '}';
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/http/request/CustomApiResult.java b/android/app/src/main/java/com/kerwin/wumei/http/request/CustomApiResult.java
new file mode 100644
index 00000000..e05a3f3b
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/http/request/CustomApiResult.java
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2018 xuexiangjys(xuexiangjys@163.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.kerwin.wumei.http.request;
+
+import com.xuexiang.xhttp2.model.ApiResult;
+
+/**
+ * @author xuexiang
+ * @since 2018/8/7 下午5:23
+ */
+public class CustomApiResult extends ApiResult {
+
+ private int errorCode;
+ private String errorInfo;
+ private T result;
+ private long timeStamp;
+
+ public int getErrorCode() {
+ return errorCode;
+ }
+
+ public CustomApiResult setErrorCode(int errorCode) {
+ this.errorCode = errorCode;
+ return this;
+ }
+
+ public String getErrorInfo() {
+ return errorInfo;
+ }
+
+ public CustomApiResult setErrorInfo(String errorInfo) {
+ this.errorInfo = errorInfo;
+ return this;
+ }
+
+ public T getResult() {
+ return result;
+ }
+
+ public CustomApiResult setResult(T result) {
+ this.result = result;
+ return this;
+ }
+
+ public long getTimeStamp() {
+ return timeStamp;
+ }
+
+ public CustomApiResult setTimeStamp(long timeStamp) {
+ this.timeStamp = timeStamp;
+ return this;
+ }
+
+ @Override
+ public int getCode() {
+ return errorCode;
+ }
+
+ @Override
+ public String getMsg() {
+ return errorInfo;
+ }
+
+ @Override
+ public boolean isSuccess() {
+ return errorCode == 0;
+ }
+
+ @Override
+ public T getData() {
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "ApiResult{" +
+ "errorCode='" + errorCode + '\'' +
+ ", errorInfo='" + errorInfo + '\'' +
+ ", timeStamp='" + timeStamp + '\'' +
+ ", result=" + result +
+ '}';
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/http/request/CustomGetRequest.java b/android/app/src/main/java/com/kerwin/wumei/http/request/CustomGetRequest.java
new file mode 100644
index 00000000..b915a3a7
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/http/request/CustomGetRequest.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2018 xuexiangjys(xuexiangjys@163.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.kerwin.wumei.http.request;
+
+import com.xuexiang.xhttp2.callback.CallBack;
+import com.xuexiang.xhttp2.callback.CallBackProxy;
+import com.xuexiang.xhttp2.callback.CallClazzProxy;
+import com.xuexiang.xhttp2.model.ApiResult;
+import com.xuexiang.xhttp2.request.GetRequest;
+
+import java.lang.reflect.Type;
+
+import io.reactivex.Observable;
+import io.reactivex.disposables.Disposable;
+
+/**
+ * 自定义请求的形式
+ *
+ * @author xuexiang
+ * @since 2018/8/7 下午6:09
+ */
+public class CustomGetRequest extends GetRequest {
+
+ public CustomGetRequest(String url) {
+ super(url);
+ }
+
+ @Override
+ public Observable execute(Type type) {
+ return execute(new CallClazzProxy, T>(type) {
+ });
+ }
+
+ @Override
+ public Disposable execute(CallBack callBack) {
+ return execute(new CallBackProxy, T>(callBack) {
+ });
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/http/request/ListApiResult.java b/android/app/src/main/java/com/kerwin/wumei/http/request/ListApiResult.java
new file mode 100644
index 00000000..07f47016
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/http/request/ListApiResult.java
@@ -0,0 +1,52 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.http.request;
+
+import com.xuexiang.xhttp2.model.ApiResult;
+
+public class ListApiResult extends ApiResult {
+
+ private T rows;
+ private int total;
+
+ public T getRows() {
+ return rows;
+ }
+ public ListApiResult setRows(T rows) {
+ this.rows = rows;
+ return this;
+ }
+
+ public int getTotal(){return total;}
+ public ListApiResult setTotal(int total){
+ this.total=total;
+ return this;
+ }
+
+ @Override
+ public boolean isSuccess() {
+ return getCode() == 200;
+ }
+
+ @Override
+ public T getData() {
+ return rows;
+ }
+
+ @Override
+ public String toString() {
+ return "ApiResult{" +
+ "code='" + CODE + '\'' +
+ ", msg='" + MSG + '\'' +
+ '}';
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/http/request/NoDataApiResult.java b/android/app/src/main/java/com/kerwin/wumei/http/request/NoDataApiResult.java
new file mode 100644
index 00000000..ebf9cc91
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/http/request/NoDataApiResult.java
@@ -0,0 +1,36 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.http.request;
+
+import com.xuexiang.xhttp2.model.ApiResult;
+
+
+public class NoDataApiResult extends ApiResult {
+
+ @Override
+ public boolean isSuccess() {
+ return getCode() == 200;
+ }
+
+ @Override
+ public T getData() {
+ return (T) "";
+ }
+
+ @Override
+ public String toString() {
+ return "ApiResult{" +
+ "code='" + CODE + '\'' +
+ ", msg='" + MSG + '\'' +
+ '}';
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/http/request/TokenApiResult.java b/android/app/src/main/java/com/kerwin/wumei/http/request/TokenApiResult.java
new file mode 100644
index 00000000..102fd3a2
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/http/request/TokenApiResult.java
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.http.request;
+
+import com.xuexiang.xhttp2.model.ApiResult;
+
+
+public class TokenApiResult extends ApiResult {
+
+ private T token= (T) "";
+
+ public T getToken() {
+ return token;
+ }
+
+ public TokenApiResult setToken(T token) {
+ this.token = token;
+ return this;
+ }
+
+ @Override
+ public boolean isSuccess() {
+ return getCode() == 200;
+ }
+
+ @Override
+ public T getData() {
+ return token;
+ }
+
+ @Override
+ public String toString() {
+ return "ApiResult{" +
+ "code='" + CODE + '\'' +
+ ", msg='" + MSG + '\'' +
+ ", token=" + token +
+ '}';
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/http/request/UserInfoApiResult.java b/android/app/src/main/java/com/kerwin/wumei/http/request/UserInfoApiResult.java
new file mode 100644
index 00000000..2e4df350
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/http/request/UserInfoApiResult.java
@@ -0,0 +1,48 @@
+/******************************************************************************
+ * 作者:kerwincui
+ * 时间:2021-06-08
+ * 邮箱:164770707@qq.com
+ * 源码地址:https://gitee.com/kerwincui/wumei-smart
+ * author: kerwincui
+ * create: 2021-06-08
+ * email:164770707@qq.com
+ * source:https://github.com/kerwincui/wumei-smart
+ ******************************************************************************/
+
+package com.kerwin.wumei.http.request;
+
+import com.xuexiang.xhttp2.model.ApiResult;
+
+
+public class UserInfoApiResult extends ApiResult {
+
+ private T user;
+
+ public T getUser() {
+ return user;
+ }
+
+ public UserInfoApiResult setUser(T user) {
+ this.user = user;
+ return this;
+ }
+
+ @Override
+ public boolean isSuccess() {
+ return getCode() == 200;
+ }
+
+ @Override
+ public T getData() {
+ return user;
+ }
+
+ @Override
+ public String toString() {
+ return "ApiResult{" +
+ "code='" + CODE + '\'' +
+ ", msg='" + MSG + '\'' +
+ ", user=" + user +
+ '}';
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/http/subscriber/NoTipRequestSubscriber.java b/android/app/src/main/java/com/kerwin/wumei/http/subscriber/NoTipRequestSubscriber.java
new file mode 100644
index 00000000..33803826
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/http/subscriber/NoTipRequestSubscriber.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2018 xuexiangjys(xuexiangjys@163.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.kerwin.wumei.http.subscriber;
+
+import com.xuexiang.xhttp2.exception.ApiException;
+import com.xuexiang.xhttp2.model.XHttpRequest;
+import com.xuexiang.xhttp2.subsciber.BaseSubscriber;
+import com.xuexiang.xutil.common.StringUtils;
+import com.xuexiang.xutil.common.logger.Logger;
+
+/**
+ * 网络请求的订阅,只存储错误的日志
+ *
+ * @author xuexiang
+ * @since 2018/8/2 下午3:37
+ */
+public abstract class NoTipRequestSubscriber extends BaseSubscriber {
+
+ /**
+ * 记录一下请求的url,确定出错的请求是哪个请求
+ */
+ private String mUrl;
+
+ public NoTipRequestSubscriber() {
+
+ }
+
+ public NoTipRequestSubscriber(XHttpRequest req) {
+ this(req.getUrl());
+ }
+
+ public NoTipRequestSubscriber(String url) {
+ mUrl = url;
+ }
+
+ @Override
+ public void onError(ApiException e) {
+ if (!StringUtils.isEmpty(mUrl)) {
+ Logger.e("网络请求的url:" + mUrl, e);
+ } else {
+ Logger.e(e);
+ }
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/http/subscriber/TipRequestSubscriber.java b/android/app/src/main/java/com/kerwin/wumei/http/subscriber/TipRequestSubscriber.java
new file mode 100644
index 00000000..40d33abd
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/http/subscriber/TipRequestSubscriber.java
@@ -0,0 +1,63 @@
+/*
+ * Copyright (C) 2018 xuexiangjys(xuexiangjys@163.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.kerwin.wumei.http.subscriber;
+
+
+import androidx.annotation.NonNull;
+
+import com.xuexiang.xhttp2.exception.ApiException;
+import com.xuexiang.xhttp2.model.XHttpRequest;
+import com.xuexiang.xhttp2.subsciber.BaseSubscriber;
+import com.xuexiang.xutil.common.StringUtils;
+import com.xuexiang.xutil.common.logger.Logger;
+import com.xuexiang.xutil.tip.ToastUtils;
+
+/**
+ * 网络请求的订阅,toast提示
+ *
+ * @author xuexiang
+ * @since 2018/8/2 下午3:42
+ */
+public abstract class TipRequestSubscriber extends BaseSubscriber {
+ /**
+ * 记录一下请求的url,确定出错的请求是哪个请求
+ */
+ private String mUrl;
+
+ public TipRequestSubscriber() {
+
+ }
+
+ public TipRequestSubscriber(@NonNull XHttpRequest req) {
+ this(req.getUrl());
+ }
+
+ public TipRequestSubscriber(String url) {
+ mUrl = url;
+ }
+
+
+ @Override
+ public void onError(ApiException e) {
+ ToastUtils.toast(e.getDisplayMessage());
+ if (!StringUtils.isEmpty(mUrl)) {
+ Logger.e("网络请求的url:" + mUrl, e);
+ } else {
+ Logger.e(e);
+ }
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/utils/DemoDataProvider.java b/android/app/src/main/java/com/kerwin/wumei/utils/DemoDataProvider.java
index 9597d62f..7428959f 100644
--- a/android/app/src/main/java/com/kerwin/wumei/utils/DemoDataProvider.java
+++ b/android/app/src/main/java/com/kerwin/wumei/utils/DemoDataProvider.java
@@ -145,7 +145,7 @@ public class DemoDataProvider {
@MemoryCache
public static List getEmptyNewInfo() {
List list = new ArrayList<>();
- for (int i = 0; i < 10; i++) {
+ for (int i = 0; i < 5; i++) {
list.add(new NewInfo());
}
return list;
diff --git a/android/app/src/main/java/com/kerwin/wumei/utils/DialogUtils.java b/android/app/src/main/java/com/kerwin/wumei/utils/DialogUtils.java
new file mode 100644
index 00000000..20f6ac3c
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/utils/DialogUtils.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2018 xuexiangjys(xuexiangjys@163.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.kerwin.wumei.utils;
+
+import android.app.AlertDialog;
+import android.content.Context;
+import android.content.DialogInterface;
+
+/**
+ * @author xuexiang
+ * @since 2018/8/3 下午3:59
+ */
+public final class DialogUtils {
+
+ private DialogUtils() {
+ throw new UnsupportedOperationException("u can't instantiate me...");
+ }
+
+ public static AlertDialog getConfirmDialog(Context context, String title, String message, DialogInterface.OnClickListener yesListener) {
+ return new AlertDialog.Builder(context)
+ .setTitle(title)
+ .setMessage(message)
+ .setPositiveButton(android.R.string.yes, yesListener)
+ .setNegativeButton(android.R.string.cancel, null)
+ .create();
+ }
+
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/utils/HProgressDialogUtils.java b/android/app/src/main/java/com/kerwin/wumei/utils/HProgressDialogUtils.java
new file mode 100644
index 00000000..e7606e27
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/utils/HProgressDialogUtils.java
@@ -0,0 +1,105 @@
+/*
+ * Copyright (C) 2018 xuexiangjys(xuexiangjys@163.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.kerwin.wumei.utils;
+
+import android.annotation.SuppressLint;
+import android.app.ProgressDialog;
+import android.content.Context;
+import android.text.TextUtils;
+
+/**
+ *
+ *
+ * @author xuexiang
+ * @since 2018/8/3 下午6:47
+ */
+public class HProgressDialogUtils {
+ private static ProgressDialog sHorizontalProgressDialog;
+
+ private HProgressDialogUtils() {
+ throw new UnsupportedOperationException("cannot be instantiated");
+ }
+
+ @SuppressLint("NewApi")
+ public static void showHorizontalProgressDialog(Context context, String msg, boolean isShowSize) {
+ cancel();
+
+ if (sHorizontalProgressDialog == null) {
+ sHorizontalProgressDialog = new ProgressDialog(context);
+ sHorizontalProgressDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
+ sHorizontalProgressDialog.setCancelable(false);
+ if (isShowSize) {
+ sHorizontalProgressDialog.setProgressNumberFormat("%2dMB/%1dMB");
+ }
+
+ }
+ if (!TextUtils.isEmpty(msg)) {
+ sHorizontalProgressDialog.setMessage(msg);
+ }
+ sHorizontalProgressDialog.show();
+
+ }
+
+ public static void setMax(long total) {
+ if (sHorizontalProgressDialog != null) {
+ sHorizontalProgressDialog.setMax(((int) total) / (1024 * 1024));
+ }
+ }
+
+ public static void cancel() {
+ if (sHorizontalProgressDialog != null) {
+ sHorizontalProgressDialog.dismiss();
+ sHorizontalProgressDialog = null;
+ }
+ }
+
+ public static void setProgress(int current) {
+ if (sHorizontalProgressDialog == null) {
+ return;
+ }
+ sHorizontalProgressDialog.setProgress(current);
+ if (sHorizontalProgressDialog.getProgress() >= sHorizontalProgressDialog.getMax()) {
+ sHorizontalProgressDialog.dismiss();
+ sHorizontalProgressDialog = null;
+ }
+ }
+
+ public static void setProgress(long current) {
+ if (sHorizontalProgressDialog == null) {
+ return;
+ }
+ sHorizontalProgressDialog.setProgress(((int) current) / (1024 * 1024));
+ if (sHorizontalProgressDialog.getProgress() >= sHorizontalProgressDialog.getMax()) {
+ sHorizontalProgressDialog.dismiss();
+ sHorizontalProgressDialog = null;
+ }
+ }
+
+ public static void onLoading(long total, long current) {
+ if (sHorizontalProgressDialog == null) {
+ return;
+ }
+ if (current == 0) {
+ sHorizontalProgressDialog.setMax(((int) total) / (1024 * 1024));
+ }
+ sHorizontalProgressDialog.setProgress(((int) current) / (1024 * 1024));
+ if (sHorizontalProgressDialog.getProgress() >= sHorizontalProgressDialog.getMax()) {
+ sHorizontalProgressDialog.dismiss();
+ sHorizontalProgressDialog = null;
+ }
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/utils/RouterUtils.java b/android/app/src/main/java/com/kerwin/wumei/utils/RouterUtils.java
new file mode 100644
index 00000000..4e03860c
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/utils/RouterUtils.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2018 xuexiangjys(xuexiangjys@163.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.kerwin.wumei.utils;
+
+import android.os.Bundle;
+import androidx.annotation.NonNull;
+
+import com.xuexiang.xrouter.facade.service.SerializationService;
+import com.xuexiang.xrouter.launcher.XRouter;
+
+/**
+ * @author xuexiang
+ * @since 2018/8/3 下午2:54
+ */
+public final class RouterUtils {
+
+ private RouterUtils() {
+ throw new UnsupportedOperationException("u can't instantiate me...");
+ }
+
+ public static Bundle getBundle(String key, Object value) {
+ Bundle bundle = new Bundle();
+ bundle.putString(key, XRouter.getInstance().navigation(SerializationService.class).object2Json(value));
+ return bundle;
+ }
+
+ /**
+ * 注入依赖
+ *
+ * @param target
+ */
+ public static void inject(@NonNull Object target) {
+ XRouter.getInstance().inject(target);
+ }
+
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/utils/SettingSPUtils.java b/android/app/src/main/java/com/kerwin/wumei/utils/SettingSPUtils.java
new file mode 100644
index 00000000..a8937da5
--- /dev/null
+++ b/android/app/src/main/java/com/kerwin/wumei/utils/SettingSPUtils.java
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2018 xuexiangjys(xuexiangjys@163.com)
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.kerwin.wumei.utils;
+
+import android.content.Context;
+
+import com.kerwin.wumei.R;
+import com.xuexiang.xutil.XUtil;
+import com.xuexiang.xutil.data.BaseSPUtil;
+
+/**
+ * @author xuexiang
+ * @since 2018/7/16 下午3:38
+ */
+public class SettingSPUtils extends BaseSPUtil {
+
+ private static SettingSPUtils sInstance;
+
+ private SettingSPUtils(Context context) {
+ super(context);
+ }
+
+ public static SettingSPUtils getInstance() {
+ if (sInstance == null) {
+ synchronized (SettingSPUtils.class) {
+ if (sInstance == null) {
+ sInstance = new SettingSPUtils(XUtil.getContext());
+ }
+ }
+ }
+ return sInstance;
+ }
+
+ /**
+ * 获取服务器地址
+ *
+ * @return
+ */
+ public String getApiURL() {
+ return getString(getString(R.string.service_api_key), getString(R.string.default_service_api));
+ }
+
+ /**
+ * 获取服务器地址
+ *
+ * @return
+ */
+ public boolean setApiURL(String apiUrl) {
+ return putString(getString(R.string.service_api_key), apiUrl);
+ }
+}
diff --git a/android/app/src/main/java/com/kerwin/wumei/utils/SettingUtils.java b/android/app/src/main/java/com/kerwin/wumei/utils/SettingUtils.java
index cab09bb4..adf4d010 100644
--- a/android/app/src/main/java/com/kerwin/wumei/utils/SettingUtils.java
+++ b/android/app/src/main/java/com/kerwin/wumei/utils/SettingUtils.java
@@ -29,11 +29,14 @@ public final class SettingUtils {
private SettingUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
-
private static final String IS_FIRST_OPEN_KEY = "is_first_open_key";
-
private static final String IS_AGREE_PRIVACY_KEY = "is_agree_privacy_key";
-
+ private static final String USER_NAME="user_name";
+ private static final String PASSWORD="password";
+ private static final String SERVERIP="serve_ip";
+ private static final String SERVERPORT="serve_port";
+ private static final String ISHTTPS="is_https";
+ private static final String APIP="ap_ip";
/**
* 是否是第一次启动
*/
@@ -48,6 +51,100 @@ public final class SettingUtils {
MMKVUtils.put(IS_FIRST_OPEN_KEY, isFirstOpen);
}
+ /**
+ * 设置用户名和密码
+ */
+ public static void setAccount(String userName,String password){
+ MMKVUtils.put(USER_NAME,userName);
+ MMKVUtils.put(PASSWORD,password);
+ }
+
+ /**
+ * 设置服务端地址
+ */
+ public static void setServeUrl(String serveIp, String servePort, Boolean isHttps){
+ MMKVUtils.put(SERVERIP,serveIp);
+ MMKVUtils.put(SERVERPORT,servePort);
+ MMKVUtils.put(ISHTTPS,isHttps);
+ }
+
+ /**
+ * 获取服务端地址
+ */
+ public static String getServeUrl(){
+ String address="";
+ if(getIsHttps()){
+ address="https://";
+ }else{
+ address="http://";
+ }
+ address=address+getServerip()+":"+getServerPort();
+ return address;
+ }
+
+ /**
+ * 设置设备AP地址
+ * @return
+ */
+ public static void setApIp(String apIp){
+ MMKVUtils.put(APIP,apIp);
+ }
+
+ /**
+ * 获取设备AP地址
+ * @return
+ */
+ public static String getApIp(){
+ return MMKVUtils.getString(APIP,"192.168.4.1");
+ }
+
+ /**
+ * 获取服务端ip
+ * @return
+ */
+ public static String getServerip(){
+ return MMKVUtils.getString(SERVERIP,"");
+ }
+
+ /**
+ * 获取服务端端口
+ * @return
+ */
+ public static String getServerPort(){
+ return MMKVUtils.getString(SERVERPORT,"");
+ }
+
+ /**
+ * 获取是否使用https
+ * @return
+ */
+ public static Boolean getIsHttps(){
+ return MMKVUtils.getBoolean(ISHTTPS,false);
+ }
+
+ /**
+ * 获取登录用户名
+ * @return
+ */
+ public static String getUserName(){
+ return MMKVUtils.getString(USER_NAME,"");
+ }
+
+ /**
+ * 获取登录密码
+ * @return
+ */
+ public static String getPassword(){
+ return MMKVUtils.getString(PASSWORD,"");
+ }
+
+ /**
+ * 清空登录密码
+ */
+ public static void clearPassword(){
+ MMKVUtils.put(PASSWORD,"");
+ }
+
/**
* @return 是否同意隐私政策
*/
diff --git a/android/app/src/main/java/com/kerwin/wumei/utils/TokenUtils.java b/android/app/src/main/java/com/kerwin/wumei/utils/TokenUtils.java
index b4897847..ee3e2c5c 100644
--- a/android/app/src/main/java/com/kerwin/wumei/utils/TokenUtils.java
+++ b/android/app/src/main/java/com/kerwin/wumei/utils/TokenUtils.java
@@ -34,13 +34,13 @@ public final class TokenUtils {
private static String sToken;
- private static final String KEY_TOKEN = "com.xuexiang.templateproject.utils.KEY_TOKEN";
+ private static final String KEY_TOKEN = "com.kerwin.wumei.utils.KEY_TOKEN";
private TokenUtils() {
throw new UnsupportedOperationException("u can't instantiate me...");
}
- private static final String KEY_PROFILE_CHANNEL = "github";
+ private static final String KEY_PROFILE_CHANNEL = "gitee";
/**
* 初始化Token信息
@@ -80,7 +80,7 @@ public final class TokenUtils {
setToken(token);
return true;
} else {
- XToastUtils.error("登录失败!");
+// XToastUtils.error("匿名用户");
return false;
}
}
@@ -92,7 +92,7 @@ public final class TokenUtils {
MobclickAgent.onProfileSignOff();
//登出时,清除账号信息
clearToken();
- XToastUtils.success("登出成功!");
+// XToastUtils.success("登出成功!");
//跳转到登录页
ActivityUtils.startActivity(LoginActivity.class);
}
diff --git a/android/app/src/main/java/com/kerwin/wumei/utils/sdkinit/XUpdateInit.java b/android/app/src/main/java/com/kerwin/wumei/utils/sdkinit/XUpdateInit.java
index a092c277..41f6d340 100644
--- a/android/app/src/main/java/com/kerwin/wumei/utils/sdkinit/XUpdateInit.java
+++ b/android/app/src/main/java/com/kerwin/wumei/utils/sdkinit/XUpdateInit.java
@@ -26,6 +26,7 @@ import com.kerwin.wumei.utils.update.CustomUpdateFailureListener;
import com.kerwin.wumei.utils.update.XHttpUpdateHttpServiceImpl;
import com.xuexiang.xupdate.XUpdate;
import com.xuexiang.xupdate.utils.UpdateUtils;
+import com.xuexiang.xutil.common.StringUtils;
/**
* XUpdate 版本更新 SDK 初始化
@@ -42,6 +43,7 @@ public final class XUpdateInit {
/**
* 应用版本更新的检查地址
*/
+ // TODO: 2021/5/26 需要开启版本更新功能的话,就需要配置一下版本更新的地址
private static final String KEY_UPDATE_URL = "";
public static void init(Application application) {
@@ -67,7 +69,21 @@ public final class XUpdateInit {
* 进行版本更新检查
*/
public static void checkUpdate(Context context, boolean needErrorTip) {
- XUpdate.newBuild(context).updateUrl(KEY_UPDATE_URL).update();
+ checkUpdate(context, KEY_UPDATE_URL, needErrorTip);
+ }
+
+ /**
+ * 进行版本更新检查
+ *
+ * @param context 上下文
+ * @param url 版本更新检查的地址
+ * @param needErrorTip 是否需要错误的提示
+ */
+ private static void checkUpdate(Context context, String url, boolean needErrorTip) {
+ if (StringUtils.isEmpty(url)) {
+ return;
+ }
+ XUpdate.newBuild(context).updateUrl(url).update();
XUpdate.get().setOnUpdateFailureListener(new CustomUpdateFailureListener(needErrorTip));
}
}
diff --git a/android/app/src/main/java/com/kerwin/wumei/widget/GuideTipsDialog.java b/android/app/src/main/java/com/kerwin/wumei/widget/GuideTipsDialog.java
index 4e44f4cb..9e3ef0a0 100644
--- a/android/app/src/main/java/com/kerwin/wumei/widget/GuideTipsDialog.java
+++ b/android/app/src/main/java/com/kerwin/wumei/widget/GuideTipsDialog.java
@@ -99,6 +99,7 @@ public class GuideTipsDialog extends BaseDialog implements View.OnClickListener,
mTvNext = findViewById(R.id.tv_next);
if (cbIgnore != null) {
+ cbIgnore.setChecked(isIgnoreTips());
cbIgnore.setOnCheckedChangeListener(this);
}
if (ivClose != null) {
diff --git a/android/app/src/main/res/drawable-hdpi/alarm.png b/android/app/src/main/res/drawable-hdpi/alarm.png
new file mode 100644
index 0000000000000000000000000000000000000000..5d620df805b1ec25c3e1e1a37b78934196da2082
GIT binary patch
literal 5665
zcmYjVXH-+&(gq9?l#&FM4hc!gg9L79cxZ5Gn+MCo3B(>3j6FBaT7os?Qq;@IkF&oGetKsoqg(tIul
zM?wtrd~k?juuzHPsQ%H~{?COMA48570$mq=pUR%4HZBHsg&b`ask<@canQwe>j8qL
zy_jgV?PcloKoKfTF%m!y)c0L!KnnB+69=6?aGD7cpFjDCkxq}0$1xkn86OQsuqal^
zvr#Q%Wtx~}S!m&C9v^d0L8_yxqdT`N57ks@?)lVpkTmXX-#dl3N>o$-Hp}Wfs68Mr
zvDiD;pK7}7CuZxZk8yi=FiGLH{PhtmjcYo@+Za(yk(-|;PAW+3hT#}%k5PSYI9jzu
zqmcC2$7pq(xGLm4n7bq3?we6Jfs!tLYH*
z4a3d;Wuu`3IW^B;*&}LD{$+HOeNe!>9*L%0{%9Pe@rVO8+iST>Xo3s1^`fWn^(c*1nB(4h%m$Ofoh&iT
ziTy&&vXy5d)Gg