timer = new HashMap<>();
-
- @Override
- public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
- super.onReceivedError(view, request, error);
- }
-
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
- return shouldOverrideUrlLoading(view, request.getUrl() + "");
- }
-
- @Nullable
- @Override
- public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
- return super.shouldInterceptRequest(view, request);
- }
-
- //
- @Override
- public boolean shouldOverrideUrlLoading(final WebView view, String url) {
- //intent:// scheme的处理 如果返回false , 则交给 DefaultWebClient 处理 , 默认会打开该Activity , 如果Activity不存在则跳到应用市场上去. true 表示拦截
- //例如优酷视频播放 ,intent://play?...package=com.youku.phone;end;
- //优酷想唤起自己应用播放该视频 , 下面拦截地址返回 true 则会在应用内 H5 播放 ,禁止优酷唤起播放该视频, 如果返回 false , DefaultWebClient 会根据intent 协议处理 该地址 , 首先匹配该应用存不存在 ,如果存在 , 唤起该应用播放 , 如果不存在 , 则跳到应用市场下载该应用 .
- if (url.startsWith("intent://") && url.contains("com.youku.phone")) {
- return true;
- }
-
- return false;
- }
-
- @Override
- public void onPageStarted(WebView view, String url, Bitmap favicon) {
- Log.i(TAG, "mUrl:" + url + " onPageStarted target:" + getUrl());
- timer.put(url, System.currentTimeMillis());
- if (url.equals(getUrl())) {
- pageNavigator(View.GONE);
- } else {
- pageNavigator(View.VISIBLE);
- }
-
- }
-
- @Override
- public void onPageFinished(WebView view, String url) {
- super.onPageFinished(view, url);
-
- if (timer.get(url) != null) {
- long overTime = System.currentTimeMillis();
- Long startTime = timer.get(url);
- Log.i(TAG, " page mUrl:" + url + " used time:" + (overTime - startTime));
- }
-
- }
-
- @Override
- public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
- super.onReceivedHttpError(view, request, errorResponse);
- }
-
- @Override
- public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
- super.onReceivedError(view, errorCode, description, failingUrl);
- }
- };
-
-
- @Override
- public void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- }
-
-
- //========================菜单功能================================//
-
- /**
- * 打开浏览器
- *
- * @param targetUrl 外部浏览器打开的地址
- */
- private void openBrowser(String targetUrl) {
- if (TextUtils.isEmpty(targetUrl) || targetUrl.startsWith("file://")) {
- XToastUtils.toast(targetUrl + " 该链接无法使用浏览器打开。");
- return;
- }
- Intent intent = new Intent();
- intent.setAction("android.intent.action.VIEW");
- Uri uri = Uri.parse(targetUrl);
- intent.setData(uri);
- startActivity(intent);
- }
-
-
- /**
- * 显示更多菜单
- *
- * @param view 菜单依附在该View下面
- */
- private void showPoPup(View view) {
- if (mPopupMenu == null) {
- mPopupMenu = new PopupMenu(getContext(), view);
- mPopupMenu.inflate(R.menu.menu_toolbar_web);
- mPopupMenu.setOnMenuItemClickListener(mOnMenuItemClickListener);
- }
- mPopupMenu.show();
- }
-
- /**
- * 菜单事件
- */
- private PopupMenu.OnMenuItemClickListener mOnMenuItemClickListener = new PopupMenu.OnMenuItemClickListener() {
- @Override
- public boolean onMenuItemClick(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.refresh:
- if (mAgentWeb != null) {
- mAgentWeb.getUrlLoader().reload(); // 刷新
- }
- return true;
-
- case R.id.copy:
- if (mAgentWeb != null) {
- toCopy(getContext(), mAgentWeb.getWebCreator().getWebView().getUrl());
- }
- return true;
- case R.id.default_browser:
- if (mAgentWeb != null) {
- openBrowser(mAgentWeb.getWebCreator().getWebView().getUrl());
- }
- return true;
- case R.id.share:
- if (mAgentWeb != null) {
- shareWebUrl(mAgentWeb.getWebCreator().getWebView().getUrl());
- }
- return true;
- default:
- return false;
- }
-
- }
- };
-
- /**
- * 分享网页链接
- *
- * @param url 网页链接
- */
- private void shareWebUrl(String url) {
- Intent shareIntent = new Intent();
- shareIntent.setAction(Intent.ACTION_SEND);
- shareIntent.putExtra(Intent.EXTRA_TEXT, url);
- shareIntent.setType("text/plain");
- //设置分享列表的标题,并且每次都显示分享列表
- startActivity(Intent.createChooser(shareIntent, "分享到"));
- }
-
-
- /**
- * 复制字符串
- *
- * @param context
- * @param text
- */
- private void toCopy(Context context, String text) {
- ClipboardManager manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
- if (manager == null) {
- return;
- }
- manager.setPrimaryClip(ClipData.newPlainText(null, text));
- }
-
- //===================生命周期管理===========================//
-
- @Override
- public void onResume() {
- mAgentWeb.getWebLifeCycle().onResume();//恢复
- super.onResume();
- }
-
- @Override
- public void onPause() {
- mAgentWeb.getWebLifeCycle().onPause(); //暂停应用内所有WebView , 调用mWebView.resumeTimers();/mAgentWeb.getWebLifeCycle().onResume(); 恢复。
- super.onPause();
- }
-
- @Override
- public boolean onFragmentKeyDown(int keyCode, KeyEvent event) {
- return mAgentWeb.handleKeyEvent(keyCode, event);
- }
-
- @Override
- public void onDestroyView() {
- mAgentWeb.getWebLifeCycle().onDestroy();
- super.onDestroyView();
- }
-
- //===================中间键===========================//
-
-
- /**
- * MiddlewareWebClientBase 是 AgentWeb 3.0.0 提供一个强大的功能,
- * 如果用户需要使用 AgentWeb 提供的功能, 不想重写 WebClientView方
- * 法覆盖AgentWeb提供的功能,那么 MiddlewareWebClientBase 是一个
- * 不错的选择 。
- *
- * @return
- */
- protected MiddlewareWebClientBase getMiddlewareWebClient() {
- return new MiddlewareWebViewClient() {
- /**
- *
- * @param view
- * @param url
- * @return
- */
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, String url) {
- // 拦截 url,不执行 DefaultWebClient#shouldOverrideUrlLoading
- if (url.startsWith("agentweb")) {
- Log.i(TAG, "agentweb scheme ~");
- return true;
- }
- // 执行 DefaultWebClient#shouldOverrideUrlLoading
- if (super.shouldOverrideUrlLoading(view, url)) {
- return true;
- }
- // do you work
- return false;
- }
-
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
- return super.shouldOverrideUrlLoading(view, request);
- }
- };
- }
-
- protected MiddlewareWebChromeBase getMiddlewareWebChrome() {
- return new MiddlewareChromeClient() {
- };
- }
-}
diff --git a/android/app/src/main/java/com/kerwin/wumei/core/webview/BaseWebViewFragment.java b/android/app/src/main/java/com/kerwin/wumei/core/webview/BaseWebViewFragment.java
deleted file mode 100644
index af3c0396..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/core/webview/BaseWebViewFragment.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.core.webview;
-
-import android.view.KeyEvent;
-
-import com.just.agentweb.core.AgentWeb;
-import com.kerwin.wumei.core.BaseFragment;
-
-/**
- * 基础web
- *
- * @author xuexiang
- * @since 2019/5/28 10:22
- */
-public abstract class BaseWebViewFragment extends BaseFragment {
-
- protected AgentWeb mAgentWeb;
-
- //===================生命周期管理===========================//
- @Override
- public void onResume() {
- if (mAgentWeb != null) {
- //恢复
- mAgentWeb.getWebLifeCycle().onResume();
- }
- super.onResume();
- }
-
- @Override
- public void onPause() {
- if (mAgentWeb != null) {
- //暂停应用内所有WebView , 调用mWebView.resumeTimers();/mAgentWeb.getWebLifeCycle().onResume(); 恢复。
- mAgentWeb.getWebLifeCycle().onPause();
- }
- super.onPause();
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- return mAgentWeb != null && mAgentWeb.handleKeyEvent(keyCode, event);
- }
-
- @Override
- public void onDestroyView() {
- if (mAgentWeb != null) {
- mAgentWeb.destroy();
- }
- super.onDestroyView();
- }
-}
diff --git a/android/app/src/main/java/com/kerwin/wumei/core/webview/FragmentKeyDown.java b/android/app/src/main/java/com/kerwin/wumei/core/webview/FragmentKeyDown.java
deleted file mode 100644
index 7094fa6f..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/core/webview/FragmentKeyDown.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.core.webview;
-
-import android.view.KeyEvent;
-
-/**
- *
- *
- * @author xuexiang
- * @since 2019/1/4 下午11:32
- */
-public interface FragmentKeyDown {
-
- /**
- * fragment按键监听
- * @param keyCode
- * @param event
- * @return
- */
- boolean onFragmentKeyDown(int keyCode, KeyEvent event);
-}
diff --git a/android/app/src/main/java/com/kerwin/wumei/core/webview/LollipopFixedWebView.java b/android/app/src/main/java/com/kerwin/wumei/core/webview/LollipopFixedWebView.java
deleted file mode 100644
index 6f5ad0cb..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/core/webview/LollipopFixedWebView.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
- * 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.core.webview;
-
-import android.annotation.TargetApi;
-import android.content.Context;
-import android.content.res.Configuration;
-import android.os.Build;
-import android.util.AttributeSet;
-import android.webkit.WebView;
-
-/**
- * 修复 Android 5.0 & 5.1 打开 WebView 闪退问题:
- * 参阅 https://stackoverflow.com/questions/41025200/android-view-inflateexception-error-inflating-class-android-webkit-webview
- */
-@SuppressWarnings("unused")
-public class LollipopFixedWebView extends WebView {
- public LollipopFixedWebView(Context context) {
- super(getFixedContext(context));
- }
-
- public LollipopFixedWebView(Context context, AttributeSet attrs) {
- super(getFixedContext(context), attrs);
- }
-
- public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr) {
- super(getFixedContext(context), attrs, defStyleAttr);
- }
-
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- super(getFixedContext(context), attrs, defStyleAttr, defStyleRes);
- }
-
- public LollipopFixedWebView(Context context, AttributeSet attrs, int defStyleAttr, boolean privateBrowsing) {
- super(getFixedContext(context), attrs, defStyleAttr, privateBrowsing);
- }
-
- public static Context getFixedContext(Context context) {
- if (isLollipopWebViewBug()) {
- // Avoid crashing on Android 5 and 6 (API level 21 to 23)
- return context.createConfigurationContext(new Configuration());
- }
- return context;
- }
-
- public static boolean isLollipopWebViewBug() {
- return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Build.VERSION.SDK_INT < Build.VERSION_CODES.M;
- }
-
-}
diff --git a/android/app/src/main/java/com/kerwin/wumei/core/webview/MiddlewareChromeClient.java b/android/app/src/main/java/com/kerwin/wumei/core/webview/MiddlewareChromeClient.java
deleted file mode 100644
index 9babc825..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/core/webview/MiddlewareChromeClient.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * 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.core.webview;
-
-import android.util.Log;
-import android.webkit.JsResult;
-import android.webkit.WebView;
-
-import com.just.agentweb.core.client.MiddlewareWebChromeBase;
-
-/**
- * WebChrome(WebChromeClient主要辅助WebView处理JavaScript的对话框、网站图片、网站title、加载进度等)中间件
- * 【浏览器】
- * @author xuexiang
- * @since 2019/1/4 下午11:31
- */
-public class MiddlewareChromeClient extends MiddlewareWebChromeBase {
-
- public MiddlewareChromeClient() {
-
- }
-
- @Override
- public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
- Log.i("Info", "onJsAlert:" + url);
- return super.onJsAlert(view, url, message, result);
- }
-
- @Override
- public void onProgressChanged(WebView view, int newProgress) {
- super.onProgressChanged(view, newProgress);
- Log.i("Info", "onProgressChanged:");
- }
-}
diff --git a/android/app/src/main/java/com/kerwin/wumei/core/webview/MiddlewareWebViewClient.java b/android/app/src/main/java/com/kerwin/wumei/core/webview/MiddlewareWebViewClient.java
deleted file mode 100644
index e4a46b61..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/core/webview/MiddlewareWebViewClient.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*
- * 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.core.webview;
-
-import android.net.Uri;
-import android.os.Build;
-import android.util.Log;
-import android.webkit.WebResourceRequest;
-import android.webkit.WebResourceResponse;
-import android.webkit.WebView;
-
-import androidx.annotation.RequiresApi;
-
-import com.just.agentweb.core.client.MiddlewareWebClientBase;
-import com.kerwin.wumei.R;
-import com.xuexiang.xui.utils.ResUtils;
-
-/**
- * 【网络请求、加载】
- * WebClient(WebViewClient 这个类主要帮助WebView处理各种通知、url加载,请求时间的)中间件
- *
- *
- * 方法的执行顺序,例如下面用了7个中间件一个 WebViewClient
- *
- * .useMiddlewareWebClient(getMiddlewareWebClient()) // 1
- * .useMiddlewareWebClient(getMiddlewareWebClient()) // 2
- * .useMiddlewareWebClient(getMiddlewareWebClient()) // 3
- * .useMiddlewareWebClient(getMiddlewareWebClient()) // 4
- * .useMiddlewareWebClient(getMiddlewareWebClient()) // 5
- * .useMiddlewareWebClient(getMiddlewareWebClient()) // 6
- * .useMiddlewareWebClient(getMiddlewareWebClient()) // 7
- * DefaultWebClient // 8
- * .setWebViewClient(mWebViewClient) // 9
- *
- *
- * 典型的洋葱模型
- * 对象内部的方法执行顺序: 1->2->3->4->5->6->7->8->9->8->7->6->5->4->3->2->1
- *
- *
- * 中断中间件的执行, 删除super.methodName(...) 这行即可
- *
- * 这里主要是做去广告的工作
- */
-public class MiddlewareWebViewClient extends MiddlewareWebClientBase {
-
- public MiddlewareWebViewClient() {
- }
-
- private static int count = 1;
-
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
- Log.i("Info", "MiddlewareWebViewClient -- > shouldOverrideUrlLoading:" + request.getUrl().toString() + " c:" + (count++));
- if (shouldOverrideUrlLoadingByApp(view, request.getUrl().toString())) {
- return true;
- }
- return super.shouldOverrideUrlLoading(view, request);
-
- }
-
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, String url) {
- Log.i("Info", "MiddlewareWebViewClient -- > shouldOverrideUrlLoading:" + url + " c:" + (count++));
- if (shouldOverrideUrlLoadingByApp(view, url)) {
- return true;
- }
- return super.shouldOverrideUrlLoading(view, url);
- }
-
- @Override
- public WebResourceResponse shouldInterceptRequest(WebView view, String url) {
- url = url.toLowerCase();
- if (!hasAdUrl(url)) {
- //正常加载
- return super.shouldInterceptRequest(view, url);
- } else {
- //含有广告资源屏蔽请求
- return new WebResourceResponse(null, null, null);
- }
- }
-
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
- @Override
- public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
- String url = request.getUrl().toString().toLowerCase();
- if (!hasAdUrl(url)) {
- //正常加载
- return super.shouldInterceptRequest(view, request);
- } else {
- //含有广告资源屏蔽请求
- return new WebResourceResponse(null, null, null);
- }
- }
-
- /**
- * 判断是否存在广告的链接
- *
- * @param url
- * @return
- */
- private static boolean hasAdUrl(String url) {
- String[] adUrls = ResUtils.getStringArray(R.array.adBlockUrl);
- for (String adUrl : adUrls) {
- if (url.contains(adUrl)) {
- return true;
- }
- }
- return false;
- }
-
-
- /**
- * 根据url的scheme处理跳转第三方app的业务,true代表拦截,false代表不拦截
- */
- private boolean shouldOverrideUrlLoadingByApp(WebView webView, final String url) {
- if (url.startsWith("http") || url.startsWith("https") || url.startsWith("ftp")) {
- //不拦截http, https, ftp的请求
- Uri uri = Uri.parse(url);
- if (uri != null && !(WebViewInterceptDialog.APP_LINK_HOST.equals(uri.getHost())
- //防止xui官网被拦截
- && url.contains("xpage"))) {
- return false;
- }
- }
-
- WebViewInterceptDialog.show(url);
- return true;
- }
-
-}
diff --git a/android/app/src/main/java/com/kerwin/wumei/core/webview/UIController.java b/android/app/src/main/java/com/kerwin/wumei/core/webview/UIController.java
deleted file mode 100644
index b5650e1e..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/core/webview/UIController.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.core.webview;
-
-import android.app.Activity;
-import android.os.Handler;
-import android.util.Log;
-import android.webkit.WebView;
-
-import com.just.agentweb.core.web.AgentWebUIControllerImplBase;
-
-import java.lang.ref.WeakReference;
-
-/**
- * 如果你需要修改某一个AgentWeb 内部的某一个弹窗 ,请看下面的例子
- * 注意写法一定要参照 DefaultUIController 的写法 ,因为UI自由定制,但是回调的方式是固定的,并且一定要回调。
- *
- * @author xuexiang
- * @since 2019-10-30 23:18
- */
-public class UIController extends AgentWebUIControllerImplBase {
-
- private WeakReference mActivity;
-
- public UIController(Activity activity) {
- mActivity = new WeakReference<>(activity);
- }
-
- @Override
- public void onShowMessage(String message, String from) {
- super.onShowMessage(message, from);
- Log.i(TAG, "message:" + message);
- }
-
- @Override
- public void onSelectItemsPrompt(WebView view, String url, String[] items, Handler.Callback callback) {
- // 使用默认的UI
- super.onSelectItemsPrompt(view, url, items, callback);
- }
-
-}
diff --git a/android/app/src/main/java/com/kerwin/wumei/core/webview/WebLayout.java b/android/app/src/main/java/com/kerwin/wumei/core/webview/WebLayout.java
deleted file mode 100644
index 341683e3..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/core/webview/WebLayout.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.core.webview;
-
-import android.app.Activity;
-import android.view.LayoutInflater;
-import android.view.ViewGroup;
-import android.webkit.WebView;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-
-import com.just.agentweb.widget.IWebLayout;
-import com.scwang.smartrefresh.layout.SmartRefreshLayout;
-import com.kerwin.wumei.R;
-
-/**
- * 定义支持下来回弹的WebView
- *
- * @author xuexiang
- * @since 2019/1/5 上午2:01
- */
-public class WebLayout implements IWebLayout {
-
- private final SmartRefreshLayout mSmartRefreshLayout;
- private WebView mWebView;
-
- public WebLayout(Activity activity) {
- mSmartRefreshLayout = (SmartRefreshLayout) LayoutInflater.from(activity).inflate(R.layout.fragment_pulldown_web, null);
- mWebView = mSmartRefreshLayout.findViewById(R.id.webView);
- }
-
- @NonNull
- @Override
- public ViewGroup getLayout() {
- return mSmartRefreshLayout;
- }
-
- @Nullable
- @Override
- public WebView getWebView() {
- return mWebView;
- }
-
-
-}
diff --git a/android/app/src/main/java/com/kerwin/wumei/core/webview/WebViewInterceptDialog.java b/android/app/src/main/java/com/kerwin/wumei/core/webview/WebViewInterceptDialog.java
deleted file mode 100644
index 406e1753..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/core/webview/WebViewInterceptDialog.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * 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.core.webview;
-
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.net.Uri;
-import android.os.Bundle;
-
-import androidx.annotation.Nullable;
-import androidx.appcompat.app.AppCompatActivity;
-
-import com.kerwin.wumei.R;
-import com.kerwin.wumei.utils.XToastUtils;
-import com.xuexiang.xui.utils.ResUtils;
-import com.xuexiang.xui.widget.dialog.DialogLoader;
-import com.xuexiang.xutil.XUtil;
-import com.xuexiang.xutil.app.ActivityUtils;
-
-import java.net.URISyntaxException;
-
-/**
- * WebView拦截提示
- *
- * @author xuexiang
- * @since 2019-10-21 9:51
- */
-public class WebViewInterceptDialog extends AppCompatActivity implements DialogInterface.OnDismissListener {
-
- private static final String KEY_INTERCEPT_URL = "key_intercept_url";
-
- // TODO: 2019-10-30 这里修改你的applink
- public static final String APP_LINK_HOST = "xuexiangjys.club";
- public static final String APP_LINK_ACTION = "com.xuexiang.xui.applink";
-
-
- /**
- * 显示WebView拦截提示
- *
- * @param url 需要拦截处理的url
- */
- public static void show(String url) {
- ActivityUtils.startActivity(WebViewInterceptDialog.class, KEY_INTERCEPT_URL, url);
- }
-
- @Override
- protected void onCreate(@Nullable Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- String url = getIntent().getStringExtra(KEY_INTERCEPT_URL);
-
- DialogLoader.getInstance().showConfirmDialog(
- this,
- getOpenTitle(url),
- ResUtils.getString(R.string.lab_yes),
- (dialog, which) -> {
- dialog.dismiss();
- if (isAppLink(url)) {
- openAppLink(this, url);
- } else {
- openApp(url);
- }
- },
- ResUtils.getString(R.string.lab_no),
- (dialog, which) -> dialog.dismiss()
- ).setOnDismissListener(this);
-
- }
-
- private String getOpenTitle(String url) {
- String scheme = getScheme(url);
- if ("mqqopensdkapi".equals(scheme)) {
- return "是否允许页面打开\"QQ\"?";
- } else {
- return ResUtils.getString(R.string.lab_open_third_app);
- }
- }
-
- private String getScheme(String url) {
- try {
- Intent intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
- return intent.getScheme();
- } catch (URISyntaxException e) {
- e.printStackTrace();
- }
- return "";
- }
-
- private boolean isAppLink(String url) {
- Uri uri = Uri.parse(url);
- return uri != null
- && APP_LINK_HOST.equals(uri.getHost())
- && (url.startsWith("http") || url.startsWith("https"));
- }
-
-
- private void openApp(String url) {
- Intent intent;
- try {
- intent = Intent.parseUri(url, Intent.URI_INTENT_SCHEME);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
- XUtil.getContext().startActivity(intent);
- } catch (Exception e) {
- XToastUtils.error("您所打开的第三方App未安装!");
- }
- }
-
- private void openAppLink(Context context, String url) {
- try {
- Intent intent = new Intent(APP_LINK_ACTION);
- intent.setData(Uri.parse(url));
- context.startActivity(intent);
- } catch (Exception e) {
- XToastUtils.error("您所打开的第三方App未安装!");
- }
- }
-
- @Override
- public void onDismiss(DialogInterface dialog) {
- finish();
- }
-}
diff --git a/android/app/src/main/java/com/kerwin/wumei/core/webview/XPageWebViewFragment.java b/android/app/src/main/java/com/kerwin/wumei/core/webview/XPageWebViewFragment.java
deleted file mode 100644
index 8e77e67a..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/core/webview/XPageWebViewFragment.java
+++ /dev/null
@@ -1,677 +0,0 @@
-/*
- * 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.core.webview;
-
-import android.content.ClipData;
-import android.content.ClipboardManager;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.Color;
-import android.net.Uri;
-import android.os.Build;
-import android.os.Bundle;
-import android.text.TextUtils;
-import android.view.Gravity;
-import android.view.KeyEvent;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-import android.webkit.WebChromeClient;
-import android.webkit.WebResourceError;
-import android.webkit.WebResourceRequest;
-import android.webkit.WebResourceResponse;
-import android.webkit.WebView;
-import android.webkit.WebViewClient;
-import android.widget.FrameLayout;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-
-import androidx.annotation.Nullable;
-import androidx.annotation.RequiresApi;
-import androidx.appcompat.widget.AppCompatImageView;
-import androidx.appcompat.widget.PopupMenu;
-import androidx.fragment.app.Fragment;
-
-import com.just.agentweb.action.PermissionInterceptor;
-import com.just.agentweb.core.AgentWeb;
-import com.just.agentweb.core.client.DefaultWebClient;
-import com.just.agentweb.core.client.MiddlewareWebChromeBase;
-import com.just.agentweb.core.client.MiddlewareWebClientBase;
-import com.just.agentweb.core.client.WebListenerManager;
-import com.just.agentweb.core.web.AbsAgentWebSettings;
-import com.just.agentweb.core.web.AgentWebConfig;
-import com.just.agentweb.core.web.IAgentWebSettings;
-import com.just.agentweb.download.AgentWebDownloader;
-import com.just.agentweb.download.DefaultDownloadImpl;
-import com.just.agentweb.download.DownloadListenerAdapter;
-import com.just.agentweb.download.DownloadingService;
-import com.just.agentweb.widget.IWebLayout;
-import com.kerwin.wumei.MyApp;
-import com.kerwin.wumei.core.BaseFragment;
-import com.kerwin.wumei.R;
-import com.kerwin.wumei.utils.XToastUtils;
-import com.xuexiang.xaop.annotation.SingleClick;
-import com.xuexiang.xpage.annotation.Page;
-import com.xuexiang.xpage.base.XPageActivity;
-import com.xuexiang.xpage.base.XPageFragment;
-import com.xuexiang.xpage.core.PageOption;
-import com.xuexiang.xui.widget.actionbar.TitleBar;
-import com.xuexiang.xutil.common.logger.Logger;
-import com.xuexiang.xutil.net.JsonUtil;
-
-import java.util.HashMap;
-
-import butterknife.BindView;
-import butterknife.OnClick;
-
-/**
- * 使用XPageFragment
- *
- * @author xuexiang
- * @since 2019-05-26 18:15
- */
-@Page(params = {AgentWebFragment.KEY_URL})
-public class XPageWebViewFragment extends BaseFragment {
-
- @BindView(R.id.iv_back)
- AppCompatImageView mIvBack;
- @BindView(R.id.view_line)
- View mLineView;
- @BindView(R.id.toolbar_title)
- TextView mTvTitle;
-
- protected AgentWeb mAgentWeb;
- private PopupMenu mPopupMenu;
-
- private DownloadingService mDownloadingService;
-
- /**
- * 打开网页
- *
- * @param xPageActivity
- * @param url
- * @return
- */
- public static Fragment openUrl(XPageActivity xPageActivity, String url) {
- return PageOption.to(XPageWebViewFragment.class)
- .putString(AgentWebFragment.KEY_URL, url)
- .open(xPageActivity);
- }
-
- /**
- * 打开网页
- *
- * @param fragment
- * @param url
- * @return
- */
- public static Fragment openUrl(XPageFragment fragment, String url) {
- return PageOption.to(XPageWebViewFragment.class)
- .setNewActivity(true)
- .putString(AgentWebFragment.KEY_URL, url)
- .open(fragment);
- }
-
- @Override
- protected TitleBar initTitle() {
- return null;
- }
-
- /**
- * 布局的资源id
- *
- * @return
- */
- @Override
- protected int getLayoutId() {
- return R.layout.fragment_agentweb;
- }
-
- /**
- * 初始化控件
- */
- @Override
- protected void initViews() {
- mAgentWeb = AgentWeb.with(this)
- //传入AgentWeb的父控件。
- .setAgentWebParent((LinearLayout) getRootView(), -1, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT))
- //设置进度条颜色与高度,-1为默认值,高度为2,单位为dp。
- .useDefaultIndicator(-1, 3)
- //设置 IAgentWebSettings。
- .setAgentWebWebSettings(getSettings())
- //WebViewClient , 与 WebView 使用一致 ,但是请勿获取WebView调用setWebViewClient(xx)方法了,会覆盖AgentWeb DefaultWebClient,同时相应的中间件也会失效。
- .setWebViewClient(mWebViewClient)
- //WebChromeClient
- .setWebChromeClient(mWebChromeClient)
- //设置WebChromeClient中间件,支持多个WebChromeClient,AgentWeb 3.0.0 加入。
- .useMiddlewareWebChrome(getMiddlewareWebChrome())
- //设置WebViewClient中间件,支持多个WebViewClient, AgentWeb 3.0.0 加入。
- .useMiddlewareWebClient(getMiddlewareWebClient())
- //权限拦截 2.0.0 加入。
- .setPermissionInterceptor(mPermissionInterceptor)
- //严格模式 Android 4.2.2 以下会放弃注入对象 ,使用AgentWebView没影响。
- .setSecurityType(AgentWeb.SecurityType.STRICT_CHECK)
- //自定义UI AgentWeb3.0.0 加入。
- .setAgentWebUIController(new UIController(getActivity()))
- //参数1是错误显示的布局,参数2点击刷新控件ID -1表示点击整个布局都刷新, AgentWeb 3.0.0 加入。
- .setMainFrameErrorView(R.layout.agentweb_error_page, -1)
- .setWebLayout(getWebLayout())
- //打开其他页面时,弹窗质询用户前往其他应用 AgentWeb 3.0.0 加入。
- .setOpenOtherPageWays(DefaultWebClient.OpenOtherPageWays.DISALLOW)
- //拦截找不到相关页面的Url AgentWeb 3.0.0 加入。
- .interceptUnkownUrl()
- //创建AgentWeb。
- .createAgentWeb()
- .ready()//设置 WebSettings。
- //WebView载入该url地址的页面并显示。
- .go(getUrl());
-
- if (MyApp.isDebug()) {
- AgentWebConfig.debug();
- }
-
- pageNavigator(View.GONE);
- // 得到 AgentWeb 最底层的控件
- addBackgroundChild(mAgentWeb.getWebCreator().getWebParentLayout());
-
- // AgentWeb 没有把WebView的功能全面覆盖 ,所以某些设置 AgentWeb 没有提供,请从WebView方面入手设置。
- mAgentWeb.getWebCreator().getWebView().setOverScrollMode(WebView.OVER_SCROLL_NEVER);
- }
-
- protected IWebLayout getWebLayout() {
- return new WebLayout(getActivity());
- }
-
- protected void addBackgroundChild(FrameLayout frameLayout) {
- TextView textView = new TextView(frameLayout.getContext());
- textView.setText("技术由 AgentWeb 提供");
- textView.setTextSize(16);
- textView.setTextColor(Color.parseColor("#727779"));
- frameLayout.setBackgroundColor(Color.parseColor("#272b2d"));
- FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(-2, -2);
- params.gravity = Gravity.CENTER_HORIZONTAL;
- final float scale = frameLayout.getContext().getResources().getDisplayMetrics().density;
- params.topMargin = (int) (15 * scale + 0.5f);
- frameLayout.addView(textView, 0, params);
- }
-
-
- private void pageNavigator(int tag) {
- //返回的导航按钮
- mIvBack.setVisibility(tag);
- mLineView.setVisibility(tag);
- }
-
- @SingleClick
- @OnClick({R.id.iv_back, R.id.iv_finish, R.id.iv_more})
- public void onViewClicked(View view) {
- switch (view.getId()) {
- case R.id.iv_back:
- // true表示AgentWeb处理了该事件
- if (!mAgentWeb.back()) {
- popToBack();
- }
- break;
- case R.id.iv_finish:
- popToBack();
- break;
- case R.id.iv_more:
- showPoPup(view);
- break;
- default:
- break;
- }
- }
-
- //=====================下载============================//
-
- /**
- * 更新于 AgentWeb 4.0.0,下载监听
- */
- protected DownloadListenerAdapter mDownloadListenerAdapter = new DownloadListenerAdapter() {
- /**
- *
- * @param url 下载链接
- * @param userAgent UserAgent
- * @param contentDisposition ContentDisposition
- * @param mimeType 资源的媒体类型
- * @param contentLength 文件长度
- * @param extra 下载配置 , 用户可以通过 Extra 修改下载icon , 关闭进度条 , 是否强制下载。
- * @return true 表示用户处理了该下载事件 , false 交给 AgentWeb 下载
- */
- @Override
- public boolean onStart(String url, String userAgent, String contentDisposition, String mimeType, long contentLength, AgentWebDownloader.Extra extra) {
- Logger.i("onStart:" + url);
- // 是否开启断点续传
- extra.setOpenBreakPointDownload(true)
- //下载通知的icon
- .setIcon(R.drawable.ic_file_download_black_24dp)
- // 连接的超时时间
- .setConnectTimeOut(6000)
- // 以8KB位单位,默认60s ,如果60s内无法从网络流中读满8KB数据,则抛出异常
- .setBlockMaxTime(10 * 60 * 1000)
- // 下载的超时时间
- .setDownloadTimeOut(Long.MAX_VALUE)
- // 串行下载更节省资源哦
- .setParallelDownload(false)
- // false 关闭进度通知
- .setEnableIndicator(true)
- // 自定义请求头
- .addHeader("Cookie", "xx")
- // 下载完成自动打开
- .setAutoOpen(true)
- // 强制下载,不管网络网络类型
- .setForceDownload(true);
- return false;
- }
-
- /**
- *
- * 不需要暂停或者停止下载该方法可以不必实现
- * @param url
- * @param downloadingService 用户可以通过 DownloadingService#shutdownNow 终止下载
- */
- @Override
- public void onBindService(String url, DownloadingService downloadingService) {
- super.onBindService(url, downloadingService);
- mDownloadingService = downloadingService;
- Logger.i("onBindService:" + url + " DownloadingService:" + downloadingService);
- }
-
- /**
- * 回调onUnbindService方法,让用户释放掉 DownloadingService。
- * @param url
- * @param downloadingService
- */
- @Override
- public void onUnbindService(String url, DownloadingService downloadingService) {
- super.onUnbindService(url, downloadingService);
- mDownloadingService = null;
- Logger.i("onUnbindService:" + url);
- }
-
- /**
- *
- * @param url 下载链接
- * @param loaded 已经下载的长度
- * @param length 文件的总大小
- * @param usedTime 耗时 ,单位ms
- * 注意该方法回调在子线程 ,线程名 AsyncTask #XX 或者 AgentWeb # XX
- */
- @Override
- public void onProgress(String url, long loaded, long length, long usedTime) {
- int mProgress = (int) ((loaded) / (float) length * 100);
- Logger.i("onProgress:" + mProgress);
- super.onProgress(url, loaded, length, usedTime);
- }
-
- /**
- *
- * @param path 文件的绝对路径
- * @param url 下载地址
- * @param throwable 如果异常,返回给用户异常
- * @return true 表示用户处理了下载完成后续的事件 ,false 默认交给AgentWeb 处理
- */
- @Override
- public boolean onResult(String path, String url, Throwable throwable) {
- //下载成功
- if (null == throwable) {
- //do you work
- } else {//下载失败
-
- }
- // true 不会发出下载完成的通知 , 或者打开文件
- return false;
- }
- };
-
- /**
- * 下载服务设置
- *
- * @return IAgentWebSettings
- */
- public IAgentWebSettings getSettings() {
- return new AbsAgentWebSettings() {
- private AgentWeb mAgentWeb;
-
- @Override
- protected void bindAgentWebSupport(AgentWeb agentWeb) {
- this.mAgentWeb = agentWeb;
- }
-
- /**
- * AgentWeb 4.0.0 内部删除了 DownloadListener 监听 ,以及相关API ,将 Download 部分完全抽离出来独立一个库,
- * 如果你需要使用 AgentWeb Download 部分 , 请依赖上 compile 'com.just.agentweb:download:4.0.0 ,
- * 如果你需要监听下载结果,请自定义 AgentWebSetting , New 出 DefaultDownloadImpl,传入DownloadListenerAdapter
- * 实现进度或者结果监听,例如下面这个例子,如果你不需要监听进度,或者下载结果,下面 setDownloader 的例子可以忽略。
- * @param webView
- * @param downloadListener
- * @return WebListenerManager
- */
- @Override
- public WebListenerManager setDownloader(WebView webView, android.webkit.DownloadListener downloadListener) {
- return super.setDownloader(webView,
- DefaultDownloadImpl
- .create(getActivity(),
- webView,
- mDownloadListenerAdapter,
- mDownloadListenerAdapter,
- mAgentWeb.getPermissionInterceptor()));
- }
- };
- }
-
- //===================WebChromeClient 和 WebViewClient===========================//
-
- /**
- * 页面空白,请检查scheme是否加上, scheme://host:port/path?query&query 。
- *
- * @return mUrl
- */
- public String getUrl() {
- String target = "";
- Bundle bundle = getArguments();
- if (bundle != null) {
- target = bundle.getString(AgentWebFragment.KEY_URL);
- }
-
- if (TextUtils.isEmpty(target)) {
- target = "https://github.com/xuexiangjys";
- }
- return target;
- }
-
- /**
- * 和浏览器相关,包括和JS的交互
- */
- protected WebChromeClient mWebChromeClient = new WebChromeClient() {
- @Override
- public void onProgressChanged(WebView view, int newProgress) {
- super.onProgressChanged(view, newProgress);
- //网页加载进度
- }
- @Override
- public void onReceivedTitle(WebView view, String title) {
- super.onReceivedTitle(view, title);
- if (mTvTitle != null && !TextUtils.isEmpty(title)) {
- if (title.length() > 10) {
- title = title.substring(0, 10).concat("...");
- }
- mTvTitle.setText(title);
- }
- }
- };
-
- /**
- * 和网页url加载相关,统计加载时间
- */
- protected WebViewClient mWebViewClient = new WebViewClient() {
- private HashMap mTimer = new HashMap<>();
-
- @Override
- public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
- super.onReceivedError(view, request, error);
- }
-
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
- return shouldOverrideUrlLoading(view, request.getUrl() + "");
- }
-
- @Nullable
- @Override
- public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
- return super.shouldInterceptRequest(view, request);
- }
- @Override
- public boolean shouldOverrideUrlLoading(final WebView view, String url) {
- //intent:// scheme的处理 如果返回false , 则交给 DefaultWebClient 处理 , 默认会打开该Activity , 如果Activity不存在则跳到应用市场上去. true 表示拦截
- //例如优酷视频播放 ,intent://play?...package=com.youku.phone;end;
- //优酷想唤起自己应用播放该视频 , 下面拦截地址返回 true 则会在应用内 H5 播放 ,禁止优酷唤起播放该视频, 如果返回 false , DefaultWebClient 会根据intent 协议处理 该地址 , 首先匹配该应用存不存在 ,如果存在 , 唤起该应用播放 , 如果不存在 , 则跳到应用市场下载该应用 .
- if (url.startsWith("intent://") && url.contains("com.youku.phone")) {
- return true;
- }
- return false;
- }
-
- @Override
- public void onPageStarted(WebView view, String url, Bitmap favicon) {
- mTimer.put(url, System.currentTimeMillis());
- if (url.equals(getUrl())) {
- pageNavigator(View.GONE);
- } else {
- pageNavigator(View.VISIBLE);
- }
- }
-
- @Override
- public void onPageFinished(WebView view, String url) {
- super.onPageFinished(view, url);
- if (mTimer.get(url) != null) {
- long overTime = System.currentTimeMillis();
- Long startTime = mTimer.get(url);
- //统计页面的使用时长
- Logger.i(" page mUrl:" + url + " used time:" + (overTime - startTime));
- }
- }
-
- @Override
- public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
- super.onReceivedHttpError(view, request, errorResponse);
- }
-
- @Override
- public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
- super.onReceivedError(view, errorCode, description, failingUrl);
- }
- };
-
- //=====================菜单========================//
-
- /**
- * 显示更多菜单
- *
- * @param view 菜单依附在该View下面
- */
- private void showPoPup(View view) {
- if (mPopupMenu == null) {
- mPopupMenu = new PopupMenu(getContext(), view);
- mPopupMenu.inflate(R.menu.menu_toolbar_web);
- mPopupMenu.setOnMenuItemClickListener(mOnMenuItemClickListener);
- }
- mPopupMenu.show();
- }
-
- /**
- * 菜单事件
- */
- private PopupMenu.OnMenuItemClickListener mOnMenuItemClickListener = new PopupMenu.OnMenuItemClickListener() {
- @Override
- public boolean onMenuItemClick(MenuItem item) {
- switch (item.getItemId()) {
- case R.id.refresh:
- if (mAgentWeb != null) {
- mAgentWeb.getUrlLoader().reload(); // 刷新
- }
- return true;
- case R.id.copy:
- if (mAgentWeb != null) {
- toCopy(getContext(), mAgentWeb.getWebCreator().getWebView().getUrl());
- }
- return true;
- case R.id.default_browser:
- if (mAgentWeb != null) {
- openBrowser(mAgentWeb.getWebCreator().getWebView().getUrl());
- }
- return true;
- case R.id.share:
- if (mAgentWeb != null) {
- shareWebUrl(mAgentWeb.getWebCreator().getWebView().getUrl());
- }
- return true;
- default:
- return false;
- }
-
- }
- };
-
- /**
- * 打开浏览器
- *
- * @param targetUrl 外部浏览器打开的地址
- */
- private void openBrowser(String targetUrl) {
- if (TextUtils.isEmpty(targetUrl) || targetUrl.startsWith("file://")) {
- XToastUtils.toast(targetUrl + " 该链接无法使用浏览器打开。");
- return;
- }
- Intent intent = new Intent();
- intent.setAction("android.intent.action.VIEW");
- Uri uri = Uri.parse(targetUrl);
- intent.setData(uri);
- startActivity(intent);
- }
-
- /**
- * 分享网页链接
- *
- * @param url 网页链接
- */
- private void shareWebUrl(String url) {
- Intent shareIntent = new Intent();
- shareIntent.setAction(Intent.ACTION_SEND);
- shareIntent.putExtra(Intent.EXTRA_TEXT, url);
- shareIntent.setType("text/plain");
- //设置分享列表的标题,并且每次都显示分享列表
- startActivity(Intent.createChooser(shareIntent, "分享到"));
- }
-
- /**
- * 复制字符串
- *
- * @param context
- * @param text
- */
- private void toCopy(Context context, String text) {
- ClipboardManager manager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
- if (manager == null) {
- return;
- }
- manager.setPrimaryClip(ClipData.newPlainText(null, text));
- }
-
- //===================生命周期管理===========================//
-
- @Override
- public void onResume() {
- if (mAgentWeb != null) {
- mAgentWeb.getWebLifeCycle().onResume();//恢复
- }
- super.onResume();
- }
-
- @Override
- public void onPause() {
- if (mAgentWeb != null) {
- mAgentWeb.getWebLifeCycle().onPause(); //暂停应用内所有WebView , 调用mWebView.resumeTimers();/mAgentWeb.getWebLifeCycle().onResume(); 恢复。
- }
- super.onPause();
- }
-
- @Override
- public boolean onKeyDown(int keyCode, KeyEvent event) {
- return mAgentWeb != null && mAgentWeb.handleKeyEvent(keyCode, event);
- }
-
- @Override
- public void onDestroyView() {
- if (mAgentWeb != null) {
- mAgentWeb.destroy();
- }
- super.onDestroyView();
- }
-
-
- //===================中间键===========================//
-
-
- /**
- * MiddlewareWebClientBase 是 AgentWeb 3.0.0 提供一个强大的功能,
- * 如果用户需要使用 AgentWeb 提供的功能, 不想重写 WebClientView方
- * 法覆盖AgentWeb提供的功能,那么 MiddlewareWebClientBase 是一个
- * 不错的选择 。
- *
- * @return
- */
- protected MiddlewareWebClientBase getMiddlewareWebClient() {
- return new MiddlewareWebViewClient() {
- /**
- *
- * @param view
- * @param url
- * @return
- */
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, String url) {
- // 拦截 url,不执行 DefaultWebClient#shouldOverrideUrlLoading
- if (url.startsWith("agentweb")) {
- return true;
- }
- // 执行 DefaultWebClient#shouldOverrideUrlLoading
- if (super.shouldOverrideUrlLoading(view, url)) {
- return true;
- }
- // do you work
- return false;
- }
-
- @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
- @Override
- public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request) {
- return super.shouldOverrideUrlLoading(view, request);
- }
- };
- }
-
- protected MiddlewareWebChromeBase getMiddlewareWebChrome() {
- return new MiddlewareChromeClient() {
- };
- }
-
- /**
- * 权限申请拦截器
- */
- protected PermissionInterceptor mPermissionInterceptor = new PermissionInterceptor() {
- /**
- * PermissionInterceptor 能达到 url1 允许授权, url2 拒绝授权的效果。
- * @param url
- * @param permissions
- * @param action
- * @return true 该Url对应页面请求权限进行拦截 ,false 表示不拦截。
- */
- @Override
- public boolean intercept(String url, String[] permissions, String action) {
- Logger.i("mUrl:" + url + " permission:" + JsonUtil.toJson(permissions) + " action:" + action);
- return false;
- }
- };
-
-}
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
deleted file mode 100644
index 90e651b5..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/entity/Dept.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/******************************************************************************
- * 作者: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
deleted file mode 100644
index c35b0f65..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/entity/DictData.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/******************************************************************************
- * 作者: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
deleted file mode 100644
index 1bee7422..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/entity/IotCategory.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/******************************************************************************
- * 作者: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
deleted file mode 100644
index a6d4634b..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/entity/IotDevice.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/******************************************************************************
- * 作者: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
deleted file mode 100644
index 6b2247cc..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/entity/IotDeviceSet.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/******************************************************************************
- * 作者: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
deleted file mode 100644
index cdd70040..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/entity/IotDeviceStatus.java
+++ /dev/null
@@ -1,234 +0,0 @@
-/******************************************************************************
- * 作者: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
deleted file mode 100644
index b15b9e4c..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/entity/IotGroup.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/******************************************************************************
- * 作者: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
deleted file mode 100644
index c089b1da..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/entity/Roles.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/******************************************************************************
- * 作者: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
deleted file mode 100644
index 86a4f78d..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/entity/User.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/******************************************************************************
- * 作者: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
deleted file mode 100644
index a26fa2cc..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/entity/bo/CaptureImage.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/******************************************************************************
- * 作者: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
deleted file mode 100644
index 0bb945ac..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/entity/vo/IotDeviceVo.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/******************************************************************************
- * 作者: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
deleted file mode 100644
index 6e327927..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/AboutFragment.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/******************************************************************************
- * 作者: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;
-
-import com.kerwin.wumei.core.BaseFragment;
-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;
-
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Locale;
-
-import butterknife.BindView;
-
-
-@Page(name = "关于")
-public class AboutFragment extends BaseFragment {
- @BindView(R.id.titlebar_min)
- TitleBar titleBarMin;
-
- @BindView(R.id.tv_version)
- TextView mVersionTextView;
- @BindView(R.id.about_list)
- 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() {
- return R.layout.fragment_about;
- }
-
- @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(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);
- String currentYear = dateFormat.format(new Date());
- mCopyrightTextView.setText(String.format(getResources().getString(R.string.about_copyright), currentYear));
- }
-}
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
deleted file mode 100644
index 2ff25e34..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/FeedbackFragment.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/******************************************************************************
- * 作者: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;
-
-import com.kerwin.wumei.R;
-import com.kerwin.wumei.core.BaseFragment;
-import com.kerwin.wumei.core.webview.AgentWebActivity;
-import com.xuexiang.xpage.annotation.Page;
-import com.xuexiang.xui.widget.grouplist.XUIGroupListView;
-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 FeedbackFragment extends BaseFragment {
-
- @Override
- protected int getLayoutId() {
- return R.layout.fragment_feedback;
- }
-
- @Override
- protected void initViews() {
-
- }
-}
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
deleted file mode 100644
index 8e950df4..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/LoginFragment.java
+++ /dev/null
@@ -1,213 +0,0 @@
-/******************************************************************************
- * 作者: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.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.ResUtils;
-import com.xuexiang.xui.utils.ThemeUtils;
-import com.xuexiang.xui.widget.actionbar.TitleBar;
-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.SettingUtils.getServerPath;
-import static com.kerwin.wumei.utils.TokenUtils.clearToken;
-
-
-/**
- * 登录页面
- *
- * @author xuexiang
- * @since 2019-11-17 22:15
- */
-@Page(anim = CoreAnim.none)
-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.iv_code)
- ImageView imgVertifyCode;
- @BindView(R.id.btn_clear)
- RoundButton btnClear;
-
- private String uuid="";
- private String token="";
-
- @Override
- protected int getLayoutId() {
- return R.layout.fragment_login;
- }
-
- @Override
- protected TitleBar initTitle() {
- TitleBar titleBar = super.initTitle()
- .setImmersive(true);
- titleBar.setBackgroundColor(Color.TRANSPARENT);
- titleBar.setTitle("");
- titleBar.setLeftImageDrawable(ResUtils.getVectorDrawable(getContext(), R.drawable.ic_login_close));
- titleBar.setActionTextColor(ThemeUtils.resolveColor(getContext(), R.attr.colorAccent));
- titleBar.addAction(new TitleBar.TextAction(R.string.title_jump_login) {
- @Override
- public void performAction(View view) {
- clearToken();
- onLoginSuccess();
- }
- });
- return titleBar;
- }
-
- @Override
- protected void initViews() {
- //隐私政策弹窗
-// if (!SettingUtils.isAgreePrivacy()) {
-// Utils.showPrivacyDialog(getContext(), (dialog, which) -> {
-// dialog.dismiss();
-// SettingUtils.setIsAgreePrivacy(true);
-// });
-// }
- getCatpureImage();
- getLocalAccount();
- }
-
- @SingleClick
- @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_clear:
- SettingUtils.clearPassword();
- etPassword.clear();
- break;
- case R.id.iv_code:
- getCatpureImage();
- break;
- case R.id.btn_login:
- if(etPhoneNumber.getEditValue().length()==0 || etPassword.getEditValue().length()==0 || etVerifyCode.getEditValue().length()==0){
- XToastUtils.error("请正确填写账号、密码和验证码");
- }else {
- loginByVerifyCode(etPhoneNumber.getEditValue(), etPassword.getEditValue(), etVerifyCode.getEditValue());
- }
- break;
- default:
- break;
- }
- }
-
- @Override
- public void onDestroyView() {
- super.onDestroyView();
- }
-
- /**
- * 登录成功的处理
- */
- private void onLoginSuccess() {
- TokenUtils.handleLoginSuccess(token);
- popToBack();
- ActivityUtils.startActivity(MainActivity.class);
- }
-
- /**
- * 获取本地存储的账号
- */
- private void getLocalAccount(){
- etPhoneNumber.setText(SettingUtils.getUserName());
- etPassword.setText(SettingUtils.getPassword());
- }
-
- /**
- * HTTP获取验证码
- */
- private void getCatpureImage(){
- XHttp.get(getServerPath()+"/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);
- }
- @Override
- public void onError(ApiException e) {
- XToastUtils.error(e.getMessage());
- }
- }){});
- }
-
- /**
- * HTTP登录
- *
- * @param phoneNumber 手机号
- * @param verifyCode 验证码
- */
- private void loginByVerifyCode(String phoneNumber,String password, String verifyCode) {
- XHttp.post(getServerPath()+ "/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();
- XToastUtils.error(e.getMessage());
- }
- }){});
- }
-
-
-
-
-}
-
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
deleted file mode 100644
index 7ea2744b..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/MessageFragment.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/******************************************************************************
- * 作者: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;
-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;
-import com.xuexiang.xui.widget.grouplist.XUIGroupListView;
-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 MessageFragment extends BaseFragment {
- @BindView(R.id.titlebar_min)
- TitleBar titleBarMin;
-
- @Override
- protected int getLayoutId() {
- return R.layout.fragment_message;
- }
-
- @Override
- protected TitleBar initTitle() {
- 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
deleted file mode 100644
index 1943a984..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/SettingsFragment.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/******************************************************************************
- * 作者: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;
-import com.xuexiang.xutil.XUtil;
-
-import butterknife.BindView;
-
-import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
-
-/**
- * @author xuexiang
- * @since 2019-10-15 22:38
- */
-@Page(name = "设置")
-public class SettingsFragment extends BaseFragment implements SuperTextView.OnSuperTextViewClickListener {
-
- @BindView(R.id.menu_common)
- SuperTextView menuCommon;
- @BindView(R.id.menu_privacy)
- SuperTextView menuPrivacy;
- @BindView(R.id.menu_push)
- SuperTextView menuPush;
- @BindView(R.id.menu_helper)
- SuperTextView menuHelper;
- @BindView(R.id.menu_change_account)
- SuperTextView menuChangeAccount;
- @BindView(R.id.menu_logout)
- SuperTextView menuLogout;
-
- @Override
- protected int getLayoutId() {
- return R.layout.fragment_settings;
- }
-
- @Override
- protected void initViews() {
- menuCommon.setOnSuperTextViewClickListener(this);
- menuPrivacy.setOnSuperTextViewClickListener(this);
- menuPush.setOnSuperTextViewClickListener(this);
- menuHelper.setOnSuperTextViewClickListener(this);
- menuChangeAccount.setOnSuperTextViewClickListener(this);
- menuLogout.setOnSuperTextViewClickListener(this);
- }
-
- /**
- * HTTP退出登录
- */
- private void logout(){
- XHttp.post(getServerPath()+"/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) {
- switch (superTextView.getId()) {
- case R.id.menu_common:
- case R.id.menu_privacy:
- case R.id.menu_push:
- case R.id.menu_helper:
- XToastUtils.toast(superTextView.getLeftString());
- break;
- case R.id.menu_change_account:
- XToastUtils.toast(superTextView.getCenterString());
- 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/fragment/device/AddDeviceFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/device/AddDeviceFragment.java
deleted file mode 100644
index 33abf32a..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/AddDeviceFragment.java
+++ /dev/null
@@ -1,303 +0,0 @@
-/*****************************************************************************
- * 作者: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.CheckBox;
-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.adapter.entity.EspTouchViewModel;
-import com.kerwin.wumei.core.BaseFragment;
-import com.xuexiang.xpage.annotation.Page;
-import com.king.view.circleprogressview.CircleProgressView;
-
-import com.xuexiang.xui.widget.textview.supertextview.SuperButton;
-
-
-import java.util.List;
-
-import butterknife.BindView;
-
-import static com.kerwin.wumei.utils.SettingUtils.getWifiPassword;
-import static com.kerwin.wumei.utils.SettingUtils.setWifiPassword;
-
-
-@Page(name = "智能配网")
-public class AddDeviceFragment extends BaseFragment {
- @BindView(R.id.advance_frame_layout)
- FrameLayout advanceFrameLayout;
- @BindView(R.id.advance_linear_layout)
- LinearLayout advanceLinearLayout;
- @BindView(R.id.advance_icon)
- 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;
- @BindView(R.id.chk_remeber)
- CheckBox chk_remeber;
- @BindView(R.id.circleProgressView)
- CircleProgressView circleProgressView;
-
- 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
- *
- * @return
- */
- @Override
- protected int getLayoutId() {
- return R.layout.fragment_add_device;
- }
-
- /**
- * 初始化控件
- */
- @Override
- protected void initViews() {
- //智能配网
- mViewModel = ((AddDeviceActivity)this.getActivity()).GetMViewModel();
-
- mViewModel.apPasswordEdit = findViewById(R.id.wifi_password_txt);
- mViewModel.apPasswordEdit.setText(getWifiPassword());
-
- mViewModel.ssidSpinner = findViewById(R.id.ssid_spinner);
- mViewModel.packageModeGroup = findViewById(R.id.packageModeGroup);
- 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();
-
- //存储wifi密码
- if(chk_remeber.isChecked()){
- setWifiPassword(mViewModel.apPasswordEdit.getText().toString());
- }else{
- setWifiPassword("");
- }
-
-// 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) {
- String[] permissions = {Manifest.permission.ACCESS_FINE_LOCATION,Manifest.permission.ACCESS_COARSE_LOCATION};
- requestPermissions(permissions, REQUEST_PERMISSION);
- }
-
- MyApp.getInstance().observeBroadcast(this, broadcast -> {
- Log.d(TAG, "onCreate: Broadcast=" + broadcast);
- ((AddDeviceActivity)this.getActivity()).onWifiChanged();
-
- List ssids=((AddDeviceActivity)this.getActivity()).GetSsids();
- if(ssids!=null && ssids.size()>0){
- Log.e(TAG, "进入数据绑定 " );
- mViewModel.ssidSpinner.setItems(ssids);
- // ssidSpinner.setOnItemSelectedListener((spinner, position, id, item) -> SnackbarUtils.Long(spinner, "Clicked " + item).show());
- // ssidSpinner.setOnNothingSelectedListener(spinner -> SnackbarUtils.Long(spinner, "Nothing selected").show());
- String ssid=((AddDeviceActivity)this.getActivity()).GetSelectedSSID();
- if(ssid!=null && ssid.length()>0 && ssids.contains(ssid)) {
- mViewModel.ssidSpinner.setSelectedItem(ssid);
- }
- }
- });
-
- }
-
- @Override
- protected void initListeners() {
- //单击高级设置项
- advanceFrameLayout.setOnClickListener(new View.OnClickListener(){
- @Override
- public void onClick(View view) {
- int visible=advanceLinearLayout.getVisibility();
- if(visible!=0) {
- advanceLinearLayout.setVisibility(View.VISIBLE);
- advanceIcon.setImageDrawable(getResources().getDrawable((R.drawable.up)));
- }else{
- advanceLinearLayout.setVisibility(View.GONE);
- advanceIcon.setImageDrawable(getResources().getDrawable((R.drawable.down)));
- }
- }
- });
-
- //显示和隐藏密码
- wifiPasswordIcon.setOnClickListener(new View.OnClickListener(){
- @Override
- public void onClick(View view){
- if(wifiPasswordIcon.getTag()==null) return;
- if(wifiPasswordIcon.getTag().toString().equals("show")){
- wifiPasswordIcon.setImageDrawable(getResources().getDrawable((R.drawable.hide)));
- wifiPasswordIcon.setTag("hide");
- mViewModel.apPasswordEdit.setTransformationMethod(PasswordTransformationMethod.getInstance());
- }else{
- wifiPasswordIcon.setImageDrawable(getResources().getDrawable((R.drawable.show)));
- wifiPasswordIcon.setTag("show");
- mViewModel.apPasswordEdit.setTransformationMethod(HideReturnsTransformationMethod.getInstance());
- }
- }
- });
-
- btnConfigCancle.setOnClickListener(new View.OnClickListener(){
- @Override
- public void onClick(View view){
- ((AddDeviceActivity)getActivity()).interruptEspTouchTask();
- cancleCounter();
- }
- });
-
- btnReturn.setOnClickListener(new View.OnClickListener(){
- @Override
- public void onClick(View view){
- popToBack();
- cancleCounter();
- }
- });
-
- }
-
- @Override
- public void onDestroyView() {
- cancleCounter();
- super.onDestroyView();
- }
-
- /**
- * 打开计时器
- */
- public void beginCounter(){
- mViewModel.confirmBtn.setEnabled(false);
- btnConfigCancle.setEnabled(true);
- showMessage("配网中...",true);
- mHander.post(mCounter);
-
- //显示进度动画,进度,动画时长
- circleProgressView.showAnimation(100,3000);
- //设置进度改变监听
- circleProgressView.setOnChangeListener(new CircleProgressView.OnChangeListener() {
- @Override
- public void onProgressChanged(float progress, float max) {
- if(progress==100){
- circleProgressView.setProgress(0);
- circleProgressView.showAnimation(100);
-
- }
- }
- });
- }
-
- /**
- * 计时器完成
- */
- public void completeCounter(){
- mCount=0;
- mHander.removeCallbacks(mCounter);
- progressTextMain.setText("100");
- circleProgressView.setOnChangeListener(null);
- circleProgressView.showAppendAnimation(100);
- }
-
- /**
- * 关闭计时器
- */
- public void cancleCounter(){
- mViewModel.confirmBtn.setEnabled(true);
- btnConfigCancle.setEnabled(false);
- showMessage("",true);
-
- mCount=0;
- mHander.removeCallbacks(mCounter);
- progressTextMain.setText("0");
- circleProgressView.setOnChangeListener(null);
- circleProgressView.showAppendAnimation(0);
- }
-
- /**
- * 计时器
- */
- 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
deleted file mode 100644
index 3193bb90..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/AddDeviceTwoFragment.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/***************************************************************************
- * 作者: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.os.Bundle;
-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 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.kerwin.wumei.utils.XToastUtils;
-import com.xuexiang.xpage.annotation.Page;
-import com.xuexiang.xui.widget.spinner.materialspinner.MaterialSpinner;
-
-import java.util.List;
-
-import butterknife.BindView;
-
-
-@Page(name = "设备信息")
-public class AddDeviceTwoFragment extends BaseFragment {
-
-
- /**
- * 布局的资源id
- * @return
- */
- @Override
- protected int getLayoutId() {
- return R.layout.fragment_add_device_two;
- }
-
- /**
- * 初始化控件
- */
- @Override
- protected void initViews() {
-
- Bundle arguments = getArguments();
- String mac = arguments.getString("device_mac");
- XToastUtils.toast("设备MAC:" + mac);
-
-
- }
-
- @Override
- protected void initListeners() {
-
-
-
-
- }
-
-}
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
deleted file mode 100644
index 90acf3b0..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceDetailFragment.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/******************************************************************************
- * 作者: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
deleted file mode 100644
index dd8e67c5..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceEditFragment.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/******************************************************************************
- * 作者: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.xui.widget.toast.XToast;
-import com.xuexiang.xutil.net.JsonUtil;
-
-import java.util.List;
-
-import butterknife.BindView;
-import butterknife.OnClick;
-
-import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
-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;
- @BindView(R.id.sp_upgrade)
- SuperButton sp_upgrade;
-
- 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,R.id.sp_upgrade})
- 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;
- case R.id.sp_upgrade:
- XToastUtils.success("固件已经是最新版本");
- 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(getServerPath()+"/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(getServerPath()+"/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(getServerPath()+"/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()==null || device.getFirmwareVersion().length()==0? "1.0" : device.getFirmwareVersion()));
- txt_create_time.setText(device.getCreateTime());
- sp_device_temperature.setText(device.getDeviceTemp()==null?0+"℃":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(getServerPath()+"/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
deleted file mode 100644
index 40756a7f..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceFragment.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/****************************************************************************
- * 作者: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 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.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.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 static com.google.android.material.tabs.TabLayout.MODE_SCROLLABLE;
-import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
-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)
- ViewPager2 viewPager;
-
- private boolean mIsShowNavigationView;
- private FragmentStateViewPager2Adapter mAdapter;
-
- /**
- * @return 返回为 null意为不需要导航栏
- */
- @Override
- protected TitleBar initTitle() {
-// mAdapter.addFragment(2, SimpleTabFragment.newInstance("动态加入"), "动态加入");
-// mAdapter.removeFragment(2);
-// mAdapter.notifyDataSetChanged();
- return null;
- }
-
- /**
- * 布局的资源id
- *
- * @return
- */
- @Override
- protected int getLayoutId() {
- return R.layout.fragment_device;
- }
-
- /**
- * 初始化控件
- */
- @Override
- protected void initViews() {
- //获取分组列表
- getGroupList(this);
- }
-
-
- @Override
- public void onTabSelected(TabLayout.Tab tab) {
-
- }
-
- @Override
- public void onTabUnselected(TabLayout.Tab tab) {
-
- }
-
- @Override
- 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(getServerPath()+"/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(getServerPath()+"/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(getServerPath()+"/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(getServerPath()+"/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(getServerPath()+"/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(getServerPath()+"/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
deleted file mode 100644
index 11fc3fa3..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceSetFragment.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/***************************************************************************
- * 作者: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.SettingUtils.getServerPath;
-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(getServerPath()+"/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
deleted file mode 100644
index 0462349d..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/DeviceStatusFragment.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*****************************************************************************
- * 作者: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.SettingUtils.getServerPath;
-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(getServerPath()+"/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(getServerPath()+"/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/EditDeviceFragment.java b/android/app/src/main/java/com/kerwin/wumei/fragment/device/EditDeviceFragment.java
deleted file mode 100644
index a05602ba..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/EditDeviceFragment.java
+++ /dev/null
@@ -1,27 +0,0 @@
-package com.kerwin.wumei.fragment.device;
-
-import com.kerwin.wumei.R;
-import com.kerwin.wumei.core.BaseFragment;
-import com.xuexiang.xpage.annotation.Page;
-
-@Page(name = "分享设备")
-public class EditDeviceFragment extends BaseFragment {
-
- /**
- * 布局的资源id
- *
- * @return
- */
- @Override
- protected int getLayoutId() {
- return R.layout.fragment_edit_device;
- }
-
- /**
- * 初始化控件
- */
- @Override
- protected void initViews() {
-
- }
-}
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
deleted file mode 100644
index 3ad33696..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/FragmentStateViewPager2Adapter.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*****************************************************************************
- * 作者: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;
-import androidx.fragment.app.Fragment;
-import androidx.viewpager2.adapter.FragmentStateAdapter;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * @author xuexiang
- * @since 2020/5/21 1:27 AM
- */
-public class FragmentStateViewPager2Adapter extends FragmentStateAdapter {
-
- private List mFragmentList = new ArrayList<>();
-
- private List mTitleList = new ArrayList<>();
-
- private List mIds = new ArrayList<>();
-
- private AtomicLong mAtomicLong = new AtomicLong(0);
-
- public FragmentStateViewPager2Adapter(@NonNull Fragment fragment) {
- super(fragment);
- }
-
- @NonNull
- @Override
- public Fragment createFragment(int position) {
- return mFragmentList.get(position);
- }
-
- public FragmentStateViewPager2Adapter addFragment(Fragment fragment, String title) {
- if (fragment != null) {
- mFragmentList.add(fragment);
- mTitleList.add(title);
- mIds.add(getAtomicGeneratedId());
- }
- return this;
- }
-
- public FragmentStateViewPager2Adapter addFragment(int index, Fragment fragment, String title) {
- if (fragment != null && index >= 0 && index <= mFragmentList.size()) {
- mFragmentList.add(index, fragment);
- mTitleList.add(index, title);
- mIds.add(index, getAtomicGeneratedId());
- }
- return this;
- }
-
- public FragmentStateViewPager2Adapter removeFragment(int index) {
- if (index >= 0 && index < mFragmentList.size()) {
- mFragmentList.remove(index);
- mTitleList.remove(index);
- mIds.remove(index);
- }
- return this;
- }
-
- private long getAtomicGeneratedId() {
- return mAtomicLong.incrementAndGet();
- }
-
- @Override
- public int getItemCount() {
- return mFragmentList.size();
- }
-
- public void clear() {
- mFragmentList.clear();
- mTitleList.clear();
- mIds.clear();
- notifyDataSetChanged();
- }
-
- public CharSequence getPageTitle(int position) {
- return mTitleList.get(position);
- }
-
- @Override
- public long getItemId(int position) {
- return mIds.get(position);
- }
-
- @Override
- public boolean containsItem(long itemId) {
- return mIds.contains(itemId);
- }
-}
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
deleted file mode 100644
index d4e9c9f2..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/GroupFragment.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/******************************************************************************
- * 作者: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;
-import com.kerwin.wumei.core.BaseFragment;
-import com.xuexiang.xpage.annotation.Page;
-
-@Page(name = "分组管理")
-public class GroupFragment extends BaseFragment {
-
- /**
- * 布局的资源id
- *
- * @return
- */
- @Override
- protected int getLayoutId() {
- return R.layout.fragment_group;
- }
-
- /**
- * 初始化控件
- */
- @Override
- protected void initViews() {
-
- }
-}
diff --git a/android/app/src/main/java/com/kerwin/wumei/fragment/device/MultiPage.java b/android/app/src/main/java/com/kerwin/wumei/fragment/device/MultiPage.java
deleted file mode 100644
index c59f1e15..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/MultiPage.java
+++ /dev/null
@@ -1,44 +0,0 @@
-package com.kerwin.wumei.fragment.device;/*
-
-
-/**
- * @author xuexiang
- * @since 2018/12/26 下午11:49
- */
-public enum MultiPage {
-
- 全部(0),
- 浇灌(1),
- 一楼(2),
- 二楼(3),
- 三楼(4),
- 走廊(5);
-
- private final int position;
-
- MultiPage(int pos) {
- position = pos;
- }
-
- public static MultiPage getPage(int position) {
- return MultiPage.values()[position];
- }
-
- public static int size() {
- return MultiPage.values().length;
- }
-
- public static String[] getPageNames() {
- MultiPage[] pages = MultiPage.values();
- String[] pageNames = new String[pages.length];
- for (int i = 0; i < pages.length; i++) {
- pageNames[i] = pages[i].name();
- }
- return pageNames;
- }
-
- public int getPosition() {
- return position;
- }
-
-}
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
deleted file mode 100644
index 1bdbe8d1..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/SceneFragment.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/******************************************************************************
- * 作者: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.graphics.Color;
-import android.util.Log;
-import android.view.View;
-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.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.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.getServerAddress;
-import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
-import static com.kerwin.wumei.utils.SettingUtils.setAccount;
-import static com.kerwin.wumei.utils.SettingUtils.setApIp;
-import static com.kerwin.wumei.utils.SettingUtils.setServeAddress;
-import static com.kerwin.wumei.utils.SettingUtils.setServePath;
-import static com.kerwin.wumei.utils.TokenUtils.clearToken;
-
-
-@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_address;
- @BindView(R.id.et_path)
- MaterialEditText et_serve_path;
- @BindView(R.id.et_ap_address)
- MaterialEditText et_ap_address;
-
- /**
- * @return 返回为 null意为不需要导航栏
- */
- @Override
- protected TitleBar initTitle() {
- return null;
- }
-
- /**
- * 布局的资源id
- *
- * @return
- */
- @Override
- protected int getLayoutId() {
- return R.layout.fragment_scene;
- }
-
- /**
- * 初始化控件
- */
- @Override
- protected void initViews() {
- et_serve_address.setText(getServerAddress());
- et_serve_path.setText(getServerPath());
- 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_serve_address.getEditValue().length()==0)
- {
- showMessage("接口地址不能为空",false);
- return;
- }
-
- switch (view.getId()) {
- case R.id.btn_save_serve:
- setServeAddress(et_serve_address.getEditValue());
- setServePath(et_serve_path.getEditValue());
- clearToken();
- setAccount("","");
- 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;
- }
- }
-
-
-
- /**
- * HTTP获取验证码(用于连接测试)
- */
- private void getCatpureImage(){
- String address=et_serve_address.getEditValue();
- String path=et_serve_path.getEditValue();
- if(path==null || path.length()==0){
- Log.d("地址", address.substring(address.length()-1));
- if(address.substring(address.length()-1).equals("/")){
- address=address.substring(0,address.length()-1);
- }
- }
- String fullPath=address+path;
- XHttp.get(fullPath+ "/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"+"地址:"+et_serve_address.getEditValue()+et_serve_path.getEditValue()+"\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
deleted file mode 100644
index 553a25e6..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/ShareDeviceFragment.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/******************************************************************************
- * 作者: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;
-import com.kerwin.wumei.core.BaseFragment;
-import com.xuexiang.xpage.annotation.Page;
-import com.xuexiang.xpage.enums.CoreAnim;
-import com.xuexiang.xui.widget.actionbar.TitleBar;
-
-@Page(name = "分享设备")
-public class ShareDeviceFragment extends BaseFragment {
-
- /**
- * 布局的资源id
- *
- * @return
- */
- @Override
- protected int getLayoutId() {
- return R.layout.fragment_share_device;
- }
-
- /**
- * 初始化控件
- */
- @Override
- protected void initViews() {
-
- }
-}
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
deleted file mode 100644
index fb3f28af..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/device/SimpleTabFragment.java
+++ /dev/null
@@ -1,386 +0,0 @@
-/******************************************************************************
- * 作者: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.Color;
-import android.os.Vibrator;
-import android.util.Log;
-import android.widget.FrameLayout;
-
-import androidx.annotation.NonNull;
-import androidx.appcompat.widget.AppCompatImageView;
-import androidx.cardview.widget.CardView;
-import androidx.fragment.app.FragmentActivity;
-import androidx.recyclerview.widget.RecyclerView;
-
-import com.alibaba.android.vlayout.DelegateAdapter;
-import com.alibaba.android.vlayout.VirtualLayoutManager;
-import com.alibaba.android.vlayout.layout.StaggeredGridLayoutHelper;
-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.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.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.widget.actionbar.TitleBar;
-import com.xuexiang.xui.widget.button.SwitchIconView;
-import com.xuexiang.xutil.net.JsonUtil;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import butterknife.BindView;
-import me.samlss.broccoli.Broccoli;
-
-import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
-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 SimpleTabFragment extends BaseFragment {
- private static final String TAG = "SimpleTabFragment";
-
-
- @BindView(R.id.recyclerView)
- RecyclerView recyclerView;
- @BindView(R.id.refreshLayout)
- SmartRefreshLayout refreshLayout;
-
- private SimpleDelegateAdapter deviceAdapter;
- private List devices=new ArrayList() {};
- private int pageNum=1;
- private int pageSize=10;
- private Long groupId=0L;
-
-
- public static SimpleTabFragment newInstance(Long groupId) {
- SimpleTabFragment fragment = new SimpleTabFragment();
- 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:" + groupId);
- }
-
- @Override
- public void onDetach() {
- super.onDetach();
- Log.e(TAG, "onDetach:" + groupId);
- }
-
- @Override
- public void onResume() {
- super.onResume();
- Log.e(TAG, "onResume:" + groupId);
- }
-
- @Override
- public void onStop() {
- super.onStop();
- Log.e(TAG, "onStop:" + groupId);
- }
-
-
- private void initView() {
-
- VirtualLayoutManager virtualLayoutManager = new VirtualLayoutManager(getContext());
- recyclerView.setLayoutManager(virtualLayoutManager);
- RecyclerView.RecycledViewPool viewPool = new RecyclerView.RecycledViewPool();
- recyclerView.setRecycledViewPool(viewPool);
- viewPool.setMaxRecycledViews(0, 10);
-
- // 设备
- FragmentActivity activity=this.getActivity();
- 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, IotDeviceVo device, int position) {
- if (device == null) {return;}
-
- //设置item宽度,适配屏幕分辨率
-// CardView view=holder.findViewById(R.id.device_item_card_view);
-// int widthPixels = getScreenWidth(activity);
-// int space=dip2px(40); //间隙=左边距+右边距+中间间隔
-// 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()==null? 0+"℃":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);
- SwitchIconView lightIconView=holder.findViewById(R.id.device_item_light_button);
- radarView.setIconEnabled(device.getIsRadar()!=null && device.getIsRadar()==1 && device.getIsOnline()==1?true:false);
- alarmView.setIconEnabled(device.getIsAlarm()!=null && device.getIsAlarm()==1 && device.getIsOnline()==1?true:false);
- switchIconView.setIconEnabled(device.getRelayStatus()!=null && device.getRelayStatus()==1 && device.getIsOnline()==1?true:false);
- lightIconView.setIconEnabled(device.getLightStatus()!=null && device.getLightStatus()==1 && device.getIsOnline()==1?true:false);
-
- //显示网络信号: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.getIsOnline()!=null && device.getRssi()!=null) {
- if (device.getIsOnline() == 1 && device.getRssi() >= -55) {
- wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_4)));
- } else if (device.getIsOnline() == 1 && device.getRssi() >= 70) {
- wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_3)));
- } else if (device.getIsOnline() == 1 && device.getRssi() >= -85) {
- wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_2)));
- } else if (device.getIsOnline() == 1 && device.getRssi() >= -100) {
- wifiView.setImageDrawable(getResources().getDrawable((R.drawable.wifi_1)));
- }
- }
-
- //其他文字、标题和图片
- FrameLayout flTitle=holder.findViewById(R.id.device_item_fl_title);
- if(device.getIsOnline()!=null && device.getIsOnline()==1){
- holder.text(R.id.device_item_wifi, "在线");
- flTitle.setBackgroundColor(Color.argb(255, 63, 208, 173));
- }else{
- holder.text(R.id.device_item_wifi, "离线");
- flTitle.setBackgroundColor(Color.argb(255, 220, 220, 220));
- //显示图标
- AppCompatImageView categoryIcon=holder.findViewById(R.id.device_item_category_icon);
- AppCompatImageView temp=holder.findViewById(R.id.device_item_temp_icon);
- categoryIcon.setColorFilter(Color.parseColor("#909399"));
- temp.setColorFilter(Color.parseColor("#909399"));
- }
-
- holder.click(R.id.device_item_light_button, v -> {
- if(device.getIsOnline()==null || device.getIsOnline()==0) return;
- //震动
- Vibrator vibrator = (Vibrator) activity.getSystemService(activity.VIBRATOR_SERVICE);
- vibrator.vibrate(100);
- // 更新灯状态
- updateDeviceStatus(
- buildDeviceLightStatus(device.getDeviceId(), device.getDeviceNum(),lightIconView.isIconEnabled()==true?0:1)
- , lightIconView);
- });
- holder.click(R.id.device_item_switch_button, v -> {
- if(device.getIsOnline()==null || device.getIsOnline()==0) return;
- //震动
- Vibrator vibrator = (Vibrator) activity.getSystemService(activity.VIBRATOR_SERVICE);
- vibrator.vibrate(100);
- // 更新继电器状态
- updateDeviceStatus(
- buildDeviceRelayStatus(device.getDeviceId(),device.getDeviceNum(),switchIconView.isIconEnabled()==true?0:1)
- , switchIconView);
- });
- 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); //打开页面进行跳转
-
- });
-
- }
-
- @Override
- protected void onBindBroccoli(RecyclerViewHolder holder, Broccoli broccoli) {
- 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(deviceAdapter);
- recyclerView.setAdapter(delegateAdapter);
-
- //下拉刷新
- refreshLayout.setOnRefreshListener(refreshLayout -> {
- refreshLayout.getLayout().postDelayed(() -> {
- pageNum=1;
- getDeviceList();
- }, 1000);
- });
- //上拉加载
- refreshLayout.setOnLoadMoreListener(refreshLayout -> {
- refreshLayout.getLayout().postDelayed(() -> {
- pageNum=pageNum+1;
- getDeviceList();
- }, 1000);
- });
-// 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,SwitchIconView iconView){
- if(!hasToken()) return;
- XHttp.put(getServerPath()+"/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);
- iconView.switchState(true);
- 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(getServerPath()+"/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(getServerPath()+"/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());
- }
- }
- }){});
- }
-
-
-}
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
deleted file mode 100644
index f3d625a3..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/news/HomePageFragment.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/******************************************************************************
- * 作者: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
deleted file mode 100644
index 03ef3381..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/news/NewsFragment.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/******************************************************************************
- * 作者: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;
-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.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.scwang.smartrefresh.layout.SmartRefreshLayout;
-import com.kerwin.wumei.R;
-import com.kerwin.wumei.utils.DemoDataProvider;
-import com.kerwin.wumei.utils.Utils;
-import com.kerwin.wumei.utils.XToastUtils;
-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 NewsFragment extends BaseFragment {
-
- @BindView(R.id.recyclerView)
- RecyclerView recyclerView;
- @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_news;
- }
-
- /**
- * 初始化控件
- */
- @Override
- protected void initViews() {
- VirtualLayoutManager virtualLayoutManager = new VirtualLayoutManager(getContext());
- recyclerView.setLayoutManager(virtualLayoutManager);
- RecyclerView.RecycledViewPool viewPool = new RecyclerView.RecycledViewPool();
- recyclerView.setRecycledViewPool(viewPool);
- viewPool.setMaxRecycledViews(0, 10);
-
- //轮播条
- SingleDelegateAdapter bannerAdapter = new SingleDelegateAdapter(R.layout.include_head_view_banner) {
- @Override
- public void onBindViewHolder(@NonNull RecyclerViewHolder holder, int position) {
- SimpleImageBanner banner = holder.findViewById(R.id.sib_simple_usage);
- banner.setSource(DemoDataProvider.getBannerList())
- .setOnItemClickListener((view, item, position1) -> XToastUtils.toast("headBanner position--->" + position1)).startScroll();
- }
- };
-
- //九宫格菜单
- GridLayoutHelper gridLayoutHelper = new GridLayoutHelper(4);
- gridLayoutHelper.setPadding(0, 16, 0, 0);
- gridLayoutHelper.setVGap(10);
- gridLayoutHelper.setHGap(0);
- SimpleDelegateAdapter commonAdapter = new SimpleDelegateAdapter(R.layout.adapter_common_grid_item, gridLayoutHelper, DemoDataProvider.getGridItems(getContext())) {
- @Override
- protected void bindData(@NonNull RecyclerViewHolder holder, int position, AdapterItem item) {
- if (item != null) {
- RadiusImageView imageView = holder.findViewById(R.id.riv_item);
- imageView.setCircle(true);
- ImageLoader.get().loadImage(imageView, item.getIcon());
- holder.text(R.id.device_item_title, item.getTitle().toString().substring(0, 1));
- holder.text(R.id.tv_sub_title, item.getTitle());
-
- holder.click(R.id.ll_container, v -> XToastUtils.toast("点击了:" + item.getTitle()));
- }
- }
- };
-
- //动态的标题
- SingleDelegateAdapter titleAdapter = new SingleDelegateAdapter(R.layout.adapter_title_item) {
- @Override
- public void onBindViewHolder(@NonNull RecyclerViewHolder holder, int position) {
- holder.text(R.id.device_item_title, "动态");
- holder.text(R.id.tv_action, "更多");
- holder.click(R.id.tv_action, v -> XToastUtils.toast("更多"));
- }
- };
-
- // 动态
- mNewsAdapter = new BroccoliSimpleDelegateAdapter(R.layout.adapter_news_card_view_list_item, new LinearLayoutHelper(), DemoDataProvider.getEmptyNewInfo()) {
- @Override
- protected void onBindData(RecyclerViewHolder holder, NewInfo model, int position) {
- if (model != null) {
- holder.text(R.id.tv_user_name, model.getUserName());
- holder.text(R.id.tv_tag, model.getTag());
- holder.text(R.id.device_item_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.tv_user_name),
- holder.findView(R.id.tv_tag),
- holder.findView(R.id.device_item_title),
- holder.findView(R.id.tv_summary),
- holder.findView(R.id.tv_praise),
- holder.findView(R.id.tv_comment),
- holder.findView(R.id.tv_read),
- holder.findView(R.id.iv_image)
- );
- }
- };
-
- DelegateAdapter delegateAdapter = new DelegateAdapter(virtualLayoutManager);
- delegateAdapter.addAdapter(bannerAdapter);
- delegateAdapter.addAdapter(commonAdapter);
- delegateAdapter.addAdapter(titleAdapter);
- delegateAdapter.addAdapter(mNewsAdapter);
-
- recyclerView.setAdapter(delegateAdapter);
- }
-
- @Override
- protected void initListeners() {
- //下拉刷新
- refreshLayout.setOnRefreshListener(refreshLayout -> {
- // TODO: 2020-02-25 这里只是模拟了网络请求
- refreshLayout.getLayout().postDelayed(() -> {
- mNewsAdapter.refresh(DemoDataProvider.getDemoNewInfos());
- refreshLayout.finishRefresh();
- }, 1000);
- });
- //上拉加载
- refreshLayout.setOnLoadMoreListener(refreshLayout -> {
- // TODO: 2020-02-25 这里只是模拟了网络请求
- refreshLayout.getLayout().postDelayed(() -> {
- mNewsAdapter.loadMore(DemoDataProvider.getDemoNewInfos());
- refreshLayout.finishLoadMore();
- }, 1000);
- });
- refreshLayout.autoRefresh();//第一次进入触发自动刷新,演示效果
- }
-}
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
deleted file mode 100644
index f7e16baa..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/profile/AccountFragment.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/******************************************************************************
- * 作者: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.getServerPath;
-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(getServerPath()+"/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
deleted file mode 100644
index c0ffee92..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/fragment/profile/ProfileFragment.java
+++ /dev/null
@@ -1,150 +0,0 @@
-/******************************************************************************
- * 作者: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;
-
-import static com.kerwin.wumei.utils.SettingUtils.getServerPath;
-
-@Page(anim = CoreAnim.none)
-public class ProfileFragment extends BaseFragment implements SuperTextView.OnSuperTextViewClickListener {
- @BindView(R.id.riv_head_pic)
- RadiusImageView rivHeadPic;
- @BindView(R.id.menu_message)
- SuperTextView menuMessage;
- @BindView(R.id.menu_logout)
- SuperTextView menuLogout;
- @BindView(R.id.control_list)
- XUIGroupListView mControlGroupListView;
- @BindView(R.id.tv_copyright)
- TextView mCopyrightTextView;
- @BindView(R.id.menu_account)
- SuperTextView menuAccount;
-
- /**
- * @return 返回为 null意为不需要导航栏
- */
- @Override
- protected TitleBar initTitle() {
- return null;
- }
-
- /**
- * 布局的资源id
- *
- * @return
- */
- @Override
- protected int getLayoutId() {
- return R.layout.fragment_profile;
- }
-
- /**
- * 初始化控件
- */
- @Override
- protected void initViews() {
- XUIGroupListView.newSection(getContext())
- .addItemView(mControlGroupListView.createItemView(getResources().getString(R.string.about_item_add_qq_group)), v -> AgentWebActivity.goWeb(getContext(), getString(R.string.url_add_qq_group)))
- .addItemView(mControlGroupListView.createItemView("应用版本 - V" + AppUtils.getAppVersionName()), v -> XToastUtils.toast("官网下载最新版本"))
- .addTo(mControlGroupListView);
- 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() {
- menuMessage.setOnSuperTextViewClickListener(this);
- menuLogout.setOnSuperTextViewClickListener(this);
- menuAccount.setOnSuperTextViewClickListener(this);
- }
-
- /**
- * HTTP退出登录
- */
- private void logout(){
- XHttp.post(getServerPath()+"/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_message:
- openNewPage(MessageFragment.class);
- break;
- 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
deleted file mode 100644
index 285b9827..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/http/callback/NoTipRequestCallBack.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 5620f1a0..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/http/callback/TipRequestCallBack.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 178a4035..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/http/interceptor/CustomLoggingInterceptor.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 5390c95e..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/http/request/CaptchaImageApiResult.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/******************************************************************************
- * 作者: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
deleted file mode 100644
index e05a3f3b..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/http/request/CustomApiResult.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
- * 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
deleted file mode 100644
index b915a3a7..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/http/request/CustomGetRequest.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * 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
deleted file mode 100644
index 07f47016..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/http/request/ListApiResult.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/******************************************************************************
- * 作者: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
deleted file mode 100644
index ebf9cc91..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/http/request/NoDataApiResult.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/******************************************************************************
- * 作者: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
deleted file mode 100644
index 102fd3a2..00000000
--- a/android/app/src/main/java/com/kerwin/wumei/http/request/TokenApiResult.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/******************************************************************************
- * 作者: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