Compare commits
29 Commits
133045fadd
...
dev
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d8e9f60f25 | ||
|
|
c7556a42ab | ||
|
|
548419cf29 | ||
|
|
dff152e7e7 | ||
|
|
0c692c77bd | ||
|
|
22f197a929 | ||
|
|
b25e3540fb | ||
|
|
ec59249b3b | ||
|
|
192ca7d3a4 | ||
|
|
69830dfc69 | ||
|
|
a9ed6f9452 | ||
|
|
5dae94788c | ||
|
|
a31443fa4c | ||
|
|
3f0260a37a | ||
|
|
ed9c825bc7 | ||
|
|
79e51ad044 | ||
|
|
1cfc6f9d73 | ||
|
|
fa44e0edbd | ||
|
|
d8d546c90a | ||
|
|
01e4f0aefa | ||
|
|
5a72fd98af | ||
|
|
21d834d805 | ||
|
|
d2610d5b61 | ||
|
|
b5e9f0de3b | ||
|
|
f53408654b | ||
|
|
fbef699b50 | ||
|
|
73d5003655 | ||
|
|
5e920037f5 | ||
|
|
a4f9d630df |
4
.idea/deploymentTargetSelector.xml
generated
4
.idea/deploymentTargetSelector.xml
generated
@@ -4,10 +4,10 @@
|
|||||||
<selectionStates>
|
<selectionStates>
|
||||||
<SelectionState runConfigName="app">
|
<SelectionState runConfigName="app">
|
||||||
<option name="selectionMode" value="DROPDOWN" />
|
<option name="selectionMode" value="DROPDOWN" />
|
||||||
<DropdownSelection timestamp="2026-06-10T01:13:16.309557300Z">
|
<DropdownSelection timestamp="2026-07-14T09:31:19.203364400Z">
|
||||||
<Target type="DEFAULT_BOOT">
|
<Target type="DEFAULT_BOOT">
|
||||||
<handle>
|
<handle>
|
||||||
<DeviceId pluginId="PhysicalDevice" identifier="serial=D122222104A9" />
|
<DeviceId pluginId="Default" identifier="serial=emulator-5554;connection=53435af5" />
|
||||||
</handle>
|
</handle>
|
||||||
</Target>
|
</Target>
|
||||||
</DropdownSelection>
|
</DropdownSelection>
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ android {
|
|||||||
minSdkVersion 26
|
minSdkVersion 26
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0.1"//version 1.0.0-appstore version 1.0.0-xh
|
versionName "Version 1.0.1"//version 1.0.0-appstore version 1.0.0-xh
|
||||||
// 添加自定义字段
|
// 添加自定义字段
|
||||||
buildConfigField "String", "APP_VERSION_NAME", "\"${versionName}\""
|
buildConfigField "String", "APP_VERSION_NAME", "\"${versionName}\""
|
||||||
buildConfigField "int", "APP_VERSION_CODE", "${versionCode}"
|
buildConfigField "int", "APP_VERSION_CODE", "${versionCode}"
|
||||||
|
|||||||
Binary file not shown.
@@ -126,7 +126,7 @@
|
|||||||
android:name="com.ckkj.water.login.LoginActivity"
|
android:name="com.ckkj.water.login.LoginActivity"
|
||||||
android:theme="@style/AppTheme.FullScreen"
|
android:theme="@style/AppTheme.FullScreen"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:windowSoftInputMode="adjustResize"/>
|
android:windowSoftInputMode="adjustPan"/>
|
||||||
<activity
|
<activity
|
||||||
android:name="com.ckkj.water.mine.WebviewUserAgreement"
|
android:name="com.ckkj.water.mine.WebviewUserAgreement"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
@@ -171,10 +171,6 @@
|
|||||||
android:name="com.ckkj.water.device.AddDeviceActivity"
|
android:name="com.ckkj.water.device.AddDeviceActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
android:windowSoftInputMode="adjustResize"/>
|
android:windowSoftInputMode="adjustResize"/>
|
||||||
<activity
|
|
||||||
android:name="com.ckkj.water.device.AddDeviceActivity_copy"
|
|
||||||
android:screenOrientation="portrait"
|
|
||||||
android:windowSoftInputMode="adjustResize"/>
|
|
||||||
<activity
|
<activity
|
||||||
android:name="com.ckkj.water.device.SelectWifiActivity"
|
android:name="com.ckkj.water.device.SelectWifiActivity"
|
||||||
android:screenOrientation="portrait"
|
android:screenOrientation="portrait"
|
||||||
|
|||||||
@@ -15,13 +15,14 @@ public class AppConfig {
|
|||||||
|
|
||||||
|
|
||||||
/**************************测试*******************************/
|
/**************************测试*******************************/
|
||||||
// public static String BASE_URL = "http://47.106.83.229:8081/";//测试http://47.106.83.166:8001/
|
// public static String BASE_URL = "http://47.106.83.229:8081/";//测试http://47.106.83.166:8001/ .
|
||||||
// public static String BASE_URL_TWO = BASE_URL;//测试
|
// public static String BASE_URL_TWO = BASE_URL;//测试
|
||||||
// public static String BASE_URL_THREE = BASE_URL;//测试
|
// public static String BASE_URL_THREE = BASE_URL;//测试
|
||||||
// public static boolean IS_TEST_REQUEST = true;
|
// public static boolean IS_TEST_REQUEST = true;
|
||||||
|
|
||||||
/**************************本地*******************************/
|
/**************************本地*******************************/
|
||||||
public static String BASE_URL = "http://192.168.1.217:8081/";//测试
|
public static String BASE_URL = "http://192.168.1.217:8082/";//后端本地测试
|
||||||
|
// public static String BASE_URL = "http://47.97.217.123:8081/";//服务器测试
|
||||||
public static String BASE_URL_TWO = BASE_URL;//测试
|
public static String BASE_URL_TWO = BASE_URL;//测试
|
||||||
public static String BASE_URL_THREE = BASE_URL;//测试
|
public static String BASE_URL_THREE = BASE_URL;//测试
|
||||||
public static boolean IS_TEST_REQUEST = true;
|
public static boolean IS_TEST_REQUEST = true;
|
||||||
@@ -113,9 +114,9 @@ public class AppConfig {
|
|||||||
//测试使用 token
|
//测试使用 token
|
||||||
public static String TEST_USER_ID = "1897194667309666304";
|
public static String TEST_USER_ID = "1897194667309666304";
|
||||||
//用户协议
|
//用户协议
|
||||||
public static String USER_AGREEMENT = "https://sta.mingdengbazi.site/yhxy.html";
|
public static String USER_AGREEMENT = "http://47.97.217.123/user-agreement";
|
||||||
//隐私政策
|
//隐私政策
|
||||||
public static String USER_PRIVACY = "https://sta.mingdengbazi.site/ysxy.html";
|
public static String USER_PRIVACY = "http://47.97.217.123/privacy";
|
||||||
//用户分享链接
|
//用户分享链接
|
||||||
public static String USER_SHARE_URL = "https://sta.mingdengbazi.site/on/index.html?code=";
|
public static String USER_SHARE_URL = "https://sta.mingdengbazi.site/on/index.html?code=";
|
||||||
|
|
||||||
|
|||||||
@@ -41,6 +41,7 @@ public class ConstantUtil {
|
|||||||
public static final int ACCESS_FINE_LOCATION = 1;
|
public static final int ACCESS_FINE_LOCATION = 1;
|
||||||
//授权读取文件
|
//授权读取文件
|
||||||
public static final int WRITE_FILE_PERMISSON_CPDE = 1001;
|
public static final int WRITE_FILE_PERMISSON_CPDE = 1001;
|
||||||
|
public static final int POST_NOTIFICATIONS_PERMISSION_CODE = 1002;
|
||||||
//读取文件
|
//读取文件
|
||||||
public static final int READ_EXTERNAL_STORAGE = 2;
|
public static final int READ_EXTERNAL_STORAGE = 2;
|
||||||
//相机权限
|
//相机权限
|
||||||
|
|||||||
@@ -11,9 +11,8 @@ import android.util.Log;
|
|||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.ckkj.water.login.entity.LoginEntity;
|
|
||||||
import com.ckkj.water.network.NetWorkManager;
|
import com.ckkj.water.network.NetWorkManager;
|
||||||
import com.ckkj.water.utils.dataUtil.SharePreUtil;
|
import com.ckkj.water.utils.dataUtil.SharePreUtil;
|
||||||
import com.ckkj.water.utils.manager.LanguageManager;
|
import com.ckkj.water.utils.manager.LanguageManager;
|
||||||
@@ -157,11 +156,11 @@ public class MyApplication extends Application {
|
|||||||
public void onActivityDestroyed(Activity activity) {}
|
public void onActivityDestroyed(Activity activity) {}
|
||||||
});
|
});
|
||||||
|
|
||||||
AutoSizeConfig.getInstance()
|
// AutoSizeConfig.getInstance()
|
||||||
// 是否使用设备真实尺寸
|
// // 是否使用设备真实尺寸
|
||||||
.setUseDeviceSize(true)
|
// .setUseDeviceSize(true)
|
||||||
// 是否支持 fragment
|
// // 是否支持 fragment
|
||||||
.setCustomFragment(true);
|
// .setCustomFragment(true);
|
||||||
android.util.Log.e("TEST", "hello");
|
android.util.Log.e("TEST", "hello");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -547,10 +547,9 @@ public abstract class BaseActivity<T extends ViewBinding, P extends IPresenter>
|
|||||||
editText.requestFocus();
|
editText.requestFocus();
|
||||||
//设置输入类型
|
//设置输入类型
|
||||||
setEditInputType(editText,inputType);
|
setEditInputType(editText,inputType);
|
||||||
|
editText.setHint(hint);
|
||||||
|
|
||||||
if(TextUtils.isEmpty(content)){
|
if(!TextUtils.isEmpty(content)){
|
||||||
editText.setHint(hint);
|
|
||||||
}else{
|
|
||||||
editText.setText(content);
|
editText.setText(content);
|
||||||
}
|
}
|
||||||
if (!TextUtils.isEmpty(content)) {
|
if (!TextUtils.isEmpty(content)) {
|
||||||
@@ -1202,6 +1201,7 @@ public abstract class BaseActivity<T extends ViewBinding, P extends IPresenter>
|
|||||||
editText.setInputType(
|
editText.setInputType(
|
||||||
InputType.TYPE_CLASS_NUMBER
|
InputType.TYPE_CLASS_NUMBER
|
||||||
);
|
);
|
||||||
|
editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(4)});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case INPUT_TYPE_LETTER:
|
case INPUT_TYPE_LETTER:
|
||||||
@@ -1252,6 +1252,10 @@ public abstract class BaseActivity<T extends ViewBinding, P extends IPresenter>
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case INPUT_TYPE_NORMAL:
|
||||||
|
editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(20)});
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
editText.setInputType(
|
editText.setInputType(
|
||||||
InputType.TYPE_CLASS_TEXT
|
InputType.TYPE_CLASS_TEXT
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.view.Window;
|
import android.view.Window;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.widget.EditText;
|
import android.widget.EditText;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@@ -949,10 +950,9 @@ public abstract class BaseFragment<T extends ViewBinding,P extends IPresenter> e
|
|||||||
|
|
||||||
//设置输入类型
|
//设置输入类型
|
||||||
setEditInputType(editText,inputType);
|
setEditInputType(editText,inputType);
|
||||||
|
editText.setHint(hint);
|
||||||
|
|
||||||
if(TextUtils.isEmpty(content)){
|
if(!TextUtils.isEmpty(content)){
|
||||||
editText.setHint(hint);
|
|
||||||
}else{
|
|
||||||
editText.setText(content);
|
editText.setText(content);
|
||||||
editText.setSelection(content.length());
|
editText.setSelection(content.length());
|
||||||
}
|
}
|
||||||
@@ -1016,6 +1016,16 @@ public abstract class BaseFragment<T extends ViewBinding,P extends IPresenter> e
|
|||||||
|
|
||||||
dialog = builder.show();
|
dialog = builder.show();
|
||||||
|
|
||||||
|
editText.requestFocus();
|
||||||
|
editText.postDelayed(() -> {
|
||||||
|
if (editText != null) {
|
||||||
|
InputMethodManager imm = (InputMethodManager) mContext.getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||||
|
if (imm != null) {
|
||||||
|
imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 200);
|
||||||
|
|
||||||
dialog.setCanceledOnTouchOutside(
|
dialog.setCanceledOnTouchOutside(
|
||||||
touchOutsideCancel
|
touchOutsideCancel
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -30,12 +30,21 @@ public class CustomTypeFilterPopupView extends PartShadowPopupView implements Vi
|
|||||||
private boolean mSelManual = false;
|
private boolean mSelManual = false;
|
||||||
//是否选择了自动排程
|
//是否选择了自动排程
|
||||||
private boolean mSelAuto = false;
|
private boolean mSelAuto = false;
|
||||||
|
private int mFilterType = -1;
|
||||||
|
|
||||||
public CustomTypeFilterPopupView(@NonNull Context context, OnClickListener listener) {
|
public CustomTypeFilterPopupView(@NonNull Context context, OnClickListener listener) {
|
||||||
super(context);
|
super(context);
|
||||||
this.mContext = context;
|
this.mContext = context;
|
||||||
this.listener = listener;
|
this.listener = listener;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public CustomTypeFilterPopupView(@NonNull Context context, OnClickListener listener, int filterType) {
|
||||||
|
super(context);
|
||||||
|
this.mContext = context;
|
||||||
|
this.listener = listener;
|
||||||
|
this.mFilterType = filterType;
|
||||||
|
}
|
||||||
|
|
||||||
public interface OnClickListener{
|
public interface OnClickListener{
|
||||||
void callBack(boolean mSelManual,boolean mSelAuto);
|
void callBack(boolean mSelManual,boolean mSelAuto);
|
||||||
}
|
}
|
||||||
@@ -59,7 +68,18 @@ public class CustomTypeFilterPopupView extends PartShadowPopupView implements Vi
|
|||||||
tvAuto.setOnClickListener(this);
|
tvAuto.setOnClickListener(this);
|
||||||
tvReset.setOnClickListener(this);
|
tvReset.setOnClickListener(this);
|
||||||
tvFinish.setOnClickListener(this);
|
tvFinish.setOnClickListener(this);
|
||||||
tvManual.setSelected(false);
|
// 根据filterType设置初始选中状态
|
||||||
|
if (mFilterType == 0) {
|
||||||
|
// 排程
|
||||||
|
mSelAuto = true;
|
||||||
|
tvAuto.setTextColor(mContext.getColor(R.color.white));
|
||||||
|
tvAuto.setSelected(true);
|
||||||
|
} else if (mFilterType == 1) {
|
||||||
|
// 手动
|
||||||
|
mSelManual = true;
|
||||||
|
tvManual.setTextColor(mContext.getColor(R.color.white));
|
||||||
|
tvManual.setSelected(true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -110,10 +130,6 @@ public class CustomTypeFilterPopupView extends PartShadowPopupView implements Vi
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.tv_finish:
|
case R.id.tv_finish:
|
||||||
if(!mSelManual && !mSelAuto){
|
|
||||||
ToastUtil.showShort(mContext,mContext.getString(R.string.history_filter_type_toast));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(listener != null){
|
if(listener != null){
|
||||||
listener.callBack(mSelManual,mSelAuto);
|
listener.callBack(mSelManual,mSelAuto);
|
||||||
this.dismiss();
|
this.dismiss();
|
||||||
|
|||||||
@@ -1,21 +1,36 @@
|
|||||||
package com.ckkj.water.device;
|
package com.ckkj.water.device;
|
||||||
|
|
||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
|
import static android.view.View.VISIBLE;
|
||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
|
import android.bluetooth.BluetoothAdapter;
|
||||||
|
import android.bluetooth.BluetoothDevice;
|
||||||
|
import android.bluetooth.BluetoothManager;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.graphics.drawable.AnimationDrawable;
|
import android.graphics.drawable.AnimationDrawable;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.ParcelUuid;
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.util.SparseArray;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
import androidx.appcompat.app.AlertDialog;
|
||||||
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
import com.chad.library.adapter.base.BaseQuickAdapter;
|
||||||
import com.ckkj.water.ConstantUtil;
|
import com.ckkj.water.ConstantUtil;
|
||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
import com.ckkj.water.base.BaseActivity;
|
import com.ckkj.water.base.BaseActivity;
|
||||||
|
import com.ckkj.water.custom.GridSpacingItemDecoration;
|
||||||
import com.ckkj.water.databinding.AddDeviceLayoutBinding;
|
import com.ckkj.water.databinding.AddDeviceLayoutBinding;
|
||||||
|
import com.ckkj.water.device.adapter.BleScanDeviceAdapter;
|
||||||
import com.ckkj.water.device.mvp.DeviceContract;
|
import com.ckkj.water.device.mvp.DeviceContract;
|
||||||
import com.ckkj.water.device.mvp.DeviceImpl;
|
import com.ckkj.water.device.mvp.DeviceImpl;
|
||||||
import com.ckkj.water.device.mvp.DevicePresenter;
|
import com.ckkj.water.device.mvp.DevicePresenter;
|
||||||
@@ -23,6 +38,7 @@ import com.ckkj.water.index.entity.WaterDeviceEntity;
|
|||||||
import com.ckkj.water.network.BaseBean;
|
import com.ckkj.water.network.BaseBean;
|
||||||
import com.ckkj.water.utils.manager.ActivityManager;
|
import com.ckkj.water.utils.manager.ActivityManager;
|
||||||
import com.ckkj.water.utils.manager.ThemeManager;
|
import com.ckkj.water.utils.manager.ThemeManager;
|
||||||
|
import com.ckkj.water.utils.manager.WaterDeviceManager;
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
import com.ckkj.water.utils.show.ToastUtil;
|
||||||
import com.gyf.immersionbar.ImmersionBar;
|
import com.gyf.immersionbar.ImmersionBar;
|
||||||
import com.maning.mlkitscanner.scan.MNScanManager;
|
import com.maning.mlkitscanner.scan.MNScanManager;
|
||||||
@@ -31,8 +47,17 @@ import com.maning.mlkitscanner.scan.callback.act.MNScanCallback;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
import no.nordicsemi.android.support.v18.scanner.BluetoothLeScannerCompat;
|
||||||
|
import no.nordicsemi.android.support.v18.scanner.ScanCallback;
|
||||||
|
import no.nordicsemi.android.support.v18.scanner.ScanFilter;
|
||||||
|
import no.nordicsemi.android.support.v18.scanner.ScanRecord;
|
||||||
|
import no.nordicsemi.android.support.v18.scanner.ScanResult;
|
||||||
|
import no.nordicsemi.android.support.v18.scanner.ScanSettings;
|
||||||
import pub.devrel.easypermissions.EasyPermissions;
|
import pub.devrel.easypermissions.EasyPermissions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -40,6 +65,21 @@ import pub.devrel.easypermissions.EasyPermissions;
|
|||||||
*/
|
*/
|
||||||
public class AddDeviceActivity extends BaseActivity<AddDeviceLayoutBinding, DevicePresenter>
|
public class AddDeviceActivity extends BaseActivity<AddDeviceLayoutBinding, DevicePresenter>
|
||||||
implements DeviceContract.DeviceView, EasyPermissions.PermissionCallbacks {
|
implements DeviceContract.DeviceView, EasyPermissions.PermissionCallbacks {
|
||||||
|
|
||||||
|
// 蓝牙相关
|
||||||
|
private BluetoothAdapter bluetoothAdapter;
|
||||||
|
private static final int REQUEST_ENABLE_BT = 1001;
|
||||||
|
private static final int REQUEST_BLUETOOTH_PERMISSION = 1002;
|
||||||
|
private List<BluetoothDevice> discoveredDevices = new ArrayList<>();
|
||||||
|
private AlertDialog deviceListDialog;
|
||||||
|
private String mUuid = "1775244d-6b43-439b-877c-060f2d9bed07";
|
||||||
|
private ScanCallback mScanCallback;
|
||||||
|
private boolean bluetoothReady = false;
|
||||||
|
private BleScanDeviceAdapter bleAdapter;
|
||||||
|
private List<WaterDeviceEntity> mDeviceList = new ArrayList<>();
|
||||||
|
private Set<String> discoveredMacSet = new HashSet<>();
|
||||||
|
private WaterDeviceManager waterDeviceManager;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DevicePresenter createPresenter() {
|
public DevicePresenter createPresenter() {
|
||||||
return new DevicePresenter(new DeviceImpl());
|
return new DevicePresenter(new DeviceImpl());
|
||||||
@@ -49,6 +89,7 @@ public class AddDeviceActivity extends BaseActivity<AddDeviceLayoutBinding, Devi
|
|||||||
@Override
|
@Override
|
||||||
public void initData(Bundle savedInstanceState) {
|
public void initData(Bundle savedInstanceState) {
|
||||||
super.initData(savedInstanceState);
|
super.initData(savedInstanceState);
|
||||||
|
|
||||||
ActivityManager.addActivity(this,getClass().getSimpleName() + "_" + ConstantUtil.ADD_DEVICE_FLAG);
|
ActivityManager.addActivity(this,getClass().getSimpleName() + "_" + ConstantUtil.ADD_DEVICE_FLAG);
|
||||||
ImmersionBar.with(this)
|
ImmersionBar.with(this)
|
||||||
.statusBarColor(R.color.mainBackgroundColor) // 设置状态栏颜色
|
.statusBarColor(R.color.mainBackgroundColor) // 设置状态栏颜色
|
||||||
@@ -56,35 +97,199 @@ public class AddDeviceActivity extends BaseActivity<AddDeviceLayoutBinding, Devi
|
|||||||
.titleBar(viewBinding.rlTitle)
|
.titleBar(viewBinding.rlTitle)
|
||||||
.init();
|
.init();
|
||||||
viewBinding.includedTitle.tvTitle.setText(R.string.add_device_title);
|
viewBinding.includedTitle.tvTitle.setText(R.string.add_device_title);
|
||||||
|
viewBinding.rvDevices.addItemDecoration(new GridSpacingItemDecoration(4, 10, true));
|
||||||
|
bleAdapter = new BleScanDeviceAdapter(mContext,R.layout.scan_ble_device_item,mDeviceList);
|
||||||
|
viewBinding.rvDevices.setAdapter(bleAdapter);
|
||||||
|
|
||||||
|
if(checkBluetoothPermissions()){
|
||||||
|
// 初始化蓝牙适配器
|
||||||
|
initBluetooth();
|
||||||
|
if (bluetoothReady) {
|
||||||
|
startBleScan();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// 启动帧动画
|
// 启动帧动画
|
||||||
ImageView ivScanAnimation = viewBinding.ivScanAnimation;
|
ImageView ivScanAnimation = viewBinding.ivScanAnimation;
|
||||||
if (ivScanAnimation.getDrawable() instanceof AnimationDrawable) {
|
if (ivScanAnimation.getDrawable() instanceof AnimationDrawable) {
|
||||||
AnimationDrawable animationDrawable = (AnimationDrawable) ivScanAnimation.getDrawable();
|
AnimationDrawable animationDrawable = (AnimationDrawable) ivScanAnimation.getDrawable();
|
||||||
animationDrawable.start();
|
animationDrawable.start();
|
||||||
}
|
}
|
||||||
new Handler().postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
// 停止帧动画
|
|
||||||
ImageView ivScanAnimation = viewBinding.ivScanAnimation;
|
|
||||||
if (ivScanAnimation.getDrawable() instanceof AnimationDrawable) {
|
|
||||||
AnimationDrawable animationDrawable = (AnimationDrawable) ivScanAnimation.getDrawable();
|
|
||||||
if (animationDrawable.isRunning()) {
|
|
||||||
animationDrawable.stop();
|
|
||||||
viewBinding.ivScanAnimation.setVisibility(GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},3000);
|
|
||||||
initListener();
|
initListener();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化监听g111
|
||||||
|
*/
|
||||||
private void initListener() {
|
private void initListener() {
|
||||||
setClick(viewBinding.includedTitle.imgBack);
|
setClick(viewBinding.includedTitle.imgBack);
|
||||||
setClick(viewBinding.tvScanAdd);
|
setClick(viewBinding.tvScanAdd);
|
||||||
|
setClick(viewBinding.btnBleScan);
|
||||||
|
|
||||||
|
if(bleAdapter != null){
|
||||||
|
bleAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
||||||
|
WaterDeviceEntity device = mDeviceList.get(position);
|
||||||
|
String deviceName = TextUtils.isEmpty(device.getDeviceName()) ?
|
||||||
|
"未知设备" : device.getDeviceName();
|
||||||
|
// 停止扫描
|
||||||
|
stopBleScan();
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putInt(ConstantUtil.ACTIVITY_NAVIGATE_FLAG,100);
|
||||||
|
bundle.putSerializable("ble_device_entity",mDeviceList.get(position));
|
||||||
|
goTo(mContext, SelectWifiActivity.class,bundle);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 开始 BLE 扫描
|
||||||
|
*/
|
||||||
|
private void startBleScan() {
|
||||||
|
BluetoothLeScannerCompat scanner = BluetoothLeScannerCompat.getScanner();
|
||||||
|
UUID SERVICE_UUID = UUID.fromString(mUuid);//1775244d-6b43-439b-877c-060f2d9bed07
|
||||||
|
ParcelUuid parcelUuid = new ParcelUuid(SERVICE_UUID);
|
||||||
|
ScanSettings settings = new ScanSettings.Builder()
|
||||||
|
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
|
||||||
|
.setReportDelay(0)
|
||||||
|
.build();
|
||||||
|
List<ScanFilter> filters = new ArrayList<>();
|
||||||
|
filters.add(new ScanFilter.Builder().setServiceUuid(parcelUuid).build());
|
||||||
|
// filters.add(new ScanFilter.Builder().setDeviceName("PROV_Water_01").build());
|
||||||
|
Log.e("TEST", "开始扫描");
|
||||||
|
mScanCallback = new ScanCallback() {
|
||||||
|
@Override
|
||||||
|
public void onScanResult(int callbackType, @NonNull ScanResult result) {
|
||||||
|
super.onScanResult(callbackType, result);
|
||||||
|
//Mac地址
|
||||||
|
String deviceAddress = result.getDevice().getAddress();
|
||||||
|
|
||||||
|
// 去重:已存在的设备不再添加
|
||||||
|
if (discoveredMacSet.contains(deviceAddress)) {//dc:da:0c:fa:2b:3a
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
discoveredMacSet.add(deviceAddress);
|
||||||
|
|
||||||
|
WaterDeviceEntity bean = new WaterDeviceEntity();
|
||||||
|
ScanRecord record = result.getScanRecord();
|
||||||
|
|
||||||
|
SparseArray<byte[]> manufacturerData = record.getManufacturerSpecificData();
|
||||||
|
|
||||||
|
//设备名字
|
||||||
|
String deviceName = result.getScanRecord() != null ?
|
||||||
|
result.getScanRecord().getDeviceName() : "无名称";
|
||||||
|
bean.setDeviceName(deviceName);
|
||||||
|
bean.setMacAddress(deviceAddress);
|
||||||
|
mDeviceList.add(bean);
|
||||||
|
bleAdapter.notifyItemInserted(mDeviceList.size() - 1);
|
||||||
|
if(bleAdapter.getItemCount() != 0){
|
||||||
|
viewBinding.rvDevices.setVisibility(VISIBLE);
|
||||||
|
// 停止帧动画
|
||||||
|
ImageView ivScanAnimation = viewBinding.ivScanAnimation;
|
||||||
|
if (ivScanAnimation.getDrawable() instanceof AnimationDrawable) {
|
||||||
|
AnimationDrawable animationDrawable = (AnimationDrawable) ivScanAnimation.getDrawable();
|
||||||
|
if (animationDrawable.isRunning()) {
|
||||||
|
animationDrawable.stop();
|
||||||
|
}
|
||||||
|
viewBinding.ivScanAnimation.setVisibility(GONE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onBatchScanResults(@NonNull List<ScanResult> results) {
|
||||||
|
super.onBatchScanResults(results);
|
||||||
|
Log.e("TEST", "批量结果: " + results.size() + " 个设备");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onScanFailed(int errorCode) {
|
||||||
|
super.onScanFailed(errorCode);
|
||||||
|
Log.e("TEST", "扫描失败: " + errorCode);
|
||||||
|
ToastUtil.showShort(mContext, "扫描失败,错误码: " + errorCode);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
scanner.startScan(filters, settings, mScanCallback);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 停止 BLE 扫描
|
||||||
|
*/
|
||||||
|
private void stopBleScan() {
|
||||||
|
if (mScanCallback != null) {
|
||||||
|
BluetoothLeScannerCompat scanner = BluetoothLeScannerCompat.getScanner();
|
||||||
|
scanner.stopScan(mScanCallback);
|
||||||
|
Log.e("TEST", "停止扫描");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化蓝牙适配器
|
||||||
|
*/
|
||||||
|
private void initBluetooth() {
|
||||||
|
BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
|
||||||
|
if (bluetoothManager != null) {
|
||||||
|
bluetoothAdapter = bluetoothManager.getAdapter();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bluetoothAdapter == null) {
|
||||||
|
ToastUtil.showShort(mContext, "设备不支持蓝牙");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// 检查蓝牙是否开启
|
||||||
|
if (!bluetoothAdapter.isEnabled()) {
|
||||||
|
Log.e("TEST", "initBluetooth: 蓝牙未开启,请求开启");
|
||||||
|
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
|
||||||
|
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
|
||||||
|
} else {
|
||||||
|
bluetoothReady = true;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查蓝牙权限
|
||||||
|
*/
|
||||||
|
private boolean checkBluetoothPermissions() {
|
||||||
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
||||||
|
|
||||||
|
String[] readPermission = new String[]{
|
||||||
|
Manifest.permission.BLUETOOTH_SCAN,
|
||||||
|
Manifest.permission.BLUETOOTH_CONNECT,
|
||||||
|
Manifest.permission.ACCESS_FINE_LOCATION
|
||||||
|
};
|
||||||
|
if (!hasRecordPermission(readPermission)) {
|
||||||
|
// 没有权限,只在ACTION_DOWN时去申请
|
||||||
|
getMorePermissionRequst(readPermission,"蓝牙扫描权限申请",
|
||||||
|
"智能浇水需要您的授权,获取蓝牙权限添加设备",REQUEST_EVENT_CODE_10003);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Android 12 以下需要位置权限才能扫描蓝牙
|
||||||
|
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
|
||||||
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
|
|
||||||
|
requestPermissions(new String[]{
|
||||||
|
Manifest.permission.ACCESS_FINE_LOCATION
|
||||||
|
}, REQUEST_BLUETOOTH_PERMISSION);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void setClick(View view) {
|
private void setClick(View view) {
|
||||||
view.setOnClickListener(this::onClick);
|
view.setOnClickListener(this::onClick);
|
||||||
}
|
}
|
||||||
@@ -95,12 +300,6 @@ public class AddDeviceActivity extends BaseActivity<AddDeviceLayoutBinding, Devi
|
|||||||
finish();
|
finish();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.img_device_item:
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putInt(ConstantUtil.ACTIVITY_NAVIGATE_FLAG,100);
|
|
||||||
goTo(mContext, SelectWifiActivity.class,bundle);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.tv_scan_add:
|
case R.id.tv_scan_add:
|
||||||
//检测有无相机权限
|
//检测有无相机权限
|
||||||
String readPermission = Manifest.permission.CAMERA;
|
String readPermission = Manifest.permission.CAMERA;
|
||||||
@@ -111,6 +310,48 @@ public class AddDeviceActivity extends BaseActivity<AddDeviceLayoutBinding, Devi
|
|||||||
scanQrcode();
|
scanQrcode();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case R.id.btn_ble_scan:
|
||||||
|
// 扫描蓝牙设备
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
||||||
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
|
if (requestCode == REQUEST_ENABLE_BT) {
|
||||||
|
if (resultCode == RESULT_OK) {
|
||||||
|
ToastUtil.showShort(mContext, "蓝牙已开启");
|
||||||
|
Log.e("BluetoothScan", "onActivityResult: 蓝牙已开启,开始扫描");
|
||||||
|
bluetoothReady = true;
|
||||||
|
startBleScan();
|
||||||
|
} else {
|
||||||
|
ToastUtil.showShort(mContext, "请开启蓝牙以扫描设备");
|
||||||
|
Log.e("BluetoothScan", "onActivityResult: 用户拒绝开启蓝牙");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, @NonNull @NotNull String[] permissions, @NonNull @NotNull int[] grantResults) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
|
||||||
|
hidePermissionDialog();
|
||||||
|
if (requestCode == REQUEST_BLUETOOTH_PERMISSION) {
|
||||||
|
boolean allGranted = true;
|
||||||
|
for (int result : grantResults) {
|
||||||
|
if (result != PackageManager.PERMISSION_GRANTED) {
|
||||||
|
allGranted = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (allGranted) {
|
||||||
|
// 初始化蓝牙适配器
|
||||||
|
initBluetooth();
|
||||||
|
} else {
|
||||||
|
ToastUtil.showShort(mContext, "需要蓝牙权限才能扫描设备");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -167,17 +408,13 @@ public class AddDeviceActivity extends BaseActivity<AddDeviceLayoutBinding, Devi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull @NotNull String[] permissions, @NonNull @NotNull int[] grantResults) {
|
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
||||||
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
|
public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
|
||||||
hidePermissionDialog();
|
hidePermissionDialog();
|
||||||
if (requestCode == REQUEST_EVENT_CODE_10001) {
|
if (requestCode == REQUEST_EVENT_CODE_10001) {
|
||||||
scanQrcode();
|
scanQrcode();
|
||||||
|
}else if(requestCode == REQUEST_EVENT_CODE_10002){
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -215,4 +452,22 @@ public class AddDeviceActivity extends BaseActivity<AddDeviceLayoutBinding, Devi
|
|||||||
public void queryDeviceBindStatusSuccess(WaterDeviceEntity bean) {
|
public void queryDeviceBindStatusSuccess(WaterDeviceEntity bean) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void queryDeviceWorkTimeSuccess(WaterDeviceEntity bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
super.onDestroy();
|
||||||
|
// 停止扫描
|
||||||
|
stopBleScan();
|
||||||
|
// 断开蓝牙连接
|
||||||
|
if (waterDeviceManager != null) {
|
||||||
|
waterDeviceManager.disconnect().enqueue();
|
||||||
|
waterDeviceManager.close();
|
||||||
|
waterDeviceManager = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,468 +0,0 @@
|
|||||||
package com.ckkj.water.device;
|
|
||||||
|
|
||||||
import static android.view.View.GONE;
|
|
||||||
import static android.view.View.VISIBLE;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.bluetooth.BluetoothAdapter;
|
|
||||||
import android.bluetooth.BluetoothDevice;
|
|
||||||
import android.bluetooth.BluetoothManager;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.graphics.drawable.AnimationDrawable;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.ParcelUuid;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.util.SparseArray;
|
|
||||||
import android.view.View;
|
|
||||||
import android.widget.ImageView;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.appcompat.app.AlertDialog;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
|
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
||||||
import com.ckkj.water.ConstantUtil;
|
|
||||||
import com.ckkj.water.R;
|
|
||||||
import com.ckkj.water.base.BaseActivity;
|
|
||||||
import com.ckkj.water.custom.GridSpacingItemDecoration;
|
|
||||||
import com.ckkj.water.databinding.AddDeviceLayoutBinding;
|
|
||||||
import com.ckkj.water.device.adapter.BleScanDeviceAdapter;
|
|
||||||
import com.ckkj.water.device.mvp.DeviceContract;
|
|
||||||
import com.ckkj.water.device.mvp.DeviceImpl;
|
|
||||||
import com.ckkj.water.device.mvp.DevicePresenter;
|
|
||||||
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
|
||||||
import com.ckkj.water.network.BaseBean;
|
|
||||||
import com.ckkj.water.utils.manager.ActivityManager;
|
|
||||||
import com.ckkj.water.utils.manager.ThemeManager;
|
|
||||||
import com.ckkj.water.utils.manager.WaterDeviceManager;
|
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
|
||||||
import com.gyf.immersionbar.ImmersionBar;
|
|
||||||
import com.maning.mlkitscanner.scan.MNScanManager;
|
|
||||||
import com.maning.mlkitscanner.scan.callback.act.MNScanCallback;
|
|
||||||
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.UUID;
|
|
||||||
|
|
||||||
import no.nordicsemi.android.support.v18.scanner.BluetoothLeScannerCompat;
|
|
||||||
import no.nordicsemi.android.support.v18.scanner.ScanCallback;
|
|
||||||
import no.nordicsemi.android.support.v18.scanner.ScanFilter;
|
|
||||||
import no.nordicsemi.android.support.v18.scanner.ScanRecord;
|
|
||||||
import no.nordicsemi.android.support.v18.scanner.ScanResult;
|
|
||||||
import no.nordicsemi.android.support.v18.scanner.ScanSettings;
|
|
||||||
import pub.devrel.easypermissions.EasyPermissions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 添加设备页面
|
|
||||||
*/
|
|
||||||
public class AddDeviceActivity_copy extends BaseActivity<AddDeviceLayoutBinding, DevicePresenter>
|
|
||||||
implements DeviceContract.DeviceView, EasyPermissions.PermissionCallbacks {
|
|
||||||
|
|
||||||
// 蓝牙相关
|
|
||||||
private BluetoothAdapter bluetoothAdapter;
|
|
||||||
private static final int REQUEST_ENABLE_BT = 1001;
|
|
||||||
private static final int REQUEST_BLUETOOTH_PERMISSION = 1002;
|
|
||||||
private List<BluetoothDevice> discoveredDevices = new ArrayList<>();
|
|
||||||
private AlertDialog deviceListDialog;
|
|
||||||
private String mUuid = "1775244d-6b43-439b-877c-060f2d9bed07";
|
|
||||||
private ScanCallback mScanCallback;
|
|
||||||
private boolean bluetoothReady = false;
|
|
||||||
private BleScanDeviceAdapter bleAdapter;
|
|
||||||
private List<WaterDeviceEntity> mDeviceList = new ArrayList<>();
|
|
||||||
private Set<String> discoveredMacSet = new HashSet<>();
|
|
||||||
private WaterDeviceManager waterDeviceManager;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DevicePresenter createPresenter() {
|
|
||||||
return new DevicePresenter(new DeviceImpl());
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initData(Bundle savedInstanceState) {
|
|
||||||
super.initData(savedInstanceState);
|
|
||||||
|
|
||||||
ActivityManager.addActivity(this,getClass().getSimpleName() + "_" + ConstantUtil.ADD_DEVICE_FLAG);
|
|
||||||
ImmersionBar.with(this)
|
|
||||||
.statusBarColor(R.color.mainBackgroundColor) // 设置状态栏颜色
|
|
||||||
.statusBarDarkFont(ThemeManager.isAppThemeLight(mContext)) // 设置状态栏字体为黑色
|
|
||||||
.titleBar(viewBinding.rlTitle)
|
|
||||||
.init();
|
|
||||||
viewBinding.includedTitle.tvTitle.setText(R.string.add_device_title);
|
|
||||||
viewBinding.rvDevices.addItemDecoration(new GridSpacingItemDecoration(4, 10, true));
|
|
||||||
bleAdapter = new BleScanDeviceAdapter(mContext,R.layout.scan_ble_device_item,mDeviceList);
|
|
||||||
viewBinding.rvDevices.setAdapter(bleAdapter);
|
|
||||||
|
|
||||||
if(checkBluetoothPermissions()){
|
|
||||||
// 初始化蓝牙适配器
|
|
||||||
initBluetooth();
|
|
||||||
if (bluetoothReady) {
|
|
||||||
startBleScan();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 启动帧动画
|
|
||||||
ImageView ivScanAnimation = viewBinding.ivScanAnimation;
|
|
||||||
if (ivScanAnimation.getDrawable() instanceof AnimationDrawable) {
|
|
||||||
AnimationDrawable animationDrawable = (AnimationDrawable) ivScanAnimation.getDrawable();
|
|
||||||
animationDrawable.start();
|
|
||||||
}
|
|
||||||
initListener();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化监听g
|
|
||||||
*/
|
|
||||||
private void initListener() {
|
|
||||||
setClick(viewBinding.includedTitle.imgBack);
|
|
||||||
setClick(viewBinding.tvScanAdd);
|
|
||||||
setClick(viewBinding.btnBleScan);
|
|
||||||
|
|
||||||
if(bleAdapter != null){
|
|
||||||
bleAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
||||||
WaterDeviceEntity device = mDeviceList.get(position);
|
|
||||||
String deviceName = TextUtils.isEmpty(device.getDeviceName()) ?
|
|
||||||
"未知设备" : device.getDeviceName();
|
|
||||||
// 停止扫描
|
|
||||||
stopBleScan();
|
|
||||||
Bundle bundle = new Bundle();
|
|
||||||
bundle.putInt(ConstantUtil.ACTIVITY_NAVIGATE_FLAG,100);
|
|
||||||
bundle.putSerializable("ble_device_entity",mDeviceList.get(position));
|
|
||||||
goTo(mContext, SelectWifiActivity.class,bundle);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 开始 BLE 扫描
|
|
||||||
*/
|
|
||||||
private void startBleScan() {
|
|
||||||
BluetoothLeScannerCompat scanner = BluetoothLeScannerCompat.getScanner();
|
|
||||||
UUID SERVICE_UUID = UUID.fromString(mUuid);//1775244d-6b43-439b-877c-060f2d9bed07
|
|
||||||
ParcelUuid parcelUuid = new ParcelUuid(SERVICE_UUID);
|
|
||||||
ScanSettings settings = new ScanSettings.Builder()
|
|
||||||
.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
|
|
||||||
.setReportDelay(0)
|
|
||||||
.build();
|
|
||||||
List<ScanFilter> filters = new ArrayList<>();
|
|
||||||
filters.add(new ScanFilter.Builder().setServiceUuid(parcelUuid).build());
|
|
||||||
// filters.add(new ScanFilter.Builder().setDeviceName("PROV_Water_01").build());
|
|
||||||
Log.e("TEST", "开始扫描");
|
|
||||||
mScanCallback = new ScanCallback() {
|
|
||||||
@Override
|
|
||||||
public void onScanResult(int callbackType, @NonNull ScanResult result) {
|
|
||||||
super.onScanResult(callbackType, result);
|
|
||||||
//Mac地址
|
|
||||||
String deviceAddress = result.getDevice().getAddress();
|
|
||||||
|
|
||||||
// 去重:已存在的设备不再添加
|
|
||||||
if (discoveredMacSet.contains(deviceAddress)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
discoveredMacSet.add(deviceAddress);
|
|
||||||
|
|
||||||
WaterDeviceEntity bean = new WaterDeviceEntity();
|
|
||||||
ScanRecord record = result.getScanRecord();
|
|
||||||
|
|
||||||
SparseArray<byte[]> manufacturerData = record.getManufacturerSpecificData();
|
|
||||||
|
|
||||||
//设备名字
|
|
||||||
String deviceName = result.getScanRecord() != null ?
|
|
||||||
result.getScanRecord().getDeviceName() : "无名称";
|
|
||||||
bean.setDeviceName(deviceName);
|
|
||||||
bean.setMacAddress(deviceAddress);
|
|
||||||
mDeviceList.add(bean);
|
|
||||||
bleAdapter.notifyItemInserted(mDeviceList.size() - 1);
|
|
||||||
if(bleAdapter.getItemCount() != 0){
|
|
||||||
viewBinding.rvDevices.setVisibility(VISIBLE);
|
|
||||||
// 停止帧动画
|
|
||||||
ImageView ivScanAnimation = viewBinding.ivScanAnimation;
|
|
||||||
if (ivScanAnimation.getDrawable() instanceof AnimationDrawable) {
|
|
||||||
AnimationDrawable animationDrawable = (AnimationDrawable) ivScanAnimation.getDrawable();
|
|
||||||
if (animationDrawable.isRunning()) {
|
|
||||||
animationDrawable.stop();
|
|
||||||
}
|
|
||||||
viewBinding.ivScanAnimation.setVisibility(GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onBatchScanResults(@NonNull List<ScanResult> results) {
|
|
||||||
super.onBatchScanResults(results);
|
|
||||||
Log.e("TEST", "批量结果: " + results.size() + " 个设备");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onScanFailed(int errorCode) {
|
|
||||||
super.onScanFailed(errorCode);
|
|
||||||
Log.e("TEST", "扫描失败: " + errorCode);
|
|
||||||
ToastUtil.showShort(mContext, "扫描失败,错误码: " + errorCode);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
scanner.startScan(filters, settings, mScanCallback);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 停止 BLE 扫描
|
|
||||||
*/
|
|
||||||
private void stopBleScan() {
|
|
||||||
if (mScanCallback != null) {
|
|
||||||
BluetoothLeScannerCompat scanner = BluetoothLeScannerCompat.getScanner();
|
|
||||||
scanner.stopScan(mScanCallback);
|
|
||||||
Log.e("TEST", "停止扫描");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 初始化蓝牙适配器
|
|
||||||
*/
|
|
||||||
private void initBluetooth() {
|
|
||||||
BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
|
|
||||||
if (bluetoothManager != null) {
|
|
||||||
bluetoothAdapter = bluetoothManager.getAdapter();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bluetoothAdapter == null) {
|
|
||||||
ToastUtil.showShort(mContext, "设备不支持蓝牙");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 检查蓝牙是否开启
|
|
||||||
if (!bluetoothAdapter.isEnabled()) {
|
|
||||||
Log.e("TEST", "initBluetooth: 蓝牙未开启,请求开启");
|
|
||||||
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
|
|
||||||
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
|
|
||||||
} else {
|
|
||||||
bluetoothReady = true;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查蓝牙权限
|
|
||||||
*/
|
|
||||||
private boolean checkBluetoothPermissions() {
|
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
|
|
||||||
|
|
||||||
String[] readPermission = new String[]{
|
|
||||||
Manifest.permission.BLUETOOTH_SCAN,
|
|
||||||
Manifest.permission.BLUETOOTH_CONNECT,
|
|
||||||
Manifest.permission.ACCESS_FINE_LOCATION
|
|
||||||
};
|
|
||||||
if (!hasRecordPermission(readPermission)) {
|
|
||||||
// 没有权限,只在ACTION_DOWN时去申请
|
|
||||||
getMorePermissionRequst(readPermission,"蓝牙扫描权限申请",
|
|
||||||
"智能浇水需要您的授权,获取蓝牙权限添加设备",REQUEST_EVENT_CODE_10003);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// Android 12 以下需要位置权限才能扫描蓝牙
|
|
||||||
if (ContextCompat.checkSelfPermission(this, Manifest.permission.ACCESS_FINE_LOCATION)
|
|
||||||
!= PackageManager.PERMISSION_GRANTED) {
|
|
||||||
|
|
||||||
requestPermissions(new String[]{
|
|
||||||
Manifest.permission.ACCESS_FINE_LOCATION
|
|
||||||
}, REQUEST_BLUETOOTH_PERMISSION);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void setClick(View view) {
|
|
||||||
view.setOnClickListener(this::onClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onClick(View v){
|
|
||||||
switch (v.getId()){
|
|
||||||
case R.id.img_back:
|
|
||||||
finish();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.tv_scan_add:
|
|
||||||
//检测有无相机权限
|
|
||||||
String readPermission = Manifest.permission.CAMERA;
|
|
||||||
if(!hasRecordPermission(readPermission)){
|
|
||||||
getPermissionRequst(readPermission,"权限申请",
|
|
||||||
"智能浇水需要您的授权访问相机,并使用扫一扫",REQUEST_EVENT_CODE_10001);
|
|
||||||
}else{
|
|
||||||
scanQrcode();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.btn_ble_scan:
|
|
||||||
// 扫描蓝牙设备
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
if (requestCode == REQUEST_ENABLE_BT) {
|
|
||||||
if (resultCode == RESULT_OK) {
|
|
||||||
ToastUtil.showShort(mContext, "蓝牙已开启");
|
|
||||||
Log.e("BluetoothScan", "onActivityResult: 蓝牙已开启,开始扫描");
|
|
||||||
bluetoothReady = true;
|
|
||||||
startBleScan();
|
|
||||||
} else {
|
|
||||||
ToastUtil.showShort(mContext, "请开启蓝牙以扫描设备");
|
|
||||||
Log.e("BluetoothScan", "onActivityResult: 用户拒绝开启蓝牙");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull @NotNull String[] permissions, @NonNull @NotNull int[] grantResults) {
|
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
||||||
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
|
|
||||||
hidePermissionDialog();
|
|
||||||
if (requestCode == REQUEST_BLUETOOTH_PERMISSION) {
|
|
||||||
boolean allGranted = true;
|
|
||||||
for (int result : grantResults) {
|
|
||||||
if (result != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
allGranted = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (allGranted) {
|
|
||||||
// 初始化蓝牙适配器
|
|
||||||
initBluetooth();
|
|
||||||
} else {
|
|
||||||
ToastUtil.showShort(mContext, "需要蓝牙权限才能扫描设备");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void scanQrcode() {
|
|
||||||
//默认扫描
|
|
||||||
MNScanManager.startScan(mContext, new MNScanCallback() {
|
|
||||||
@Override
|
|
||||||
public void onActivityResult(int resultCode, Intent data) {
|
|
||||||
switch (resultCode) {
|
|
||||||
case MNScanManager.RESULT_SUCCESS:
|
|
||||||
ArrayList<String> results = data.getStringArrayListExtra(MNScanManager.INTENT_KEY_RESULT_SUCCESS);
|
|
||||||
if(results != null){
|
|
||||||
ToastUtil.showShort(mContext,results.get(0).toString());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case MNScanManager.RESULT_FAIL:
|
|
||||||
String resultError = data.getStringExtra(MNScanManager.INTENT_KEY_RESULT_ERROR);
|
|
||||||
break;
|
|
||||||
case MNScanManager.RESULT_CANCLE:
|
|
||||||
ToastUtil.showShort(mContext,"取消扫码");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
// 停止帧动画
|
|
||||||
ImageView ivScanAnimation = viewBinding.ivScanAnimation;
|
|
||||||
if (ivScanAnimation.getDrawable() instanceof AnimationDrawable) {
|
|
||||||
AnimationDrawable animationDrawable = (AnimationDrawable) ivScanAnimation.getDrawable();
|
|
||||||
if (animationDrawable.isRunning()) {
|
|
||||||
animationDrawable.stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLayoutResId(Bundle savedInstanceState) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showError(String message) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logOut(BaseBean bean) {
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
|
|
||||||
hidePermissionDialog();
|
|
||||||
if (requestCode == REQUEST_EVENT_CODE_10001) {
|
|
||||||
scanQrcode();
|
|
||||||
}else if(requestCode == REQUEST_EVENT_CODE_10002){
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addDeviceSuccess(WaterDeviceEntity bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getDeviceDetailInfo(WaterDeviceEntity bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void editDeviceInfoSuccess(BaseBean bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteDeviceSuccess(BaseBean bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void turnOnOffDeviceSuccess(BaseBean bean, String status) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void queryDeviceBindStatusSuccess(WaterDeviceEntity bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
// 停止扫描
|
|
||||||
stopBleScan();
|
|
||||||
// 断开蓝牙连接
|
|
||||||
if (waterDeviceManager != null) {
|
|
||||||
waterDeviceManager.disconnect().enqueue();
|
|
||||||
waterDeviceManager.close();
|
|
||||||
waterDeviceManager = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,6 +3,7 @@ package com.ckkj.water.device;
|
|||||||
import static android.view.View.GONE;
|
import static android.view.View.GONE;
|
||||||
import static android.view.View.VISIBLE;
|
import static android.view.View.VISIBLE;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
import android.graphics.drawable.AnimationDrawable;
|
import android.graphics.drawable.AnimationDrawable;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
@@ -33,6 +34,7 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
|||||||
private AnimationDrawable animationDrawable;
|
private AnimationDrawable animationDrawable;
|
||||||
private Handler handler = new Handler(Looper.getMainLooper());
|
private Handler handler = new Handler(Looper.getMainLooper());
|
||||||
private static final long ANIMATION_DURATION = 5000L; // 5秒
|
private static final long ANIMATION_DURATION = 5000L; // 5秒
|
||||||
|
private static final long PROVISION_TIMEOUT_MS = 60_000L;
|
||||||
|
|
||||||
private String mWifiName;
|
private String mWifiName;
|
||||||
private String mWifiPassword;
|
private String mWifiPassword;
|
||||||
@@ -41,6 +43,17 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
|||||||
private boolean isBleConnecting = false;
|
private boolean isBleConnecting = false;
|
||||||
private boolean isBleConnected = false;
|
private boolean isBleConnected = false;
|
||||||
private boolean provisioningStarted = false;
|
private boolean provisioningStarted = false;
|
||||||
|
private boolean provisionTimeoutHandled;
|
||||||
|
private final Runnable provisionTimeoutRunnable = () -> {
|
||||||
|
if (provisionTimeoutHandled || isFinishing()) return;
|
||||||
|
provisionTimeoutHandled = true;
|
||||||
|
if (espProvisionManager != null) {
|
||||||
|
espProvisionManager.setCallback(null);
|
||||||
|
espProvisionManager.disconnect();
|
||||||
|
}
|
||||||
|
ToastUtil.showShort(mContext, getString(R.string.device_provision_timeout));
|
||||||
|
finish();
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
protected void onCreate(Bundle savedInstanceState) {
|
||||||
@@ -100,6 +113,9 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
|||||||
|
|
||||||
|
|
||||||
private void initEspProvision() {
|
private void initEspProvision() {
|
||||||
|
provisionTimeoutHandled = false;
|
||||||
|
handler.removeCallbacks(provisionTimeoutRunnable);
|
||||||
|
handler.postDelayed(provisionTimeoutRunnable, PROVISION_TIMEOUT_MS);
|
||||||
espProvisionManager = EspProvisionManager.init(mContext).setCallback(new ProvisionCallback() {
|
espProvisionManager = EspProvisionManager.init(mContext).setCallback(new ProvisionCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void onConnecting() {
|
public void onConnecting() {
|
||||||
@@ -127,6 +143,7 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String deviceName, String deviceType) {
|
public void onSuccess(String deviceName, String deviceType) {
|
||||||
|
handler.removeCallbacks(provisionTimeoutRunnable);
|
||||||
Log.i("TEST", "DeviceConnectActivity===== deviceName:" + deviceName + "配网成功");
|
Log.i("TEST", "DeviceConnectActivity===== deviceName:" + deviceName + "配网成功");
|
||||||
ToastUtil.showShort(mContext, deviceName + "配网成功");
|
ToastUtil.showShort(mContext, deviceName + "配网成功");
|
||||||
handler.postDelayed(new Runnable() {
|
handler.postDelayed(new Runnable() {
|
||||||
@@ -144,13 +161,15 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailed(int errorCode, String message) {
|
public void onFailed(int errorCode, String message) {
|
||||||
|
handler.removeCallbacks(provisionTimeoutRunnable);
|
||||||
isBleConnecting = false;
|
isBleConnecting = false;
|
||||||
if (errorCode != 0) {
|
if (errorCode != 0) {
|
||||||
isBleConnected = espProvisionManager != null && espProvisionManager.isConnected();
|
isBleConnected = espProvisionManager != null && espProvisionManager.isConnected();
|
||||||
}
|
}
|
||||||
Log.i("TEST", "DeviceConnectActivity===== errorCode == " + errorCode + " message == " + message);
|
Log.i("TEST", "DeviceConnectActivity===== errorCode == " + errorCode + " message == " + message);
|
||||||
ToastUtil.showShort(mContext, message);
|
ToastUtil.showShort(mContext, message);
|
||||||
hideDialogLoading();
|
//配网失败,返回到设备添加页面
|
||||||
|
returnToAddDeviceAfterFailed();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -178,6 +197,34 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void returnToAddDeviceAfterFailed() {
|
||||||
|
hideDialogLoading();
|
||||||
|
handler.removeCallbacksAndMessages(null);
|
||||||
|
if (animationDrawable != null && animationDrawable.isRunning()) {
|
||||||
|
animationDrawable.stop();
|
||||||
|
animationDrawable = null;
|
||||||
|
}
|
||||||
|
provisioningStarted = false;
|
||||||
|
isBleConnecting = false;
|
||||||
|
isBleConnected = false;
|
||||||
|
|
||||||
|
if (espProvisionManager != null) {
|
||||||
|
espProvisionManager.setCallback(null);
|
||||||
|
espProvisionManager.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
Intent intent = new Intent(this, AddDeviceActivity.class);
|
||||||
|
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
|
||||||
|
handler.postDelayed(() -> {
|
||||||
|
if (!isFinishing()) {
|
||||||
|
startActivity(intent);
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}, 1500L);
|
||||||
|
}
|
||||||
|
|
||||||
private void connectBleDevice() {
|
private void connectBleDevice() {
|
||||||
if (mBleDeviceEntity == null || espProvisionManager == null) {
|
if (mBleDeviceEntity == null || espProvisionManager == null) {
|
||||||
ToastUtil.showShort(mContext, "\u8bbe\u5907\u8fde\u63a5\u672a\u521d\u59cb\u5316");
|
ToastUtil.showShort(mContext, "\u8bbe\u5907\u8fde\u63a5\u672a\u521d\u59cb\u5316");
|
||||||
@@ -221,14 +268,15 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
|
handler.removeCallbacks(provisionTimeoutRunnable);
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
handler.removeCallbacksAndMessages(null);
|
handler.removeCallbacksAndMessages(null);
|
||||||
if (animationDrawable != null && animationDrawable.isRunning()) {
|
if (animationDrawable != null && animationDrawable.isRunning()) {
|
||||||
animationDrawable.stop();
|
animationDrawable.stop();
|
||||||
}
|
}
|
||||||
if (espProvisionManager != null) {
|
if (espProvisionManager != null) {
|
||||||
espProvisionManager.disconnect();
|
|
||||||
espProvisionManager.setCallback(null);
|
espProvisionManager.setCallback(null);
|
||||||
|
espProvisionManager.disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -281,4 +329,12 @@ public class DeviceConnectActivity extends BaseActivity<DeviceConnectLayoutBindi
|
|||||||
public void queryDeviceBindStatusSuccess(WaterDeviceEntity bean) {
|
public void queryDeviceBindStatusSuccess(WaterDeviceEntity bean) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void queryDeviceWorkTimeSuccess(WaterDeviceEntity bean) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ package com.ckkj.water.device;
|
|||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.os.Looper;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@@ -21,15 +23,19 @@ import com.ckkj.water.device.mvp.DeviceImpl;
|
|||||||
import com.ckkj.water.device.mvp.DevicePresenter;
|
import com.ckkj.water.device.mvp.DevicePresenter;
|
||||||
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
||||||
import com.ckkj.water.network.BaseBean;
|
import com.ckkj.water.network.BaseBean;
|
||||||
import com.ckkj.water.utils.ClickUtils;
|
import com.ckkj.water.utils.FastClickUtils;
|
||||||
import com.ckkj.water.utils.manager.PowerIconManage;
|
import com.ckkj.water.utils.manager.PowerIconManage;
|
||||||
import com.ckkj.water.utils.manager.ThemeManager;
|
import com.ckkj.water.utils.manager.ThemeManager;
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
import com.ckkj.water.utils.show.ToastUtil;
|
||||||
import com.gyf.immersionbar.ImmersionBar;
|
import com.gyf.immersionbar.ImmersionBar;
|
||||||
import com.lxj.xpopup.XPopup;
|
import com.lxj.xpopup.XPopup;
|
||||||
|
|
||||||
|
import java.text.ParseException;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import de.greenrobot.event.Subscribe;
|
import de.greenrobot.event.Subscribe;
|
||||||
import de.greenrobot.event.ThreadMode;
|
import de.greenrobot.event.ThreadMode;
|
||||||
@@ -40,12 +46,40 @@ import de.greenrobot.event.ThreadMode;
|
|||||||
public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBinding, DevicePresenter>
|
public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBinding, DevicePresenter>
|
||||||
implements DeviceContract.DeviceView {
|
implements DeviceContract.DeviceView {
|
||||||
|
|
||||||
|
private static final long DEVICE_DETAIL_POLL_INTERVAL_MS = 10_000L;
|
||||||
private List<String> mTimeList = new ArrayList<>();
|
private List<String> mTimeList = new ArrayList<>();
|
||||||
private WaterDeviceEntity mDeviceEntity;
|
private WaterDeviceEntity mDeviceEntity;
|
||||||
private WaterDeviceEntity mRemoteDeviceEntity;
|
private WaterDeviceEntity mRemoteDeviceEntity;
|
||||||
private DeviceTimeSelectAdapter mAdapter;
|
private DeviceTimeSelectAdapter mAdapter;
|
||||||
//用户自定义的浇水时长
|
//用户自定义的浇水时长
|
||||||
private int mCustomDuration = 0;
|
private int mCustomDuration = 0;
|
||||||
|
private final Handler mProgressHandler = new Handler(Looper.getMainLooper());
|
||||||
|
private final Handler mDeviceDetailPollHandler = new Handler(Looper.getMainLooper());
|
||||||
|
private boolean mIsDeviceDetailPolling;
|
||||||
|
private long mWorkStartTime = 0L;
|
||||||
|
private long mWorkEndTime = 0L;
|
||||||
|
private boolean mHasRefreshAfterWorkFinished = false;
|
||||||
|
private final Runnable mWorkProgressRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
updateWorkProgress();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
/**
|
||||||
|
* 轮询请求设备详情
|
||||||
|
*/
|
||||||
|
private final Runnable mDeviceDetailPollRunnable = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!mIsDeviceDetailPolling) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (mDeviceEntity != null && !TextUtils.isEmpty(mDeviceEntity.getDeviceNo())) {
|
||||||
|
mPresenter.getDeviceDetailInfo(mDeviceEntity.getDeviceNo());
|
||||||
|
}
|
||||||
|
mDeviceDetailPollHandler.postDelayed(this, DEVICE_DETAIL_POLL_INTERVAL_MS);
|
||||||
|
}
|
||||||
|
};
|
||||||
@Override
|
@Override
|
||||||
public DevicePresenter createPresenter() {
|
public DevicePresenter createPresenter() {
|
||||||
return new DevicePresenter(new DeviceImpl());
|
return new DevicePresenter(new DeviceImpl());
|
||||||
@@ -59,29 +93,14 @@ public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBindi
|
|||||||
mDeviceEntity = (WaterDeviceEntity) bundle.getSerializable("device_info");
|
mDeviceEntity = (WaterDeviceEntity) bundle.getSerializable("device_info");
|
||||||
if(mDeviceEntity != null){
|
if(mDeviceEntity != null){
|
||||||
showLoadingDialog();
|
showLoadingDialog();
|
||||||
|
//查询设备详情
|
||||||
mPresenter.getDeviceDetailInfo(mDeviceEntity.getDeviceNo());
|
mPresenter.getDeviceDetailInfo(mDeviceEntity.getDeviceNo());
|
||||||
viewBinding.includedTitle.tvTitle.setText(mDeviceEntity.getDeviceName());
|
//查询设备当前工作进度
|
||||||
if(mDeviceEntity.getStatus().equals("1") || mDeviceEntity.getStatus().equals("2")){
|
if(mDeviceEntity.getWorkStatus().equals("1")){
|
||||||
if(mDeviceEntity.getWorkStatus().equals("1")){
|
mPresenter.getDeviceWorkProgress(mDeviceEntity.getDeviceNo());
|
||||||
viewBinding.tvDeviceStatus.setText(getString(R.string.device_status_working));
|
|
||||||
viewBinding.tvDeviceStatus.setTextColor(mContext.getResources().getColor(R.color.color_zhu));
|
|
||||||
viewBinding.tvConfirm.setText(getString(R.string.device_control_stop));
|
|
||||||
}else{
|
|
||||||
viewBinding.tvDeviceStatus.setText(getString(R.string.device_status_not_working));
|
|
||||||
viewBinding.tvDeviceStatus.setTextColor(mContext.getResources().getColor(R.color.color_999999));
|
|
||||||
viewBinding.tvConfirm.setText(getString(R.string.device_control_start));
|
|
||||||
}
|
|
||||||
viewBinding.linearWifi.setBackground(mContext.getResources().getDrawable(R.drawable.shape_device_ctrl_green_cor12));
|
|
||||||
viewBinding.imgWifiLogo.setImageResource(R.mipmap.icon_ctrl_wifi_white);
|
|
||||||
}else{
|
|
||||||
viewBinding.tvDeviceStatus.setText(getString(R.string.device_status_offline));
|
|
||||||
viewBinding.tvDeviceStatus.setTextColor(mContext.getResources().getColor(R.color.color_999999));
|
|
||||||
viewBinding.tvConfirm.setEnabled(false);
|
|
||||||
viewBinding.tvConfirm.setTextColor(mContext.getResources().getColor(R.color.color_999999));
|
|
||||||
viewBinding.tvConfirm.setBackgroundResource((R.drawable.shape_gray_button_bg_enable));
|
|
||||||
viewBinding.linearWifi.setBackground(mContext.getResources().getDrawable(R.drawable.shape_device_ctrl_white_cor12));
|
|
||||||
viewBinding.imgWifiLogo.setImageResource(R.mipmap.icon_ctrl_wifi_green);
|
|
||||||
}
|
}
|
||||||
|
viewBinding.includedTitle.tvTitle.setText(mDeviceEntity.getDeviceName());
|
||||||
|
updateDeviceStatus(mDeviceEntity);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -110,6 +129,11 @@ public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBindi
|
|||||||
mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
mAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
||||||
|
//此时处于工作中,不可点击
|
||||||
|
if(mDeviceEntity.getWorkStatus().equals("1")){
|
||||||
|
ToastUtil.showShort(mContext,getString(R.string.tips_device_working_stop_task));
|
||||||
|
return;
|
||||||
|
}
|
||||||
mAdapter.setOnSelPosition(position);
|
mAdapter.setOnSelPosition(position);
|
||||||
mCustomDuration = 0;
|
mCustomDuration = 0;
|
||||||
viewBinding.tvWorkDuartion.setHint(getString(R.string.device_custom_work_time));
|
viewBinding.tvWorkDuartion.setHint(getString(R.string.device_custom_work_time));
|
||||||
@@ -124,6 +148,35 @@ public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBindi
|
|||||||
initListener();
|
initListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void updateDeviceStatus(WaterDeviceEntity entity) {
|
||||||
|
if(entity.getStatus().equals("1") || entity.getStatus().equals("2")){
|
||||||
|
if(entity.getWorkStatus().equals("1")){
|
||||||
|
viewBinding.tvDeviceStatus.setText(getString(R.string.device_status_working));
|
||||||
|
viewBinding.tvDeviceStatus.setTextColor(mContext.getResources().getColor(R.color.color_zhu));
|
||||||
|
viewBinding.tvConfirm.setText(getString(R.string.device_control_stop));
|
||||||
|
}else{
|
||||||
|
viewBinding.tvDeviceStatus.setText(getString(R.string.device_status_not_working));
|
||||||
|
viewBinding.tvDeviceStatus.setTextColor(mContext.getResources().getColor(R.color.color_999999));
|
||||||
|
viewBinding.tvConfirm.setText(getString(R.string.device_control_start));
|
||||||
|
stopWorkProgressUpdate();
|
||||||
|
updateProgressView(0);
|
||||||
|
}
|
||||||
|
viewBinding.linearWifi.setBackground(mContext.getResources().getDrawable(R.drawable.shape_device_ctrl_green_cor12));
|
||||||
|
viewBinding.imgWifiLogo.setImageResource(R.mipmap.icon_ctrl_wifi_white);
|
||||||
|
}else{
|
||||||
|
viewBinding.tvDeviceStatus.setText(getString(R.string.device_status_offline));
|
||||||
|
viewBinding.tvDeviceStatus.setTextColor(mContext.getResources().getColor(R.color.color_E60000));
|
||||||
|
viewBinding.tvConfirm.setEnabled(false);
|
||||||
|
viewBinding.tvConfirm.setTextColor(mContext.getResources().getColor(R.color.color_999999));
|
||||||
|
viewBinding.tvConfirm.setBackgroundResource((R.drawable.shape_gray_button_bg_enable));
|
||||||
|
viewBinding.linearWifi.setBackground(mContext.getResources().getDrawable(R.drawable.shape_device_ctrl_white_cor12));
|
||||||
|
viewBinding.imgWifiLogo.setImageResource(R.mipmap.icon_ctrl_wifi_green);
|
||||||
|
stopWorkProgressUpdate();
|
||||||
|
updateProgressView(0);
|
||||||
|
}
|
||||||
|
viewBinding.tvDeviceUpdateTime.setText(getString(R.string.update_time) + entity.getPowerLevelUpdatatime());
|
||||||
|
}
|
||||||
|
|
||||||
private void initListener() {
|
private void initListener() {
|
||||||
setClick(viewBinding.includedTitle.imgBack);
|
setClick(viewBinding.includedTitle.imgBack);
|
||||||
setClick(viewBinding.includedTitle.imgSetting);
|
setClick(viewBinding.includedTitle.imgSetting);
|
||||||
@@ -178,13 +231,18 @@ public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBindi
|
|||||||
.isDestroyOnDismiss(true) //对于只使用一次的弹窗,推荐设置这个
|
.isDestroyOnDismiss(true) //对于只使用一次的弹窗,推荐设置这个
|
||||||
.atView(viewBinding.linearBat)
|
.atView(viewBinding.linearBat)
|
||||||
.hasShadowBg(false) // 去掉半透明背景
|
.hasShadowBg(false) // 去掉半透明背景
|
||||||
.asCustom(new CustomBubbleAttachPopup(mContext,"设备电量:"+
|
.asCustom(new CustomBubbleAttachPopup(mContext,getString(R.string.device_battery)+
|
||||||
mDeviceEntity.getPowerLevel() + "%" +
|
mDeviceEntity.getPowerLevel() + "%" +
|
||||||
" 更新时间: 05- 11 18:00"))
|
getString(R.string.update_time) + mDeviceEntity.getPowerLevelUpdatatime()))
|
||||||
.show();
|
.show();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.tv_work_duartion:
|
case R.id.tv_work_duartion:
|
||||||
|
//此时处于工作中,不可点击
|
||||||
|
if(mDeviceEntity.getWorkStatus().equals("1")){
|
||||||
|
ToastUtil.showShort(mContext,getString(R.string.tips_device_working_stop_task));
|
||||||
|
return;
|
||||||
|
}
|
||||||
inputDuration(mCustomDuration);
|
inputDuration(mCustomDuration);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -295,7 +353,7 @@ public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBindi
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 防止快速点击
|
// 防止快速点击
|
||||||
if (!ClickUtils.onclickTimes()) {
|
if (!FastClickUtils.onclickTimes()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -343,12 +401,30 @@ public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBindi
|
|||||||
@Override
|
@Override
|
||||||
public void getDeviceDetailInfo(WaterDeviceEntity bean) {
|
public void getDeviceDetailInfo(WaterDeviceEntity bean) {
|
||||||
hideDialogLoading();
|
hideDialogLoading();
|
||||||
viewBinding.imgBatStatus.setImageResource(PowerIconManage.getInstance().
|
if(!TextUtils.isEmpty(bean.getPowerStatus()) && bean.getPowerStatus().equals("1")){
|
||||||
getPowerVerIcon(Integer.parseInt(bean.getPowerLevel())));
|
viewBinding.imgBatStatus.setImageResource(R.mipmap.icon_charging);
|
||||||
mRemoteDeviceEntity = bean;
|
}else{
|
||||||
|
viewBinding.imgBatStatus.setImageResource(PowerIconManage.getInstance().
|
||||||
|
getPowerVerIcon(Integer.parseInt(bean.getPowerLevel())));
|
||||||
|
}
|
||||||
|
|
||||||
|
mDeviceEntity = bean;
|
||||||
|
updateDeviceStatus( bean);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deviceAccessLost() {
|
||||||
|
stopDeviceDetailPolling();
|
||||||
|
showDialogtextInterBackKey(null, false, false, false,
|
||||||
|
getString(R.string.tip_text), getString(R.string.device_control_access_lost),
|
||||||
|
"", getString(R.string.confirm_text), new BaseFragment.OnDialogClick() {
|
||||||
|
@Override public void onCancelClick() { finish(); }
|
||||||
|
@Override public void onConfirmClick() { finish(); }
|
||||||
|
}, true);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开关设备成功
|
* 开关设备成功
|
||||||
* @param bean
|
* @param bean
|
||||||
@@ -364,10 +440,15 @@ public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBindi
|
|||||||
if(status.equals("0")){
|
if(status.equals("0")){
|
||||||
showCenterTipDialog(R.mipmap.icon_dialog_success,getString(R.string.end_watering));
|
showCenterTipDialog(R.mipmap.icon_dialog_success,getString(R.string.end_watering));
|
||||||
viewBinding.tvConfirm.setText(getString(R.string.start_watering));
|
viewBinding.tvConfirm.setText(getString(R.string.start_watering));
|
||||||
|
stopWorkProgressUpdate();
|
||||||
|
updateProgressView(0);
|
||||||
}else{
|
}else{
|
||||||
showCenterTipDialog(R.mipmap.icon_dialog_success,getString(R.string.start_watering));
|
showCenterTipDialog(R.mipmap.icon_dialog_success,getString(R.string.start_watering));
|
||||||
viewBinding.tvConfirm.setText(getString(R.string.end_watering));
|
viewBinding.tvConfirm.setText(getString(R.string.end_watering));
|
||||||
|
mPresenter.getDeviceWorkProgress(mDeviceEntity.getDeviceNo());
|
||||||
}
|
}
|
||||||
|
//开关设备之后,更新一下当前设备状态
|
||||||
|
mPresenter.getDeviceDetailInfo(mDeviceEntity.getDeviceNo());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -382,6 +463,121 @@ public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBindi
|
|||||||
ToastUtil.showShort(mContext,message);
|
ToastUtil.showShort(mContext,message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询到设备目前的工作时间,控制进度条的展示
|
||||||
|
* @param bean
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void queryDeviceWorkTimeSuccess(WaterDeviceEntity bean) {
|
||||||
|
if (bean == null || TextUtils.isEmpty(bean.getStartTime()) || TextUtils.isEmpty(bean.getEndTime())) {
|
||||||
|
stopWorkProgressUpdate();
|
||||||
|
updateProgressView(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
mWorkStartTime = parseWorkTime(bean.getStartTime());
|
||||||
|
mWorkEndTime = parseWorkTime(bean.getEndTime());
|
||||||
|
mHasRefreshAfterWorkFinished = false;
|
||||||
|
if (mWorkStartTime <= 0 || mWorkEndTime <= mWorkStartTime) {
|
||||||
|
stopWorkProgressUpdate();
|
||||||
|
updateProgressView(0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
updateWorkProgress();
|
||||||
|
|
||||||
|
//"startTime": "2026-07-06 16:35:00",
|
||||||
|
//"endTime": "2026-07-06 16:37:00"
|
||||||
|
//bean.getStartTime(),bean.getEndTime(),这两个字段。
|
||||||
|
//Todo 根据以上开始时间和结束时间,以及当前时间,计算进度条的进度,viewBinding.progressWork,做到实时更新。
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private long parseWorkTime(String time) {
|
||||||
|
try {
|
||||||
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.CHINA);
|
||||||
|
Date date = format.parse(time);
|
||||||
|
return date == null ? 0L : date.getTime();
|
||||||
|
} catch (ParseException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateWorkProgress() {
|
||||||
|
long now = System.currentTimeMillis();
|
||||||
|
int progress;
|
||||||
|
if (now <= mWorkStartTime) {
|
||||||
|
progress = 0;
|
||||||
|
} else if (now >= mWorkEndTime) {
|
||||||
|
progress = 100;
|
||||||
|
} else {
|
||||||
|
progress = (int) ((now - mWorkStartTime) * 100 / (mWorkEndTime - mWorkStartTime));
|
||||||
|
}
|
||||||
|
|
||||||
|
updateProgressView(progress);
|
||||||
|
mProgressHandler.removeCallbacks(mWorkProgressRunnable);
|
||||||
|
if (progress < 100 && mDeviceEntity != null && "1".equals(mDeviceEntity.getWorkStatus())) {
|
||||||
|
mProgressHandler.postDelayed(mWorkProgressRunnable, 1000);
|
||||||
|
} else if (progress >= 100 && !mHasRefreshAfterWorkFinished
|
||||||
|
&& mDeviceEntity != null && !TextUtils.isEmpty(mDeviceEntity.getDeviceNo())) {
|
||||||
|
mHasRefreshAfterWorkFinished = true;
|
||||||
|
ToastUtil.showShort(mContext,"任务结束");
|
||||||
|
showLoadingDialog();
|
||||||
|
mProgressHandler.postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (mDeviceEntity != null && !TextUtils.isEmpty(mDeviceEntity.getDeviceNo())) {
|
||||||
|
mPresenter.getDeviceDetailInfo(mDeviceEntity.getDeviceNo());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 1500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateProgressView(int progress) {
|
||||||
|
viewBinding.progressWork.setProgress(progress);
|
||||||
|
viewBinding.tvProgressPercent.setText(getString(R.string.device_work_progress_title) + progress + "%");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopWorkProgressUpdate() {
|
||||||
|
mProgressHandler.removeCallbacksAndMessages(null);
|
||||||
|
mWorkStartTime = 0L;
|
||||||
|
mWorkEndTime = 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startDeviceDetailPolling() {
|
||||||
|
mIsDeviceDetailPolling = true;
|
||||||
|
mDeviceDetailPollHandler.removeCallbacks(mDeviceDetailPollRunnable);
|
||||||
|
mDeviceDetailPollHandler.postDelayed(mDeviceDetailPollRunnable, DEVICE_DETAIL_POLL_INTERVAL_MS);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopDeviceDetailPolling() {
|
||||||
|
mIsDeviceDetailPolling = false;
|
||||||
|
mDeviceDetailPollHandler.removeCallbacks(mDeviceDetailPollRunnable);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onResume() {
|
||||||
|
super.onResume();
|
||||||
|
startDeviceDetailPolling();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onPause() {
|
||||||
|
stopDeviceDetailPolling();
|
||||||
|
super.onPause();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onDestroy() {
|
||||||
|
stopWorkProgressUpdate();
|
||||||
|
stopDeviceDetailPolling();
|
||||||
|
super.onDestroy();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void logOut(BaseBean bean) {
|
public void logOut(BaseBean bean) {
|
||||||
|
|
||||||
@@ -409,4 +605,8 @@ public class DeviceControlActivity extends BaseActivity<DeviceControlLayoutBindi
|
|||||||
public void queryDeviceBindStatusSuccess(WaterDeviceEntity bean) {
|
public void queryDeviceBindStatusSuccess(WaterDeviceEntity bean) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -107,4 +107,9 @@ public class DeviceInfoActivity extends BaseActivity<DeviceInfoLayoutBinding, De
|
|||||||
public void queryDeviceBindStatusSuccess(WaterDeviceEntity bean) {
|
public void queryDeviceBindStatusSuccess(WaterDeviceEntity bean) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void queryDeviceWorkTimeSuccess(WaterDeviceEntity bean) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import android.view.View;
|
|||||||
import com.ckkj.water.ConstantUtil;
|
import com.ckkj.water.ConstantUtil;
|
||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
import com.ckkj.water.base.BaseActivity;
|
import com.ckkj.water.base.BaseActivity;
|
||||||
|
import com.ckkj.water.base.BaseFragment;
|
||||||
import com.ckkj.water.databinding.SetDeviceNameLayoutBinding;
|
import com.ckkj.water.databinding.SetDeviceNameLayoutBinding;
|
||||||
import com.ckkj.water.device.mvp.DeviceContract;
|
import com.ckkj.water.device.mvp.DeviceContract;
|
||||||
import com.ckkj.water.device.mvp.DeviceImpl;
|
import com.ckkj.water.device.mvp.DeviceImpl;
|
||||||
@@ -90,7 +91,7 @@ public class DeviceReNameActivity extends BaseActivity<SetDeviceNameLayoutBindin
|
|||||||
@Override
|
@Override
|
||||||
public void addDeviceSuccess(WaterDeviceEntity bean) {
|
public void addDeviceSuccess(WaterDeviceEntity bean) {
|
||||||
hideDialogLoading();
|
hideDialogLoading();
|
||||||
ToastUtil.showShort(mContext,"设备保存成功");
|
ToastUtil.showShort(mContext,getString(R.string.device_save_success));
|
||||||
ActivityManager.removeActivityByTag(ConstantUtil.ADD_DEVICE_FLAG);
|
ActivityManager.removeActivityByTag(ConstantUtil.ADD_DEVICE_FLAG);
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -116,7 +117,22 @@ public class DeviceReNameActivity extends BaseActivity<SetDeviceNameLayoutBindin
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showError(String message) {
|
public void showError(String message) {
|
||||||
|
hideDialogLoading();
|
||||||
|
showDialogtext(null, false, false, false,
|
||||||
|
getString(R.string.tip_text),
|
||||||
|
message,
|
||||||
|
null,
|
||||||
|
getString(R.string.confirm_text),
|
||||||
|
new BaseFragment.OnDialogClick() {
|
||||||
|
@Override
|
||||||
|
public void onCancelClick() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfirmClick() {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -144,4 +160,9 @@ public class DeviceReNameActivity extends BaseActivity<SetDeviceNameLayoutBindin
|
|||||||
public void queryDeviceBindStatusSuccess(WaterDeviceEntity bean) {
|
public void queryDeviceBindStatusSuccess(WaterDeviceEntity bean) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void queryDeviceWorkTimeSuccess(WaterDeviceEntity bean) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ public class DeviceSettingsActivity extends BaseActivity<DeviceSettingsLayoutBin
|
|||||||
setClick(viewBinding.rlDevInfo);
|
setClick(viewBinding.rlDevInfo);
|
||||||
setClick(viewBinding.rlDevWifiManager);
|
setClick(viewBinding.rlDevWifiManager);
|
||||||
setClick(viewBinding.rlDevUnbind);
|
setClick(viewBinding.rlDevUnbind);
|
||||||
|
setClick(viewBinding.rlResetDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setClick(View view) {
|
private void setClick(View view) {
|
||||||
@@ -113,12 +114,28 @@ public class DeviceSettingsActivity extends BaseActivity<DeviceSettingsLayoutBin
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.rl_dev_wifi_manager:
|
case R.id.rl_dev_wifi_manager:
|
||||||
Bundle bundle = new Bundle();
|
showDialogtext(null, false, false, true,
|
||||||
bundle.putInt(ConstantUtil.ACTIVITY_NAVIGATE_FLAG,200);
|
getString(R.string.tip_text),
|
||||||
goToForResult(mContext, SelectWifiActivity.class,REQUEST_EVENT_CODE_10001,bundle);
|
getString(R.string.reset_device_provision),
|
||||||
|
getString(R.string.cancel_text),
|
||||||
|
getString(R.string.confirm_text),
|
||||||
|
new BaseFragment.OnDialogClick() {
|
||||||
|
@Override
|
||||||
|
public void onCancelClick() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfirmClick() {
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putInt(ConstantUtil.ACTIVITY_NAVIGATE_FLAG,100);
|
||||||
|
bundle.putSerializable("ble_device_entity",mDeviceEntity);
|
||||||
|
goToForResult(mContext, SelectWifiActivity.class,REQUEST_EVENT_CODE_10001,bundle);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.rl_dev_unbind:
|
case R.id.rl_dev_unbind://解绑
|
||||||
showDialogtext(null, false, false, true,
|
showDialogtext(null, false, false, true,
|
||||||
getString(R.string.tip_text), getString(R.string.tip_unbind_device),
|
getString(R.string.tip_text), getString(R.string.tip_unbind_device),
|
||||||
getString(R.string.cancel_text), getString(R.string.confirm_text), new BaseFragment.OnDialogClick() {
|
getString(R.string.cancel_text), getString(R.string.confirm_text), new BaseFragment.OnDialogClick() {
|
||||||
@@ -133,6 +150,21 @@ public class DeviceSettingsActivity extends BaseActivity<DeviceSettingsLayoutBin
|
|||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case R.id.rl_reset_device://恢复出厂设置
|
||||||
|
showDialogtext(null, false, false, true,
|
||||||
|
getString(R.string.tip_text), getString(R.string.restore_factory_settings_warning),
|
||||||
|
getString(R.string.cancel_text), getString(R.string.confirm_text), new BaseFragment.OnDialogClick() {
|
||||||
|
@Override
|
||||||
|
public void onCancelClick() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfirmClick() {
|
||||||
|
mPresenter.factoryResetDevice(mDeviceEntity);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -190,6 +222,19 @@ public class DeviceSettingsActivity extends BaseActivity<DeviceSettingsLayoutBin
|
|||||||
},500);
|
},500);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void factoryResetDeviceSuccess(BaseBean bean) {
|
||||||
|
hideDialogLoading();
|
||||||
|
ToastUtil.showShort(mContext, getString(R.string.factory_reset_success));
|
||||||
|
EventBus.getDefault().post(new EventMessage(EventMessage.ACTIVITY_FINISH));
|
||||||
|
new Handler().postDelayed(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
}, 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getLayoutResId(Bundle savedInstanceState) {
|
public int getLayoutResId(Bundle savedInstanceState) {
|
||||||
@@ -198,7 +243,8 @@ public class DeviceSettingsActivity extends BaseActivity<DeviceSettingsLayoutBin
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void showError(String message) {
|
public void showError(String message) {
|
||||||
|
hideDialogLoading();
|
||||||
|
ToastUtil.showShort(mContext,message);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -229,4 +275,9 @@ public class DeviceSettingsActivity extends BaseActivity<DeviceSettingsLayoutBin
|
|||||||
public void queryDeviceBindStatusSuccess(WaterDeviceEntity bean) {
|
public void queryDeviceBindStatusSuccess(WaterDeviceEntity bean) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void queryDeviceWorkTimeSuccess(WaterDeviceEntity bean) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,9 +9,13 @@ import android.graphics.drawable.AnimationDrawable;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
import android.text.InputType;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.text.method.PasswordTransformationMethod;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.ckkj.water.ConstantUtil;
|
import com.ckkj.water.ConstantUtil;
|
||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
@@ -36,6 +40,7 @@ import com.gyf.immersionbar.ImmersionBar;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -44,6 +49,10 @@ import java.util.Set;
|
|||||||
public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, DevicePresenter>
|
public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, DevicePresenter>
|
||||||
implements DeviceContract.DeviceView {
|
implements DeviceContract.DeviceView {
|
||||||
|
|
||||||
|
private static final long BLE_CONNECT_TIMEOUT = 40 * 1000L;
|
||||||
|
//当前密码显示/隐藏
|
||||||
|
private boolean isPasswordVisible = false;
|
||||||
|
|
||||||
private WifiListAdapter wifiListAdapter;
|
private WifiListAdapter wifiListAdapter;
|
||||||
//100 来自设备添加, 200 来自设备信息
|
//100 来自设备添加, 200 来自设备信息
|
||||||
private int WITCH_FROM_CODE = 100;
|
private int WITCH_FROM_CODE = 100;
|
||||||
@@ -56,9 +65,23 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
private boolean isBleConnecting = false;
|
private boolean isBleConnecting = false;
|
||||||
private boolean isBleConnected = false;
|
private boolean isBleConnected = false;
|
||||||
private boolean keepBleConnectionForProvision = false;
|
private boolean keepBleConnectionForProvision = false;
|
||||||
private Handler bleConnectHandler = new Handler();
|
private boolean isBleConnectTimedOut = false;
|
||||||
|
private boolean isBleConnectTimeoutRunning = false;
|
||||||
|
private Handler bleConnectHandler = new Handler(Looper.getMainLooper());
|
||||||
private AnimationDrawable animationDrawable;
|
private AnimationDrawable animationDrawable;
|
||||||
private Handler handler = new Handler(Looper.getMainLooper());
|
private Handler handler = new Handler(Looper.getMainLooper());
|
||||||
|
private final Runnable bleConnectTask = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
connectBleDevice();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
private final Runnable bleConnectTimeoutTask = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
handleBleConnectTimeout();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public DevicePresenter createPresenter() {
|
public DevicePresenter createPresenter() {
|
||||||
@@ -74,7 +97,7 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
bleConnectHandler.removeCallbacksAndMessages(null);
|
cancelBleConnectTask();
|
||||||
if (WITCH_FROM_CODE == 100 && espProvisionManager != null && !keepBleConnectionForProvision) {
|
if (WITCH_FROM_CODE == 100 && espProvisionManager != null && !keepBleConnectionForProvision) {
|
||||||
espProvisionManager.disconnect();
|
espProvisionManager.disconnect();
|
||||||
espProvisionManager.setCallback(null);
|
espProvisionManager.setCallback(null);
|
||||||
@@ -149,6 +172,7 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
setClick(viewBinding.includedTitle.imgBack);
|
setClick(viewBinding.includedTitle.imgBack);
|
||||||
setClick(viewBinding.tvSelectWifi);
|
setClick(viewBinding.tvSelectWifi);
|
||||||
setClick(viewBinding.tvNext);
|
setClick(viewBinding.tvNext);
|
||||||
|
setClick(viewBinding.imgPsdShowHide);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setClick(View view) {
|
private void setClick(View view) {
|
||||||
@@ -193,15 +217,44 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case R.id.img_psd_show_hide:
|
||||||
|
togglePasswordVisibility();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void togglePasswordVisibility() {
|
||||||
|
EditText etPassword = viewBinding.etInputPsd;
|
||||||
|
ImageView ivToggle = viewBinding.imgPsdShowHide;
|
||||||
|
|
||||||
|
if (etPassword == null || ivToggle == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPasswordVisible) {
|
||||||
|
// 隐藏密码
|
||||||
|
etPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||||
|
etPassword.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||||
|
ivToggle.setImageResource(R.mipmap.icon_psd_hide);
|
||||||
|
} else {
|
||||||
|
// 显示密码
|
||||||
|
etPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
|
||||||
|
etPassword.setTransformationMethod(null);
|
||||||
|
ivToggle.setImageResource(R.mipmap.icon_psd_show);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保持光标位置
|
||||||
|
etPassword.setSelection(etPassword.getText().length());
|
||||||
|
isPasswordVisible = !isPasswordVisible;
|
||||||
|
}
|
||||||
|
|
||||||
private void goToDeviceConnect(String wifiPassword) {
|
private void goToDeviceConnect(String wifiPassword) {
|
||||||
if (espProvisionManager == null) {
|
if (espProvisionManager == null) {
|
||||||
initEspProvision();
|
initEspProvision();
|
||||||
}
|
}
|
||||||
if (mBleDeviceEntity == null) {
|
if (mBleDeviceEntity == null) {
|
||||||
ToastUtil.showShort(mContext, "\u8bbe\u5907\u8fde\u63a5\u672a\u521d\u59cb\u5316");
|
ToastUtil.showShort(mContext, getString(R.string.device_not_initialized));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
isBleConnected = espProvisionManager != null && espProvisionManager.isConnected();
|
isBleConnected = espProvisionManager != null && espProvisionManager.isConnected();
|
||||||
@@ -209,7 +262,7 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
if (!isBleConnecting) {
|
if (!isBleConnecting) {
|
||||||
scheduleBleConnect();
|
scheduleBleConnect();
|
||||||
}
|
}
|
||||||
ToastUtil.showShort(mContext, "\u8bbe\u5907\u8fde\u63a5\u4e2d\uff0c\u8bf7\u7a0d\u540e\u518d\u8bd5");
|
ToastUtil.showShort(mContext, getString(R.string.device_connecting_please_wait));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,6 +271,7 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
bundle.putString("wifi_password", wifiPassword);
|
bundle.putString("wifi_password", wifiPassword);
|
||||||
bundle.putSerializable("ble_device_entity", mBleDeviceEntity);
|
bundle.putSerializable("ble_device_entity", mBleDeviceEntity);
|
||||||
keepBleConnectionForProvision = true;
|
keepBleConnectionForProvision = true;
|
||||||
|
cancelBleConnectTask();
|
||||||
goTo(mContext, DeviceConnectActivity.class, bundle);
|
goTo(mContext, DeviceConnectActivity.class, bundle);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@@ -230,6 +284,7 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
public void onConnecting() {
|
public void onConnecting() {
|
||||||
isBleConnecting = true;
|
isBleConnecting = true;
|
||||||
isBleConnected = false;
|
isBleConnected = false;
|
||||||
|
startBleConnectTimeout();
|
||||||
Log.i("TEST","onConnecting");
|
Log.i("TEST","onConnecting");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -237,9 +292,10 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
public void onConnected() {
|
public void onConnected() {
|
||||||
isBleConnecting = false;
|
isBleConnecting = false;
|
||||||
isBleConnected = true;
|
isBleConnected = true;
|
||||||
|
cancelBleConnectTask();
|
||||||
Log.i("TEST","onConnected设备连接成功");
|
Log.i("TEST","onConnected设备连接成功");
|
||||||
stopConnectAnimation();
|
stopConnectAnimation();
|
||||||
ToastUtil.showShort(mContext, "设备连接成功");
|
ToastUtil.showShort(mContext, getString(R.string.device_connected_success));
|
||||||
//Tips 蓝牙扫描添加的设备不同于二维码扫描连接的设备,由于无法拿到deviceNo,所以需要请求接口获取
|
//Tips 蓝牙扫描添加的设备不同于二维码扫描连接的设备,由于无法拿到deviceNo,所以需要请求接口获取
|
||||||
mPresenter.bindDeviceStatus(mBleDeviceEntity);
|
mPresenter.bindDeviceStatus(mBleDeviceEntity);
|
||||||
}
|
}
|
||||||
@@ -253,7 +309,7 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
@Override
|
@Override
|
||||||
public void onSuccess(String deviceName, String deviceType) {
|
public void onSuccess(String deviceName, String deviceType) {
|
||||||
Log.i("TEST","deviceName:" + deviceName + "连接成功");
|
Log.i("TEST","deviceName:" + deviceName + "连接成功");
|
||||||
ToastUtil.showShort(mContext, deviceName + "连接成功");
|
ToastUtil.showShort(mContext, getString(R.string.connection_success));
|
||||||
new Handler().postDelayed(new Runnable() {
|
new Handler().postDelayed(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
@@ -264,6 +320,7 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailed(int errorCode, String message) {
|
public void onFailed(int errorCode, String message) {
|
||||||
|
cancelBleConnectTask();
|
||||||
isBleConnecting = false;
|
isBleConnecting = false;
|
||||||
if (errorCode != 0) {
|
if (errorCode != 0) {
|
||||||
isBleConnected = espProvisionManager != null && espProvisionManager .isConnected();
|
isBleConnected = espProvisionManager != null && espProvisionManager .isConnected();
|
||||||
@@ -278,9 +335,13 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
public void onDisconnected() {
|
public void onDisconnected() {
|
||||||
isBleConnecting = false;
|
isBleConnecting = false;
|
||||||
isBleConnected = false;
|
isBleConnected = false;
|
||||||
|
cancelBleConnectTask();
|
||||||
stopConnectAnimation();
|
stopConnectAnimation();
|
||||||
Log.i("TEST","onDisconnected");
|
Log.i("TEST","onDisconnected");
|
||||||
ToastUtil.showShort(mContext, "设备已断开");
|
if (isBleConnectTimedOut) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ToastUtil.showShort(mContext, getString(R.string.device_disconnected));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -305,13 +366,9 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
*/
|
*/
|
||||||
private void scheduleBleConnect() {
|
private void scheduleBleConnect() {
|
||||||
startConnectAnimation();
|
startConnectAnimation();
|
||||||
bleConnectHandler.removeCallbacksAndMessages(null);
|
startBleConnectTimeout();
|
||||||
bleConnectHandler.postDelayed(new Runnable() {
|
bleConnectHandler.removeCallbacks(bleConnectTask);
|
||||||
@Override
|
bleConnectHandler.postDelayed(bleConnectTask, 1000);
|
||||||
public void run() {
|
|
||||||
connectBleDevice();
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void connectBleDevice() {
|
private void connectBleDevice() {
|
||||||
@@ -321,7 +378,42 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
if (isBleConnected || isBleConnecting) {
|
if (isBleConnected || isBleConnecting) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
espProvisionManager.connect(mBleDeviceEntity.getMacAddress(), mBleDeviceEntity.getDeviceName());
|
espProvisionManager.connect(mBleDeviceEntity.getMacAddress().toUpperCase(Locale.ROOT),
|
||||||
|
mBleDeviceEntity.getDeviceName());
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startBleConnectTimeout() {
|
||||||
|
if (isBleConnected || keepBleConnectionForProvision) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isBleConnectTimeoutRunning) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isBleConnectTimedOut = false;
|
||||||
|
isBleConnectTimeoutRunning = true;
|
||||||
|
bleConnectHandler.removeCallbacks(bleConnectTimeoutTask);
|
||||||
|
bleConnectHandler.postDelayed(bleConnectTimeoutTask, BLE_CONNECT_TIMEOUT);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cancelBleConnectTask() {
|
||||||
|
isBleConnectTimeoutRunning = false;
|
||||||
|
bleConnectHandler.removeCallbacks(bleConnectTask);
|
||||||
|
bleConnectHandler.removeCallbacks(bleConnectTimeoutTask);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleBleConnectTimeout() {
|
||||||
|
if (WITCH_FROM_CODE != 100 || isBleConnected || keepBleConnectionForProvision) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
isBleConnectTimedOut = true;
|
||||||
|
isBleConnecting = false;
|
||||||
|
cancelBleConnectTask();
|
||||||
|
if (espProvisionManager != null) {
|
||||||
|
espProvisionManager.disconnect();
|
||||||
|
}
|
||||||
|
stopConnectAnimation();
|
||||||
|
ToastUtil.showShort(mContext, getString(R.string.ble_connect_timeout));
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void scanWifi() {
|
private void scanWifi() {
|
||||||
@@ -329,7 +421,7 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
viewBinding.tvNext.setVisibility(View.GONE);
|
viewBinding.tvNext.setVisibility(View.GONE);
|
||||||
|
|
||||||
if (espProvisionManager == null || !espProvisionManager.isConnected()) {
|
if (espProvisionManager == null || !espProvisionManager.isConnected()) {
|
||||||
ToastUtil.showShort(mContext, "设备未连接,请稍后重试");
|
ToastUtil.showShort(mContext, getString(R.string.device_not_connected_retry));
|
||||||
hideDialogLoading();
|
hideDialogLoading();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -344,7 +436,7 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
@Override
|
@Override
|
||||||
public void onWiFiScanFailed(Exception e) {
|
public void onWiFiScanFailed(Exception e) {
|
||||||
runOnUiThread(() -> {
|
runOnUiThread(() -> {
|
||||||
ToastUtil.showShort(mContext, "扫描失败: " + e.getMessage());
|
ToastUtil.showShort(mContext, getString(R.string.scan_failed) + e.getMessage());
|
||||||
hideDialogLoading();
|
hideDialogLoading();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -382,6 +474,11 @@ public class SelectWifiActivity extends BaseActivity<DeviceResetWifiBinding, Dev
|
|||||||
mBleDeviceEntity = bean.getBindDevice();
|
mBleDeviceEntity = bean.getBindDevice();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void queryDeviceWorkTimeSuccess(WaterDeviceEntity bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addDeviceSuccess(WaterDeviceEntity bean) {
|
public void addDeviceSuccess(WaterDeviceEntity bean) {
|
||||||
|
|
||||||
|
|||||||
@@ -1,391 +0,0 @@
|
|||||||
package com.ckkj.water.device;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.content.BroadcastReceiver;
|
|
||||||
import android.content.Context;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.content.IntentFilter;
|
|
||||||
import android.content.pm.PackageManager;
|
|
||||||
import android.net.wifi.ScanResult;
|
|
||||||
import android.net.wifi.WifiManager;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.core.app.ActivityCompat;
|
|
||||||
|
|
||||||
import com.ckkj.water.ConstantUtil;
|
|
||||||
import com.ckkj.water.R;
|
|
||||||
import com.ckkj.water.base.BaseActivity;
|
|
||||||
import com.ckkj.water.databinding.DeviceResetWifiBinding;
|
|
||||||
import com.ckkj.water.device.adapter.WifiListAdapter;
|
|
||||||
import com.ckkj.water.device.mvp.DeviceContract;
|
|
||||||
import com.ckkj.water.device.mvp.DeviceImpl;
|
|
||||||
import com.ckkj.water.device.mvp.DevicePresenter;
|
|
||||||
import com.ckkj.water.espBle.EspProvisionManager;
|
|
||||||
import com.ckkj.water.espBle.ProvisionCallback;
|
|
||||||
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
|
||||||
import com.ckkj.water.network.BaseBean;
|
|
||||||
import com.ckkj.water.permission.PermissionActivity;
|
|
||||||
import com.ckkj.water.utils.manager.ActivityManager;
|
|
||||||
import com.ckkj.water.utils.manager.ThemeManager;
|
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
|
||||||
import com.gyf.immersionbar.ImmersionBar;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 配置wifi
|
|
||||||
*/
|
|
||||||
public class SelectWifiActivity_copy extends BaseActivity<DeviceResetWifiBinding, DevicePresenter>
|
|
||||||
implements DeviceContract.DeviceView {
|
|
||||||
|
|
||||||
private WifiManager wifiManager;
|
|
||||||
private WifiListAdapter wifiListAdapter;
|
|
||||||
private WifiScanReceiver wifiScanReceiver;
|
|
||||||
//100 来自设备添加, 200 来自设备信息
|
|
||||||
private int WITCH_FROM_CODE = 100;
|
|
||||||
|
|
||||||
private String mWifiName = "";
|
|
||||||
|
|
||||||
private WaterDeviceEntity mBleDeviceEntity;
|
|
||||||
private EspProvisionManager espProvisionManager;
|
|
||||||
private boolean isBleConnecting = false;
|
|
||||||
private boolean isBleConnected = false;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public DevicePresenter createPresenter() {
|
|
||||||
return new DevicePresenter(new DeviceImpl());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
wifiManager = (WifiManager) getApplicationContext().getSystemService(Context.WIFI_SERVICE);
|
|
||||||
wifiScanReceiver = new WifiScanReceiver();
|
|
||||||
ActivityManager.addActivity(this,getClass().getSimpleName() + "_" + ConstantUtil.ADD_DEVICE_FLAG);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResume() {
|
|
||||||
super.onResume();
|
|
||||||
registerReceiver(wifiScanReceiver, new IntentFilter(WifiManager.SCAN_RESULTS_AVAILABLE_ACTION));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onPause() {
|
|
||||||
super.onPause();
|
|
||||||
unregisterReceiver(wifiScanReceiver);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onDestroy() {
|
|
||||||
super.onDestroy();
|
|
||||||
if (WITCH_FROM_CODE == 100 && espProvisionManager != null) {
|
|
||||||
espProvisionManager.disconnect();
|
|
||||||
espProvisionManager.setCallback(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initData(Bundle savedInstanceState) {
|
|
||||||
super.initData(savedInstanceState);
|
|
||||||
Bundle bundle = getIntent().getExtras();
|
|
||||||
if(bundle != null){
|
|
||||||
WITCH_FROM_CODE = bundle.getInt(ConstantUtil.ACTIVITY_NAVIGATE_FLAG);
|
|
||||||
mBleDeviceEntity = (WaterDeviceEntity) bundle.getSerializable("ble_device_entity");
|
|
||||||
}
|
|
||||||
|
|
||||||
ImmersionBar.with(this)
|
|
||||||
.statusBarColor(R.color.color_gray_theme)
|
|
||||||
.statusBarDarkFont(ThemeManager.isAppThemeLight(mContext))
|
|
||||||
.titleBar(viewBinding.rlTitle)
|
|
||||||
.init();
|
|
||||||
if(WITCH_FROM_CODE == 200){
|
|
||||||
viewBinding.tvNext.setText(getString(R.string.confirm_text));
|
|
||||||
}
|
|
||||||
viewBinding.includedTitle.tvTitle.setText(R.string.select_wifi_tip);
|
|
||||||
|
|
||||||
initListener();
|
|
||||||
initWifiList();
|
|
||||||
if (WITCH_FROM_CODE == 100) {
|
|
||||||
initEspProvision();
|
|
||||||
connectBleDevice();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initWifiList() {
|
|
||||||
wifiListAdapter = new WifiListAdapter(mContext);
|
|
||||||
viewBinding.rvWifiList.setAdapter(wifiListAdapter);
|
|
||||||
wifiListAdapter.setOnWifiItemClickListener(wifiName -> {
|
|
||||||
mWifiName = wifiName;
|
|
||||||
viewBinding.etWifiName.setText(wifiName);
|
|
||||||
viewBinding.rvWifiList.setVisibility(View.GONE);
|
|
||||||
viewBinding.linearWifiInfo.setVisibility(View.VISIBLE);
|
|
||||||
viewBinding.tvNext.setVisibility(View.VISIBLE);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initListener() {
|
|
||||||
setClick(viewBinding.includedTitle.imgBack);
|
|
||||||
setClick(viewBinding.tvSelectWifi);
|
|
||||||
setClick(viewBinding.tvNext);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setClick(View view) {
|
|
||||||
view.setOnClickListener(this::onClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onClick(View view){
|
|
||||||
switch (view.getId()){
|
|
||||||
case R.id.img_back:
|
|
||||||
finish();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.tv_select_wifi:
|
|
||||||
String[] permission = {
|
|
||||||
Manifest.permission.ACCESS_FINE_LOCATION
|
|
||||||
};
|
|
||||||
boolean hasPermission = hasRecordPermission(permission);
|
|
||||||
if(!hasPermission){
|
|
||||||
goTo(mContext, PermissionActivity.class,null);
|
|
||||||
}else{
|
|
||||||
}
|
|
||||||
scanWifi();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.tv_next:
|
|
||||||
if(TextUtils.isEmpty(mWifiName)){
|
|
||||||
ToastUtil.showShort(mContext,getString(R.string.toast_select_wifi_tip));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(TextUtils.isEmpty(viewBinding.etInputPsd.getText().toString())){
|
|
||||||
ToastUtil.showShort(mContext,getString(R.string.toast_select_wifi_psd_tip));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if(WITCH_FROM_CODE == 100){
|
|
||||||
provisionWifi();
|
|
||||||
}else{
|
|
||||||
Intent intent = new Intent();
|
|
||||||
intent.putExtra("wifi_name",mWifiName);
|
|
||||||
intent.putExtra("wifi_psd",viewBinding.etInputPsd.getText().toString());
|
|
||||||
setResult(RESULT_OK,intent);
|
|
||||||
finish();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 配置网络
|
|
||||||
*/
|
|
||||||
private void provisionWifi() {
|
|
||||||
if (espProvisionManager == null) {
|
|
||||||
ToastUtil.showShort(mContext, "设备连接未初始化");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!isBleConnected) {
|
|
||||||
if (!isBleConnecting) {
|
|
||||||
connectBleDevice();
|
|
||||||
}
|
|
||||||
ToastUtil.showShort(mContext, "设备连接中,请稍后再试");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
showProgressLoadingDialog(0);
|
|
||||||
espProvisionManager.provisionWifi(mWifiName, viewBinding.etInputPsd.getText().toString());
|
|
||||||
// goTo(mContext,DeviceConnectActivity.class,null);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initEspProvision() {
|
|
||||||
espProvisionManager = EspProvisionManager.init(mContext).setCallback(new ProvisionCallback() {
|
|
||||||
@Override
|
|
||||||
public void onConnecting() {
|
|
||||||
isBleConnecting = true;
|
|
||||||
isBleConnected = false;
|
|
||||||
Log.i("TEST","onConnecting");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConnected() {
|
|
||||||
isBleConnecting = false;
|
|
||||||
isBleConnected = true;
|
|
||||||
Log.i("TEST","onConnected设备连接成功");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProvisioning(int progress) {
|
|
||||||
Log.i("TEST","WIFI连接进度 == " + progress);
|
|
||||||
mProgressLoadingDialog.setProgress(progress);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSuccess(String deviceName, String deviceType) {
|
|
||||||
Log.i("TEST","deviceName:" + deviceName + "连接成功");
|
|
||||||
ToastUtil.showShort(mContext, deviceName + "连接成功");
|
|
||||||
new Handler().postDelayed(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
hideDialogLoading();
|
|
||||||
}
|
|
||||||
}, 800);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailed(int errorCode, String message) {
|
|
||||||
isBleConnecting = false;
|
|
||||||
if (errorCode != 0) {
|
|
||||||
isBleConnected = espProvisionManager != null && espProvisionManager .isConnected();
|
|
||||||
}
|
|
||||||
Log.i("TEST","errorCode == " + errorCode + " message == " + message);
|
|
||||||
ToastUtil.showShort(mContext, message);
|
|
||||||
hideDialogLoading();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisconnected() {
|
|
||||||
isBleConnecting = false;
|
|
||||||
isBleConnected = false;
|
|
||||||
hideDialogLoading();
|
|
||||||
Log.i("TEST","onDisconnected");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onWifiListReceived(String[] wifiList) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onWifiListFailed(String message) {
|
|
||||||
Log.i("TEST","onWifiListFailed-Msg==" + message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onProvisioningRejected() {
|
|
||||||
Log.i("TEST","onProvisioningRejected");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 连接设备
|
|
||||||
*/
|
|
||||||
private void connectBleDevice() {
|
|
||||||
if (WITCH_FROM_CODE != 100 || mBleDeviceEntity == null || espProvisionManager == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (isBleConnected || isBleConnecting) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
espProvisionManager.connect(mBleDeviceEntity.getMacAddress(), mBleDeviceEntity.getDeviceName());
|
|
||||||
}
|
|
||||||
|
|
||||||
private void scanWifi() {
|
|
||||||
showLoadingDialog();
|
|
||||||
viewBinding.tvNext.setVisibility(View.GONE);
|
|
||||||
if (wifiManager != null && wifiManager.isWifiEnabled()) {
|
|
||||||
wifiManager.startScan();
|
|
||||||
} else {
|
|
||||||
ToastUtil.showShort(mContext, getString(R.string.wifi_not_enabled));
|
|
||||||
hideDialogLoading();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void displayWifiList(List<ScanResult> scanResults) {
|
|
||||||
Set<String> wifiSet = new HashSet<>();
|
|
||||||
List<String> wifiNameList = new ArrayList<>();
|
|
||||||
|
|
||||||
for (ScanResult result : scanResults) {
|
|
||||||
String wifiName = result.SSID;
|
|
||||||
if (wifiName != null && !wifiName.isEmpty() && !wifiSet.contains(wifiName)) {
|
|
||||||
wifiSet.add(wifiName);
|
|
||||||
wifiNameList.add(wifiName);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
hideDialogLoading();
|
|
||||||
|
|
||||||
if (wifiNameList.isEmpty()) {
|
|
||||||
ToastUtil.showShort(mContext, getString(R.string.no_wifi_found));
|
|
||||||
viewBinding.linearWifiInfo.setVisibility(View.VISIBLE);
|
|
||||||
viewBinding.rvWifiList.setVisibility(View.GONE);
|
|
||||||
} else {
|
|
||||||
wifiListAdapter.setData(wifiNameList);
|
|
||||||
viewBinding.linearWifiInfo.setVisibility(View.GONE);
|
|
||||||
viewBinding.rvWifiList.setVisibility(View.VISIBLE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void addDeviceSuccess(WaterDeviceEntity bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getDeviceDetailInfo(WaterDeviceEntity bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void editDeviceInfoSuccess(BaseBean bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deleteDeviceSuccess(BaseBean bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void turnOnOffDeviceSuccess(BaseBean bean, String status) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void queryDeviceBindStatusSuccess(WaterDeviceEntity bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private class WifiScanReceiver extends BroadcastReceiver {
|
|
||||||
@Override
|
|
||||||
public void onReceive(Context context, Intent intent) {
|
|
||||||
if (WifiManager.SCAN_RESULTS_AVAILABLE_ACTION.equals(intent.getAction())) {
|
|
||||||
boolean success = intent.getBooleanExtra(WifiManager.EXTRA_RESULTS_UPDATED, false);
|
|
||||||
if (success) {
|
|
||||||
if (ActivityCompat.checkSelfPermission(mContext, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
|
|
||||||
// TODO: Consider calling
|
|
||||||
// ActivityCompat#requestPermissions
|
|
||||||
// here to request the missing permissions, and then overriding
|
|
||||||
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
|
|
||||||
// int[] grantResults)
|
|
||||||
// to handle the case where the user grants the permission. See the documentation
|
|
||||||
// for ActivityCompat#requestPermissions for more details.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<ScanResult> results = wifiManager.getScanResults();
|
|
||||||
displayWifiList(results);
|
|
||||||
} else {
|
|
||||||
ToastUtil.showShort(mContext, getString(R.string.wifi_scan_failed));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getLayoutResId(Bundle savedInstanceState) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showError(String message) {
|
|
||||||
ToastUtil.showShort(mContext,message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logOut(BaseBean bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -27,18 +27,32 @@ public class DeviceContract {
|
|||||||
//删除设备信息
|
//删除设备信息
|
||||||
void deleteDevice(String id, IndexContract.CallBack callBack);
|
void deleteDevice(String id, IndexContract.CallBack callBack);
|
||||||
|
|
||||||
|
//恢复设备出厂设置
|
||||||
|
void factoryResetDevice(String id, IndexContract.CallBack callBack);
|
||||||
|
|
||||||
//手动开启关闭设备
|
//手动开启关闭设备
|
||||||
void turnOnOffDevice(JSONObject json, IndexContract.CallBack callBack);
|
void turnOnOffDevice(JSONObject json, IndexContract.CallBack callBack);
|
||||||
|
|
||||||
|
//设备当前工作的开始时间和结束时间
|
||||||
|
void queryDeviceWorkTime(Map<String,String> map , IndexContract.CallBack callBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface DeviceView extends IView {
|
public interface DeviceView extends IView {
|
||||||
//添加设备成功g
|
//添加设备成功g
|
||||||
void addDeviceSuccess(WaterDeviceEntity bean);
|
void addDeviceSuccess(WaterDeviceEntity bean);
|
||||||
void getDeviceDetailInfo(WaterDeviceEntity bean);
|
void getDeviceDetailInfo(WaterDeviceEntity bean);
|
||||||
|
default void deviceAccessLost() {
|
||||||
|
}
|
||||||
void editDeviceInfoSuccess(BaseBean bean);
|
void editDeviceInfoSuccess(BaseBean bean);
|
||||||
void deleteDeviceSuccess(BaseBean bean);
|
void deleteDeviceSuccess(BaseBean bean);
|
||||||
|
default void factoryResetDeviceSuccess(BaseBean bean) {
|
||||||
|
}
|
||||||
void turnOnOffDeviceSuccess(BaseBean bean, String status);
|
void turnOnOffDeviceSuccess(BaseBean bean, String status);
|
||||||
|
|
||||||
void queryDeviceBindStatusSuccess(WaterDeviceEntity bean);
|
void queryDeviceBindStatusSuccess(WaterDeviceEntity bean);
|
||||||
|
//查询设备目前工作状态
|
||||||
|
void queryDeviceWorkTimeSuccess(WaterDeviceEntity bean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -4,9 +4,11 @@ import com.ckkj.water.index.entity.WaterDeviceEntity;
|
|||||||
import com.ckkj.water.index.mvp.IndexContract;
|
import com.ckkj.water.index.mvp.IndexContract;
|
||||||
import com.ckkj.water.network.BaseBean;
|
import com.ckkj.water.network.BaseBean;
|
||||||
import com.ckkj.water.network.NetWorkManager;
|
import com.ckkj.water.network.NetWorkManager;
|
||||||
|
import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import io.reactivex.Observer;
|
import io.reactivex.Observer;
|
||||||
@@ -33,6 +35,8 @@ public class DeviceImpl implements DeviceContract.DataModel{
|
|||||||
public void onNext(@NonNull BaseBean<WaterDeviceEntity> bean) {
|
public void onNext(@NonNull BaseBean<WaterDeviceEntity> bean) {
|
||||||
if (bean.getCode() == 200) {
|
if (bean.getCode() == 200) {
|
||||||
callBack.success(bean.getData(),0);
|
callBack.success(bean.getData(),0);
|
||||||
|
} else {
|
||||||
|
callBack.fail(bean.getCode() == 501 ? "DEVICE_ACCESS_LOST" : bean.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -166,6 +170,46 @@ public class DeviceImpl implements DeviceContract.DataModel{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 恢复设备出厂设置
|
||||||
|
* @param deviceNo 设备编号
|
||||||
|
* @param callBack 请求结果回调
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void factoryResetDevice(String deviceNo, IndexContract.CallBack callBack) {
|
||||||
|
try {
|
||||||
|
NetWorkManager.getRequest().deviceFactoryReset(NetWorkManager.getToken(), deviceNo)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.unsubscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Observer<BaseBean>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(@NonNull BaseBean bean) {
|
||||||
|
if (bean.getCode() == 200) {
|
||||||
|
callBack.success(bean, 0);
|
||||||
|
} else {
|
||||||
|
callBack.fail(bean.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(@NonNull Throwable e) {
|
||||||
|
callBack.fail(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 手动开启关闭设备
|
* 手动开启关闭设备
|
||||||
* @param json
|
* @param json
|
||||||
@@ -205,4 +249,41 @@ public class DeviceImpl implements DeviceContract.DataModel{
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备工作时间
|
||||||
|
* @param map
|
||||||
|
* @param callBack
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void queryDeviceWorkTime(Map<String, String> map, IndexContract.CallBack callBack) {
|
||||||
|
NetWorkManager.getRequest().queryDeviceWorkTime(NetWorkManager.getToken(),map)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.unsubscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Observer<BaseBean<WaterDeviceEntity>>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(@NonNull BaseBean<WaterDeviceEntity> bean) {
|
||||||
|
if (bean.getCode() == 200) {
|
||||||
|
callBack.success(bean.getData(),0);
|
||||||
|
} else {
|
||||||
|
callBack.fail(bean.getCode() == 501 ? "DEVICE_ACCESS_LOST" : bean.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(@NonNull Throwable e) {
|
||||||
|
callBack.fail(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -49,7 +49,11 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
|||||||
@Override
|
@Override
|
||||||
public void fail(String msg) {
|
public void fail(String msg) {
|
||||||
if(DevicePresenter.this.getView() != null){
|
if(DevicePresenter.this.getView() != null){
|
||||||
DevicePresenter.this.getView().showError( msg);
|
if ("DEVICE_ACCESS_LOST".equals(msg)) {
|
||||||
|
DevicePresenter.this.getView().deviceAccessLost();
|
||||||
|
} else {
|
||||||
|
DevicePresenter.this.getView().showError(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -76,7 +80,11 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
|||||||
@Override
|
@Override
|
||||||
public void fail(String msg) {
|
public void fail(String msg) {
|
||||||
if(DevicePresenter.this.getView() != null){
|
if(DevicePresenter.this.getView() != null){
|
||||||
DevicePresenter.this.getView().showError( msg);
|
if ("DEVICE_ACCESS_LOST".equals(msg)) {
|
||||||
|
DevicePresenter.this.getView().deviceAccessLost();
|
||||||
|
} else {
|
||||||
|
DevicePresenter.this.getView().showError(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -104,7 +112,11 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
|||||||
@Override
|
@Override
|
||||||
public void fail(String msg) {
|
public void fail(String msg) {
|
||||||
if(DevicePresenter.this.getView() != null){
|
if(DevicePresenter.this.getView() != null){
|
||||||
DevicePresenter.this.getView().showError( msg);
|
if ("DEVICE_ACCESS_LOST".equals(msg)) {
|
||||||
|
DevicePresenter.this.getView().deviceAccessLost();
|
||||||
|
} else {
|
||||||
|
DevicePresenter.this.getView().showError(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -135,6 +147,28 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 恢复设备出厂设置
|
||||||
|
* @param deviceEntity 设备信息
|
||||||
|
*/
|
||||||
|
public void factoryResetDevice(WaterDeviceEntity deviceEntity) {
|
||||||
|
impl.factoryResetDevice(deviceEntity.getDeviceNo(), new IndexContract.CallBack<BaseBean>() {
|
||||||
|
@Override
|
||||||
|
public void success(BaseBean bean, int total) {
|
||||||
|
if (DevicePresenter.this.getView() != null) {
|
||||||
|
DevicePresenter.this.getView().factoryResetDeviceSuccess(bean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fail(String msg) {
|
||||||
|
if (DevicePresenter.this.getView() != null) {
|
||||||
|
DevicePresenter.this.getView().showError(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 开启/关闭浇水
|
* 开启/关闭浇水
|
||||||
* @param deviceEntity
|
* @param deviceEntity
|
||||||
@@ -159,7 +193,11 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
|||||||
@Override
|
@Override
|
||||||
public void fail(String msg) {
|
public void fail(String msg) {
|
||||||
if(DevicePresenter.this.getView() != null){
|
if(DevicePresenter.this.getView() != null){
|
||||||
DevicePresenter.this.getView().showError( msg);
|
if ("DEVICE_ACCESS_LOST".equals(msg)) {
|
||||||
|
DevicePresenter.this.getView().deviceAccessLost();
|
||||||
|
} else {
|
||||||
|
DevicePresenter.this.getView().showError(msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -175,7 +213,8 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
|||||||
public void bindDeviceStatus(WaterDeviceEntity entity) {
|
public void bindDeviceStatus(WaterDeviceEntity entity) {
|
||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("macAddress",entity.getMacAddress());
|
json.put("macAddress",
|
||||||
|
entity.getMacAddress() == null ? "" : entity.getMacAddress().toLowerCase());
|
||||||
new IndexImpl().queryDeviceBindStatus(json, new IndexContract.CallBack<WaterDeviceEntity>() {
|
new IndexImpl().queryDeviceBindStatus(json, new IndexContract.CallBack<WaterDeviceEntity>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(WaterDeviceEntity bean, int total) {
|
public void success(WaterDeviceEntity bean, int total) {
|
||||||
@@ -198,4 +237,33 @@ public class DevicePresenter extends BasePresenter<DeviceContract.DeviceView> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询设备工作的开始时间和结束时间,计算进度
|
||||||
|
* @param deviceNo
|
||||||
|
*/
|
||||||
|
public void getDeviceWorkProgress(String deviceNo) {
|
||||||
|
Map<String,String> map = new HashMap<>();
|
||||||
|
map.put("deviceNo",deviceNo);
|
||||||
|
impl.queryDeviceWorkTime(map, new IndexContract.CallBack<WaterDeviceEntity>() {
|
||||||
|
@Override
|
||||||
|
public void success(WaterDeviceEntity bean, int total) {
|
||||||
|
if(DevicePresenter.this.getView() != null){
|
||||||
|
DevicePresenter.this.getView().queryDeviceWorkTimeSuccess(bean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fail(String msg) {
|
||||||
|
if(DevicePresenter.this.getView() != null){
|
||||||
|
if ("DEVICE_ACCESS_LOST".equals(msg)) {
|
||||||
|
DevicePresenter.this.getView().deviceAccessLost();
|
||||||
|
} else {
|
||||||
|
DevicePresenter.this.getView().showError(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ import android.view.WindowManager;
|
|||||||
import android.view.animation.Animation;
|
import android.view.animation.Animation;
|
||||||
import android.view.animation.AnimationUtils;
|
import android.view.animation.AnimationUtils;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
import android.widget.LinearLayout;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
@@ -48,8 +49,10 @@ public class DialogAppUpdate {
|
|||||||
public static View layoutView;
|
public static View layoutView;
|
||||||
private Dialog mDialog;
|
private Dialog mDialog;
|
||||||
private Activity mContext;
|
private Activity mContext;
|
||||||
private TextView tvTitle,tvContent,tvConfirm,tvCancel;
|
private TextView tvTitle,tvContent,tvConfirm,tvCancel,tvVersionName;
|
||||||
|
private TextView tvProgressPercent;
|
||||||
private RelativeLayout rlUpdateContent;
|
private RelativeLayout rlUpdateContent;
|
||||||
|
private LinearLayout llProgressContainer,llButton;
|
||||||
private ImageView imgClose,imgClear;
|
private ImageView imgClose,imgClear;
|
||||||
private String startTime = "";
|
private String startTime = "";
|
||||||
private String endTime = "";
|
private String endTime = "";
|
||||||
@@ -84,7 +87,7 @@ public class DialogAppUpdate {
|
|||||||
this.mContext = context;
|
this.mContext = context;
|
||||||
this.mIsForceUpdate = isForceUpdate;
|
this.mIsForceUpdate = isForceUpdate;
|
||||||
this.mVersionBean = bean;
|
this.mVersionBean = bean;
|
||||||
mDwonLoadUrl = bean.getVersionUrl();
|
mDwonLoadUrl = bean.getDownloadUrl();
|
||||||
mDialog = new Dialog(context, R.style.ActionSheetDialogStyle);
|
mDialog = new Dialog(context, R.style.ActionSheetDialogStyle);
|
||||||
//填充对话框的布局
|
//填充对话框的布局
|
||||||
layoutView = LayoutInflater.from(context).inflate(layoutId, null);
|
layoutView = LayoutInflater.from(context).inflate(layoutId, null);
|
||||||
@@ -122,29 +125,28 @@ public class DialogAppUpdate {
|
|||||||
dialogWindow.setAttributes(lp);
|
dialogWindow.setAttributes(lp);
|
||||||
}
|
}
|
||||||
tvTitle = layoutView.findViewById(R.id.tv_title);
|
tvTitle = layoutView.findViewById(R.id.tv_title);
|
||||||
|
tvVersionName = layoutView.findViewById(R.id.tv_version);
|
||||||
tvContent = layoutView.findViewById(R.id.tv_update_content);
|
tvContent = layoutView.findViewById(R.id.tv_update_content);
|
||||||
tvConfirm = layoutView.findViewById(R.id.tv_update);
|
tvConfirm = layoutView.findViewById(R.id.tv_update);
|
||||||
tvCancel = layoutView.findViewById(R.id.tv_cencel);
|
tvCancel = layoutView.findViewById(R.id.tv_cancel);
|
||||||
progressBar = layoutView.findViewById(R.id.progress_bar);
|
progressBar = layoutView.findViewById(R.id.progress_bar);
|
||||||
rlUpdateContent = layoutView.findViewById(R.id.rel_file_content);
|
rlUpdateContent = layoutView.findViewById(R.id.rel_file_content);
|
||||||
|
llProgressContainer = layoutView.findViewById(R.id.ll_progress_container);
|
||||||
|
llButton = layoutView.findViewById(R.id.Linear_button);
|
||||||
tvConfirm.setOnClickListener(onclick);
|
tvConfirm.setOnClickListener(onclick);
|
||||||
tvCancel.setOnClickListener(onclick);
|
tvCancel.setOnClickListener(onclick);
|
||||||
if(isForceUpdate){
|
if(isForceUpdate){
|
||||||
tvCancel.setVisibility(View.GONE);
|
tvCancel.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
// 初始化 DownloadManager
|
tvVersionName.setText(bean.getLatestVersion());
|
||||||
downloadManager = (DownloadManager) mContext.getSystemService(Context.DOWNLOAD_SERVICE);
|
// 解析更新说明,支持纯文本和HTML格式
|
||||||
notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
|
String releaseNotes = bean.getReleaseNotes();
|
||||||
|
releaseNotes = releaseNotes.replace("\n", "<br>");
|
||||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||||
tvContent.setText(Html.fromHtml(bean.getVersionDescription(), Html.FROM_HTML_MODE_LEGACY));
|
tvContent.setText(Html.fromHtml(releaseNotes, Html.FROM_HTML_MODE_LEGACY));
|
||||||
} else {
|
} else {
|
||||||
|
tvContent.setText(Html.fromHtml(releaseNotes));
|
||||||
}
|
}
|
||||||
String [] desStr = bean.getVersionDescription().split("#");
|
|
||||||
String desLine = "";
|
|
||||||
for(String str : desStr){
|
|
||||||
desLine = desLine + str + "\n";
|
|
||||||
}
|
|
||||||
tvContent.setText(desLine);
|
|
||||||
tvContent.setLineSpacing(0, 1.2f);
|
tvContent.setLineSpacing(0, 1.2f);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,9 +165,18 @@ public class DialogAppUpdate {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!mIsForceUpdate && Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||||
|
if (ContextCompat.checkSelfPermission(mContext, Manifest.permission.POST_NOTIFICATIONS)
|
||||||
|
!= PackageManager.PERMISSION_GRANTED) {
|
||||||
|
if(mListener != null){
|
||||||
|
mListener.callBackGetPermisson(Manifest.permission.POST_NOTIFICATIONS);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
startUpdateApp();
|
startUpdateApp();
|
||||||
break;
|
break;
|
||||||
case R.id.tv_cencel:
|
case R.id.tv_cancel:
|
||||||
dismiss();
|
dismiss();
|
||||||
AppConfig.USER_CONFIRM_UPDATE_APP = true;
|
AppConfig.USER_CONFIRM_UPDATE_APP = true;
|
||||||
break;
|
break;
|
||||||
@@ -176,8 +187,8 @@ public class DialogAppUpdate {
|
|||||||
public void startUpdateApp() {
|
public void startUpdateApp() {
|
||||||
//强制更新,不需要隐藏dialog
|
//强制更新,不需要隐藏dialog
|
||||||
if(mIsForceUpdate){
|
if(mIsForceUpdate){
|
||||||
progressBar.setVisibility(View.VISIBLE);
|
llProgressContainer.setVisibility(View.VISIBLE);
|
||||||
rlUpdateContent.setVisibility(View.GONE);
|
llButton.setVisibility(View.GONE);
|
||||||
progressBar.setMax(100);
|
progressBar.setMax(100);
|
||||||
}else{
|
}else{
|
||||||
ToastUtil.showShort(mContext,"可在任务栏查看下载进度");
|
ToastUtil.showShort(mContext,"可在任务栏查看下载进度");
|
||||||
@@ -188,7 +199,6 @@ public class DialogAppUpdate {
|
|||||||
File apkFile = new File(downloadDir, fileName);
|
File apkFile = new File(downloadDir, fileName);
|
||||||
String apkPath = apkFile.getAbsolutePath();
|
String apkPath = apkFile.getAbsolutePath();
|
||||||
DownLoadApk downloadTask = new DownLoadApk(mContext,mIsForceUpdate);
|
DownLoadApk downloadTask = new DownLoadApk(mContext,mIsForceUpdate);
|
||||||
downloadTask.startDownload(mDwonLoadUrl, fileName,apkPath);
|
|
||||||
downloadTask.setDownLoadCallback(new DownLoadApk.DownLoadCallback() {
|
downloadTask.setDownLoadCallback(new DownLoadApk.DownLoadCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void updateProgress(long currentProgress, long total) {
|
public void updateProgress(long currentProgress, long total) {
|
||||||
@@ -209,6 +219,7 @@ public class DialogAppUpdate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
downloadTask.startDownload(mDwonLoadUrl, fileName,apkPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void show() {
|
public void show() {
|
||||||
@@ -224,4 +235,4 @@ public class DialogAppUpdate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,13 +39,17 @@ public class EspProvisionManager {
|
|||||||
private static final long CONNECT_COOLDOWN = 1200L;
|
private static final long CONNECT_COOLDOWN = 1200L;
|
||||||
private static final long QUICK_DISCONNECT_WINDOW = 3000L;
|
private static final long QUICK_DISCONNECT_WINDOW = 3000L;
|
||||||
private static final long RETRY_DELAY = 1200L;
|
private static final long RETRY_DELAY = 1200L;
|
||||||
|
private static final long PROGRESS_UPDATE_INTERVAL = 500L;
|
||||||
private static final int MAX_CONNECT_RETRY = 2;
|
private static final int MAX_CONNECT_RETRY = 2;
|
||||||
|
private static final int MAX_AUTO_PROGRESS = 99;
|
||||||
|
|
||||||
private ESPDevice espDevice;
|
private ESPDevice espDevice;
|
||||||
private ProvisionCallback callback;
|
private ProvisionCallback callback;
|
||||||
private boolean connecting;
|
private boolean connecting;
|
||||||
private boolean connected;
|
private boolean connected;
|
||||||
private boolean provisioning;
|
private boolean provisioning;
|
||||||
|
private int provisionProgress;
|
||||||
|
private int provisionTargetProgress;
|
||||||
private boolean eventBusRegistered;
|
private boolean eventBusRegistered;
|
||||||
private boolean ignoreNextDisconnectEvent;
|
private boolean ignoreNextDisconnectEvent;
|
||||||
private boolean expectDisconnected; // 标记是否预期断开(配网成功后)
|
private boolean expectDisconnected; // 标记是否预期断开(配网成功后)
|
||||||
@@ -95,6 +99,21 @@ public class EspProvisionManager {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private final Runnable provisionProgressTask = new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (!provisioning) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (provisionProgress < provisionTargetProgress) {
|
||||||
|
notifyProvisioning(provisionProgress + 1);
|
||||||
|
}
|
||||||
|
if (provisionProgress < MAX_AUTO_PROGRESS) {
|
||||||
|
mainHandler.postDelayed(provisionProgressTask, PROGRESS_UPDATE_INTERVAL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
private EspProvisionManager(Context context) {
|
private EspProvisionManager(Context context) {
|
||||||
this.context = context.getApplicationContext();
|
this.context = context.getApplicationContext();
|
||||||
this.mainHandler = new Handler(Looper.getMainLooper());
|
this.mainHandler = new Handler(Looper.getMainLooper());
|
||||||
@@ -137,6 +156,10 @@ public class EspProvisionManager {
|
|||||||
return provisioning;
|
return provisioning;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getProvisionProgress() {
|
||||||
|
return provisionProgress;
|
||||||
|
}
|
||||||
|
|
||||||
public void connect(String deviceAddress, String deviceName) {
|
public void connect(String deviceAddress, String deviceName) {
|
||||||
connect(deviceAddress, deviceName, AppConfig.BLUETOOTH_DEVICE_UUID);
|
connect(deviceAddress, deviceName, AppConfig.BLUETOOTH_DEVICE_UUID);
|
||||||
}
|
}
|
||||||
@@ -277,10 +300,13 @@ public class EspProvisionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
provisioning = true;
|
provisioning = true;
|
||||||
|
provisionProgress = 0;
|
||||||
|
provisionTargetProgress = 29;
|
||||||
mainHandler.removeCallbacks(provisionTimeoutTask);
|
mainHandler.removeCallbacks(provisionTimeoutTask);
|
||||||
mainHandler.postDelayed(provisionTimeoutTask, ProvisionConfig.PROVISION_TIMEOUT);
|
mainHandler.postDelayed(provisionTimeoutTask, ProvisionConfig.PROVISION_TIMEOUT);
|
||||||
notifyProvisioning(0);
|
notifyProvisioning(0);
|
||||||
|
startProvisionProgressTask();
|
||||||
|
//wifi 密码 回调
|
||||||
espDevice.provision(ssid, password == null ? "" : password, new ProvisionListener() {
|
espDevice.provision(ssid, password == null ? "" : password, new ProvisionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void createSessionFailed(Exception e) {
|
public void createSessionFailed(Exception e) {
|
||||||
@@ -289,7 +315,7 @@ public class EspProvisionManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void wifiConfigSent() {
|
public void wifiConfigSent() {
|
||||||
notifyProvisioning(30);
|
advanceProvisionProgress(30, 59);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -300,7 +326,7 @@ public class EspProvisionManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void wifiConfigApplied() {
|
public void wifiConfigApplied() {
|
||||||
notifyProvisioning(60);
|
advanceProvisionProgress(60, MAX_AUTO_PROGRESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -456,9 +482,12 @@ public class EspProvisionManager {
|
|||||||
private void resetState(boolean clearDevice) {
|
private void resetState(boolean clearDevice) {
|
||||||
mainHandler.removeCallbacks(connectionTimeoutTask);
|
mainHandler.removeCallbacks(connectionTimeoutTask);
|
||||||
mainHandler.removeCallbacks(provisionTimeoutTask);
|
mainHandler.removeCallbacks(provisionTimeoutTask);
|
||||||
|
stopProvisionProgressTask();
|
||||||
connecting = false;
|
connecting = false;
|
||||||
connected = false;
|
connected = false;
|
||||||
provisioning = false;
|
provisioning = false;
|
||||||
|
provisionProgress = 0;
|
||||||
|
provisionTargetProgress = 0;
|
||||||
ignoreNextDisconnectEvent = false;
|
ignoreNextDisconnectEvent = false;
|
||||||
expectDisconnected = false;
|
expectDisconnected = false;
|
||||||
if (clearDevice) {
|
if (clearDevice) {
|
||||||
@@ -478,6 +507,7 @@ public class EspProvisionManager {
|
|||||||
|
|
||||||
private void finishProvisionSuccess() {
|
private void finishProvisionSuccess() {
|
||||||
mainHandler.removeCallbacks(provisionTimeoutTask);
|
mainHandler.removeCallbacks(provisionTimeoutTask);
|
||||||
|
stopProvisionProgressTask();
|
||||||
provisioning = false;
|
provisioning = false;
|
||||||
expectDisconnected = true; // 标记为预期断开
|
expectDisconnected = true; // 标记为预期断开
|
||||||
notifyProvisioning(100);
|
notifyProvisioning(100);
|
||||||
@@ -486,10 +516,27 @@ public class EspProvisionManager {
|
|||||||
|
|
||||||
private void finishProvisionFailed(int errorCode, String message) {
|
private void finishProvisionFailed(int errorCode, String message) {
|
||||||
mainHandler.removeCallbacks(provisionTimeoutTask);
|
mainHandler.removeCallbacks(provisionTimeoutTask);
|
||||||
|
stopProvisionProgressTask();
|
||||||
provisioning = false;
|
provisioning = false;
|
||||||
notifyFailed(errorCode, message);
|
notifyFailed(errorCode, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void advanceProvisionProgress(int minProgress, int targetProgress) {
|
||||||
|
int nextProgress = Math.max(provisionProgress, minProgress);
|
||||||
|
provisionTargetProgress = Math.max(nextProgress, Math.min(targetProgress, MAX_AUTO_PROGRESS));
|
||||||
|
notifyProvisioning(nextProgress);
|
||||||
|
startProvisionProgressTask();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void startProvisionProgressTask() {
|
||||||
|
mainHandler.removeCallbacks(provisionProgressTask);
|
||||||
|
mainHandler.postDelayed(provisionProgressTask, PROGRESS_UPDATE_INTERVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void stopProvisionProgressTask() {
|
||||||
|
mainHandler.removeCallbacks(provisionProgressTask);
|
||||||
|
}
|
||||||
|
|
||||||
private String getProvisionFailureMessage(ESPConstants.ProvisionFailureReason failureReason) {
|
private String getProvisionFailureMessage(ESPConstants.ProvisionFailureReason failureReason) {
|
||||||
if (failureReason == ESPConstants.ProvisionFailureReason.AUTH_FAILED) {
|
if (failureReason == ESPConstants.ProvisionFailureReason.AUTH_FAILED) {
|
||||||
return "WiFi 密码错误";
|
return "WiFi 密码错误";
|
||||||
@@ -540,11 +587,13 @@ public class EspProvisionManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void notifyProvisioning(final int progress) {
|
private void notifyProvisioning(final int progress) {
|
||||||
|
provisionProgress = Math.max(0, Math.min(progress, 100));
|
||||||
runOnMainThread(new Runnable() {
|
runOnMainThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
provisionProgress = Math.max(0, Math.min(progress, 100));
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onProvisioning(progress);
|
callback.onProvisioning(provisionProgress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
package com.ckkj.water.guide;
|
package com.ckkj.water.guide;
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.content.res.Configuration;
|
||||||
|
import android.content.res.Resources;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.ckkj.water.AppConfig;
|
import com.ckkj.water.AppConfig;
|
||||||
import com.ckkj.water.login.LoginActivity;
|
import com.ckkj.water.login.LoginActivity;
|
||||||
import com.ckkj.water.login.RegisterActivity;
|
|
||||||
import com.ckkj.water.login.RegisterSuccessActivity;
|
|
||||||
import com.gyf.immersionbar.ImmersionBar;
|
import com.gyf.immersionbar.ImmersionBar;
|
||||||
import com.ckkj.water.ConstantUtil;
|
import com.ckkj.water.ConstantUtil;
|
||||||
import com.ckkj.water.MyApplication;
|
import com.ckkj.water.MyApplication;
|
||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
import com.ckkj.water.base.BaseActivity;
|
import com.ckkj.water.base.BaseActivity;
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
import com.ckkj.water.databinding.GuideLayoutBinding;
|
import com.ckkj.water.databinding.GuideLayoutBinding;
|
||||||
import com.ckkj.water.main.MainContract;
|
import com.ckkj.water.main.MainContract;
|
||||||
import com.ckkj.water.main.MainImpl;
|
import com.ckkj.water.main.MainImpl;
|
||||||
@@ -26,8 +26,9 @@ import com.ckkj.water.network.BaseBean;
|
|||||||
import com.ckkj.water.utils.dataUtil.SharePreUtil;
|
import com.ckkj.water.utils.dataUtil.SharePreUtil;
|
||||||
import com.ckkj.water.utils.manager.ActivityManager;
|
import com.ckkj.water.utils.manager.ActivityManager;
|
||||||
|
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
import me.jessyan.autosize.internal.CancelAdapt;
|
import me.jessyan.autosize.internal.CancelAdapt;
|
||||||
import me.jessyan.autosize.internal.CustomAdapt;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author fengxiaoyang
|
* @author fengxiaoyang
|
||||||
@@ -56,8 +57,13 @@ public class LaunchActivity extends BaseActivity<GuideLayoutBinding, MainPresent
|
|||||||
//首次进入,弹框提示隐私政策
|
//首次进入,弹框提示隐私政策
|
||||||
if (mIsFirstEnterApp) {
|
if (mIsFirstEnterApp) {
|
||||||
//首次进入
|
//首次进入
|
||||||
showDialogtext("温馨提示", mContext.getResources().getString(R.string.tips_yinsizhengce_dialog),
|
showDialogtext(
|
||||||
"同意", "拒绝", "用户隐私协议", new OnDialogClick() {
|
getSystemLanguageString(R.string.tip_text),
|
||||||
|
getSystemLanguageString(R.string.tips_yinsizhengce_dialog),
|
||||||
|
getSystemLanguageString(R.string.agree),
|
||||||
|
getSystemLanguageString(R.string.reject),
|
||||||
|
getSystemLanguageString(R.string.user_agreement)
|
||||||
|
, new OnDialogClick() {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCancelClick() {
|
public void onCancelClick() {
|
||||||
@@ -116,6 +122,16 @@ public class LaunchActivity extends BaseActivity<GuideLayoutBinding, MainPresent
|
|||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String getSystemLanguageString(int resId) {
|
||||||
|
Locale systemLocale = Resources.getSystem().getConfiguration().getLocales().get(0);
|
||||||
|
Locale targetLocale = Locale.CHINESE.getLanguage().equals(systemLocale.getLanguage())
|
||||||
|
? Locale.SIMPLIFIED_CHINESE
|
||||||
|
: Locale.ENGLISH;
|
||||||
|
Configuration configuration = new Configuration(getResources().getConfiguration());
|
||||||
|
configuration.setLocale(targetLocale);
|
||||||
|
return createConfigurationContext(configuration).getString(resId);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MainPresenter createPresenter() {
|
public MainPresenter createPresenter() {
|
||||||
|
|||||||
@@ -15,9 +15,7 @@ import com.ckkj.water.history.entity.WateringRecord;
|
|||||||
import com.ckkj.water.history.mvp.HistoryContract;
|
import com.ckkj.water.history.mvp.HistoryContract;
|
||||||
import com.ckkj.water.history.mvp.HistoryPresenter;
|
import com.ckkj.water.history.mvp.HistoryPresenter;
|
||||||
import com.ckkj.water.network.BaseBean;
|
import com.ckkj.water.network.BaseBean;
|
||||||
import com.ckkj.water.plan.BindDeviceFragment;
|
import com.ckkj.water.plan.adapter.ViewPagerAdapter;
|
||||||
import com.ckkj.water.plan.WaterConfigFragment;
|
|
||||||
import com.ckkj.water.plate.adapter.ViewPagerAdapter;
|
|
||||||
import com.ckkj.water.utils.manager.ThemeManager;
|
import com.ckkj.water.utils.manager.ThemeManager;
|
||||||
import com.gyf.immersionbar.ImmersionBar;
|
import com.gyf.immersionbar.ImmersionBar;
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,11 @@ import com.ckkj.water.plan.mvp.WaterPlanImpl;
|
|||||||
import com.ckkj.water.plan.mvp.WaterPlanPresenter;
|
import com.ckkj.water.plan.mvp.WaterPlanPresenter;
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
import com.ckkj.water.utils.show.ToastUtil;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author fengxiaoyang
|
* @author fengxiaoyang
|
||||||
@@ -47,10 +51,79 @@ public class StatisticFragment extends BaseFragment<WaterCountFragmentLayoutBind
|
|||||||
viewBinding.tvThisMonthValue.setText(entity.getMonCount()+"");
|
viewBinding.tvThisMonthValue.setText(entity.getMonCount()+"");
|
||||||
viewBinding.tvPlanValue.setText(entity.getSchedule()+"");
|
viewBinding.tvPlanValue.setText(entity.getSchedule()+"");
|
||||||
viewBinding.tvManuallyValue.setText(entity.getManualNum()+"");
|
viewBinding.tvManuallyValue.setText(entity.getManualNum()+"");
|
||||||
viewBinding.tvTotalDurationValue.setText(entity.getAllTime()+"");
|
setTotalDuration(entity.getAllTime());
|
||||||
|
setAverageDuration(entity.getAverageTime());
|
||||||
|
setWeekAndMonthDate();
|
||||||
// viewBinding.tvTotalValue.setText(entity.getCount()+"");
|
// viewBinding.tvTotalValue.setText(entity.getCount()+"");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setTotalDuration(int totalMinutes) {
|
||||||
|
if (totalMinutes < 60) {
|
||||||
|
viewBinding.tvTotalDurationValue.setText(totalMinutes + "");
|
||||||
|
viewBinding.tvTotalDurationHourUnit.setText("min");
|
||||||
|
viewBinding.tvTotalDurationMinValue.setVisibility(android.view.View.GONE);
|
||||||
|
viewBinding.tvTotalDurationMinUnit.setVisibility(android.view.View.GONE);
|
||||||
|
} else {
|
||||||
|
int hours = totalMinutes / 60;
|
||||||
|
int minutes = totalMinutes % 60;
|
||||||
|
viewBinding.tvTotalDurationHourUnit.setText("h");
|
||||||
|
viewBinding.tvTotalDurationValue.setText(hours + "");
|
||||||
|
if (minutes == 0) {
|
||||||
|
viewBinding.tvTotalDurationMinValue.setVisibility(android.view.View.GONE);
|
||||||
|
viewBinding.tvTotalDurationMinUnit.setVisibility(android.view.View.GONE);
|
||||||
|
} else {
|
||||||
|
viewBinding.tvTotalDurationMinValue.setVisibility(android.view.View.VISIBLE);
|
||||||
|
viewBinding.tvTotalDurationMinUnit.setVisibility(android.view.View.VISIBLE);
|
||||||
|
viewBinding.tvTotalDurationMinValue.setText(minutes + "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setAverageDuration(int avgMinutes) {
|
||||||
|
if (avgMinutes < 60) {
|
||||||
|
viewBinding.tvAverageHourValue.setText(avgMinutes + "");
|
||||||
|
viewBinding.tvAverageHourUnit.setText("min");
|
||||||
|
viewBinding.tvAverageMinValue.setVisibility(android.view.View.GONE);
|
||||||
|
viewBinding.tvAverageMinUnit.setVisibility(android.view.View.GONE);
|
||||||
|
} else {
|
||||||
|
int hours = avgMinutes / 60;
|
||||||
|
int minutes = avgMinutes % 60;
|
||||||
|
viewBinding.tvAverageHourUnit.setText("h");
|
||||||
|
viewBinding.tvAverageHourValue.setText(hours + "");
|
||||||
|
if (minutes == 0) {
|
||||||
|
viewBinding.tvAverageMinValue.setVisibility(android.view.View.GONE);
|
||||||
|
viewBinding.tvAverageMinUnit.setVisibility(android.view.View.GONE);
|
||||||
|
} else {
|
||||||
|
viewBinding.tvAverageMinValue.setVisibility(android.view.View.VISIBLE);
|
||||||
|
viewBinding.tvAverageMinUnit.setVisibility(android.view.View.VISIBLE);
|
||||||
|
viewBinding.tvAverageMinValue.setText(minutes + "");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setWeekAndMonthDate() {
|
||||||
|
SimpleDateFormat monthFormat = new SimpleDateFormat("M月", Locale.CHINA);
|
||||||
|
SimpleDateFormat dayFormat = new SimpleDateFormat("M.d", Locale.CHINA);
|
||||||
|
|
||||||
|
Calendar calendar = Calendar.getInstance();
|
||||||
|
|
||||||
|
// 设置当月日期显示
|
||||||
|
viewBinding.tvThisMonthDate.setVisibility(android.view.View.VISIBLE);
|
||||||
|
viewBinding.tvThisMonthDate.setText(monthFormat.format(calendar.getTime()));
|
||||||
|
|
||||||
|
// 计算本周的开始日期(周一)和结束日期(周日)
|
||||||
|
int dayOfWeek = calendar.get(Calendar.DAY_OF_WEEK);
|
||||||
|
int mondayOffset = (dayOfWeek == Calendar.SUNDAY) ? -6 : Calendar.MONDAY - dayOfWeek;
|
||||||
|
calendar.add(Calendar.DAY_OF_MONTH, mondayOffset);
|
||||||
|
Date weekStart = calendar.getTime();
|
||||||
|
calendar.add(Calendar.DAY_OF_MONTH, 6);
|
||||||
|
Date weekEnd = calendar.getTime();
|
||||||
|
|
||||||
|
// 设置本周日期显示
|
||||||
|
viewBinding.tvWeekDate.setVisibility(android.view.View.VISIBLE);
|
||||||
|
viewBinding.tvWeekDate.setText(dayFormat.format(weekStart) + " - " + dayFormat.format(weekEnd));
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HistoryPresenter createPresenter() {
|
public HistoryPresenter createPresenter() {
|
||||||
return new HistoryPresenter(new HistoryImpl());
|
return new HistoryPresenter(new HistoryImpl());
|
||||||
|
|||||||
@@ -99,8 +99,11 @@ public class TabHistoryFragment extends BaseFragment<TabHistoryFragmentLayoutBin
|
|||||||
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
|
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
|
||||||
switch (view.getId()){
|
switch (view.getId()){
|
||||||
case R.id.img_delete:
|
case R.id.img_delete:
|
||||||
showDialogtext(null, false, false, "提示",
|
showDialogtext(null, false, false,
|
||||||
"确定删除该记录", "取消", "删除",
|
getString(R.string.tip_text),
|
||||||
|
getString(R.string.confirm_delete_record),
|
||||||
|
getString(R.string.cancel_text),
|
||||||
|
getString(R.string.confirm_text),
|
||||||
new OnDialogClick() {
|
new OnDialogClick() {
|
||||||
@Override
|
@Override
|
||||||
public void onCancelClick() {
|
public void onCancelClick() {
|
||||||
@@ -180,15 +183,16 @@ public class TabHistoryFragment extends BaseFragment<TabHistoryFragmentLayoutBin
|
|||||||
.asCustom(new CustomTypeFilterPopupView(getContext(), new CustomTypeFilterPopupView.OnClickListener() {
|
.asCustom(new CustomTypeFilterPopupView(getContext(), new CustomTypeFilterPopupView.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void callBack(boolean mSelManual, boolean mSelAuto) {
|
public void callBack(boolean mSelManual, boolean mSelAuto) {
|
||||||
if(mSelManual){
|
if (mSelManual) {
|
||||||
mFilterType = 1;
|
mFilterType = 1;
|
||||||
}
|
} else if (mSelAuto) {
|
||||||
if(mSelAuto){
|
|
||||||
mFilterType = 0;
|
mFilterType = 0;
|
||||||
|
} else {
|
||||||
|
mFilterType = -1;
|
||||||
}
|
}
|
||||||
getWaterHistoryList();
|
getWaterHistoryList();
|
||||||
}
|
}
|
||||||
}));
|
}, mFilterType));
|
||||||
typePopupView.show();
|
typePopupView.show();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ public class WateringHistoryAdapter extends BaseQuickAdapter<WateringRecord, Bas
|
|||||||
helper.setText(R.id.tv_plan_duration,mContext.getString(R.string.device_work_times_title)
|
helper.setText(R.id.tv_plan_duration,mContext.getString(R.string.device_work_times_title)
|
||||||
+ ":" + item.getDurationMin() + "min");
|
+ ":" + item.getDurationMin() + "min");
|
||||||
helper.setText(R.id.tv_plan_type,mContext.getString(R.string.tab_filter_type)
|
helper.setText(R.id.tv_plan_type,mContext.getString(R.string.tab_filter_type)
|
||||||
+ ":" + item.getTriggerType());
|
+ ":" + (item.getTriggerType().equals("0") ?
|
||||||
|
mContext.getString(R.string.history_filter_auto) :
|
||||||
|
mContext.getString(R.string.history_filter_manual)));
|
||||||
helper.addOnClickListener(R.id.img_delete);
|
helper.addOnClickListener(R.id.img_delete);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
package com.ckkj.water.history.mvp;
|
package com.ckkj.water.history.mvp;
|
||||||
|
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
|
||||||
import com.ckkj.water.history.entity.WaterStatisticsEntity;
|
import com.ckkj.water.history.entity.WaterStatisticsEntity;
|
||||||
import com.ckkj.water.history.entity.WateringRecord;
|
import com.ckkj.water.history.entity.WateringRecord;
|
||||||
import com.ckkj.water.network.BaseBean;
|
import com.ckkj.water.network.BaseBean;
|
||||||
|
|||||||
@@ -28,19 +28,19 @@ public class HistoryPresenter extends BasePresenter<HistoryContract.HistoryView>
|
|||||||
public void getWaterHistoryList(int mCurrentPage, String mFilterStartTime, String mFilterEndTime, int mFilterType) {
|
public void getWaterHistoryList(int mCurrentPage, String mFilterStartTime, String mFilterEndTime, int mFilterType) {
|
||||||
Map<String,String> map = new HashMap<>();
|
Map<String,String> map = new HashMap<>();
|
||||||
map.put("pageNum",mCurrentPage+"");
|
map.put("pageNum",mCurrentPage+"");
|
||||||
|
|
||||||
if(!TextUtils.isEmpty(mFilterStartTime)){
|
if(!TextUtils.isEmpty(mFilterStartTime)){
|
||||||
// map.put("beginTime",mFilterStartTime);
|
|
||||||
map.put("params[beginTime]", mFilterStartTime);
|
map.put("params[beginTime]", mFilterStartTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!TextUtils.isEmpty(mFilterStartTime)){
|
if(!TextUtils.isEmpty(mFilterStartTime)){
|
||||||
// map.put("endTime",mFilterEndTime);
|
|
||||||
map.put("params[endTime]", mFilterEndTime);
|
map.put("params[endTime]", mFilterEndTime);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(mFilterType != -1){
|
if(mFilterType != -1){
|
||||||
map.put("triggerType",mFilterType+"");
|
map.put("triggerType",mFilterType+"");
|
||||||
}
|
}
|
||||||
|
|
||||||
impl.getHistoryList(map, new HistoryContract.CallBack<List<WateringRecord>>() {
|
impl.getHistoryList(map, new HistoryContract.CallBack<List<WateringRecord>>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(List<WateringRecord> list,int total) {
|
public void success(List<WateringRecord> list,int total) {
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import android.content.Intent;
|
|||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
@@ -23,11 +22,9 @@ import com.ckkj.water.custom.view.CustomRefreshHeader;
|
|||||||
import com.ckkj.water.databinding.IndexFragmentLayoutBinding;
|
import com.ckkj.water.databinding.IndexFragmentLayoutBinding;
|
||||||
import com.ckkj.water.ConstantUtil;
|
import com.ckkj.water.ConstantUtil;
|
||||||
import com.ckkj.water.device.AddDeviceActivity;
|
import com.ckkj.water.device.AddDeviceActivity;
|
||||||
import com.ckkj.water.device.AddDeviceActivity_copy;
|
|
||||||
import com.ckkj.water.device.DeviceControlActivity;
|
import com.ckkj.water.device.DeviceControlActivity;
|
||||||
import com.ckkj.water.device.DeviceReNameActivity;
|
import com.ckkj.water.device.DeviceReNameActivity;
|
||||||
import com.ckkj.water.device.SelectWifiActivity;
|
import com.ckkj.water.device.SelectWifiActivity;
|
||||||
import com.ckkj.water.history.entity.WateringRecord;
|
|
||||||
import com.ckkj.water.index.adapter.DeviceAdapter;
|
import com.ckkj.water.index.adapter.DeviceAdapter;
|
||||||
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
||||||
import com.ckkj.water.index.mvp.IndexContract;
|
import com.ckkj.water.index.mvp.IndexContract;
|
||||||
@@ -35,9 +32,7 @@ import com.ckkj.water.index.mvp.IndexImpl;
|
|||||||
import com.ckkj.water.index.mvp.IndexPresenter;
|
import com.ckkj.water.index.mvp.IndexPresenter;
|
||||||
import com.ckkj.water.network.BaseBean;
|
import com.ckkj.water.network.BaseBean;
|
||||||
import com.ckkj.water.permission.PermissionActivity;
|
import com.ckkj.water.permission.PermissionActivity;
|
||||||
import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
import com.ckkj.water.utils.show.ToastUtil;
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.maning.mlkitscanner.scan.MNScanManager;
|
import com.maning.mlkitscanner.scan.MNScanManager;
|
||||||
import com.maning.mlkitscanner.scan.callback.act.MNScanCallback;
|
import com.maning.mlkitscanner.scan.callback.act.MNScanCallback;
|
||||||
import com.scwang.smart.refresh.footer.ClassicsFooter;
|
import com.scwang.smart.refresh.footer.ClassicsFooter;
|
||||||
@@ -141,7 +136,7 @@ public class IndexFragment extends BaseFragment<IndexFragmentLayoutBinding, Inde
|
|||||||
|
|
||||||
case R.id.img_add:
|
case R.id.img_add:
|
||||||
if(checkBluetoothPermissions()){
|
if(checkBluetoothPermissions()){
|
||||||
goTo(mContext, AddDeviceActivity_copy.class,null);
|
goTo(mContext, AddDeviceActivity.class,null);
|
||||||
}else{
|
}else{
|
||||||
goTo(mContext, PermissionActivity.class,null);
|
goTo(mContext, PermissionActivity.class,null);
|
||||||
|
|
||||||
@@ -165,13 +160,13 @@ public class IndexFragment extends BaseFragment<IndexFragmentLayoutBinding, Inde
|
|||||||
ArrayList<String> results = data.getStringArrayListExtra(MNScanManager.INTENT_KEY_RESULT_SUCCESS);
|
ArrayList<String> results = data.getStringArrayListExtra(MNScanManager.INTENT_KEY_RESULT_SUCCESS);
|
||||||
|
|
||||||
if (results == null || results.isEmpty()) {
|
if (results == null || results.isEmpty()) {
|
||||||
ToastUtil.showShort(mContext, "二维码内容不能为空");
|
ToastUtil.showShort(mContext, getString(R.string.qr_content_empty));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String scanContent = results.get(0);
|
String scanContent = results.get(0);
|
||||||
if (TextUtils.isEmpty(scanContent)) {
|
if (TextUtils.isEmpty(scanContent)) {
|
||||||
ToastUtil.showShort(mContext, "二维码内容不能为空");
|
ToastUtil.showShort(mContext, getString(R.string.qr_content_empty));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,14 +174,14 @@ public class IndexFragment extends BaseFragment<IndexFragmentLayoutBinding, Inde
|
|||||||
try {
|
try {
|
||||||
json = new JSONObject(scanContent);
|
json = new JSONObject(scanContent);
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
ToastUtil.showShort(mContext, "二维码格式错误");
|
ToastUtil.showShort(mContext, getString(R.string.qr_format_error));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
WaterDeviceEntity entity = new WaterDeviceEntity();
|
WaterDeviceEntity entity = new WaterDeviceEntity();
|
||||||
if(TextUtils.isEmpty(json.getString("mac"))
|
if(TextUtils.isEmpty(json.getString("mac"))
|
||||||
|| TextUtils.isEmpty(json.getString("name"))){
|
|| TextUtils.isEmpty(json.getString("name"))){
|
||||||
ToastUtil.showShort(mContext,"请扫描正确的二维码");
|
ToastUtil.showShort(mContext,getString(R.string.scan_correct_qr));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
entity.setMacAddress(json.getString("mac"));
|
entity.setMacAddress(json.getString("mac"));
|
||||||
@@ -196,7 +191,7 @@ public class IndexFragment extends BaseFragment<IndexFragmentLayoutBinding, Inde
|
|||||||
mPresenter.bindDeviceStatus(entity);
|
mPresenter.bindDeviceStatus(entity);
|
||||||
}
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
ToastUtil.showShort(mContext, "二维码格式错误");
|
ToastUtil.showShort(mContext, getString(R.string.scan_correct_qr));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -204,7 +199,7 @@ public class IndexFragment extends BaseFragment<IndexFragmentLayoutBinding, Inde
|
|||||||
String resultError = data.getStringExtra(MNScanManager.INTENT_KEY_RESULT_ERROR);
|
String resultError = data.getStringExtra(MNScanManager.INTENT_KEY_RESULT_ERROR);
|
||||||
break;
|
break;
|
||||||
case MNScanManager.RESULT_CANCLE:
|
case MNScanManager.RESULT_CANCLE:
|
||||||
ToastUtil.showShort(mContext,"取消扫码");
|
ToastUtil.showShort(mContext,getString(R.string.cancel_scan));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -215,6 +210,21 @@ public class IndexFragment extends BaseFragment<IndexFragmentLayoutBinding, Inde
|
|||||||
deviceAdapter = new DeviceAdapter(mContext,R.layout.index_device_list_item,devList);
|
deviceAdapter = new DeviceAdapter(mContext,R.layout.index_device_list_item,devList);
|
||||||
viewBinding.rvDevices.setAdapter(deviceAdapter);
|
viewBinding.rvDevices.setAdapter(deviceAdapter);
|
||||||
deviceAdapter.setOnItemClickListener((adapter, view, position) -> {
|
deviceAdapter.setOnItemClickListener((adapter, view, position) -> {
|
||||||
|
if(!devList.get(position).getBindingStatus().equals("ACTIVE")){
|
||||||
|
showDialogtext(null, false, false,
|
||||||
|
getString(R.string.tip_text), getString(R.string.device_no_permission_delete_message),
|
||||||
|
getString(R.string.cancel_text), getString(R.string.confirm_text), new BaseFragment.OnDialogClick() {
|
||||||
|
@Override
|
||||||
|
public void onCancelClick() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfirmClick() {
|
||||||
|
mPresenter.removeDeviceEntry(devList.get(position).getDeviceNo());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putSerializable("device_info",devList.get(position));
|
bundle.putSerializable("device_info",devList.get(position));
|
||||||
goTo(mContext, DeviceControlActivity.class,bundle);
|
goTo(mContext, DeviceControlActivity.class,bundle);
|
||||||
@@ -258,12 +268,19 @@ public class IndexFragment extends BaseFragment<IndexFragmentLayoutBinding, Inde
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeDeviceEntrySuccess(BaseBean bean) {
|
||||||
|
ToastUtil.showShort(mContext, getString(R.string.remove_success));
|
||||||
|
mCurrentPage = 1;
|
||||||
|
mPresenter.getDevicesList(mCurrentPage);
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 查询当前设备绑定状态
|
* 查询当前设备绑定状态
|
||||||
* @param entity
|
* @param entity
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void queryDeviceBindStatusSuccess(WaterDeviceEntity entity) {
|
public void queryDeviceBindStatusSuccess(WaterDeviceEntity entity) {
|
||||||
|
pendingDeviceEntity = entity.getBindDevice();
|
||||||
switch (entity.getBindDeviceStatus()){
|
switch (entity.getBindDeviceStatus()){
|
||||||
|
|
||||||
case 200:
|
case 200:
|
||||||
@@ -274,9 +291,10 @@ public class IndexFragment extends BaseFragment<IndexFragmentLayoutBinding, Inde
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 302:
|
case 302:
|
||||||
|
case 305:
|
||||||
// 这是一台没有在mqtt中注册的设备,需要通过蓝牙连接配网,(可理解为新设备,走蓝牙,配网)
|
// 这是一台没有在mqtt中注册的设备,需要通过蓝牙连接配网,(可理解为新设备,走蓝牙,配网)
|
||||||
// 先检查蓝牙权限和开启状态
|
// 先检查蓝牙权限和开启状态
|
||||||
pendingDeviceEntity = entity;
|
|
||||||
checkBluetoothAndProceed();
|
checkBluetoothAndProceed();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -428,7 +446,7 @@ public class IndexFragment extends BaseFragment<IndexFragmentLayoutBinding, Inde
|
|||||||
public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
|
public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
|
||||||
hidePermissionDialog();
|
hidePermissionDialog();
|
||||||
if (requestCode == REQUEST_EVENT_CODE_BLUETOOTH_PERMISSION) {
|
if (requestCode == REQUEST_EVENT_CODE_BLUETOOTH_PERMISSION) {
|
||||||
ToastUtil.showShort(mContext, "需要蓝牙权限才能添加设备");
|
ToastUtil.showShort(mContext, getString(R.string.bluetooth_permission_required));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -456,7 +474,7 @@ public class IndexFragment extends BaseFragment<IndexFragmentLayoutBinding, Inde
|
|||||||
goToDeviceProvisioning();
|
goToDeviceProvisioning();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ToastUtil.showShort(mContext, "需要蓝牙权限才能添加设备");
|
ToastUtil.showShort(mContext, getString(R.string.bluetooth_permission_required));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -466,13 +484,13 @@ public class IndexFragment extends BaseFragment<IndexFragmentLayoutBinding, Inde
|
|||||||
super.onActivityResult(requestCode, resultCode, data);
|
super.onActivityResult(requestCode, resultCode, data);
|
||||||
if (requestCode == REQUEST_ENABLE_BT) {
|
if (requestCode == REQUEST_ENABLE_BT) {
|
||||||
if (resultCode == -1) { // RESULT_OK
|
if (resultCode == -1) { // RESULT_OK
|
||||||
ToastUtil.showShort(mContext, "蓝牙已开启");
|
ToastUtil.showShort(mContext, getString(R.string.bluetooth_enabled));
|
||||||
bluetoothReady = true;
|
bluetoothReady = true;
|
||||||
if (pendingDeviceEntity != null) {
|
if (pendingDeviceEntity != null) {
|
||||||
goToDeviceProvisioning();
|
goToDeviceProvisioning();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ToastUtil.showShort(mContext, "请开启蓝牙以添加设备");
|
ToastUtil.showShort(mContext, getString(R.string.enable_bluetooth_to_add_device));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -480,3 +498,5 @@ public class IndexFragment extends BaseFragment<IndexFragmentLayoutBinding, Inde
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import com.chad.library.adapter.base.BaseViewHolder;
|
|||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
||||||
import com.ckkj.water.utils.manager.PowerIconManage;
|
import com.ckkj.water.utils.manager.PowerIconManage;
|
||||||
import com.esafirm.imagepicker.model.Image;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -28,69 +27,49 @@ public class DeviceAdapter extends BaseQuickAdapter<WaterDeviceEntity, BaseViewH
|
|||||||
ImageView imgPower = holder.getView(R.id.img_battery);
|
ImageView imgPower = holder.getView(R.id.img_battery);
|
||||||
View viewStatus = holder.getView(R.id.view_status_dot);
|
View viewStatus = holder.getView(R.id.view_status_dot);
|
||||||
holder.setText(R.id.tv_device_name,item.getDeviceName());
|
holder.setText(R.id.tv_device_name,item.getDeviceName());
|
||||||
holder.setText(R.id.tv_device_serial,item.getDeviceSn());
|
holder.setText(R.id.tv_device_serial,item.getDeviceNo());
|
||||||
switch (item.getWorkStatus()){
|
//设备联网在线
|
||||||
case "0"://待机
|
if ("1".equals(item.getStatus())) {
|
||||||
holder.setText(R.id.tv_device_status,mContext.getString(R.string.device_status_not_working));
|
switch (item.getWorkStatus() == null ? "0" : item.getWorkStatus()){
|
||||||
holder.setTextColor(R.id.tv_device_status,mContext.getResources().getColor(R.color.color_999999));
|
case "0"://待机
|
||||||
viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_status_dot_999999));
|
holder.setText(R.id.tv_device_status,mContext.getString(R.string.device_status_not_working));
|
||||||
break;
|
holder.setTextColor(R.id.tv_device_status,mContext.getResources().getColor(R.color.color_999999));
|
||||||
|
viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_status_dot_999999));
|
||||||
|
break;
|
||||||
|
|
||||||
case "1"://工作中
|
case "1"://工作中
|
||||||
holder.setText(R.id.tv_device_status,mContext.getString(R.string.device_status_working));
|
holder.setText(R.id.tv_device_status,mContext.getString(R.string.device_status_working));
|
||||||
holder.setTextColor(R.id.tv_device_status,mContext.getResources().getColor(R.color.color_24B326));
|
holder.setTextColor(R.id.tv_device_status,mContext.getResources().getColor(R.color.color_24B326));
|
||||||
viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_status_dot_green));
|
viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_status_dot_green));
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
holder.setText(R.id.tv_device_status,mContext.getString(R.string.device_status_offline));
|
||||||
|
holder.setTextColor(R.id.tv_device_status,mContext.getResources().getColor(R.color.color_E60000));
|
||||||
|
viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_status_dot_red));
|
||||||
}
|
}
|
||||||
// if(item.getStatus().equals("1") || item.getStatus().equals("2")){
|
|
||||||
// }else{
|
|
||||||
// holder.setText(R.id.tv_device_status,mContext.getString(R.string.device_status_offline));
|
|
||||||
// holder.setTextColor(R.id.tv_device_status,mContext.getResources().getColor(R.color.color_999999));
|
|
||||||
// viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_status_dot_999999));
|
|
||||||
// }
|
|
||||||
|
|
||||||
holder.setText(R.id.tv_battery_level,item.getPowerLevel());
|
|
||||||
imgPower.setImageResource(PowerIconManage.getInstance().getPowerIcon(Integer.parseInt(item.getPowerLevel())));
|
String powerLevel = item.getPowerLevel();
|
||||||
|
int power = 0;
|
||||||
|
if (powerLevel != null) {
|
||||||
|
try {
|
||||||
|
power = Integer.parseInt(powerLevel.trim());
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
power = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ("1".equals(item.getPowerStatus())) {
|
||||||
|
holder.setText(R.id.tv_battery_level, "充电中 " + (powerLevel == null ? "0%" : powerLevel + "%"));
|
||||||
|
imgPower.setImageResource(R.mipmap.icon_charging);
|
||||||
|
} else {
|
||||||
|
holder.setText(R.id.tv_battery_level, powerLevel == null ? "0%" : powerLevel + "%");
|
||||||
|
imgPower.setImageResource(PowerIconManage.getInstance().getPowerIcon(power));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// public DeviceAdapter() {
|
|
||||||
// super();
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void onBindViewHolder(@NonNull ViewHolder holder, int position, @NonNull String data) {
|
|
||||||
// holder.tvDeviceName.setText(deviceNames[position]);
|
|
||||||
// holder.tvDeviceSerial.setText(deviceSerials[position]);
|
|
||||||
// holder.tvDeviceStatus.setText(deviceStatuses[position]);
|
|
||||||
// holder.tvBatteryLevel.setText(batteryLevels[position] + "%");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @NonNull
|
|
||||||
// @Override
|
|
||||||
// public ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
|
||||||
// View view = LayoutInflater.from(parent.getContext())
|
|
||||||
// .inflate(R.layout.index_device_list_item, parent, false);
|
|
||||||
// return new ViewHolder(view);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// protected void convert(ViewHolder helper, String item) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// static class ViewHolder extends RecyclerView.ViewHolder {
|
|
||||||
// TextView tvDeviceName;
|
|
||||||
// TextView tvDeviceSerial;
|
|
||||||
// TextView tvDeviceStatus;
|
|
||||||
// TextView tvBatteryLevel;
|
|
||||||
//
|
|
||||||
// public ViewHolder(@NonNull View itemView) {
|
|
||||||
// super(itemView);
|
|
||||||
// tvDeviceName = itemView.findViewById(R.id.tv_device_name);
|
|
||||||
// tvDeviceSerial = itemView.findViewById(R.id.tv_device_serial);
|
|
||||||
// tvDeviceStatus = itemView.findViewById(R.id.tv_device_status);
|
|
||||||
// tvBatteryLevel = itemView.findViewById(R.id.tv_battery_level);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,8 @@ public class WaterDeviceEntity implements Serializable {
|
|||||||
private String status;
|
private String status;
|
||||||
private String workStatus;
|
private String workStatus;
|
||||||
private String powerLevel;
|
private String powerLevel;
|
||||||
private Object powerLevelUpdatatime;
|
private String powerStatus;
|
||||||
|
private String powerLevelUpdatatime;
|
||||||
private String wifiName;
|
private String wifiName;
|
||||||
private String wifiPassword;
|
private String wifiPassword;
|
||||||
private String deviceEm;
|
private String deviceEm;
|
||||||
@@ -48,6 +49,9 @@ public class WaterDeviceEntity implements Serializable {
|
|||||||
private int bindDeviceStatus;
|
private int bindDeviceStatus;
|
||||||
private String bindDeviceStatusName;
|
private String bindDeviceStatusName;
|
||||||
private WaterDeviceEntity bindDevice;
|
private WaterDeviceEntity bindDevice;
|
||||||
|
private String startTime;
|
||||||
|
private String endTime;
|
||||||
|
private String bindingStatus;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@@ -77,5 +81,9 @@ public class WaterDeviceEntity implements Serializable {
|
|||||||
private Object deviceImgX;
|
private Object deviceImgX;
|
||||||
private String powerLevelUpdatatimeX;
|
private String powerLevelUpdatatimeX;
|
||||||
private Object expirationTimeX;
|
private Object expirationTimeX;
|
||||||
|
private String checkStatus = "0";
|
||||||
|
private String bindingStatus;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.ckkj.water.index.mvp;
|
|||||||
|
|
||||||
import com.ckkj.water.base.IView;
|
import com.ckkj.water.base.IView;
|
||||||
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
||||||
|
import com.ckkj.water.network.BaseBean;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@@ -25,6 +26,8 @@ public class IndexContract {
|
|||||||
void getDeviceList(Map<String,String> map,CallBack callBack);
|
void getDeviceList(Map<String,String> map,CallBack callBack);
|
||||||
//查询二维码当前设备绑定状态
|
//查询二维码当前设备绑定状态
|
||||||
void queryDeviceBindStatus(JSONObject json, CallBack callBack);
|
void queryDeviceBindStatus(JSONObject json, CallBack callBack);
|
||||||
|
//从设备列表中移除设备
|
||||||
|
void removeDeviceEntry(String deviceNo, CallBack callBack);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,5 +35,8 @@ public class IndexContract {
|
|||||||
void getDeviceListSuccess(List<WaterDeviceEntity> list, int total);
|
void getDeviceListSuccess(List<WaterDeviceEntity> list, int total);
|
||||||
//查询二维码当前设备绑定状态
|
//查询二维码当前设备绑定状态
|
||||||
void queryDeviceBindStatusSuccess(WaterDeviceEntity entity);
|
void queryDeviceBindStatusSuccess(WaterDeviceEntity entity);
|
||||||
|
//从设备列表中移除设备成功
|
||||||
|
void removeDeviceEntrySuccess(BaseBean bean);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -91,4 +91,35 @@ public class IndexImpl implements IndexContract.DataModel{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
@Override
|
||||||
|
public void removeDeviceEntry(String deviceNo, IndexContract.CallBack callBack) {
|
||||||
|
NetWorkManager.getRequest().removeDeviceEntry(NetWorkManager.getToken(), deviceNo)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.unsubscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Observer<BaseBean>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(@NonNull BaseBean bean) {
|
||||||
|
if (bean.getCode() == 200) {
|
||||||
|
callBack.success(bean, 0);
|
||||||
|
} else {
|
||||||
|
callBack.fail(bean.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(@NonNull Throwable e) {
|
||||||
|
callBack.fail(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
|
||||||
|
|||||||
@@ -47,7 +47,8 @@ public class IndexPresenter extends BasePresenter<IndexContract.IndexView>{
|
|||||||
public void bindDeviceStatus(WaterDeviceEntity entity) {
|
public void bindDeviceStatus(WaterDeviceEntity entity) {
|
||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("macAddress",entity.getMacAddress());
|
json.put("macAddress",
|
||||||
|
entity.getMacAddress() == null ? "" : entity.getMacAddress().toLowerCase());
|
||||||
mImpl.queryDeviceBindStatus(json, new IndexContract.CallBack<WaterDeviceEntity>() {
|
mImpl.queryDeviceBindStatus(json, new IndexContract.CallBack<WaterDeviceEntity>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(WaterDeviceEntity bean, int total) {
|
public void success(WaterDeviceEntity bean, int total) {
|
||||||
@@ -70,4 +71,22 @@ public class IndexPresenter extends BasePresenter<IndexContract.IndexView>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void removeDeviceEntry(String deviceNo) {
|
||||||
|
mImpl.removeDeviceEntry(deviceNo, new IndexContract.CallBack<BaseBean>() {
|
||||||
|
@Override
|
||||||
|
public void success(BaseBean bean, int total) {
|
||||||
|
if (IndexPresenter.this.getView() != null) {
|
||||||
|
IndexPresenter.this.getView().removeDeviceEntrySuccess(bean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fail(String msg) {
|
||||||
|
if (IndexPresenter.this.getView() != null) {
|
||||||
|
IndexPresenter.this.getView().showError(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,12 @@ package com.ckkj.water.login;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
|
import android.text.InputType;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.text.method.PasswordTransformationMethod;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
import com.ckkj.water.base.BaseActivity;
|
import com.ckkj.water.base.BaseActivity;
|
||||||
@@ -23,6 +27,10 @@ import com.gyf.immersionbar.ImmersionBar;
|
|||||||
*/
|
*/
|
||||||
public class ForgetPasswordActivity extends BaseActivity<RegisterLayoutBinding, LoginPresenter>
|
public class ForgetPasswordActivity extends BaseActivity<RegisterLayoutBinding, LoginPresenter>
|
||||||
implements LoginContract.LoginView {
|
implements LoginContract.LoginView {
|
||||||
|
|
||||||
|
private boolean isPasswordVisible = false;
|
||||||
|
private boolean isConfirmPasswordVisible = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoginPresenter createPresenter() {
|
public LoginPresenter createPresenter() {
|
||||||
return new LoginPresenter(new LoginImpl());
|
return new LoginPresenter(new LoginImpl());
|
||||||
@@ -50,6 +58,8 @@ public class ForgetPasswordActivity extends BaseActivity<RegisterLayoutBinding,
|
|||||||
setClick(viewBinding.includedTitle.imgBack);
|
setClick(viewBinding.includedTitle.imgBack);
|
||||||
setClick(viewBinding.tvGetVerifiCode);
|
setClick(viewBinding.tvGetVerifiCode);
|
||||||
setClick(viewBinding.tvCommit);
|
setClick(viewBinding.tvCommit);
|
||||||
|
setClick(viewBinding.imgPsdShowHide);
|
||||||
|
setClick(viewBinding.imgPsdShowHideAgin);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setClick(View view) {
|
private void setClick(View view) {
|
||||||
@@ -111,11 +121,39 @@ public class ForgetPasswordActivity extends BaseActivity<RegisterLayoutBinding,
|
|||||||
viewBinding.etVerfiCode.getText().toString(),
|
viewBinding.etVerfiCode.getText().toString(),
|
||||||
viewBinding.etInputPsd.getText().toString());
|
viewBinding.etInputPsd.getText().toString());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case R.id.img_psd_show_hide:
|
||||||
|
togglePasswordVisibility(viewBinding.etInputPsd, viewBinding.imgPsdShowHide, isPasswordVisible);
|
||||||
|
isPasswordVisible = !isPasswordVisible;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R.id.img_psd_show_hide_agin:
|
||||||
|
togglePasswordVisibility(viewBinding.etInputPsdAgin, viewBinding.imgPsdShowHideAgin, isConfirmPasswordVisible);
|
||||||
|
isConfirmPasswordVisible = !isConfirmPasswordVisible;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void togglePasswordVisibility(EditText editText, ImageView imageView, boolean isVisible) {
|
||||||
|
if (editText == null || imageView == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
private CountDownTimer cdTimer = new CountDownTimer(6000, 1000) {
|
if (isVisible) {
|
||||||
|
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||||
|
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||||
|
imageView.setImageResource(R.mipmap.icon_psd_hide);
|
||||||
|
} else {
|
||||||
|
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
|
||||||
|
editText.setTransformationMethod(null);
|
||||||
|
imageView.setImageResource(R.mipmap.icon_psd_show);
|
||||||
|
}
|
||||||
|
|
||||||
|
editText.setSelection(editText.getText().length());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private CountDownTimer cdTimer = new CountDownTimer(60000, 1000) {
|
||||||
@Override
|
@Override
|
||||||
public void onTick(long millisUntilFinished) {
|
public void onTick(long millisUntilFinished) {
|
||||||
viewBinding.tvGetVerifiCode.setText("(" + millisUntilFinished / 1000 + ") " + getString(R.string.login_resend));
|
viewBinding.tvGetVerifiCode.setText("(" + millisUntilFinished / 1000 + ") " + getString(R.string.login_resend));
|
||||||
@@ -153,7 +191,9 @@ public class ForgetPasswordActivity extends BaseActivity<RegisterLayoutBinding,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getPhoneCodeSuccess(BaseBean bean) {
|
public void getPhoneCodeSuccess(BaseBean bean) {
|
||||||
|
hideDialogLoading();
|
||||||
|
ToastUtil.showLong(mContext, getString(R.string.login_code_sent));
|
||||||
|
cdTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -10,18 +10,23 @@ import android.graphics.Typeface;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.text.InputType;
|
||||||
import android.text.SpannableString;
|
import android.text.SpannableString;
|
||||||
import android.text.Spanned;
|
import android.text.Spanned;
|
||||||
import android.text.TextPaint;
|
import android.text.TextPaint;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
|
import android.text.method.PasswordTransformationMethod;
|
||||||
import android.text.style.ClickableSpan;
|
import android.text.style.ClickableSpan;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
|
import com.ckkj.water.mine.WebviewUserAgreement;
|
||||||
import com.ckkj.water.utils.manager.LanguageManager;
|
import com.ckkj.water.utils.manager.LanguageManager;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.gyf.immersionbar.ImmersionBar;
|
import com.gyf.immersionbar.ImmersionBar;
|
||||||
@@ -49,7 +54,8 @@ public class LoginActivity extends BaseActivity<LoginLayoutBinding, LoginPresent
|
|||||||
implements LoginContract.LoginView {
|
implements LoginContract.LoginView {
|
||||||
|
|
||||||
private boolean mYinsiConfirm = false;
|
private boolean mYinsiConfirm = false;
|
||||||
//当前登录方式 验证码100 密码 200
|
private boolean isPasswordVisible = false;
|
||||||
|
//当前登录方式 验证码100 密码 200..
|
||||||
private static int LOGIN_TYPE_STATUS_CODE = 100;
|
private static int LOGIN_TYPE_STATUS_CODE = 100;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -80,6 +86,7 @@ public class LoginActivity extends BaseActivity<LoginLayoutBinding, LoginPresent
|
|||||||
setClick(viewBinding.tvLanguage);
|
setClick(viewBinding.tvLanguage);
|
||||||
setClick(viewBinding.tvResetPsd);
|
setClick(viewBinding.tvResetPsd);
|
||||||
setClick(viewBinding.checkboxRead);
|
setClick(viewBinding.checkboxRead);
|
||||||
|
setClick(viewBinding.imgPsdShowHide);
|
||||||
setClick(viewBinding.btn133);
|
setClick(viewBinding.btn133);
|
||||||
setClick(viewBinding.btn151);
|
setClick(viewBinding.btn151);
|
||||||
}
|
}
|
||||||
@@ -106,7 +113,10 @@ public class LoginActivity extends BaseActivity<LoginLayoutBinding, LoginPresent
|
|||||||
content,
|
content,
|
||||||
userAgreementText,
|
userAgreementText,
|
||||||
() -> {
|
() -> {
|
||||||
ToastUtil.showShort(mContext, "用户协议");
|
// 跳转用户协议
|
||||||
|
Bundle bundle = new Bundle();
|
||||||
|
bundle.putInt("from_requse_code", WebviewUserAgreement.AGREEMENT_CODE);
|
||||||
|
goToWihoutNoPresent(mContext, WebviewUserAgreement.class,bundle);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -115,7 +125,10 @@ public class LoginActivity extends BaseActivity<LoginLayoutBinding, LoginPresent
|
|||||||
content,
|
content,
|
||||||
privacyPolicyText,
|
privacyPolicyText,
|
||||||
() -> {
|
() -> {
|
||||||
ToastUtil.showShort(mContext, "隐私政策");
|
// 跳转隐私政策
|
||||||
|
Bundle bundleYS = new Bundle();
|
||||||
|
bundleYS.putInt("from_requse_code",WebviewUserAgreement.PRIVACY_CODE);
|
||||||
|
goToWihoutNoPresent(mContext, WebviewUserAgreement.class,bundleYS);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -271,15 +284,6 @@ public class LoginActivity extends BaseActivity<LoginLayoutBinding, LoginPresent
|
|||||||
goTo(mContext, ForgetPasswordActivity.class,null);
|
goTo(mContext, ForgetPasswordActivity.class,null);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// case R.id.checkbox_read:
|
|
||||||
// if (mYinsiConfirm) {
|
|
||||||
// mYinsiConfirm = false;
|
|
||||||
// viewBinding.checkboxRead.setChecked(false);
|
|
||||||
// } else {
|
|
||||||
// mYinsiConfirm = true;
|
|
||||||
// viewBinding.checkboxRead.setChecked(true);
|
|
||||||
// }
|
|
||||||
// break;
|
|
||||||
case R.id.tv_login:
|
case R.id.tv_login:
|
||||||
if (TextUtils.isEmpty(viewBinding.etAccount.getText().toString())) {
|
if (TextUtils.isEmpty(viewBinding.etAccount.getText().toString())) {
|
||||||
ToastUtil.showShort(mContext, getString(R.string.login_error_phone_empty));
|
ToastUtil.showShort(mContext, getString(R.string.login_error_phone_empty));
|
||||||
@@ -322,11 +326,15 @@ public class LoginActivity extends BaseActivity<LoginLayoutBinding, LoginPresent
|
|||||||
// new Handler().postDelayed(() -> hideDialogLoading(), 1000);
|
// new Handler().postDelayed(() -> hideDialogLoading(), 1000);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case R.id.img_psd_show_hide:
|
||||||
|
togglePasswordVisibility();
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private CountDownTimer cdTimer = new CountDownTimer(6000, 1000) {
|
private CountDownTimer cdTimer = new CountDownTimer(60000, 1000) {
|
||||||
@Override
|
@Override
|
||||||
public void onTick(long millisUntilFinished) {
|
public void onTick(long millisUntilFinished) {
|
||||||
viewBinding.tvGetVerifiCode.setText("(" + millisUntilFinished / 1000 + ") " + getString(R.string.login_resend));
|
viewBinding.tvGetVerifiCode.setText("(" + millisUntilFinished / 1000 + ") " + getString(R.string.login_resend));
|
||||||
@@ -346,6 +354,31 @@ public class LoginActivity extends BaseActivity<LoginLayoutBinding, LoginPresent
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private void togglePasswordVisibility() {
|
||||||
|
EditText etPassword = viewBinding.etInputPsd;
|
||||||
|
ImageView ivToggle = viewBinding.imgPsdShowHide;
|
||||||
|
|
||||||
|
if (etPassword == null || ivToggle == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPasswordVisible) {
|
||||||
|
// 隐藏密码
|
||||||
|
etPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||||
|
etPassword.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||||
|
ivToggle.setImageResource(R.mipmap.icon_psd_hide);
|
||||||
|
} else {
|
||||||
|
// 显示密码
|
||||||
|
etPassword.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
|
||||||
|
etPassword.setTransformationMethod(null);
|
||||||
|
ivToggle.setImageResource(R.mipmap.icon_psd_show);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 保持光标位置
|
||||||
|
etPassword.setSelection(etPassword.getText().length());
|
||||||
|
isPasswordVisible = !isPasswordVisible;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void registerSuccess(BaseBean bean) {
|
public void registerSuccess(BaseBean bean) {
|
||||||
|
|
||||||
@@ -354,8 +387,8 @@ public class LoginActivity extends BaseActivity<LoginLayoutBinding, LoginPresent
|
|||||||
@Override
|
@Override
|
||||||
public void getPhoneCodeSuccess(BaseBean bean) {
|
public void getPhoneCodeSuccess(BaseBean bean) {
|
||||||
hideDialogLoading();
|
hideDialogLoading();
|
||||||
ToastUtil.showLong(mContext, getString(R.string.login_code_sent) + ":" + bean.getDataString());
|
ToastUtil.showLong(mContext, getString(R.string.login_code_sent));
|
||||||
// cdTimer.start();
|
cdTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -2,8 +2,12 @@ package com.ckkj.water.login;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.CountDownTimer;
|
import android.os.CountDownTimer;
|
||||||
|
import android.text.InputType;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.text.method.PasswordTransformationMethod;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
import com.ckkj.water.base.BaseActivity;
|
import com.ckkj.water.base.BaseActivity;
|
||||||
@@ -13,6 +17,7 @@ import com.ckkj.water.login.mvp.LoginContract;
|
|||||||
import com.ckkj.water.login.mvp.LoginImpl;
|
import com.ckkj.water.login.mvp.LoginImpl;
|
||||||
import com.ckkj.water.login.mvp.LoginPresenter;
|
import com.ckkj.water.login.mvp.LoginPresenter;
|
||||||
import com.ckkj.water.network.BaseBean;
|
import com.ckkj.water.network.BaseBean;
|
||||||
|
import com.ckkj.water.utils.FastClickUtils;
|
||||||
import com.ckkj.water.utils.manager.ThemeManager;
|
import com.ckkj.water.utils.manager.ThemeManager;
|
||||||
import com.ckkj.water.utils.number.PhoneNumberUtils;
|
import com.ckkj.water.utils.number.PhoneNumberUtils;
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
import com.ckkj.water.utils.show.ToastUtil;
|
||||||
@@ -22,6 +27,10 @@ import me.jessyan.autosize.internal.CustomAdapt;
|
|||||||
|
|
||||||
public class RegisterActivity extends BaseActivity<RegisterLayoutBinding, LoginPresenter>
|
public class RegisterActivity extends BaseActivity<RegisterLayoutBinding, LoginPresenter>
|
||||||
implements LoginContract.LoginView {
|
implements LoginContract.LoginView {
|
||||||
|
|
||||||
|
private boolean isPasswordVisible = false;
|
||||||
|
private boolean isConfirmPasswordVisible = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LoginPresenter createPresenter() {
|
public LoginPresenter createPresenter() {
|
||||||
return new LoginPresenter(new LoginImpl());
|
return new LoginPresenter(new LoginImpl());
|
||||||
@@ -48,6 +57,8 @@ public class RegisterActivity extends BaseActivity<RegisterLayoutBinding, LoginP
|
|||||||
setClick(viewBinding.includedTitle.imgBack);
|
setClick(viewBinding.includedTitle.imgBack);
|
||||||
setClick(viewBinding.tvGetVerifiCode);
|
setClick(viewBinding.tvGetVerifiCode);
|
||||||
setClick(viewBinding.tvCommit);
|
setClick(viewBinding.tvCommit);
|
||||||
|
setClick(viewBinding.imgPsdShowHide);
|
||||||
|
setClick(viewBinding.imgPsdShowHideAgin);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setClick(View view) {
|
private void setClick(View view) {
|
||||||
@@ -61,6 +72,11 @@ public class RegisterActivity extends BaseActivity<RegisterLayoutBinding, LoginP
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.tv_get_verifi_code:
|
case R.id.tv_get_verifi_code:
|
||||||
|
// 防止快速点击
|
||||||
|
if (!FastClickUtils.onclickTimes()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (TextUtils.isEmpty(viewBinding.etAccount.getText().toString())) {
|
if (TextUtils.isEmpty(viewBinding.etAccount.getText().toString())) {
|
||||||
ToastUtil.showShort(mContext, getString(R.string.login_error_phone_empty));
|
ToastUtil.showShort(mContext, getString(R.string.login_error_phone_empty));
|
||||||
return;
|
return;
|
||||||
@@ -72,10 +88,14 @@ public class RegisterActivity extends BaseActivity<RegisterLayoutBinding, LoginP
|
|||||||
}
|
}
|
||||||
//发送短信
|
//发送短信
|
||||||
mPresenter.getPhoneCode(viewBinding.etAccount.getText().toString(),"");
|
mPresenter.getPhoneCode(viewBinding.etAccount.getText().toString(),"");
|
||||||
// cdTimer.start();
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.tv_commit:
|
case R.id.tv_commit:
|
||||||
|
// 防止快速点击
|
||||||
|
if (!FastClickUtils.onclickTimes()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (TextUtils.isEmpty(viewBinding.etAccount.getText().toString())) {
|
if (TextUtils.isEmpty(viewBinding.etAccount.getText().toString())) {
|
||||||
ToastUtil.showShort(mContext, getString(R.string.login_error_phone_empty));
|
ToastUtil.showShort(mContext, getString(R.string.login_error_phone_empty));
|
||||||
return;
|
return;
|
||||||
@@ -110,11 +130,21 @@ public class RegisterActivity extends BaseActivity<RegisterLayoutBinding, LoginP
|
|||||||
viewBinding.etVerfiCode.getText().toString(),
|
viewBinding.etVerfiCode.getText().toString(),
|
||||||
viewBinding.etInputPsd.getText().toString());
|
viewBinding.etInputPsd.getText().toString());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case R.id.img_psd_show_hide:
|
||||||
|
togglePasswordVisibility(viewBinding.etInputPsd, viewBinding.imgPsdShowHide, isPasswordVisible);
|
||||||
|
isPasswordVisible = !isPasswordVisible;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R.id.img_psd_show_hide_agin:
|
||||||
|
togglePasswordVisibility(viewBinding.etInputPsdAgin, viewBinding.imgPsdShowHideAgin, isConfirmPasswordVisible);
|
||||||
|
isConfirmPasswordVisible = !isConfirmPasswordVisible;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private CountDownTimer cdTimer = new CountDownTimer(6000, 1000) {
|
private CountDownTimer cdTimer = new CountDownTimer(60000, 1000) {
|
||||||
@Override
|
@Override
|
||||||
public void onTick(long millisUntilFinished) {
|
public void onTick(long millisUntilFinished) {
|
||||||
viewBinding.tvGetVerifiCode.setText("(" + millisUntilFinished / 1000 + ") " + getString(R.string.login_resend));
|
viewBinding.tvGetVerifiCode.setText("(" + millisUntilFinished / 1000 + ") " + getString(R.string.login_resend));
|
||||||
@@ -135,16 +165,40 @@ public class RegisterActivity extends BaseActivity<RegisterLayoutBinding, LoginP
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@Override
|
private void togglePasswordVisibility(EditText editText, ImageView imageView, boolean isVisible) {
|
||||||
public void registerSuccess(BaseBean bean) {
|
if (editText == null || imageView == null) {
|
||||||
hideDialogLoading();
|
return;
|
||||||
ToastUtil.showShort(mContext,"注册成功");
|
}
|
||||||
finish();
|
|
||||||
|
if (isVisible) {
|
||||||
|
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||||
|
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||||
|
imageView.setImageResource(R.mipmap.icon_psd_hide);
|
||||||
|
} else {
|
||||||
|
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
|
||||||
|
editText.setTransformationMethod(null);
|
||||||
|
imageView.setImageResource(R.mipmap.icon_psd_show);
|
||||||
|
}
|
||||||
|
|
||||||
|
editText.setSelection(editText.getText().length());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void getPhoneCodeSuccess(BaseBean bean) {
|
public void registerSuccess(BaseBean bean) {
|
||||||
|
hideDialogLoading();
|
||||||
|
ToastUtil.showShort(mContext,getString(R.string.register_success_title));
|
||||||
|
finish();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取验证码成功
|
||||||
|
* @param bean
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void getPhoneCodeSuccess(BaseBean bean) {
|
||||||
|
hideDialogLoading();
|
||||||
|
ToastUtil.showShort(mContext,getString(R.string.verification_code_sent));
|
||||||
|
cdTimer.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ public class LoginContract {
|
|||||||
public interface DataModel{
|
public interface DataModel{
|
||||||
//手机验证码登录
|
//手机验证码登录
|
||||||
void register(JSONObject json, CallBack callBack);
|
void register(JSONObject json, CallBack callBack);
|
||||||
|
|
||||||
//获取手机验证码
|
//获取手机验证码
|
||||||
void getPhoneCode(Map<String,Object> map, CallBack callBack);
|
void getPhoneCode(Map<String,Object> map, CallBack callBack);
|
||||||
//手机验证码登录
|
//手机验证码登录
|
||||||
@@ -31,6 +30,10 @@ public class LoginContract {
|
|||||||
void updatePsdByVerifyCode(JSONObject json, CallBack callBack);
|
void updatePsdByVerifyCode(JSONObject json, CallBack callBack);
|
||||||
//退出登录
|
//退出登录
|
||||||
void logout(JSONObject json, CallBack callBack);
|
void logout(JSONObject json, CallBack callBack);
|
||||||
|
//注销账号--发送验证码
|
||||||
|
void logoffAccountCode(Map<String,Object> map, CallBack callBack);
|
||||||
|
//注销账号--确认注销
|
||||||
|
void logoffAccount(JSONObject json, CallBack callBack);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface LoginView extends IView{
|
public interface LoginView extends IView{
|
||||||
|
|||||||
@@ -105,6 +105,88 @@ public class LoginImpl implements LoginContract.DataModel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注销账号--发送验证码
|
||||||
|
* @param map
|
||||||
|
* @param callBack
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void logoffAccountCode(Map<String, Object> map, LoginContract.CallBack callBack) {
|
||||||
|
try {
|
||||||
|
NetWorkManager.getRequest().logoffAccountCode(NetWorkManager.getToken())
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.unsubscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Observer<BaseBean>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(@NonNull BaseBean bean) {
|
||||||
|
if (bean.getCode() == 200) {
|
||||||
|
callBack.success(bean);
|
||||||
|
} else {
|
||||||
|
callBack.fail(bean.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(@NonNull Throwable e) {
|
||||||
|
callBack.fail(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 注销账号--确认
|
||||||
|
* @param json
|
||||||
|
* @param callBack
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void logoffAccount(JSONObject json, LoginContract.CallBack callBack) {
|
||||||
|
try {
|
||||||
|
NetWorkManager.getRequest().confirmLogiffAccount(NetWorkManager.getToken(), NetWorkManager.toRequestBody(json))
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.unsubscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Observer<BaseBean>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(@NonNull BaseBean bean) {
|
||||||
|
if (bean.getCode() == 200) {
|
||||||
|
callBack.success(bean);
|
||||||
|
} else {
|
||||||
|
callBack.fail(bean.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(@NonNull Throwable e) {
|
||||||
|
callBack.fail(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 使用验证码登录
|
* 使用验证码登录
|
||||||
* @param json
|
* @param json
|
||||||
@@ -226,4 +308,6 @@ public class LoginImpl implements LoginContract.DataModel {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package com.ckkj.water.main;
|
package com.ckkj.water.main;
|
||||||
|
|
||||||
import com.ckkj.water.base.IView;
|
import com.ckkj.water.base.IView;
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
import com.ckkj.water.main.entity.CheckVersionEntity;
|
import com.ckkj.water.main.entity.CheckVersionEntity;
|
||||||
import com.ckkj.water.network.BaseBean;
|
import com.ckkj.water.network.BaseBean;
|
||||||
|
|
||||||
@@ -12,7 +12,7 @@ import java.util.Map;
|
|||||||
public interface MainContract {
|
public interface MainContract {
|
||||||
interface DataModel{
|
interface DataModel{
|
||||||
//新版本检测
|
//新版本检测
|
||||||
void checkAppVersionCode(JSONObject json, CallBack callBack);
|
void checkAppVersionCode(Map<String,String> map, CallBack callBack);
|
||||||
//运势
|
//运势
|
||||||
void getYunshiData(Map<String,Object> map, CallBack callBack);
|
void getYunshiData(Map<String,Object> map, CallBack callBack);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,13 +20,13 @@ public class MainImpl implements MainContract.DataModel{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 检测新版本
|
* 检测新版本
|
||||||
* @param jsonObject
|
* @param map
|
||||||
* @param callBack
|
* @param callBack
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void checkAppVersionCode(JSONObject jsonObject, MainContract.CallBack callBack) {
|
public void checkAppVersionCode(Map<String,String> map, MainContract.CallBack callBack) {
|
||||||
try {
|
try {
|
||||||
NetWorkManager.getRequest().checkVersionCode(NetWorkManager.getToken(),NetWorkManager.toRequestBody(jsonObject))
|
NetWorkManager.getRequest().checkVersionCode(NetWorkManager.getToken(),map)
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.unsubscribeOn(Schedulers.io())
|
.unsubscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
package com.ckkj.water.main;
|
package com.ckkj.water.main;
|
||||||
|
|
||||||
|
import com.ckkj.water.BuildConfig;
|
||||||
import com.ckkj.water.base.BasePresenter;
|
import com.ckkj.water.base.BasePresenter;
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
|
||||||
import com.ckkj.water.login.mvp.LoginContract;
|
|
||||||
import com.ckkj.water.main.entity.CheckVersionEntity;
|
import com.ckkj.water.main.entity.CheckVersionEntity;
|
||||||
import com.ckkj.water.mine.mvp.MineImpl;
|
|
||||||
import com.ckkj.water.network.BaseBean;
|
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@@ -24,8 +21,10 @@ public class MainPresenter extends BasePresenter<MainContract.MainView> {
|
|||||||
* 获取用户信息
|
* 获取用户信息
|
||||||
*/
|
*/
|
||||||
public void checkNewVersion() {
|
public void checkNewVersion() {
|
||||||
JSONObject json = new JSONObject();
|
Map<String,String> map = new HashMap<>();
|
||||||
mainImpl.checkAppVersionCode(json, new MainContract.CallBack<CheckVersionEntity>() {
|
map.put("platform","android");
|
||||||
|
map.put("currentVersion", BuildConfig.APP_VERSION_NAME);
|
||||||
|
mainImpl.checkAppVersionCode(map, new MainContract.CallBack<CheckVersionEntity>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(CheckVersionEntity bean) {
|
public void success(CheckVersionEntity bean) {
|
||||||
if( MainPresenter.this.getView() != null){
|
if( MainPresenter.this.getView() != null){
|
||||||
|
|||||||
@@ -1,5 +1,9 @@
|
|||||||
package com.ckkj.water.main.activity;
|
package com.ckkj.water.main.activity;
|
||||||
|
|
||||||
|
import static com.ckkj.water.ConstantUtil.POST_NOTIFICATIONS_PERMISSION_CODE;
|
||||||
|
import static com.ckkj.water.ConstantUtil.WRITE_FILE_PERMISSON_CPDE;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
@@ -18,13 +22,12 @@ import com.ckkj.water.mine.MineCenterFragment;
|
|||||||
import com.ckkj.water.plan.WaterPlanFragment;
|
import com.ckkj.water.plan.WaterPlanFragment;
|
||||||
import com.ckkj.water.utils.manager.ThemeManager;
|
import com.ckkj.water.utils.manager.ThemeManager;
|
||||||
import com.gyf.immersionbar.ImmersionBar;
|
import com.gyf.immersionbar.ImmersionBar;
|
||||||
import com.ckkj.water.AppConfig;
|
|
||||||
import com.ckkj.water.ConstantUtil;
|
import com.ckkj.water.ConstantUtil;
|
||||||
import com.ckkj.water.EventMessage;
|
import com.ckkj.water.EventMessage;
|
||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
import com.ckkj.water.adapter.ViewPageAdapter;
|
import com.ckkj.water.adapter.ViewPageAdapter;
|
||||||
import com.ckkj.water.base.BaseActivity;
|
import com.ckkj.water.base.BaseActivity;
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
import com.ckkj.water.databinding.MainActivityLayoutBinding;
|
import com.ckkj.water.databinding.MainActivityLayoutBinding;
|
||||||
import com.ckkj.water.dialog.DialogAppUpdate;
|
import com.ckkj.water.dialog.DialogAppUpdate;
|
||||||
import com.ckkj.water.main.MainContract;
|
import com.ckkj.water.main.MainContract;
|
||||||
@@ -33,7 +36,6 @@ import com.ckkj.water.main.MainPresenter;
|
|||||||
import com.ckkj.water.main.entity.CheckVersionEntity;
|
import com.ckkj.water.main.entity.CheckVersionEntity;
|
||||||
import com.ckkj.water.network.BaseBean;
|
import com.ckkj.water.network.BaseBean;
|
||||||
import com.ckkj.water.utils.AppInfoUtil;
|
import com.ckkj.water.utils.AppInfoUtil;
|
||||||
import com.ckkj.water.utils.dataUtil.SharePreUtil;
|
|
||||||
import com.ckkj.water.utils.manager.ActivityManager;
|
import com.ckkj.water.utils.manager.ActivityManager;
|
||||||
import com.ckkj.water.utils.manager.WaterUserInfoManager;
|
import com.ckkj.water.utils.manager.WaterUserInfoManager;
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
import com.ckkj.water.utils.show.ToastUtil;
|
||||||
@@ -105,7 +107,7 @@ public class MainActivity extends BaseActivity<MainActivityLayoutBinding, MainPr
|
|||||||
@Override
|
@Override
|
||||||
public void initData(Bundle savedInstanceState) {
|
public void initData(Bundle savedInstanceState) {
|
||||||
super.initData(savedInstanceState);
|
super.initData(savedInstanceState);
|
||||||
// mPresenter.checkNewVersion();
|
mPresenter.checkNewVersion();
|
||||||
// 清空Fragment列表,避免状态恢复问题
|
// 清空Fragment列表,避免状态恢复问题
|
||||||
mFragmentList.clear();
|
mFragmentList.clear();
|
||||||
mFragmentList.add(new IndexFragment());
|
mFragmentList.add(new IndexFragment());
|
||||||
@@ -310,9 +312,25 @@ public class MainActivity extends BaseActivity<MainActivityLayoutBinding, MainPr
|
|||||||
public void onRequestPermissionsResult(int requestCode, @NonNull @NotNull String[] permissions, @NonNull @NotNull int[] grantResults) {
|
public void onRequestPermissionsResult(int requestCode, @NonNull @NotNull String[] permissions, @NonNull @NotNull int[] grantResults) {
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
|
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
|
||||||
|
hidePermissionDialog();
|
||||||
|
if(requestCode == WRITE_FILE_PERMISSON_CPDE){
|
||||||
|
if(mUpdateDialog != null && grantResults.length > 0 && grantResults[0] == android.content.pm.PackageManager.PERMISSION_GRANTED){
|
||||||
|
mUpdateDialog.startUpdateApp();
|
||||||
|
}
|
||||||
|
}else if(requestCode == POST_NOTIFICATIONS_PERMISSION_CODE){
|
||||||
|
if(mUpdateDialog != null && grantResults.length > 0 && grantResults[0] == android.content.pm.PackageManager.PERMISSION_GRANTED){
|
||||||
|
mUpdateDialog.startUpdateApp();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPermissionsGranted(int requestCode, @NonNull @NotNull List<String> perms) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDestroy() {
|
protected void onDestroy() {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
@@ -358,24 +376,34 @@ public class MainActivity extends BaseActivity<MainActivityLayoutBinding, MainPr
|
|||||||
if(bean == null){
|
if(bean == null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(bean.getVersionCoercion().equals("0")){//不强制
|
if(!bean.isForceUpdate()){//不强制
|
||||||
isForceUpdate = false;
|
isForceUpdate = false;
|
||||||
}else{
|
}else{
|
||||||
isForceUpdate = true;
|
isForceUpdate = true;
|
||||||
}
|
}
|
||||||
//前期强制更新
|
//前期强制更新
|
||||||
// isForceUpdate = true;
|
// isForceUpdate = true;
|
||||||
if(bean.getVersionNumber() > versionCode){
|
if(bean.getVersionCode() > versionCode){
|
||||||
//App更新dialog
|
//App更新dialog
|
||||||
mUpdateDialog = new DialogAppUpdate(mContext,R.layout.dialog_app_update,isForceUpdate,bean);
|
mUpdateDialog = new DialogAppUpdate(mContext,R.layout.dialog_app_update_water,isForceUpdate,bean);
|
||||||
mUpdateDialog.show();
|
mUpdateDialog.show();
|
||||||
mUpdateDialog.setOnDialogListener(new DialogAppUpdate.DialogListener() {
|
mUpdateDialog.setOnDialogListener(new DialogAppUpdate.DialogListener() {
|
||||||
@Override
|
@Override
|
||||||
public void callBackGetPermisson(String permission) {
|
public void callBackGetPermisson(String permission) {
|
||||||
if (!hasRecordPermission(permission)) {
|
if (!hasRecordPermission(permission)) {
|
||||||
|
if (Manifest.permission.POST_NOTIFICATIONS.equals(permission)) {
|
||||||
|
getPermissionRequst(permission,
|
||||||
|
"通知权限申请",
|
||||||
|
|
||||||
|
"渥田氏需要通知权限来显示应用下载进度",
|
||||||
|
POST_NOTIFICATIONS_PERMISSION_CODE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
// 没有权限,只在ACTION_DOWN时去申请
|
// 没有权限,只在ACTION_DOWN时去申请
|
||||||
getPermissionRequst(permission,"文件存储权限申请",
|
getPermissionRequst(permission,
|
||||||
"星语明灯需要您的授权,获取存储权限来更新您的应用",PICK_IMAGE_REQUEST_300);
|
"文件存储权限申请",
|
||||||
|
"渥田氏需要您的授权,获取存储权限来更新您的应用",
|
||||||
|
WRITE_FILE_PERMISSON_CPDE);
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
|
|
||||||
@@ -415,14 +443,6 @@ public class MainActivity extends BaseActivity<MainActivityLayoutBinding, MainPr
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPermissionsGranted(int requestCode, @NonNull @NotNull List<String> perms) {
|
|
||||||
if (requestCode == ConstantUtil.WRITE_FILE_PERMISSON_CPDE) {
|
|
||||||
if(mUpdateDialog != null){
|
|
||||||
mUpdateDialog.startUpdateApp();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPermissionsDenied(int requestCode, @NonNull @NotNull List<String> perms) {
|
public void onPermissionsDenied(int requestCode, @NonNull @NotNull List<String> perms) {
|
||||||
|
|||||||
@@ -1,41 +1,32 @@
|
|||||||
package com.ckkj.water.main.entity;
|
package com.ckkj.water.main.entity;
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.NoArgsConstructor;
|
import lombok.NoArgsConstructor;
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
@Data
|
||||||
|
@NoArgsConstructor
|
||||||
public class CheckVersionEntity implements Serializable {
|
public class CheckVersionEntity implements Serializable {
|
||||||
|
|
||||||
|
|
||||||
@SerializedName("versionNumber")
|
/**
|
||||||
private int versionNumber;
|
* platform : android
|
||||||
@SerializedName("versionEnd")
|
* currentVersion : 1.0.1
|
||||||
private String versionEnd;
|
* latestVersion : 1.0.0
|
||||||
@SerializedName("versionCoercion")
|
* versionCode : 1
|
||||||
private String versionCoercion;
|
* updateAvailable : true
|
||||||
@SerializedName("versionDescription")
|
* forceUpdate : false
|
||||||
private String versionDescription;
|
* downloadUrl : null
|
||||||
@SerializedName("versionName")
|
* releaseNotes : null
|
||||||
private String versionName;
|
*/
|
||||||
@SerializedName("versionUrl")
|
|
||||||
private String versionUrl;
|
private String platform;
|
||||||
@SerializedName("versionHide1")
|
private String currentVersion;
|
||||||
private String versionHide1;
|
private String latestVersion;
|
||||||
@SerializedName("versionHide2")
|
private int versionCode;
|
||||||
private String versionHide2;
|
private boolean updateAvailable;
|
||||||
@SerializedName("versionHide3")
|
private boolean forceUpdate;
|
||||||
private String versionHide3;
|
private String downloadUrl;
|
||||||
@SerializedName("versionHide4")
|
private String releaseNotes;
|
||||||
private String versionHide4;
|
|
||||||
@SerializedName("versionHide5")
|
|
||||||
private Object versionHide5;
|
|
||||||
@SerializedName("versionHide6")
|
|
||||||
private Object versionHide6;
|
|
||||||
@SerializedName("paipanApiKey")
|
|
||||||
private String paipanApiKey;
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import android.view.View;
|
|||||||
|
|
||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
import com.ckkj.water.base.BaseActivity;
|
import com.ckkj.water.base.BaseActivity;
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
import com.ckkj.water.main.entity.CheckVersionEntity;
|
||||||
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
import com.ckkj.water.databinding.AppThemeChangeLayoutBinding;
|
import com.ckkj.water.databinding.AppThemeChangeLayoutBinding;
|
||||||
import com.ckkj.water.mine.mvp.MineContract;
|
import com.ckkj.water.mine.mvp.MineContract;
|
||||||
import com.ckkj.water.mine.mvp.MineImpl;
|
import com.ckkj.water.mine.mvp.MineImpl;
|
||||||
@@ -122,4 +123,24 @@ public class AppThemActivity extends BaseActivity<AppThemeChangeLayoutBinding, M
|
|||||||
public void logOutSuccess(BaseBean bean) {
|
public void logOutSuccess(BaseBean bean) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uploadImageSuccess(MineUserInfoBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getAppVersionSuccess(CheckVersionEntity bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getAccountLogoffCodeSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void confirmAccountLogoffCodeSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import android.os.CountDownTimer;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
import com.ckkj.water.main.entity.CheckVersionEntity;
|
||||||
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
import com.gyf.immersionbar.ImmersionBar;
|
import com.gyf.immersionbar.ImmersionBar;
|
||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
import com.ckkj.water.base.BaseActivity;
|
import com.ckkj.water.base.BaseActivity;
|
||||||
@@ -14,7 +15,6 @@ import com.ckkj.water.mine.mvp.MineContract;
|
|||||||
import com.ckkj.water.mine.mvp.MineImpl;
|
import com.ckkj.water.mine.mvp.MineImpl;
|
||||||
import com.ckkj.water.mine.mvp.MinePresenter;
|
import com.ckkj.water.mine.mvp.MinePresenter;
|
||||||
import com.ckkj.water.network.BaseBean;
|
import com.ckkj.water.network.BaseBean;
|
||||||
import com.ckkj.water.utils.manager.WaterUserInfoManager;
|
|
||||||
import com.ckkj.water.utils.number.PhoneNumberUtils;
|
import com.ckkj.water.utils.number.PhoneNumberUtils;
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
import com.ckkj.water.utils.show.ToastUtil;
|
||||||
|
|
||||||
@@ -151,4 +151,24 @@ public class ChangePhoneActivity extends BaseActivity<ChangePhoneActivityBinding
|
|||||||
public void logOutSuccess(BaseBean bean) {
|
public void logOutSuccess(BaseBean bean) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uploadImageSuccess(MineUserInfoBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getAppVersionSuccess(CheckVersionEntity bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getAccountLogoffCodeSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void confirmAccountLogoffCodeSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -1,22 +1,21 @@
|
|||||||
package com.ckkj.water.mine;
|
package com.ckkj.water.mine;
|
||||||
|
|
||||||
import static android.view.View.INVISIBLE;
|
import static android.view.View.INVISIBLE;
|
||||||
|
import static android.view.View.VISIBLE;
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
|
import com.bumptech.glide.Glide;
|
||||||
import com.ckkj.water.AppConfig;
|
import com.ckkj.water.AppConfig;
|
||||||
import com.ckkj.water.ConstantUtil;
|
import com.ckkj.water.ConstantUtil;
|
||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
import com.ckkj.water.base.BaseFragment;
|
import com.ckkj.water.base.BaseFragment;
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
import com.ckkj.water.main.entity.CheckVersionEntity;
|
||||||
import com.ckkj.water.databinding.MineFragmentBinding;
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
import com.ckkj.water.databinding.MineFragmentLayoutBinding;
|
import com.ckkj.water.databinding.MineFragmentLayoutBinding;
|
||||||
import com.ckkj.water.login.LoginActivity;
|
import com.ckkj.water.login.LoginActivity;
|
||||||
import com.ckkj.water.main.entity.CheckVersionEntity;
|
|
||||||
import com.ckkj.water.mine.entity.MemberComboEntity;
|
|
||||||
import com.ckkj.water.mine.mvp.MineContract;
|
import com.ckkj.water.mine.mvp.MineContract;
|
||||||
import com.ckkj.water.mine.mvp.MineImpl;
|
import com.ckkj.water.mine.mvp.MineImpl;
|
||||||
import com.ckkj.water.mine.mvp.MinePresenter;
|
import com.ckkj.water.mine.mvp.MinePresenter;
|
||||||
@@ -26,16 +25,11 @@ import com.ckkj.water.utils.manager.ActivityManager;
|
|||||||
import com.ckkj.water.utils.manager.LanguageManager;
|
import com.ckkj.water.utils.manager.LanguageManager;
|
||||||
import com.ckkj.water.utils.manager.ThemeManager;
|
import com.ckkj.water.utils.manager.ThemeManager;
|
||||||
import com.ckkj.water.utils.manager.WaterUserInfoManager;
|
import com.ckkj.water.utils.manager.WaterUserInfoManager;
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.gyf.immersionbar.ImmersionBar;
|
import com.gyf.immersionbar.ImmersionBar;
|
||||||
import com.lxj.xpopup.XPopup;
|
import com.lxj.xpopup.XPopup;
|
||||||
import com.lxj.xpopup.interfaces.OnSelectListener;
|
import com.lxj.xpopup.interfaces.OnSelectListener;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import de.greenrobot.event.EventBus;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author fengxiaoyang
|
* @author fengxiaoyang
|
||||||
* @date 2026/5/16
|
* @date 2026/5/16
|
||||||
@@ -52,6 +46,7 @@ public class MineCenterFragment extends BaseFragment<MineFragmentLayoutBinding,
|
|||||||
.titleBar(viewBinding.rlTitle)
|
.titleBar(viewBinding.rlTitle)
|
||||||
.init();
|
.init();
|
||||||
viewBinding.includedTitle.imgBack.setVisibility(INVISIBLE);
|
viewBinding.includedTitle.imgBack.setVisibility(INVISIBLE);
|
||||||
|
viewBinding.includedTitle.imgSetting.setVisibility(VISIBLE);
|
||||||
viewBinding.includedTitle.tvTitle.setText(getString(R.string.mine_center_title));
|
viewBinding.includedTitle.tvTitle.setText(getString(R.string.mine_center_title));
|
||||||
initListener();
|
initListener();
|
||||||
}
|
}
|
||||||
@@ -70,6 +65,7 @@ public class MineCenterFragment extends BaseFragment<MineFragmentLayoutBinding,
|
|||||||
setClick(viewBinding.linearPsdManage);
|
setClick(viewBinding.linearPsdManage);
|
||||||
setClick(viewBinding.linearTheme);
|
setClick(viewBinding.linearTheme);
|
||||||
setClick(viewBinding.btnDelete);
|
setClick(viewBinding.btnDelete);
|
||||||
|
setClick(viewBinding.includedTitle.imgSetting);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setClick(View view) {
|
private void setClick(View view) {
|
||||||
@@ -78,6 +74,11 @@ public class MineCenterFragment extends BaseFragment<MineFragmentLayoutBinding,
|
|||||||
|
|
||||||
public void onClick(View v){
|
public void onClick(View v){
|
||||||
switch (v.getId()){
|
switch (v.getId()){
|
||||||
|
|
||||||
|
case R.id.img_setting:
|
||||||
|
goTo(mContext, SettingsActivity.class,null);
|
||||||
|
break;
|
||||||
|
|
||||||
case R.id.linear_info:
|
case R.id.linear_info:
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
bundle.putSerializable(ConstantUtil.USER_INFO_JSON_CONTENT,mUserBean);
|
bundle.putSerializable(ConstantUtil.USER_INFO_JSON_CONTENT,mUserBean);
|
||||||
@@ -152,6 +153,13 @@ public class MineCenterFragment extends BaseFragment<MineFragmentLayoutBinding,
|
|||||||
}else{
|
}else{
|
||||||
viewBinding.tvUserAccount.setText(bean.getUser().getPhonenumber());
|
viewBinding.tvUserAccount.setText(bean.getUser().getPhonenumber());
|
||||||
}
|
}
|
||||||
|
if(!TextUtils.isEmpty(bean.getUser().getAvatar())){
|
||||||
|
// 刷新头像显示
|
||||||
|
Glide.with(mContext)
|
||||||
|
.load(bean.getUser().getAvatar())
|
||||||
|
.error(mContext.getDrawable(R.mipmap.icon_mine_user_head_defaul))
|
||||||
|
.into(viewBinding.imgAvatar);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -165,6 +173,26 @@ public class MineCenterFragment extends BaseFragment<MineFragmentLayoutBinding,
|
|||||||
goTo(mContext, LoginActivity.class,null);
|
goTo(mContext, LoginActivity.class,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uploadImageSuccess(MineUserInfoBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getAppVersionSuccess(CheckVersionEntity bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getAccountLogoffCodeSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void confirmAccountLogoffCodeSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateUserInfoSuccess(BaseBean bean) {
|
public void updateUserInfoSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
|||||||
@@ -1,290 +0,0 @@
|
|||||||
package com.ckkj.water.mine;
|
|
||||||
|
|
||||||
import static android.app.Activity.RESULT_OK;
|
|
||||||
|
|
||||||
import android.Manifest;
|
|
||||||
import android.content.Intent;
|
|
||||||
import android.net.Uri;
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.view.View;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.alibaba.sdk.android.oss.ClientException;
|
|
||||||
import com.alibaba.sdk.android.oss.ServiceException;
|
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
|
||||||
import com.esafirm.imagepicker.features.ImagePicker;
|
|
||||||
import com.esafirm.imagepicker.model.Image;
|
|
||||||
import com.ckkj.water.AppConfig;
|
|
||||||
import com.ckkj.water.EventMessage;
|
|
||||||
import com.ckkj.water.R;
|
|
||||||
import com.ckkj.water.base.BaseFragment;
|
|
||||||
import com.ckkj.water.base.inter.UploadCallback;
|
|
||||||
import com.ckkj.water.databinding.MineFragmentBinding;
|
|
||||||
import com.ckkj.water.login.LoginActivity;
|
|
||||||
import com.ckkj.water.mine.mvp.MineContract;
|
|
||||||
import com.ckkj.water.mine.mvp.MineImpl;
|
|
||||||
import com.ckkj.water.mine.mvp.MinePresenter;
|
|
||||||
import com.ckkj.water.network.BaseBean;
|
|
||||||
import com.ckkj.water.utils.LubanCompressUtil;
|
|
||||||
import com.ckkj.water.utils.PreviewFileUtil;
|
|
||||||
import com.ckkj.water.utils.click.ClickUtil;
|
|
||||||
import com.ckkj.water.utils.dataUtil.FileUtil;
|
|
||||||
import com.ckkj.water.utils.manager.WaterUserInfoManager;
|
|
||||||
import com.ckkj.water.utils.oss.OssUploadHelper;
|
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
|
||||||
import com.lxj.xpopup.XPopup;
|
|
||||||
import com.lxj.xpopup.interfaces.OnSelectListener;
|
|
||||||
import com.yalantis.ucrop.UCrop;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import de.greenrobot.event.EventBus;
|
|
||||||
import pub.devrel.easypermissions.EasyPermissions;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fengxiaoyang 新分支
|
|
||||||
* @date 2025/7/7
|
|
||||||
* @description TODO: 描述该类的作用
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class MineFragment extends BaseFragment<MineFragmentBinding, MinePresenter>
|
|
||||||
implements MineContract.MineView {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initData(Bundle state) {
|
|
||||||
viewBinding.includedTitle.imgBack.setVisibility(View.GONE);
|
|
||||||
viewBinding.includedTitle.imgSetting.setVisibility(View.VISIBLE);
|
|
||||||
ClickUtil.addClickPart(viewBinding.includedTitle.imgSetting, 50);
|
|
||||||
ClickUtil.addClickPart(viewBinding.imgEdit, 50);
|
|
||||||
viewBinding.includedTitle.tvTitle.setText("个人中心");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onResumeInitData() {
|
|
||||||
super.onResumeInitData();
|
|
||||||
if (AppConfig.USER_LOGIN) {
|
|
||||||
// mPresenter.getUserinfo();
|
|
||||||
} else {
|
|
||||||
viewBinding.tvDefaulBirthtime.setVisibility(View.VISIBLE);
|
|
||||||
viewBinding.tvDefaulStar.setVisibility(View.VISIBLE);
|
|
||||||
viewBinding.tvUserBirthTime.setVisibility(View.GONE);
|
|
||||||
viewBinding.tvUserStar.setVisibility(View.GONE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public MinePresenter createPresenter() {
|
|
||||||
return new MinePresenter(new MineImpl());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onClick(View v) {
|
|
||||||
switch (v.getId()) {
|
|
||||||
case R.id.img_user_head:
|
|
||||||
if (!AppConfig.USER_LOGIN) {
|
|
||||||
goTo(mContext, LoginActivity.class, null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
new XPopup.Builder(mContext).asBottomList(
|
|
||||||
getString(R.string.avatar),
|
|
||||||
new String[]{
|
|
||||||
getString(R.string.upload_avatar),
|
|
||||||
getString(R.string.view_full_image)}, new OnSelectListener() {
|
|
||||||
@Override
|
|
||||||
public void onSelect(int position, String text) {
|
|
||||||
switch (position) {
|
|
||||||
case 0:
|
|
||||||
String readPermission = Manifest.permission.READ_EXTERNAL_STORAGE;
|
|
||||||
if (!hasRecordPermission(readPermission)) {
|
|
||||||
// 没有权限,只在ACTION_DOWN时去申请+
|
|
||||||
getPermissionRequst(readPermission,
|
|
||||||
getString(R.string.request_camera_storage_permission),
|
|
||||||
getString(R.string.avatar_permission_tips),
|
|
||||||
REQUEST_CODE_100);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
imagePicker(1, REQUEST_CODE_100, MineFragment.this);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
// String suffix = FileUtil.getFileSuffixWithQuestion(WaterUserInfoManager.getInstance().getUserInfo().getAvatar());
|
|
||||||
// PreviewFileUtil.previewFiles(mContext, suffix, WaterUserInfoManager.getInstance().getUserInfo().getAvatar());
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).show();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.img_setting:
|
|
||||||
goTo(mContext, SettingsActivity.class, null);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.img_edit://编辑出生日期
|
|
||||||
if (!AppConfig.USER_LOGIN) {
|
|
||||||
goTo(mContext, LoginActivity.class, null);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 发送EventBus消息,让MainActivity切换到FateFragment
|
|
||||||
EventBus.getDefault().post(new EventMessage(EventMessage.SWITCH_TO_FATE_FRAGMENT));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.linear_tobe_vip:
|
|
||||||
|
|
||||||
case R.id.lienar_share_be_vip:
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
|
|
||||||
super.onActivityResult(requestCode, resultCode, data);
|
|
||||||
if (resultCode == RESULT_OK) {
|
|
||||||
switch (requestCode) {
|
|
||||||
case 100://头像
|
|
||||||
List<Image> images = ImagePicker.getImages(data);
|
|
||||||
Uri sourceUri = Uri.fromFile(new File(images.get(0).getPath()));
|
|
||||||
Uri destinationUri = Uri.fromFile(new File(mContext.getCacheDir(), "cropped_image.jpg"));
|
|
||||||
UCrop.of(sourceUri, destinationUri)
|
|
||||||
.withAspectRatio(1, 1) // 设置裁剪框比例,1:1 为正方形
|
|
||||||
.withMaxResultSize(1000, 1000) // 设置裁剪后的最大图片尺寸
|
|
||||||
.start(requireContext(), this);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case UCrop.REQUEST_CROP:
|
|
||||||
showLoadingDialog();
|
|
||||||
Uri resultUri = UCrop.getOutput(data);
|
|
||||||
String filePath = resultUri.getPath();
|
|
||||||
if (!TextUtils.isEmpty(filePath)) {
|
|
||||||
getCompressFile(new File(filePath));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void getCompressFile(File file) {
|
|
||||||
LubanCompressUtil.getInstance().getCompressFile(mContext, file, new LubanCompressUtil.CompressCallback() {
|
|
||||||
@Override
|
|
||||||
public void success(File file) {
|
|
||||||
if (file != null) {
|
|
||||||
if (file.exists()) {
|
|
||||||
long fileSizeInBytes = file.length(); // 获取文件大小(字节)
|
|
||||||
long fileSizeInMB = fileSizeInBytes / (1024 * 1024); // 转换为MB
|
|
||||||
String fileName = file.getName();
|
|
||||||
if (fileSizeInMB > 5) {
|
|
||||||
hideDialogLoading();
|
|
||||||
ToastUtil.showShort(mContext, "文件大小超出5M");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!fileName.toLowerCase().endsWith(".png") &&
|
|
||||||
!fileName.toLowerCase().endsWith(".jpg") &&
|
|
||||||
!fileName.toLowerCase().endsWith(".jpeg")) {
|
|
||||||
ToastUtil.showShort(mContext, "文件格式不正确");
|
|
||||||
hideDialogLoading();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<String> filePath = new ArrayList<>();
|
|
||||||
filePath.add(file.getPath());
|
|
||||||
OssUploadHelper helper = new OssUploadHelper(mContext);
|
|
||||||
helper.upload(AppConfig.UPLOAD_TYPE_200, fileName, filePath, new UploadCallback() {
|
|
||||||
@Override
|
|
||||||
public void onSuccess(List<String> urls) {
|
|
||||||
mContext.runOnUiThread(new Runnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
if (!TextUtils.isEmpty(urls.get(0))) {
|
|
||||||
// mPresenter.updateUserAvatar(urls.get(0));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onFailure(ClientException clientException, ServiceException serviceException) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
ToastUtil.showShort(mContext, "文件不存在");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void fail(String failMsg) {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNetChange(int netModel) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showError(String message) {
|
|
||||||
hideDialogLoading();
|
|
||||||
ToastUtil.showShort(mContext, message);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logOut(BaseBean bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
|
||||||
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
|
||||||
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
|
|
||||||
hidePermissionDialog();
|
|
||||||
if (requestCode == REQUEST_CODE_100) {
|
|
||||||
imagePicker(1, REQUEST_CODE_100, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getUserInfoSuccess(MineUserInfoBean bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateUserInfoSuccess(BaseBean bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updateUserPasswordSuccess(BaseBean bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logOutSuccess(BaseBean bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -13,7 +13,8 @@ import com.bumptech.glide.Glide;
|
|||||||
import com.ckkj.water.ConstantUtil;
|
import com.ckkj.water.ConstantUtil;
|
||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
import com.ckkj.water.base.BaseActivity;
|
import com.ckkj.water.base.BaseActivity;
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
import com.ckkj.water.main.entity.CheckVersionEntity;
|
||||||
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
import com.ckkj.water.databinding.MineInformationLayoutBinding;
|
import com.ckkj.water.databinding.MineInformationLayoutBinding;
|
||||||
import com.ckkj.water.mine.mvp.MineContract;
|
import com.ckkj.water.mine.mvp.MineContract;
|
||||||
import com.ckkj.water.mine.mvp.MineImpl;
|
import com.ckkj.water.mine.mvp.MineImpl;
|
||||||
@@ -22,6 +23,7 @@ import com.ckkj.water.network.BaseBean;
|
|||||||
import com.ckkj.water.utils.LubanCompressUtil;
|
import com.ckkj.water.utils.LubanCompressUtil;
|
||||||
import com.ckkj.water.utils.PreviewFileUtil;
|
import com.ckkj.water.utils.PreviewFileUtil;
|
||||||
import com.ckkj.water.utils.dataUtil.FileUtil;
|
import com.ckkj.water.utils.dataUtil.FileUtil;
|
||||||
|
import com.ckkj.water.utils.dataUtil.SharePreUtil;
|
||||||
import com.ckkj.water.utils.manager.ThemeManager;
|
import com.ckkj.water.utils.manager.ThemeManager;
|
||||||
import com.ckkj.water.utils.manager.WaterUserInfoManager;
|
import com.ckkj.water.utils.manager.WaterUserInfoManager;
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
import com.ckkj.water.utils.show.ToastUtil;
|
||||||
@@ -56,6 +58,13 @@ public class MineInfomationActivity extends BaseActivity<MineInformationLayoutBi
|
|||||||
if(bundle != null){
|
if(bundle != null){
|
||||||
mUserBean = (MineUserInfoBean) bundle.getSerializable(ConstantUtil.USER_INFO_JSON_CONTENT);
|
mUserBean = (MineUserInfoBean) bundle.getSerializable(ConstantUtil.USER_INFO_JSON_CONTENT);
|
||||||
viewBinding.tvNicknameValue.setText(mUserBean.getUser().getNickName());
|
viewBinding.tvNicknameValue.setText(mUserBean.getUser().getNickName());
|
||||||
|
if(!TextUtils.isEmpty(mUserBean.getUser().getAvatar())){
|
||||||
|
// 刷新头像显示
|
||||||
|
Glide.with(mContext)
|
||||||
|
.load(mUserBean.getUser().getAvatar())
|
||||||
|
.error(mContext.getDrawable(R.mipmap.icon_mine_user_head_defaul))
|
||||||
|
.into(viewBinding.imgAvatar);
|
||||||
|
}
|
||||||
if(TextUtils.isEmpty(mUserBean.getUser().getEmail())){
|
if(TextUtils.isEmpty(mUserBean.getUser().getEmail())){
|
||||||
viewBinding.tvBindPhoneValue.setText(mUserBean.getUser().getPhonenumber());
|
viewBinding.tvBindPhoneValue.setText(mUserBean.getUser().getPhonenumber());
|
||||||
}else{
|
}else{
|
||||||
@@ -112,8 +121,8 @@ public class MineInfomationActivity extends BaseActivity<MineInformationLayoutBi
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
// String suffix = FileUtil.getFileSuffixWithQuestion(WaterUserInfoManager.getInstance().getUserInfo().getAvatar());
|
String suffix = FileUtil.getFileSuffixWithQuestion(mUserBean.getUser().getAvatar());
|
||||||
// PreviewFileUtil.previewFiles(mContext, suffix, WaterUserInfoManager.getInstance().getUserInfo().getAvatar());
|
PreviewFileUtil.previewFiles(mContext, suffix, mUserBean.getUser().getAvatar());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -141,7 +150,7 @@ public class MineInfomationActivity extends BaseActivity<MineInformationLayoutBi
|
|||||||
@Override
|
@Override
|
||||||
public void onConfirmClisk(String content) {
|
public void onConfirmClisk(String content) {
|
||||||
showLoadingDialog();
|
showLoadingDialog();
|
||||||
mPresenter.updateUserInfo(content);
|
mPresenter.updateUserInfo(content,null);
|
||||||
mUserBean.getUser().setNickName(content);
|
mUserBean.getUser().setNickName(content);
|
||||||
viewBinding.tvNicknameValue.setText(content);
|
viewBinding.tvNicknameValue.setText(content);
|
||||||
}
|
}
|
||||||
@@ -197,6 +206,50 @@ public class MineInfomationActivity extends BaseActivity<MineInformationLayoutBi
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uploadImageSuccess(MineUserInfoBean bean) {
|
||||||
|
hideDialogLoading();
|
||||||
|
// 后端约定:data 为上传后的头像访问URL(String)
|
||||||
|
String avatarUrl = bean.getUrl();
|
||||||
|
if (TextUtils.isEmpty(avatarUrl)) {
|
||||||
|
ToastUtil.showShort(mContext, getString(R.string.avatar_update_success));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 更新内存中的用户信息
|
||||||
|
if (mUserBean != null && mUserBean.getUser() != null) {
|
||||||
|
mUserBean.getUser().setAvatar(avatarUrl);
|
||||||
|
WaterUserInfoManager.getInstance().setUserInfo(mUserBean);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 缓存头像地址到本地
|
||||||
|
SharePreUtil.putString(ConstantUtil.SHARE_PRE_NAME, mContext,
|
||||||
|
ConstantUtil.USER_INFO_AVATAR, avatarUrl);
|
||||||
|
|
||||||
|
// 刷新头像显示
|
||||||
|
Glide.with(mContext)
|
||||||
|
.load(avatarUrl)
|
||||||
|
.error(mContext.getDrawable(R.mipmap.icon_mine_user_head_defaul))
|
||||||
|
.into(viewBinding.imgAvatar);
|
||||||
|
|
||||||
|
ToastUtil.showShort(mContext, getString(R.string.avatar_update_success));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getAppVersionSuccess(CheckVersionEntity bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getAccountLogoffCodeSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void confirmAccountLogoffCodeSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private void getCompressFile(File file) {
|
private void getCompressFile(File file) {
|
||||||
LubanCompressUtil.getInstance().getCompressFile(mContext, file, new LubanCompressUtil.CompressCallback() {
|
LubanCompressUtil.getInstance().getCompressFile(mContext, file, new LubanCompressUtil.CompressCallback() {
|
||||||
@@ -220,13 +273,17 @@ public class MineInfomationActivity extends BaseActivity<MineInformationLayoutBi
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
hideDialogLoading();
|
// 上传图片
|
||||||
ToastUtil.showShort(mContext,getString(R.string.avatar_update_success));
|
mPresenter.uploadImage(file);
|
||||||
|
|
||||||
Glide.with(mContext)
|
|
||||||
.load(file)
|
// hideDialogLoading();
|
||||||
.error(mContext.getDrawable(R.mipmap.icon_mine_user_head_defaul))
|
// ToastUtil.showShort(mContext,getString(R.string.avatar_update_success));
|
||||||
.into(viewBinding.imgAvatar);
|
//
|
||||||
|
// Glide.with(mContext)
|
||||||
|
// .load(file)
|
||||||
|
// .error(mContext.getDrawable(R.mipmap.icon_mine_user_head_defaul))
|
||||||
|
// .into(viewBinding.imgAvatar);
|
||||||
} else {
|
} else {
|
||||||
ToastUtil.showShort(mContext, getString(R.string.file_not_exist));
|
ToastUtil.showShort(mContext, getString(R.string.file_not_exist));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ import android.view.View;
|
|||||||
|
|
||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
import com.ckkj.water.base.BaseActivity;
|
import com.ckkj.water.base.BaseActivity;
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
import com.ckkj.water.main.entity.CheckVersionEntity;
|
||||||
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
import com.ckkj.water.databinding.PasswordManLayoutBinding;
|
import com.ckkj.water.databinding.PasswordManLayoutBinding;
|
||||||
import com.ckkj.water.login.ForgetPasswordActivity;
|
import com.ckkj.water.login.ForgetPasswordActivity;
|
||||||
import com.ckkj.water.mine.mvp.MineContract;
|
import com.ckkj.water.mine.mvp.MineContract;
|
||||||
@@ -101,4 +102,24 @@ public class PsdManageActivity extends BaseActivity<PasswordManLayoutBinding, Mi
|
|||||||
public void logOutSuccess(BaseBean bean) {
|
public void logOutSuccess(BaseBean bean) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uploadImageSuccess(MineUserInfoBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getAppVersionSuccess(CheckVersionEntity bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getAccountLogoffCodeSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void confirmAccountLogoffCodeSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,12 +1,17 @@
|
|||||||
package com.ckkj.water.mine;
|
package com.ckkj.water.mine;
|
||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.InputType;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import android.text.method.PasswordTransformationMethod;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.widget.EditText;
|
||||||
|
import android.widget.ImageView;
|
||||||
|
|
||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
import com.ckkj.water.base.BaseActivity;
|
import com.ckkj.water.base.BaseActivity;
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
import com.ckkj.water.main.entity.CheckVersionEntity;
|
||||||
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
import com.ckkj.water.databinding.ResetPsdLayoutBinding;
|
import com.ckkj.water.databinding.ResetPsdLayoutBinding;
|
||||||
import com.ckkj.water.mine.mvp.MineContract;
|
import com.ckkj.water.mine.mvp.MineContract;
|
||||||
import com.ckkj.water.mine.mvp.MineImpl;
|
import com.ckkj.water.mine.mvp.MineImpl;
|
||||||
@@ -24,6 +29,10 @@ import com.gyf.immersionbar.ImmersionBar;
|
|||||||
public class ResetPsdActivity extends BaseActivity<ResetPsdLayoutBinding, MinePresenter>
|
public class ResetPsdActivity extends BaseActivity<ResetPsdLayoutBinding, MinePresenter>
|
||||||
implements MineContract.MineView {
|
implements MineContract.MineView {
|
||||||
|
|
||||||
|
private boolean isOldPasswordVisible = false;
|
||||||
|
private boolean isNewPasswordVisible = false;
|
||||||
|
private boolean isConfirmPasswordVisible = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initData(Bundle savedInstanceState) {
|
public void initData(Bundle savedInstanceState) {
|
||||||
super.initData(savedInstanceState);
|
super.initData(savedInstanceState);
|
||||||
@@ -40,6 +49,9 @@ public class ResetPsdActivity extends BaseActivity<ResetPsdLayoutBinding, MinePr
|
|||||||
private void initListener() {
|
private void initListener() {
|
||||||
setClick(viewBinding.includedTitle.imgBack);
|
setClick(viewBinding.includedTitle.imgBack);
|
||||||
setClick(viewBinding.tvCommit);
|
setClick(viewBinding.tvCommit);
|
||||||
|
setClick(viewBinding.imgPsdShowHideOld);
|
||||||
|
setClick(viewBinding.imgPsdShowHideNew1);
|
||||||
|
setClick(viewBinding.imgPsdShowHideNew2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setClick(View view) {
|
private void setClick(View view) {
|
||||||
@@ -77,9 +89,45 @@ public class ResetPsdActivity extends BaseActivity<ResetPsdLayoutBinding, MinePr
|
|||||||
mPresenter.updateUserPsdByOld(viewBinding.etCurrentPsd.getText().toString(),
|
mPresenter.updateUserPsdByOld(viewBinding.etCurrentPsd.getText().toString(),
|
||||||
viewBinding.etInputConfirmPsd.getText().toString());
|
viewBinding.etInputConfirmPsd.getText().toString());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case R.id.img_psd_show_hide_old:
|
||||||
|
togglePasswordVisibility(viewBinding.etCurrentPsd, viewBinding.imgPsdShowHideOld,
|
||||||
|
isOldPasswordVisible);
|
||||||
|
isOldPasswordVisible = !isOldPasswordVisible;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R.id.img_psd_show_hide_new1:
|
||||||
|
togglePasswordVisibility(viewBinding.etNewPsd, viewBinding.imgPsdShowHideNew1,
|
||||||
|
isNewPasswordVisible);
|
||||||
|
isNewPasswordVisible = !isNewPasswordVisible;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R.id.img_psd_show_hide_new2:
|
||||||
|
togglePasswordVisibility(viewBinding.etInputConfirmPsd, viewBinding.imgPsdShowHideNew2,
|
||||||
|
isConfirmPasswordVisible);
|
||||||
|
isConfirmPasswordVisible = !isConfirmPasswordVisible;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void togglePasswordVisibility(EditText editText, ImageView imageView, boolean isVisible) {
|
||||||
|
if (editText == null || imageView == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isVisible) {
|
||||||
|
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
||||||
|
editText.setTransformationMethod(PasswordTransformationMethod.getInstance());
|
||||||
|
imageView.setImageResource(R.mipmap.icon_psd_hide);
|
||||||
|
} else {
|
||||||
|
editText.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
|
||||||
|
editText.setTransformationMethod(null);
|
||||||
|
imageView.setImageResource(R.mipmap.icon_psd_show);
|
||||||
|
}
|
||||||
|
|
||||||
|
editText.setSelection(editText.getText().length());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 密码重置成功
|
* 密码重置成功
|
||||||
* @param bean
|
* @param bean
|
||||||
@@ -96,6 +144,26 @@ public class ResetPsdActivity extends BaseActivity<ResetPsdLayoutBinding, MinePr
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uploadImageSuccess(MineUserInfoBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getAppVersionSuccess(CheckVersionEntity bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getAccountLogoffCodeSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void confirmAccountLogoffCodeSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MinePresenter createPresenter() {
|
public MinePresenter createPresenter() {
|
||||||
return new MinePresenter(new MineImpl());
|
return new MinePresenter(new MineImpl());
|
||||||
|
|||||||
@@ -1,12 +1,22 @@
|
|||||||
package com.ckkj.water.mine;
|
package com.ckkj.water.mine;
|
||||||
|
|
||||||
|
import static com.ckkj.water.ConstantUtil.POST_NOTIFICATIONS_PERMISSION_CODE;
|
||||||
|
import static com.ckkj.water.ConstantUtil.WRITE_FILE_PERMISSON_CPDE;
|
||||||
|
|
||||||
|
import android.Manifest;
|
||||||
import android.content.pm.PackageInfo;
|
import android.content.pm.PackageInfo;
|
||||||
import android.content.pm.PackageManager;
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
|
import com.ckkj.water.main.MainContract;
|
||||||
|
import com.ckkj.water.main.entity.CheckVersionEntity;
|
||||||
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
|
import com.ckkj.water.utils.AppInfoUtil;
|
||||||
|
import com.ckkj.water.utils.manager.ThemeManager;
|
||||||
import com.gyf.immersionbar.ImmersionBar;
|
import com.gyf.immersionbar.ImmersionBar;
|
||||||
import com.ckkj.water.AppConfig;
|
import com.ckkj.water.AppConfig;
|
||||||
import com.ckkj.water.EventMessage;
|
import com.ckkj.water.EventMessage;
|
||||||
@@ -24,9 +34,13 @@ import com.ckkj.water.utils.manager.ActivityManager;
|
|||||||
import com.ckkj.water.utils.manager.WaterUserInfoManager;
|
import com.ckkj.water.utils.manager.WaterUserInfoManager;
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
import com.ckkj.water.utils.show.ToastUtil;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import de.greenrobot.event.EventBus;
|
import de.greenrobot.event.EventBus;
|
||||||
|
import pub.devrel.easypermissions.EasyPermissions;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author fengxiaoyang
|
* @author fengxiaoyang
|
||||||
@@ -35,23 +49,21 @@ import de.greenrobot.event.EventBus;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public class SettingsActivity extends BaseActivity<ActivitySettingsLayoutBinding, MinePresenter>
|
public class SettingsActivity extends BaseActivity<ActivitySettingsLayoutBinding, MinePresenter>
|
||||||
implements MineContract.MineView {
|
implements MineContract.MineView, MainContract.MainView, EasyPermissions.PermissionCallbacks{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initData(Bundle savedInstanceState) {
|
public void initData(Bundle savedInstanceState) {
|
||||||
super.initData(savedInstanceState);
|
super.initData(savedInstanceState);
|
||||||
ImmersionBar.with(this)
|
ImmersionBar.with(this)
|
||||||
.statusBarColor(R.color.white)
|
.statusBarDarkFont(ThemeManager.isAppThemeLight(mContext)) // 白色状态栏图标
|
||||||
.statusBarDarkFont(true)
|
.navigationBarColor(R.color.color_gray_theme)
|
||||||
.titleBar(viewBinding.rlTitle) // 替换为你的标题栏View
|
.titleBar(viewBinding.rlTitle)
|
||||||
.keyboardEnable(true)
|
|
||||||
.navigationBarDarkIcon(true)
|
|
||||||
.init();
|
.init();
|
||||||
viewBinding.includeTitle.tvTitle.setText("设置");
|
viewBinding.includeTitle.tvTitle.setText(R.string.settings_title);
|
||||||
viewBinding.includeTitle.imgBack.setOnClickListener(c -> finish());
|
viewBinding.includeTitle.imgBack.setOnClickListener(c -> finish());
|
||||||
if(AppConfig.USER_LOGIN){
|
if(AppConfig.USER_LOGIN){
|
||||||
// viewBinding.tvUserPhone.setText(WaterUserInfoManager.getInstance().getUserInfo().getMobile());
|
// viewBinding.tvUserPhone.setText(WaterUserInfoManager.getInstance().getUserInfo().getMobile());
|
||||||
viewBinding.tvLogOut.setVisibility(View.VISIBLE);
|
// viewBinding.tvLogOut.setVisibility(View.VISIBLE);
|
||||||
}
|
}
|
||||||
//获取本应用所占用的缓存
|
//获取本应用所占用的缓存
|
||||||
displayCacheSize();
|
displayCacheSize();
|
||||||
@@ -62,12 +74,28 @@ public class SettingsActivity extends BaseActivity<ActivitySettingsLayoutBinding
|
|||||||
PackageInfo packageInfo = packageManager.getPackageInfo(mContext.getPackageName(), 0);
|
PackageInfo packageInfo = packageManager.getPackageInfo(mContext.getPackageName(), 0);
|
||||||
// 获取版本名称
|
// 获取版本名称
|
||||||
String versionName = packageInfo.versionName;
|
String versionName = packageInfo.versionName;
|
||||||
viewBinding.tvVersionName.setText("version " + versionName);
|
viewBinding.tvVersionName.setText(versionName);
|
||||||
} catch (PackageManager.NameNotFoundException e) {
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
initListener();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void initListener() {
|
||||||
|
setClick(viewBinding.rlCheckVersion);
|
||||||
|
setClick(viewBinding.rlSetCache);
|
||||||
|
setClick(viewBinding.rlUserAgreement);
|
||||||
|
setClick(viewBinding.rlUserPrivacy);
|
||||||
|
setClick(viewBinding.rlLogOff);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setClick(View view) {
|
||||||
|
view.setOnClickListener(this::onClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MinePresenter createPresenter() {
|
public MinePresenter createPresenter() {
|
||||||
return new MinePresenter(new MineImpl());
|
return new MinePresenter(new MineImpl());
|
||||||
@@ -81,16 +109,11 @@ public class SettingsActivity extends BaseActivity<ActivitySettingsLayoutBinding
|
|||||||
public void onClick(View v) {
|
public void onClick(View v) {
|
||||||
switch (v.getId()){
|
switch (v.getId()){
|
||||||
|
|
||||||
case R.id.rl_change_phone:
|
|
||||||
goTo(mContext, ChangePhoneActivity.class,null);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.rl_check_version://版本检测
|
case R.id.rl_check_version://版本检测
|
||||||
//版本检测更新
|
//版本检测更新
|
||||||
|
mPresenter.checkNewVersion();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.rl_commit_service:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.rl_set_cache:
|
case R.id.rl_set_cache:
|
||||||
showLoadingDialog();
|
showLoadingDialog();
|
||||||
@@ -99,32 +122,12 @@ public class SettingsActivity extends BaseActivity<ActivitySettingsLayoutBinding
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
hideDialogLoading();
|
hideDialogLoading();
|
||||||
ToastUtil.showShort(mContext,"缓存清除成功");
|
ToastUtil.showShort(mContext,getString(R.string.cache_cleared_success));
|
||||||
displayCacheSize();
|
displayCacheSize();
|
||||||
}
|
}
|
||||||
},800);
|
},800);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.tv_log_out:
|
|
||||||
showDialogtext(mContext.getResources().getDrawable(R.mipmap.img_location), false, false,true,
|
|
||||||
getString(R.string.tip_text),
|
|
||||||
getString(R.string.logout_dialog_tips),
|
|
||||||
getString(R.string.cancel_text),
|
|
||||||
getString(R.string.confirm_text),
|
|
||||||
new BaseFragment.OnDialogClick() {
|
|
||||||
@Override
|
|
||||||
public void onCancelClick() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConfirmClick() {
|
|
||||||
WaterUserInfoManager.getInstance().clearUser(mContext);
|
|
||||||
ActivityManager.removeAllActivity();
|
|
||||||
goTo(mContext, LoginActivity.class,null);
|
|
||||||
EventBus.getDefault().post(new EventMessage(EventMessage.USER_LOGIN_LOST));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.rl_user_agreement://用户协议
|
case R.id.rl_user_agreement://用户协议
|
||||||
Bundle bundle = new Bundle();
|
Bundle bundle = new Bundle();
|
||||||
@@ -224,4 +227,114 @@ public class SettingsActivity extends BaseActivity<ActivitySettingsLayoutBinding
|
|||||||
public void logOutSuccess(BaseBean bean) {
|
public void logOutSuccess(BaseBean bean) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uploadImageSuccess(MineUserInfoBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getAppVersionSuccess(CheckVersionEntity bean) {
|
||||||
|
int versionCode = (int) AppInfoUtil.getAppVersionCode(mContext);
|
||||||
|
if(bean == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(!bean.isForceUpdate()){//不强制
|
||||||
|
isForceUpdate = false;
|
||||||
|
}else{
|
||||||
|
isForceUpdate = true;
|
||||||
|
}
|
||||||
|
//前期强制更新
|
||||||
|
// isForceUpdate = true;
|
||||||
|
if(bean.getVersionCode() > versionCode){
|
||||||
|
//App更新dialog
|
||||||
|
mUpdateDialog = new DialogAppUpdate(mContext,R.layout.dialog_app_update_water,isForceUpdate,bean);
|
||||||
|
mUpdateDialog.show();
|
||||||
|
mUpdateDialog.setOnDialogListener(new DialogAppUpdate.DialogListener() {
|
||||||
|
@Override
|
||||||
|
public void callBackGetPermisson(String permission) {
|
||||||
|
if (!hasRecordPermission(permission)) {
|
||||||
|
if (Manifest.permission.POST_NOTIFICATIONS.equals(permission)) {
|
||||||
|
getPermissionRequst(permission,
|
||||||
|
getString(R.string.notification_permission_request),
|
||||||
|
getString(R.string.notification_permission_desc),
|
||||||
|
POST_NOTIFICATIONS_PERMISSION_CODE);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 没有权限,只在ACTION_DOWN时去申请
|
||||||
|
getPermissionRequst(permission,
|
||||||
|
getString(R.string.storage_permission_request),
|
||||||
|
getString(R.string.storage_permission_desc),
|
||||||
|
WRITE_FILE_PERMISSON_CPDE);
|
||||||
|
}else{
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void downLoadFinish() {
|
||||||
|
runOnUiThread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
ToastUtil.showShort(mContext,getString(R.string.download_complete_installing));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
ToastUtil.showShort(mContext,"当前已是最新版本");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getAccountLogoffCodeSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void confirmAccountLogoffCodeSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void activationVipSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getVersionCheck(CheckVersionEntity bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getYunshiDataSuccess(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onRequestPermissionsResult(int requestCode, @NonNull @NotNull String[] permissions, @NonNull @NotNull int[] grantResults) {
|
||||||
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
|
||||||
|
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this);
|
||||||
|
hidePermissionDialog();
|
||||||
|
if(requestCode == WRITE_FILE_PERMISSON_CPDE){
|
||||||
|
if(mUpdateDialog != null && grantResults.length > 0 && grantResults[0] == android.content.pm.PackageManager.PERMISSION_GRANTED){
|
||||||
|
mUpdateDialog.startUpdateApp();
|
||||||
|
}
|
||||||
|
}else if(requestCode == POST_NOTIFICATIONS_PERMISSION_CODE){
|
||||||
|
if(mUpdateDialog != null && grantResults.length > 0 && grantResults[0] == android.content.pm.PackageManager.PERMISSION_GRANTED){
|
||||||
|
mUpdateDialog.startUpdateApp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,7 +5,12 @@ import android.os.CountDownTimer;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
import com.ckkj.water.base.BaseFragment;
|
||||||
|
import com.ckkj.water.login.LoginActivity;
|
||||||
|
import com.ckkj.water.main.entity.CheckVersionEntity;
|
||||||
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
|
import com.ckkj.water.utils.manager.ActivityManager;
|
||||||
|
import com.ckkj.water.utils.manager.WaterUserInfoManager;
|
||||||
import com.gyf.immersionbar.ImmersionBar;
|
import com.gyf.immersionbar.ImmersionBar;
|
||||||
import com.ckkj.water.AppConfig;
|
import com.ckkj.water.AppConfig;
|
||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
@@ -15,8 +20,6 @@ import com.ckkj.water.mine.mvp.MineContract;
|
|||||||
import com.ckkj.water.mine.mvp.MineImpl;
|
import com.ckkj.water.mine.mvp.MineImpl;
|
||||||
import com.ckkj.water.mine.mvp.MinePresenter;
|
import com.ckkj.water.mine.mvp.MinePresenter;
|
||||||
import com.ckkj.water.network.BaseBean;
|
import com.ckkj.water.network.BaseBean;
|
||||||
import com.ckkj.water.utils.manager.WaterUserInfoManager;
|
|
||||||
import com.ckkj.water.utils.number.PhoneNumberUtils;
|
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
import com.ckkj.water.utils.show.ToastUtil;
|
||||||
|
|
||||||
|
|
||||||
@@ -47,13 +50,26 @@ public class UserLogOffAccountActivity extends BaseActivity<UserLogOffActivityBi
|
|||||||
.statusBarDarkFont(true) // 设置状态栏字体为黑色
|
.statusBarDarkFont(true) // 设置状态栏字体为黑色
|
||||||
.titleBar(viewBinding.rlTitle)
|
.titleBar(viewBinding.rlTitle)
|
||||||
.init();
|
.init();
|
||||||
viewBinding.includeTitle.tvTitle.setText("注销账号");
|
viewBinding.includeTitle.tvTitle.setText(getString(R.string.delete_account));
|
||||||
|
viewBinding.includeTitle.imgBack.setOnClickListener(c -> finish());
|
||||||
if(AppConfig.USER_LOGIN){
|
if(AppConfig.USER_LOGIN){
|
||||||
// String phoneNum = WaterUserInfoManager.getInstance().getUserInfo().getMobile();
|
String userAccount = (!TextUtils.isEmpty(WaterUserInfoManager.getInstance().getUserInfo().getUser().getPhonenumber()) ?
|
||||||
// if(!TextUtils.isEmpty(phoneNum)){
|
WaterUserInfoManager.getInstance().getUserInfo().getUser().getPhonenumber() :
|
||||||
// viewBinding.tvUserPhone.setText(PhoneNumberUtils.hidePhoneNumber(phoneNum));
|
WaterUserInfoManager.getInstance().getUserInfo().getUser().getEmail());
|
||||||
// }
|
if(!TextUtils.isEmpty(userAccount)){
|
||||||
|
viewBinding.tvUserPhone.setText(userAccount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
initListener();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initListener() {
|
||||||
|
setClick(viewBinding.tvGetCode);
|
||||||
|
setClick(viewBinding.tvCommit);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setClick(View view) {
|
||||||
|
view.setOnClickListener(this::onClick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -65,26 +81,64 @@ public class UserLogOffAccountActivity extends BaseActivity<UserLogOffActivityBi
|
|||||||
|
|
||||||
case R.id.tv_get_code:
|
case R.id.tv_get_code:
|
||||||
showLoadingDialog();
|
showLoadingDialog();
|
||||||
|
mPresenter.getAccountLogoffCode();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.tv_commit:
|
case R.id.tv_commit:
|
||||||
if(TextUtils.isEmpty(viewBinding.edVerCode.getText().toString().trim())){
|
if(TextUtils.isEmpty(viewBinding.edVerCode.getText().toString().trim())){
|
||||||
ToastUtil.showShort(mContext,"请填写验证码");
|
ToastUtil.showShort(mContext, getString(R.string.login_error_code_empty));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(viewBinding.edVerCode.getText().toString().trim().length() < 6){
|
if(viewBinding.edVerCode.getText().toString().trim().length() < 6){
|
||||||
ToastUtil.showShort(mContext,"请填写6位验证码");
|
ToastUtil.showShort(mContext,getString(R.string.login_error_code_invalid));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
showDialogtext(null, false, false, true,
|
||||||
|
getString(R.string.tip_text),
|
||||||
|
getString(R.string.delete_account_tip),
|
||||||
|
getString(R.string.cancel_text),
|
||||||
|
getString(R.string.confirm_text),
|
||||||
|
new BaseFragment.OnDialogClick() {
|
||||||
|
@Override
|
||||||
|
public void onCancelClick() {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onConfirmClick() {
|
||||||
|
mPresenter.confirmAccountLogoff(viewBinding.edVerCode.getText().toString().trim());
|
||||||
|
}
|
||||||
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取账号注销验证码成功
|
||||||
|
* @param bean
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void getAccountLogoffCodeSuccess(BaseBean bean) {
|
||||||
|
hideDialogLoading();
|
||||||
|
ToastUtil.showShort(mContext,getString(R.string.verification_code_sent));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确认账号注销成功
|
||||||
|
* @param bean
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void confirmAccountLogoffCodeSuccess(BaseBean bean) {
|
||||||
|
WaterUserInfoManager.getInstance().clearUser(mContext);
|
||||||
|
ActivityManager.removeAllActivity();
|
||||||
|
goTo(mContext, LoginActivity.class,null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private CountDownTimer cdTimer = new CountDownTimer(60000, 1000) {
|
private CountDownTimer cdTimer = new CountDownTimer(60000, 1000) {
|
||||||
@Override
|
@Override
|
||||||
public void onTick(long millisUntilFinished) {
|
public void onTick(long millisUntilFinished) {
|
||||||
viewBinding.tvGetCode.setText("(" + millisUntilFinished / 1000 + ")秒后重发");
|
viewBinding.tvGetCode.setText("(" + millisUntilFinished / 1000 + ")" + getString(R.string.resend_after_seconds));
|
||||||
viewBinding.tvGetCode.setSelected(true);
|
viewBinding.tvGetCode.setSelected(true);
|
||||||
viewBinding.tvGetCode.setClickable(false);
|
viewBinding.tvGetCode.setClickable(false);
|
||||||
viewBinding.tvGetCode.setTextColor(mContext.getColor(R.color.color_c8c8c8));
|
viewBinding.tvGetCode.setTextColor(mContext.getColor(R.color.color_c8c8c8));
|
||||||
@@ -92,7 +146,7 @@ public class UserLogOffAccountActivity extends BaseActivity<UserLogOffActivityBi
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFinish() {
|
public void onFinish() {
|
||||||
viewBinding.tvGetCode.setText("重新发送");
|
viewBinding.tvGetCode.setText(getString(R.string.resend));
|
||||||
viewBinding.tvGetCode.setSelected(false);
|
viewBinding.tvGetCode.setSelected(false);
|
||||||
viewBinding.tvGetCode.setClickable(true);
|
viewBinding.tvGetCode.setClickable(true);
|
||||||
viewBinding.tvGetCode.setTextColor(mContext.getColor(R.color.color_zhu));
|
viewBinding.tvGetCode.setTextColor(mContext.getColor(R.color.color_zhu));
|
||||||
@@ -131,4 +185,16 @@ public class UserLogOffAccountActivity extends BaseActivity<UserLogOffActivityBi
|
|||||||
public void logOutSuccess(BaseBean bean) {
|
public void logOutSuccess(BaseBean bean) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void uploadImageSuccess(MineUserInfoBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getAppVersionSuccess(CheckVersionEntity bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
package com.ckkj.water.base.entity;
|
package com.ckkj.water.mine.entity;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@@ -26,6 +26,8 @@ public class MineUserInfoBean implements Serializable {
|
|||||||
private UserBean user;
|
private UserBean user;
|
||||||
private List<?> permissions;
|
private List<?> permissions;
|
||||||
private List<?> roles;
|
private List<?> roles;
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
@Data
|
@Data
|
||||||
@@ -64,7 +66,7 @@ public class MineUserInfoBean implements Serializable {
|
|||||||
private String email;
|
private String email;
|
||||||
private String phonenumber;
|
private String phonenumber;
|
||||||
private String sex;
|
private String sex;
|
||||||
private Object avatar;
|
private String avatar;
|
||||||
private String password;
|
private String password;
|
||||||
private String status;
|
private String status;
|
||||||
private String loginIp;
|
private String loginIp;
|
||||||
@@ -77,5 +79,6 @@ public class MineUserInfoBean implements Serializable {
|
|||||||
private Object roleId;
|
private Object roleId;
|
||||||
private Object oldPassword;
|
private Object oldPassword;
|
||||||
private List<?> roles;
|
private List<?> roles;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,12 @@
|
|||||||
package com.ckkj.water.mine.mvp;
|
package com.ckkj.water.mine.mvp;
|
||||||
|
|
||||||
import com.ckkj.water.base.IView;
|
import com.ckkj.water.base.IView;
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
|
||||||
import com.ckkj.water.login.mvp.LoginContract;
|
|
||||||
import com.ckkj.water.main.entity.CheckVersionEntity;
|
import com.ckkj.water.main.entity.CheckVersionEntity;
|
||||||
import com.ckkj.water.mine.entity.InviteeRecordEntity;
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
import com.ckkj.water.mine.entity.MemberComboEntity;
|
|
||||||
import com.ckkj.water.mine.entity.RecommendDataEntity;
|
|
||||||
import com.ckkj.water.mine.entity.RewardRecordEntity;
|
|
||||||
import com.ckkj.water.network.BaseBean;
|
import com.ckkj.water.network.BaseBean;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -33,6 +27,8 @@ public class MineContract {
|
|||||||
void updateUserInfo(JSONObject json, CallBack callBack);
|
void updateUserInfo(JSONObject json, CallBack callBack);
|
||||||
//通过旧密码,修改新密码
|
//通过旧密码,修改新密码
|
||||||
void updateUserPwdByOld(JSONObject json, CallBack callBack);
|
void updateUserPwdByOld(JSONObject json, CallBack callBack);
|
||||||
|
//上传图片
|
||||||
|
void uploadImage(JSONObject json, CallBack callBack);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -47,6 +43,14 @@ public class MineContract {
|
|||||||
void updateUserPasswordSuccess(BaseBean bean);
|
void updateUserPasswordSuccess(BaseBean bean);
|
||||||
//退出登录
|
//退出登录
|
||||||
void logOutSuccess(BaseBean bean);
|
void logOutSuccess(BaseBean bean);
|
||||||
|
//上传图片成功
|
||||||
|
void uploadImageSuccess(MineUserInfoBean bean);
|
||||||
|
//获取新版本信息成功
|
||||||
|
void getAppVersionSuccess(CheckVersionEntity bean);
|
||||||
|
//获取注销账号验证码成功
|
||||||
|
void getAccountLogoffCodeSuccess(BaseBean bean);
|
||||||
|
//确认注销账号成功
|
||||||
|
void confirmAccountLogoffCodeSuccess(BaseBean bean);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface RecommendModel{
|
public interface RecommendModel{
|
||||||
|
|||||||
@@ -1,15 +1,12 @@
|
|||||||
package com.ckkj.water.mine.mvp;
|
package com.ckkj.water.mine.mvp;
|
||||||
|
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
import com.ckkj.water.login.mvp.LoginContract;
|
|
||||||
import com.ckkj.water.mine.entity.MemberComboEntity;
|
|
||||||
import com.ckkj.water.network.BaseBean;
|
import com.ckkj.water.network.BaseBean;
|
||||||
import com.ckkj.water.network.LoginStateManager;
|
|
||||||
import com.ckkj.water.network.NetWorkManager;
|
import com.ckkj.water.network.NetWorkManager;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.List;
|
import java.io.File;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import io.reactivex.Observer;
|
import io.reactivex.Observer;
|
||||||
@@ -17,6 +14,9 @@ import io.reactivex.android.schedulers.AndroidSchedulers;
|
|||||||
import io.reactivex.annotations.NonNull;
|
import io.reactivex.annotations.NonNull;
|
||||||
import io.reactivex.disposables.Disposable;
|
import io.reactivex.disposables.Disposable;
|
||||||
import io.reactivex.schedulers.Schedulers;
|
import io.reactivex.schedulers.Schedulers;
|
||||||
|
import okhttp3.MediaType;
|
||||||
|
import okhttp3.MultipartBody;
|
||||||
|
import okhttp3.RequestBody;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author fengxiaoyang
|
* @author fengxiaoyang
|
||||||
@@ -140,4 +140,76 @@ public class MineImpl implements MineContract.DataModel {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传图片
|
||||||
|
*
|
||||||
|
* @param json 预留参数,目前接口不需要,但保留扩展能力(例如上传类型/用户ID等)
|
||||||
|
* @param callBack 上传结果回调
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void uploadImage(JSONObject json, MineContract.CallBack callBack) {
|
||||||
|
File file = null;
|
||||||
|
if (json != null && json.has("file")) {
|
||||||
|
try {
|
||||||
|
String path = json.getString("file");
|
||||||
|
if (path != null && !path.isEmpty()) {
|
||||||
|
file = new File(path);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (file == null || !file.exists()) {
|
||||||
|
callBack.fail("文件不存在");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 推断 MIME 类型:根据后缀决定 image/jpeg 或 image/png,其它统一用 image/jpeg
|
||||||
|
String fileName = file.getName().toLowerCase();
|
||||||
|
MediaType mediaType;
|
||||||
|
if (fileName.endsWith(".png")) {
|
||||||
|
mediaType = MediaType.parse("image/png");
|
||||||
|
} else if (fileName.endsWith(".jpg") || fileName.endsWith(".jpeg")) {
|
||||||
|
mediaType = MediaType.parse("image/jpeg");
|
||||||
|
} else {
|
||||||
|
mediaType = MediaType.parse("image/jpeg");
|
||||||
|
}
|
||||||
|
RequestBody requestBody = RequestBody.create(mediaType, file);
|
||||||
|
// 参数名固定为 "file",与后端约定一致
|
||||||
|
MultipartBody.Part part = MultipartBody.Part.createFormData("file", file.getName(), requestBody);
|
||||||
|
|
||||||
|
try {
|
||||||
|
NetWorkManager.getRequest().uploadImage(NetWorkManager.getToken(), part)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.unsubscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(new Observer<BaseBean<MineUserInfoBean>>() {
|
||||||
|
@Override
|
||||||
|
public void onSubscribe(@NonNull Disposable d) {
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNext(@NonNull BaseBean<MineUserInfoBean> bean) {
|
||||||
|
if (bean.getCode() == 200) {
|
||||||
|
callBack.success(bean.getData());
|
||||||
|
} else {
|
||||||
|
callBack.fail(bean.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onError(@NonNull Throwable e) {
|
||||||
|
callBack.fail(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onComplete() {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
callBack.fail(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
package com.ckkj.water.mine.mvp;
|
package com.ckkj.water.mine.mvp;
|
||||||
|
|
||||||
import android.text.Editable;
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.ckkj.water.ConstantUtil;
|
import com.ckkj.water.BuildConfig;
|
||||||
import com.ckkj.water.base.BasePresenter;
|
import com.ckkj.water.base.BasePresenter;
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
import com.ckkj.water.main.MainContract;
|
||||||
import com.ckkj.water.base.entity.UserInfoEntity;
|
import com.ckkj.water.main.MainImpl;
|
||||||
|
import com.ckkj.water.main.MainPresenter;
|
||||||
|
import com.ckkj.water.main.entity.CheckVersionEntity;
|
||||||
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
import com.ckkj.water.login.mvp.LoginContract;
|
import com.ckkj.water.login.mvp.LoginContract;
|
||||||
import com.ckkj.water.login.mvp.LoginImpl;
|
import com.ckkj.water.login.mvp.LoginImpl;
|
||||||
import com.ckkj.water.network.BaseBean;
|
import com.ckkj.water.network.BaseBean;
|
||||||
import com.ckkj.water.utils.dataUtil.SharePreUtil;
|
|
||||||
import com.ckkj.water.utils.manager.WaterUserInfoManager;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -58,12 +58,18 @@ public class MinePresenter extends BasePresenter<MineContract.MineView> {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 修改用户信息
|
* 修改用户信息
|
||||||
* @param content
|
* @param nickName
|
||||||
|
* @param avatar
|
||||||
*/
|
*/
|
||||||
public void updateUserInfo(String content) {
|
public void updateUserInfo(String nickName,String avatar) {
|
||||||
try {
|
try {
|
||||||
JSONObject json = new JSONObject();
|
JSONObject json = new JSONObject();
|
||||||
json.put("nickName", content);
|
if(!TextUtils.isEmpty(nickName)){
|
||||||
|
json.put("nickName", nickName);
|
||||||
|
}
|
||||||
|
if(!TextUtils.isEmpty(avatar)){
|
||||||
|
json.put("avatar", avatar);
|
||||||
|
}
|
||||||
impl.updateUserInfo(json, new MineContract.CallBack<BaseBean>() {
|
impl.updateUserInfo(json, new MineContract.CallBack<BaseBean>() {
|
||||||
@Override
|
@Override
|
||||||
public void success(BaseBean bean) {
|
public void success(BaseBean bean) {
|
||||||
@@ -135,4 +141,109 @@ public class MinePresenter extends BasePresenter<MineContract.MineView> {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传图片
|
||||||
|
* @param file 已压缩后的图片文件
|
||||||
|
*/
|
||||||
|
public void uploadImage(File file) {
|
||||||
|
try {
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("file", file == null ? "" : file.getAbsolutePath());
|
||||||
|
impl.uploadImage(json, new MineContract.CallBack<MineUserInfoBean>() {
|
||||||
|
@Override
|
||||||
|
public void success(MineUserInfoBean bean) {
|
||||||
|
if (MinePresenter.this.getView() != null) {
|
||||||
|
MinePresenter.this.getView().uploadImageSuccess(bean);
|
||||||
|
updateUserInfo(null,bean.getUrl());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fail(String msg) {
|
||||||
|
if (MinePresenter.this.getView() != null) {
|
||||||
|
MinePresenter.this.getView().showError(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
if (getView() != null) {
|
||||||
|
getView().showError(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void checkNewVersion() {
|
||||||
|
Map<String,String> map = new HashMap<>();
|
||||||
|
map.put("platform","android");
|
||||||
|
map.put("currentVersion", BuildConfig.APP_VERSION_NAME);
|
||||||
|
new MainImpl().checkAppVersionCode(map, new MainContract.CallBack<CheckVersionEntity>() {
|
||||||
|
@Override
|
||||||
|
public void success(CheckVersionEntity bean) {
|
||||||
|
if( MinePresenter.this.getView() != null){
|
||||||
|
MinePresenter.this.getView().getAppVersionSuccess(bean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fail(String msg) {
|
||||||
|
if( MinePresenter.this.getView() != null){
|
||||||
|
MinePresenter.this.getView().showError(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取注销账号验证码
|
||||||
|
*/
|
||||||
|
public void getAccountLogoffCode() {
|
||||||
|
new LoginImpl().logoffAccountCode(null, new LoginContract.CallBack<BaseBean>() {
|
||||||
|
@Override
|
||||||
|
public void success(BaseBean bean) {
|
||||||
|
if(MinePresenter.this.getView() != null){
|
||||||
|
MinePresenter.this.getView().getAccountLogoffCodeSuccess(bean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fail(String msg) {
|
||||||
|
if(MinePresenter.this.getView() != null){
|
||||||
|
MinePresenter.this.getView().showError(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 确认注销账号
|
||||||
|
* @param verCode
|
||||||
|
*/
|
||||||
|
public void confirmAccountLogoff(String verCode) {
|
||||||
|
try {
|
||||||
|
Map<String,String> map = new HashMap<>();
|
||||||
|
map.put("code",verCode);
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("code",verCode);
|
||||||
|
new LoginImpl().logoffAccount(json, new LoginContract.CallBack<BaseBean>() {
|
||||||
|
@Override
|
||||||
|
public void success(BaseBean bean) {
|
||||||
|
if(MinePresenter.this.getView() != null){
|
||||||
|
MinePresenter.this.getView().confirmAccountLogoffCodeSuccess(bean);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fail(String msg) {
|
||||||
|
if(MinePresenter.this.getView() != null){
|
||||||
|
MinePresenter.this.getView().showError(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (JSONException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.ckkj.water.network;
|
package com.ckkj.water.network;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
@@ -388,7 +389,9 @@ public class NetWorkManager {
|
|||||||
public static Map<String, String> getToken() {
|
public static Map<String, String> getToken() {
|
||||||
Map<String, String> map = new HashMap<>();
|
Map<String, String> map = new HashMap<>();
|
||||||
try {
|
try {
|
||||||
map.put("Authorization", "Bearer " + AppConfig.USER_TOKEN);
|
if(!TextUtils.isEmpty(AppConfig.USER_TOKEN)){
|
||||||
|
map.put("Authorization", "Bearer " + AppConfig.USER_TOKEN);
|
||||||
|
}
|
||||||
map.put("clientId", AppConfig.APP_CLIENT_ID);
|
map.put("clientId", AppConfig.APP_CLIENT_ID);
|
||||||
map.put("content-language", LanguageManager.getCurrentRequestLanguage());
|
map.put("content-language", LanguageManager.getCurrentRequestLanguage());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -2,28 +2,29 @@ package com.ckkj.water.network;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
import com.ckkj.water.history.entity.WaterStatisticsEntity;
|
import com.ckkj.water.history.entity.WaterStatisticsEntity;
|
||||||
import com.ckkj.water.history.entity.WateringRecord;
|
import com.ckkj.water.history.entity.WateringRecord;
|
||||||
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
||||||
import com.ckkj.water.login.entity.LoginEntity;
|
import com.ckkj.water.login.entity.LoginEntity;
|
||||||
import com.ckkj.water.main.entity.CheckVersionEntity;
|
import com.ckkj.water.main.entity.CheckVersionEntity;
|
||||||
import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||||
import com.ckkj.water.plate.entity.BaziResultBean;
|
|
||||||
import com.ckkj.water.plate.entity.BaziSaveSuccessEntity;
|
|
||||||
import com.ckkj.water.plate.entity.PaipanHistoryEntity;
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
|
import okhttp3.MultipartBody;
|
||||||
import okhttp3.RequestBody;
|
import okhttp3.RequestBody;
|
||||||
import retrofit2.http.Body;
|
import retrofit2.http.Body;
|
||||||
import retrofit2.http.DELETE;
|
import retrofit2.http.DELETE;
|
||||||
import retrofit2.http.GET;
|
import retrofit2.http.GET;
|
||||||
|
import retrofit2.http.HTTP;
|
||||||
import retrofit2.http.HeaderMap;
|
import retrofit2.http.HeaderMap;
|
||||||
|
import retrofit2.http.Multipart;
|
||||||
import retrofit2.http.POST;
|
import retrofit2.http.POST;
|
||||||
import retrofit2.http.PUT;
|
import retrofit2.http.PUT;
|
||||||
|
import retrofit2.http.Part;
|
||||||
import retrofit2.http.Path;
|
import retrofit2.http.Path;
|
||||||
import retrofit2.http.QueryMap;
|
import retrofit2.http.QueryMap;
|
||||||
|
|
||||||
@@ -36,6 +37,16 @@ public interface Request {
|
|||||||
//发送验证码
|
//发送验证码
|
||||||
@GET("resource/code")
|
@GET("resource/code")
|
||||||
Observable<BaseBean> sendPhoneCode(@HeaderMap Map<String, String> headMap,@QueryMap Map<String, Object> map);
|
Observable<BaseBean> sendPhoneCode(@HeaderMap Map<String, String> headMap,@QueryMap Map<String, Object> map);
|
||||||
|
|
||||||
|
//注销使用--发送验证码
|
||||||
|
@GET("resource/account/cancel/code")
|
||||||
|
Observable<BaseBean> logoffAccountCode(@HeaderMap Map<String, String> headMap);
|
||||||
|
|
||||||
|
//注销账户
|
||||||
|
@HTTP(method = "DELETE", path = "auth/account", hasBody = true)
|
||||||
|
Observable<BaseBean> confirmLogiffAccount(@HeaderMap Map<String,String> headMap,@Body RequestBody requestBody);
|
||||||
|
|
||||||
|
|
||||||
//注册
|
//注册
|
||||||
@POST("auth/register")
|
@POST("auth/register")
|
||||||
Observable<BaseBean> register(@Body RequestBody requestBody);
|
Observable<BaseBean> register(@Body RequestBody requestBody);
|
||||||
@@ -54,6 +65,13 @@ public interface Request {
|
|||||||
@PUT("app/v1/updataUser")
|
@PUT("app/v1/updataUser")
|
||||||
Observable<BaseBean> updateUserInfo(@HeaderMap Map<String, String> headMap, @Body RequestBody requestBody);
|
Observable<BaseBean> updateUserInfo(@HeaderMap Map<String, String> headMap, @Body RequestBody requestBody);
|
||||||
|
|
||||||
|
//上传图片
|
||||||
|
@Multipart
|
||||||
|
@POST("app/v1/uploadImage")
|
||||||
|
Observable<BaseBean<MineUserInfoBean>> uploadImage(@HeaderMap Map<String, String> headMap,@Part MultipartBody.Part file);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//首页设备列表
|
//首页设备列表
|
||||||
@GET("app/v1/deviceList")
|
@GET("app/v1/deviceList")
|
||||||
Observable<BaseBean<List<WaterDeviceEntity>>> getIndexDeviceList(@HeaderMap Map<String, String> headMap);
|
Observable<BaseBean<List<WaterDeviceEntity>>> getIndexDeviceList(@HeaderMap Map<String, String> headMap);
|
||||||
@@ -74,6 +92,11 @@ public interface Request {
|
|||||||
@PUT("app/v1/switchDevice")
|
@PUT("app/v1/switchDevice")
|
||||||
Observable<BaseBean<WaterPlanWeekEntity>> switchDevice(@HeaderMap Map<String, String> headMap, @Body RequestBody requestBody);
|
Observable<BaseBean<WaterPlanWeekEntity>> switchDevice(@HeaderMap Map<String, String> headMap, @Body RequestBody requestBody);
|
||||||
|
|
||||||
|
//查询设备工作开始时间和结束时间
|
||||||
|
@GET("app/v1/latestWaterLog")
|
||||||
|
Observable<BaseBean<WaterDeviceEntity>> queryDeviceWorkTime(@HeaderMap Map<String, String> headMap,@QueryMap Map<String, String> map);
|
||||||
|
|
||||||
|
|
||||||
//修改更新设备信息
|
//修改更新设备信息
|
||||||
@PUT("app/v1/updateDeviceInfo")
|
@PUT("app/v1/updateDeviceInfo")
|
||||||
Observable<BaseBean> updateDeviceInfo(@HeaderMap Map<String, String> headMap, @Body RequestBody requestBody);
|
Observable<BaseBean> updateDeviceInfo(@HeaderMap Map<String, String> headMap, @Body RequestBody requestBody);
|
||||||
@@ -124,6 +147,17 @@ public interface Request {
|
|||||||
@DELETE("app/v1/deleteDevice/{deviceNo}")
|
@DELETE("app/v1/deleteDevice/{deviceNo}")
|
||||||
Observable<BaseBean> unBindDevice(@HeaderMap Map<String,String> headMap, @Path("deviceNo") String id);
|
Observable<BaseBean> unBindDevice(@HeaderMap Map<String,String> headMap, @Path("deviceNo") String id);
|
||||||
|
|
||||||
|
|
||||||
|
//设备列表中,移除该设备
|
||||||
|
@DELETE("app/v1/removeDeviceEntry/{deviceNo}")
|
||||||
|
Observable<BaseBean> removeDeviceEntry(@HeaderMap Map<String,String> headMap, @Path("deviceNo") String id);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//设备恢复出厂设置
|
||||||
|
@DELETE("app/v1/factoryReset/{deviceNo}")
|
||||||
|
Observable<BaseBean> deviceFactoryReset(@HeaderMap Map<String,String> headMap, @Path("deviceNo") String id);
|
||||||
|
|
||||||
//排程解绑设备
|
//排程解绑设备
|
||||||
@DELETE("app/v1/deleteScheduleDevice")
|
@DELETE("app/v1/deleteScheduleDevice")
|
||||||
Observable<BaseBean> planUnBindDevice(@HeaderMap Map<String,String> headMap,@QueryMap Map<String, String> map);
|
Observable<BaseBean> planUnBindDevice(@HeaderMap Map<String,String> headMap,@QueryMap Map<String, String> map);
|
||||||
@@ -140,28 +174,14 @@ public interface Request {
|
|||||||
Observable<BaseBean<WaterStatisticsEntity>> getDataStatistics(@HeaderMap Map<String, String> headMap);
|
Observable<BaseBean<WaterStatisticsEntity>> getDataStatistics(@HeaderMap Map<String, String> headMap);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@POST("mobile/version?end=android")
|
|
||||||
Observable<BaseBean<CheckVersionEntity>> checkVersionCode(@HeaderMap Map<String, String> headMap, @Body RequestBody requestBody);
|
|
||||||
//版本检测更新
|
//版本检测更新
|
||||||
|
@GET("app/v1/checkVersion")
|
||||||
|
Observable<BaseBean<CheckVersionEntity>> checkVersionCode(@HeaderMap Map<String, String> headMap, @QueryMap Map<String, String> map);
|
||||||
|
|
||||||
@POST("mine/api/versionNum")
|
@POST("mine/api/versionNum")
|
||||||
Observable<BaseBean<CheckVersionEntity>> getVersionCheck(@HeaderMap Map<String, String> headMap, @QueryMap Map<String, Object> map);
|
Observable<BaseBean<CheckVersionEntity>> getVersionCheck(@HeaderMap Map<String, String> headMap, @QueryMap Map<String, Object> map);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//保存排盘结果
|
|
||||||
@POST("mobile/paiPan")
|
|
||||||
Observable<BaseBean<BaziSaveSuccessEntity>> startPaipan(@HeaderMap Map<String, String> headMap, @Body RequestBody requestBody);
|
|
||||||
//AI解析排盘结果
|
|
||||||
@POST("mobile/paiPan/ai")
|
|
||||||
Observable<BaseBean> aiParesBaziResult(@HeaderMap Map<String, String> headMap, @Body RequestBody requestBody);
|
|
||||||
//开始排盘
|
|
||||||
@POST("https://api.yuanfenju.com/index.php/v1/Bazi/jingpan")
|
|
||||||
Observable<BaseYfjApiBean<BaziResultBean>> startPaipanByYfj(@HeaderMap Map<String, String> headMap, @QueryMap Map<String, Object> map);
|
|
||||||
//获取运势历史列表
|
|
||||||
@GET("mobile/paiPan/records")
|
|
||||||
Observable<BaseBean<PaipanHistoryEntity>> getPaipanHistoryList(@HeaderMap Map<String, String> headMap);
|
|
||||||
//删除历史记录
|
//删除历史记录
|
||||||
@POST("mobile/paiPan/record")
|
@POST("mobile/paiPan/record")
|
||||||
Observable<BaseBean> deletePaipanRecordById(@HeaderMap Map<String, String> headMap, @QueryMap Map<String, Object> map);
|
Observable<BaseBean> deletePaipanRecordById(@HeaderMap Map<String, String> headMap, @QueryMap Map<String, Object> map);
|
||||||
|
|||||||
@@ -5,16 +5,13 @@ import android.content.pm.PackageManager;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Toast;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.core.content.ContextCompat;
|
import androidx.core.content.ContextCompat;
|
||||||
|
|
||||||
import com.ckkj.water.ConstantUtil;
|
|
||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
import com.ckkj.water.base.BaseActivity;
|
import com.ckkj.water.base.BaseActivity;
|
||||||
import com.ckkj.water.base.BaseActivityNoP;
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
|
||||||
import com.ckkj.water.databinding.PermissionLayoutBinding;
|
import com.ckkj.water.databinding.PermissionLayoutBinding;
|
||||||
import com.ckkj.water.main.MainContract;
|
import com.ckkj.water.main.MainContract;
|
||||||
import com.ckkj.water.main.MainImpl;
|
import com.ckkj.water.main.MainImpl;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
|||||||
import com.ckkj.water.plan.mvp.WaterPlanContract;
|
import com.ckkj.water.plan.mvp.WaterPlanContract;
|
||||||
import com.ckkj.water.plan.mvp.WaterPlanImpl;
|
import com.ckkj.water.plan.mvp.WaterPlanImpl;
|
||||||
import com.ckkj.water.plan.mvp.WaterPlanPresenter;
|
import com.ckkj.water.plan.mvp.WaterPlanPresenter;
|
||||||
import com.ckkj.water.plate.adapter.ViewPagerAdapter;
|
import com.ckkj.water.plan.adapter.ViewPagerAdapter;
|
||||||
import com.ckkj.water.utils.manager.ThemeManager;
|
import com.ckkj.water.utils.manager.ThemeManager;
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
import com.ckkj.water.utils.show.ToastUtil;
|
||||||
import com.gyf.immersionbar.ImmersionBar;
|
import com.gyf.immersionbar.ImmersionBar;
|
||||||
@@ -76,7 +76,7 @@ public class AddWaterPlanActivity extends BaseActivity<AddWaterPlanLayoutBinding
|
|||||||
viewBinding.includedTitle.tvTitle.setText(R.string.add_water_plan_title);
|
viewBinding.includedTitle.tvTitle.setText(R.string.add_water_plan_title);
|
||||||
viewBinding.tvBound.setVisibility(GONE);
|
viewBinding.tvBound.setVisibility(GONE);
|
||||||
}
|
}
|
||||||
mFragmentList.add(new WaterConfigFragment_copy());
|
mFragmentList.add(new WaterConfigFragment());
|
||||||
mFragmentList.add(new PlanBoundDeviceFragment());
|
mFragmentList.add(new PlanBoundDeviceFragment());
|
||||||
mFragmentList.add(new BindDeviceFragment());
|
mFragmentList.add(new BindDeviceFragment());
|
||||||
ViewPagerAdapter adapter = new ViewPagerAdapter(mContext, mFragmentList);
|
ViewPagerAdapter adapter = new ViewPagerAdapter(mContext, mFragmentList);
|
||||||
@@ -92,7 +92,7 @@ public class AddWaterPlanActivity extends BaseActivity<AddWaterPlanLayoutBinding
|
|||||||
// 编辑模式下,延迟传递数据给 WaterConfigFragment,等 viewBinding 初始化完成后调用
|
// 编辑模式下,延迟传递数据给 WaterConfigFragment,等 viewBinding 初始化完成后调用
|
||||||
if (mIsEditMode && mEditEntity != null) {
|
if (mIsEditMode && mEditEntity != null) {
|
||||||
viewBinding.viewpage.post(() -> {
|
viewBinding.viewpage.post(() -> {
|
||||||
WaterConfigFragment_copy configFragment = (WaterConfigFragment_copy) mFragmentList.get(0);
|
WaterConfigFragment configFragment = (WaterConfigFragment) mFragmentList.get(0);
|
||||||
configFragment.setEditEntity(mEditEntity);
|
configFragment.setEditEntity(mEditEntity);
|
||||||
|
|
||||||
PlanBoundDeviceFragment boundDeviceFragment = (PlanBoundDeviceFragment) mFragmentList.get(1);
|
PlanBoundDeviceFragment boundDeviceFragment = (PlanBoundDeviceFragment) mFragmentList.get(1);
|
||||||
@@ -137,7 +137,7 @@ public class AddWaterPlanActivity extends BaseActivity<AddWaterPlanLayoutBinding
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case R.id.tv_bind:
|
case R.id.tv_bind:
|
||||||
WaterConfigFragment_copy configFragment = (WaterConfigFragment_copy) mFragmentList.get(0);
|
WaterConfigFragment configFragment = (WaterConfigFragment) mFragmentList.get(0);
|
||||||
|
|
||||||
// 检查是否有未保存的数据变更
|
// 检查是否有未保存的数据变更
|
||||||
if (configFragment.hasDataChanged()) {
|
if (configFragment.hasDataChanged()) {
|
||||||
@@ -221,7 +221,7 @@ public class AddWaterPlanActivity extends BaseActivity<AddWaterPlanLayoutBinding
|
|||||||
* 切换到绑定设备页面
|
* 切换到绑定设备页面
|
||||||
*/
|
*/
|
||||||
private void proceedToBindDevice() {
|
private void proceedToBindDevice() {
|
||||||
WaterConfigFragment_copy configFragment = (WaterConfigFragment_copy) mFragmentList.get(0);
|
WaterConfigFragment configFragment = (WaterConfigFragment) mFragmentList.get(0);
|
||||||
WaterPlanWeekEntity entity = mIsEditMode ? mEditEntity : mNewAddEntity;
|
WaterPlanWeekEntity entity = mIsEditMode ? mEditEntity : mNewAddEntity;
|
||||||
if (entity == null) {
|
if (entity == null) {
|
||||||
entity = configFragment.getRemoteEntity();
|
entity = configFragment.getRemoteEntity();
|
||||||
|
|||||||
@@ -42,10 +42,10 @@ public class BindDeviceFragment extends BaseFragment<PlanBindDeviceLayoutBinding
|
|||||||
@Override
|
@Override
|
||||||
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
||||||
mAdapter.toggleSelection(position);
|
mAdapter.toggleSelection(position);
|
||||||
if(mDeviceList.get(position).getStatus().equals("0")){
|
if(mDeviceList.get(position).getCheckStatus().equals("0")){
|
||||||
mDeviceList.get(position).setStatus("1");
|
mDeviceList.get(position).setCheckStatus("1");
|
||||||
}else{
|
}else{
|
||||||
mDeviceList.get(position).setStatus("0");
|
mDeviceList.get(position).setCheckStatus("0");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -71,7 +71,7 @@ public class BindDeviceFragment extends BaseFragment<PlanBindDeviceLayoutBinding
|
|||||||
boolean isSelected = false;
|
boolean isSelected = false;
|
||||||
List<String> selected = new ArrayList<>();
|
List<String> selected = new ArrayList<>();
|
||||||
for(WaterDeviceEntity.DeviceListBean bean : mDeviceList){
|
for(WaterDeviceEntity.DeviceListBean bean : mDeviceList){
|
||||||
if(bean.getStatus().equals("1")){
|
if(bean.getCheckStatus().equals("1")){
|
||||||
isSelected = true;
|
isSelected = true;
|
||||||
selected.add(bean.getDeviceNo());
|
selected.add(bean.getDeviceNo());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,8 +55,11 @@ public class PlanBoundDeviceFragment extends BaseFragment<PlanBoundDeviceLayoutB
|
|||||||
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
|
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
|
||||||
switch (view.getId()){
|
switch (view.getId()){
|
||||||
case R.id.img_delete:
|
case R.id.img_delete:
|
||||||
showDialogtext(null, false, false, "提示",
|
showDialogtext(null, false, false,
|
||||||
"确定解绑该设备?", "取消", "解绑",
|
getString(R.string.tip_text),
|
||||||
|
getString(R.string.confirm_unbind_device),
|
||||||
|
getString(R.string.cancel_text),
|
||||||
|
getString(R.string.confirm_text),
|
||||||
new OnDialogClick() {
|
new OnDialogClick() {
|
||||||
@Override
|
@Override
|
||||||
public void onCancelClick() {
|
public void onCancelClick() {
|
||||||
|
|||||||
@@ -117,8 +117,11 @@ public class PlanDetailActivity extends BaseActivity<WaterPlanDetailLayoutBindin
|
|||||||
|
|
||||||
case R.id.btn_delete://删除
|
case R.id.btn_delete://删除
|
||||||
showDialogtext(null, false, false, true,
|
showDialogtext(null, false, false, true,
|
||||||
getString(R.string.tip_text), getString(R.string.delete_plan_tip),
|
getString(R.string.tip_text),
|
||||||
getString(R.string.cancel_text), getString(R.string.confirm_text), new BaseFragment.OnDialogClick() {
|
getString(R.string.delete_plan_tip),
|
||||||
|
getString(R.string.cancel_text),
|
||||||
|
getString(R.string.confirm_text),
|
||||||
|
new BaseFragment.OnDialogClick() {
|
||||||
@Override
|
@Override
|
||||||
public void onCancelClick() {
|
public void onCancelClick() {
|
||||||
}
|
}
|
||||||
@@ -153,6 +156,7 @@ public class PlanDetailActivity extends BaseActivity<WaterPlanDetailLayoutBindin
|
|||||||
// 开启任务,调用接口后再更新 Switch
|
// 开启任务,调用接口后再更新 Switch
|
||||||
mPresenter.updatePlanStatus(mDetailEntity, "1");
|
mPresenter.updatePlanStatus(mDetailEntity, "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,8 +174,10 @@ public class PlanDetailActivity extends BaseActivity<WaterPlanDetailLayoutBindin
|
|||||||
viewBinding.tvPlanName.setText(entity.getName());
|
viewBinding.tvPlanName.setText(entity.getName());
|
||||||
if(entity.getStatus().equals("1")){
|
if(entity.getStatus().equals("1")){
|
||||||
viewBinding.switchButton.setChecked(true);
|
viewBinding.switchButton.setChecked(true);
|
||||||
|
viewBinding.tvPlanStatus.setText(getString(R.string.plan_on));
|
||||||
}else{
|
}else{
|
||||||
viewBinding.switchButton.setChecked(false);
|
viewBinding.switchButton.setChecked(false);
|
||||||
|
viewBinding.tvPlanStatus.setText(getString(R.string.plan_off));
|
||||||
}
|
}
|
||||||
//针对周一 --- 周日的日期,只显示勾选的日期
|
//针对周一 --- 周日的日期,只显示勾选的日期
|
||||||
List<WaterPlanWeekEntity.DetailsBean> list = new ArrayList<>();
|
List<WaterPlanWeekEntity.DetailsBean> list = new ArrayList<>();
|
||||||
@@ -243,10 +249,12 @@ public class PlanDetailActivity extends BaseActivity<WaterPlanDetailLayoutBindin
|
|||||||
hideDialogLoading();
|
hideDialogLoading();
|
||||||
mDetailEntity.setStatus(status);
|
mDetailEntity.setStatus(status);
|
||||||
if(status.equals("1")){
|
if(status.equals("1")){
|
||||||
showCenterTipDialog(R.mipmap.icon_dialog_success,"任务已开启");
|
showCenterTipDialog(R.mipmap.icon_dialog_success,getString(R.string.task_started));
|
||||||
viewBinding.switchButton.setChecked(true);
|
viewBinding.switchButton.setChecked(true);
|
||||||
|
viewBinding.tvPlanStatus.setText(getString(R.string.plan_on));
|
||||||
}else{
|
}else{
|
||||||
viewBinding.switchButton.setChecked(false);
|
viewBinding.switchButton.setChecked(false);
|
||||||
|
viewBinding.tvPlanStatus.setText(getString(R.string.plan_off));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ import android.text.Editable;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.bigkoo.pickerview.builder.TimePickerBuilder;
|
import com.bigkoo.pickerview.builder.TimePickerBuilder;
|
||||||
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
|
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
|
||||||
@@ -13,55 +16,236 @@ import com.chad.library.adapter.base.BaseQuickAdapter;
|
|||||||
import com.ckkj.water.R;
|
import com.ckkj.water.R;
|
||||||
import com.ckkj.water.base.BaseActivity;
|
import com.ckkj.water.base.BaseActivity;
|
||||||
import com.ckkj.water.base.BaseFragment;
|
import com.ckkj.water.base.BaseFragment;
|
||||||
import com.ckkj.water.databinding.WaterConfigFragmentLayoutBinding;
|
import com.ckkj.water.databinding.WaterConfigFragmentLayoutCopyBinding;
|
||||||
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
||||||
import com.ckkj.water.network.BaseBean;
|
import com.ckkj.water.network.BaseBean;
|
||||||
import com.ckkj.water.plan.adapter.WaterPlanWeekAdapter;
|
import com.ckkj.water.plan.adapter.WaterPlanTimeDataAdapter;
|
||||||
|
import com.ckkj.water.plan.adapter.WaterPlanWeekAdapter_copy;
|
||||||
import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
||||||
import com.ckkj.water.plan.mvp.WaterPlanContract;
|
import com.ckkj.water.plan.mvp.WaterPlanContract;
|
||||||
import com.ckkj.water.plan.mvp.WaterPlanImpl;
|
import com.ckkj.water.plan.mvp.WaterPlanImpl;
|
||||||
import com.ckkj.water.plan.mvp.WaterPlanPresenter;
|
import com.ckkj.water.plan.mvp.WaterPlanPresenter;
|
||||||
|
import com.ckkj.water.utils.FastClickUtils;
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
import com.ckkj.water.utils.show.ToastUtil;
|
||||||
import com.ckkj.water.utils.time.ZYTimeUtils;
|
import com.ckkj.water.utils.time.ZYTimeUtils;
|
||||||
|
import com.yanzhenjie.recyclerview.OnItemMenuClickListener;
|
||||||
|
import com.yanzhenjie.recyclerview.SwipeMenu;
|
||||||
|
import com.yanzhenjie.recyclerview.SwipeMenuBridge;
|
||||||
|
import com.yanzhenjie.recyclerview.SwipeMenuCreator;
|
||||||
|
import com.yanzhenjie.recyclerview.SwipeMenuItem;
|
||||||
|
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
|
||||||
|
import com.yanzhenjie.recyclerview.widget.DefaultItemDecoration;
|
||||||
|
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
/**
|
public class WaterConfigFragment extends BaseFragment<WaterConfigFragmentLayoutCopyBinding, WaterPlanPresenter>
|
||||||
* 配置信息页面
|
|
||||||
*/
|
|
||||||
public class WaterConfigFragment extends BaseFragment<WaterConfigFragmentLayoutBinding, WaterPlanPresenter>
|
|
||||||
implements WaterPlanContract.WaterPlanView {
|
implements WaterPlanContract.WaterPlanView {
|
||||||
private List<WaterPlanWeekEntity.DetailsBean> mConfigList = new ArrayList<>();
|
//本地新增排程时的实体
|
||||||
//用户本地操作排程时的数据
|
private WaterPlanWeekEntity mLocalEntity;
|
||||||
private WaterPlanWeekEntity mConfigEntity;
|
//新增之后返回的实体
|
||||||
//排程接口新增成功之后,接口返回的该排程在远端的数据信息
|
private WaterPlanWeekEntity mRemoteEntity;
|
||||||
private WaterPlanWeekEntity mRemoteConfigEntity;
|
private List<WaterPlanWeekEntity.DetailsBean> weekList = new ArrayList<>();
|
||||||
private WaterPlanWeekAdapter mWeekAdapter;
|
private List<WaterPlanWeekEntity.TimeDataBean> timeList = new ArrayList<>();
|
||||||
private String mPlanName = "";
|
private WaterPlanWeekAdapter_copy mWeekAdapter;
|
||||||
public static boolean isConfigSave;
|
private WaterPlanTimeDataAdapter mTimeAdapter;
|
||||||
|
private RecyclerView.ItemDecoration itemDecoration;
|
||||||
|
private boolean isConfigSubmitted = false;
|
||||||
//当下是否编辑模式
|
//当下是否编辑模式
|
||||||
private boolean mIsEditMode = false;
|
private boolean mIsEditMode = false;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void initData(Bundle state) {
|
public void initData(Bundle state) {
|
||||||
mConfigEntity = new WaterPlanWeekEntity();
|
// 设置菜单创建器。
|
||||||
|
viewBinding.rvTimes.setSwipeMenuCreator(mSwipeMenuCreator);
|
||||||
|
viewBinding.rvTimes.setOnItemMenuClickListener(mItemMenuClickListener);
|
||||||
|
itemDecoration = new DefaultItemDecoration
|
||||||
|
(mContext.getColor(R.color.transparent),20,40);
|
||||||
|
viewBinding.rvTimes.addItemDecoration(itemDecoration);
|
||||||
List<WaterPlanWeekEntity.DetailsBean> list = new ArrayList<>();
|
List<WaterPlanWeekEntity.DetailsBean> list = new ArrayList<>();
|
||||||
for(int i = 0; i < 7; i++){
|
for(int i = 0; i < 7; i++){
|
||||||
WaterPlanWeekEntity.DetailsBean bean = new WaterPlanWeekEntity.DetailsBean();
|
WaterPlanWeekEntity.DetailsBean bean = new WaterPlanWeekEntity.DetailsBean();
|
||||||
|
WaterPlanWeekEntity.TimeDataBean timeData = new WaterPlanWeekEntity.TimeDataBean();
|
||||||
|
List<WaterPlanWeekEntity.TimeDataBean> timeDataList = new ArrayList<>();
|
||||||
|
timeDataList.add(timeData);
|
||||||
|
bean.setTimeData(timeDataList);
|
||||||
bean.setWeekday(i + 1);
|
bean.setWeekday(i + 1);
|
||||||
bean.setStatus("0");
|
bean.setStatus("0");
|
||||||
bean.setWeekName(ZYTimeUtils.getWeekName(i,mContext));
|
bean.setWeekName(ZYTimeUtils.getWeekName(i,mContext));
|
||||||
|
bean.setTriggerType("0");
|
||||||
list.add(bean);
|
list.add(bean);
|
||||||
}
|
}
|
||||||
mConfigEntity.setDetails(list);
|
weekList = list;
|
||||||
mWeekAdapter = new WaterPlanWeekAdapter(mContext,R.layout.plan_week_config_item, mConfigEntity.getDetails());
|
//这里先处理新增,后面再处理编辑
|
||||||
viewBinding.rvWeekConfig.setAdapter(mWeekAdapter);
|
mLocalEntity = new WaterPlanWeekEntity();
|
||||||
|
mLocalEntity.setStatus("1");
|
||||||
|
mLocalEntity.setDetails(weekList);
|
||||||
|
//顶部周一、周二。。。。。
|
||||||
|
mWeekAdapter = new WaterPlanWeekAdapter_copy(mContext, R.layout.plan_period_item,list);
|
||||||
|
viewBinding.rvWeek.setAdapter(mWeekAdapter);
|
||||||
|
//周期对应的 时间配置
|
||||||
|
List<WaterPlanWeekEntity.TimeDataBean> timeList = weekList.get(0).getTimeData();
|
||||||
|
mTimeAdapter = new WaterPlanTimeDataAdapter(mContext,R.layout.include_plan_time_item_layout,timeList);
|
||||||
|
viewBinding.rvTimes.setAdapter(mTimeAdapter);
|
||||||
|
viewBinding.switchButton.setChecked(weekList.get(0).getStatus().equals("1"));
|
||||||
initListener();
|
initListener();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void initListener() {
|
||||||
|
setClick(viewBinding.tvCommit);
|
||||||
|
setClick(viewBinding.imgAdd);
|
||||||
|
setClick(viewBinding.switchButton);
|
||||||
|
//头部 周一~周日
|
||||||
|
mWeekAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
||||||
|
mWeekAdapter.setSelPos(position);
|
||||||
|
List<WaterPlanWeekEntity.TimeDataBean> timeList = weekList.get(position).getTimeData();
|
||||||
|
mTimeAdapter.setNewData(timeList);
|
||||||
|
viewBinding.switchButton.setChecked(weekList.get(position).getStatus().equals("1"));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//周期对应的 时间配置
|
||||||
|
mTimeAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
|
||||||
|
@Override
|
||||||
|
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
|
||||||
|
switch (view.getId()){
|
||||||
|
case R.id.tv_select_time:
|
||||||
|
selectStartTime(position);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R.id.tv_plan_duration:
|
||||||
|
inputDuration(position);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//输入框监听
|
||||||
|
viewBinding.editPlanName.addTextChangedListener(new TextWatcher() {
|
||||||
|
@Override
|
||||||
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void afterTextChanged(Editable s) {
|
||||||
|
String planName = "";
|
||||||
|
if(!TextUtils.isEmpty(s.toString())){
|
||||||
|
planName = s.toString();
|
||||||
|
}
|
||||||
|
mLocalEntity.setName(planName);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void setClick(View view) {
|
||||||
|
view.setOnClickListener(this::onClick);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onClick(View v){
|
||||||
|
int selPos = mWeekAdapter.getmPos();
|
||||||
|
switch (v.getId()){
|
||||||
|
|
||||||
|
case R.id.img_add:
|
||||||
|
isConfigSubmitted = false;
|
||||||
|
WaterPlanWeekEntity.TimeDataBean timeDataAdd = new WaterPlanWeekEntity.TimeDataBean();
|
||||||
|
weekList.get(selPos).getTimeData().add(timeDataAdd);
|
||||||
|
mTimeAdapter.notifyItemInserted(weekList.get(selPos).getTimeData().size() - 1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R.id.switch_button:
|
||||||
|
if(weekList.get(selPos).getStatus().equals("0")){
|
||||||
|
weekList.get(selPos).setStatus("1");
|
||||||
|
viewBinding.switchButton.setChecked(true);
|
||||||
|
}else{
|
||||||
|
weekList.get(selPos).setStatus("0");
|
||||||
|
viewBinding.switchButton.setChecked(false);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case R.id.tv_commit:
|
||||||
|
// 防止快速点击
|
||||||
|
if (!FastClickUtils.onclickTimes()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 如果已经保存过(mRemoteEntity 不为空),则走更新逻辑;否则走新增逻辑
|
||||||
|
if (mRemoteEntity != null) {
|
||||||
|
updateConfig();
|
||||||
|
} else {
|
||||||
|
validateAndSave();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isConfigSubmitted() {
|
||||||
|
return isConfigSubmitted;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取当前排程名称
|
||||||
|
* @return 排程名称
|
||||||
|
*/
|
||||||
|
public String getPlanName() {
|
||||||
|
if (mLocalEntity != null) {
|
||||||
|
return mLocalEntity.getName();
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查是否至少配置了一天的时间
|
||||||
|
* @return true表示有时间配置,false表示没有配置任何时间
|
||||||
|
*/
|
||||||
|
public boolean hasTimeConfig() {
|
||||||
|
for (WaterPlanWeekEntity.DetailsBean dayBean : weekList) {
|
||||||
|
List<WaterPlanWeekEntity.TimeDataBean> timeDataList = dayBean.getTimeData();
|
||||||
|
if (timeDataList != null && !timeDataList.isEmpty()) {
|
||||||
|
for (WaterPlanWeekEntity.TimeDataBean timeData : timeDataList) {
|
||||||
|
if (!TextUtils.isEmpty(timeData.getStartTime()) && timeData.getDurationMin() > 0) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验并保存配置(供外部调用)
|
||||||
|
* @return true表示校验通过并已提交保存,false表示校验失败
|
||||||
|
*/
|
||||||
|
public boolean commitConfig() {
|
||||||
|
return validateAndSave();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 更新配置(用于数据变更后调用)
|
||||||
|
* @return true表示校验通过并已提交更新,false表示校验失败
|
||||||
|
*/
|
||||||
|
public boolean updateConfig() {
|
||||||
|
if (!validateConfig()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 调用更新接口
|
||||||
|
if(mLocalEntity != null){
|
||||||
|
mPresenter.updateConfig(mLocalEntity);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置编辑模式的排程数据
|
* 设置编辑模式的排程数据
|
||||||
* @param entity 从详情页传来的排程数据
|
* @param entity 从详情页传来的排程数据
|
||||||
@@ -72,18 +256,22 @@ public class WaterConfigFragment extends BaseFragment<WaterConfigFragmentLayoutB
|
|||||||
}
|
}
|
||||||
mIsEditMode = true;
|
mIsEditMode = true;
|
||||||
// 深拷贝数据到 mConfigEntity,用于本地编辑
|
// 深拷贝数据到 mConfigEntity,用于本地编辑
|
||||||
mConfigEntity = cloneEntity(entity);
|
mLocalEntity = cloneEntity(entity);
|
||||||
// 保存远程原始数据,用于后续变化检测
|
// 保存远程原始数据,用于后续变化检测
|
||||||
mRemoteConfigEntity = entity;
|
mRemoteEntity = entity;
|
||||||
isConfigSave = true;
|
isConfigSubmitted = true;
|
||||||
|
|
||||||
// 初始化 UI
|
// 初始化 UI
|
||||||
viewBinding.etPlanName.setText(entity.getName());
|
viewBinding.editPlanName.setText(entity.getName());
|
||||||
mPlanName = entity.getName();
|
|
||||||
|
|
||||||
// 更新周配置列表的显示,使用 mConfigEntity.getDetails() 保证数据一致
|
// 更新周配置列表的显示,使用 mConfigEntity.getDetails() 保证数据一致
|
||||||
if (mConfigEntity.getDetails() != null) {
|
if (mLocalEntity.getDetails() != null) {
|
||||||
mWeekAdapter.setNewData(mConfigEntity.getDetails());
|
weekList = mLocalEntity.getDetails();
|
||||||
|
if(!weekList.isEmpty()){
|
||||||
|
viewBinding.switchButton.setChecked(weekList.get(0).getStatus().equals("1"));
|
||||||
|
mWeekAdapter.setNewData(mLocalEntity.getDetails());
|
||||||
|
mTimeAdapter.setNewData(weekList.get(mWeekAdapter.getmPos()).getTimeData());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -103,12 +291,18 @@ public class WaterConfigFragment extends BaseFragment<WaterConfigFragmentLayoutB
|
|||||||
List<WaterPlanWeekEntity.DetailsBean> detailsList = new ArrayList<>();
|
List<WaterPlanWeekEntity.DetailsBean> detailsList = new ArrayList<>();
|
||||||
for (WaterPlanWeekEntity.DetailsBean bean : source.getDetails()) {
|
for (WaterPlanWeekEntity.DetailsBean bean : source.getDetails()) {
|
||||||
WaterPlanWeekEntity.DetailsBean newBean = new WaterPlanWeekEntity.DetailsBean();
|
WaterPlanWeekEntity.DetailsBean newBean = new WaterPlanWeekEntity.DetailsBean();
|
||||||
|
List<WaterPlanWeekEntity.TimeDataBean> timeDataList = new ArrayList<>();
|
||||||
|
for(WaterPlanWeekEntity.TimeDataBean timeDataBean : bean.getTimeData()){
|
||||||
|
WaterPlanWeekEntity.TimeDataBean newTimeDataBean = new WaterPlanWeekEntity.TimeDataBean();
|
||||||
|
newTimeDataBean.setStartTime(ZYTimeUtils.formatHHmm(timeDataBean.getStartTime()));
|
||||||
|
newTimeDataBean.setDurationMin(timeDataBean.getDurationMin());
|
||||||
|
timeDataList.add(newTimeDataBean);
|
||||||
|
}
|
||||||
|
newBean.setTimeData(timeDataList);
|
||||||
newBean.setId(bean.getId());
|
newBean.setId(bean.getId());
|
||||||
newBean.setWeekday(bean.getWeekday());
|
newBean.setWeekday(bean.getWeekday());
|
||||||
newBean.setWeekName(ZYTimeUtils.getWeekName(bean.getWeekday() - 1,mContext));
|
newBean.setWeekName(ZYTimeUtils.getWeekName(bean.getWeekday() - 1,mContext));
|
||||||
newBean.setStatus(bean.getStatus());
|
newBean.setStatus(bean.getStatus());
|
||||||
newBean.setStartTime(ZYTimeUtils.formatHHmm(bean.getStartTime()));
|
|
||||||
newBean.setDurationMin(bean.getDurationMin());
|
|
||||||
detailsList.add(newBean);
|
detailsList.add(newBean);
|
||||||
}
|
}
|
||||||
target.setDetails(detailsList);
|
target.setDetails(detailsList);
|
||||||
@@ -117,103 +311,283 @@ public class WaterConfigFragment extends BaseFragment<WaterConfigFragmentLayoutB
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initListener() {
|
|
||||||
setClick(viewBinding.tvCommit);
|
|
||||||
mWeekAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
|
|
||||||
switch (view.getId()){
|
|
||||||
case R.id.linear_week://选中
|
|
||||||
case R.id.checkbox:
|
|
||||||
if(mConfigEntity.getDetails().get(position).getStatus().equals("1")){
|
|
||||||
mConfigEntity.getDetails().get(position).setStatus("0");
|
|
||||||
}else{
|
|
||||||
mConfigEntity.getDetails().get(position).setStatus("1");
|
|
||||||
}
|
|
||||||
mWeekAdapter.notifyItemChanged(position);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.tv_select_time:
|
/**
|
||||||
selectStartTime(position);
|
* 校验配置
|
||||||
break;
|
* @return true表示校验通过,false表示校验失败
|
||||||
|
*/
|
||||||
case R.id.tv_plan_duration:
|
private boolean validateConfig() {
|
||||||
inputDuration(position);
|
if(TextUtils.isEmpty(viewBinding.editPlanName.getText().toString())){
|
||||||
|
ToastUtil.showShort(mContext,getString(R.string.plan_name_text_empty_hint));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 检查七天的所有时间配置是否全部为空
|
||||||
|
boolean allTimeEmpty = true;
|
||||||
|
for (WaterPlanWeekEntity.DetailsBean dayBean : weekList) {
|
||||||
|
List<WaterPlanWeekEntity.TimeDataBean> timeDataList = dayBean.getTimeData();
|
||||||
|
if (timeDataList != null && !timeDataList.isEmpty()) {
|
||||||
|
for (WaterPlanWeekEntity.TimeDataBean timeData : timeDataList) {
|
||||||
|
if (!TextUtils.isEmpty(timeData.getStartTime()) && timeData.getDurationMin() > 0) {
|
||||||
|
allTimeEmpty = false;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
if (!allTimeEmpty) break;
|
||||||
|
}
|
||||||
|
if (allTimeEmpty) {
|
||||||
|
ToastUtil.showShort(mContext, getString(R.string.schedule_select_at_least_one_day));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// 校验每一天内的时间是否有冲突
|
||||||
|
String conflictMsg = checkTimeConflict();
|
||||||
|
if (conflictMsg != null) {
|
||||||
|
ToastUtil.showShort(mContext, conflictMsg);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
viewBinding.etPlanName.addTextChangedListener(new TextWatcher() {
|
/**
|
||||||
@Override
|
* 校验配置并保存(新增)
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
* @return true表示校验通过并已提交保存,false表示校验失败
|
||||||
|
*/
|
||||||
|
private boolean validateAndSave() {
|
||||||
|
if (!validateConfig()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(mLocalEntity != null){
|
||||||
|
mPresenter.saveConfig(mLocalEntity);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
* 获取远程实体(用于AddWaterPlanActivity比对)
|
||||||
|
* @return mRemoteEntity
|
||||||
|
*/
|
||||||
|
public WaterPlanWeekEntity getRemoteEntity() {
|
||||||
|
return mRemoteEntity;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
/**
|
||||||
public void afterTextChanged(Editable s) {
|
* 获取本地实体(用于AddWaterPlanActivity比对)
|
||||||
if(!TextUtils.isEmpty(s.toString())){
|
* @return mLocalEntity
|
||||||
mPlanName = s.toString();
|
*/
|
||||||
mConfigEntity.setName(s.toString());
|
public WaterPlanWeekEntity getLocalEntity() {
|
||||||
|
return mLocalEntity;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查本地数据是否与远程数据有变更
|
||||||
|
* @return true表示有变更,false表示无变更
|
||||||
|
*/
|
||||||
|
public boolean hasDataChanged() {
|
||||||
|
if (mRemoteEntity == null || mLocalEntity == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 比对排程名称
|
||||||
|
String localName = mLocalEntity.getName();
|
||||||
|
String remoteName = mRemoteEntity.getName();
|
||||||
|
if (!TextUtils.isEmpty(localName) && !localName.equals(remoteName)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 比对排程状态
|
||||||
|
String localStatus = mLocalEntity.getStatus();
|
||||||
|
String remoteStatus = mRemoteEntity.getStatus();
|
||||||
|
if (!TextUtils.isEmpty(localStatus) && !localStatus.equals(remoteStatus)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 比对 details 列表
|
||||||
|
List<WaterPlanWeekEntity.DetailsBean> localDetails = mLocalEntity.getDetails();
|
||||||
|
List<WaterPlanWeekEntity.DetailsBean> remoteDetails = mRemoteEntity.getDetails();
|
||||||
|
|
||||||
|
if (localDetails == null && remoteDetails == null) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (localDetails == null || remoteDetails == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (localDetails.size() != remoteDetails.size()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 逐个比对每个 DetailsBean
|
||||||
|
for (int i = 0; i < localDetails.size(); i++) {
|
||||||
|
WaterPlanWeekEntity.DetailsBean localDetail = localDetails.get(i);
|
||||||
|
WaterPlanWeekEntity.DetailsBean remoteDetail = remoteDetails.get(i);
|
||||||
|
|
||||||
|
// 比对 status
|
||||||
|
String localDetailStatus = localDetail.getStatus();
|
||||||
|
String remoteDetailStatus = remoteDetail.getStatus();
|
||||||
|
if (!TextUtils.isEmpty(localDetailStatus) && !localDetailStatus.equals(remoteDetailStatus)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 比对 triggerType
|
||||||
|
String localTriggerType = localDetail.getTriggerType();
|
||||||
|
String remoteTriggerType = remoteDetail.getTriggerType();
|
||||||
|
if (!TextUtils.isEmpty(localTriggerType) && !localTriggerType.equals(remoteTriggerType)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 比对 timeData 列表
|
||||||
|
List<WaterPlanWeekEntity.TimeDataBean> localTimeData = localDetail.getTimeData();
|
||||||
|
List<WaterPlanWeekEntity.TimeDataBean> remoteTimeData = remoteDetail.getTimeData();
|
||||||
|
|
||||||
|
if (localTimeData == null && remoteTimeData == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (localTimeData == null || remoteTimeData == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (localTimeData.size() != remoteTimeData.size()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 逐个比对 TimeDataBean
|
||||||
|
for (int j = 0; j < localTimeData.size(); j++) {
|
||||||
|
WaterPlanWeekEntity.TimeDataBean localTime = localTimeData.get(j);
|
||||||
|
WaterPlanWeekEntity.TimeDataBean remoteTime = remoteTimeData.get(j);
|
||||||
|
|
||||||
|
// 比对 startTime
|
||||||
|
String localStartTime = localTime.getStartTime();
|
||||||
|
String remoteStartTime = remoteTime.getStartTime();
|
||||||
|
if (!TextUtils.isEmpty(localStartTime) && !localStartTime.equals(remoteStartTime)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 比对 durationMin
|
||||||
|
if (localTime.getDurationMin() != remoteTime.getDurationMin()) {
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View v){
|
/**
|
||||||
switch (v.getId()){
|
* 校验每一天内的时间配置是否有冲突
|
||||||
case R.id.tv_commit:
|
* @return null表示无冲突,返回具体提示信息表示有冲突
|
||||||
commitConfig();
|
*/
|
||||||
break;
|
private String checkTimeConflict() {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm", Locale.getDefault());
|
||||||
|
|
||||||
|
for (int dayIndex = 0; dayIndex < weekList.size(); dayIndex++) {
|
||||||
|
WaterPlanWeekEntity.DetailsBean dayBean = weekList.get(dayIndex);
|
||||||
|
List<WaterPlanWeekEntity.TimeDataBean> timeDataList = dayBean.getTimeData();
|
||||||
|
|
||||||
|
if (timeDataList == null || timeDataList.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 收集该天所有有效的时间段(开始时间 + 结束时间)
|
||||||
|
List<long[]> periods = new ArrayList<>();
|
||||||
|
for (WaterPlanWeekEntity.TimeDataBean timeData : timeDataList) {
|
||||||
|
if (TextUtils.isEmpty(timeData.getStartTime()) || timeData.getDurationMin() <= 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
Date startDate = sdf.parse(timeData.getStartTime());
|
||||||
|
long startMinutes = startDate.getHours() * 60 + startDate.getMinutes();
|
||||||
|
long endMinutes = startMinutes + timeData.getDurationMin();
|
||||||
|
periods.add(new long[]{startMinutes, endMinutes});
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 检查是否有冲突
|
||||||
|
for (int i = 0; i < periods.size(); i++) {
|
||||||
|
for (int j = i + 1; j < periods.size(); j++) {
|
||||||
|
long[] p1 = periods.get(i);
|
||||||
|
long[] p2 = periods.get(j);
|
||||||
|
// 冲突条件:一个段的开始时间在另一个段的结束时间之前(即有重叠)
|
||||||
|
// 不冲突:p1.end <= p2.start 或 p2.end <= p1.start
|
||||||
|
if (!(p1[1] <= p2[0] || p2[1] <= p1[0])) {
|
||||||
|
String dayName = dayBean.getWeekName();
|
||||||
|
return dayName + getString(R.string.schedule_time_conflict);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 选择开始时间
|
||||||
|
* @param position
|
||||||
|
*/
|
||||||
|
private void selectStartTime(int position) {
|
||||||
|
boolean times[] = {false, false, false, true, true, false};
|
||||||
|
Calendar selectedTime = Calendar.getInstance();
|
||||||
|
String startTime = weekList.get(mWeekAdapter.getmPos()).getTimeData().get(position).getStartTime();
|
||||||
|
if (!TextUtils.isEmpty(startTime)) {
|
||||||
|
try {
|
||||||
|
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm", Locale.getDefault());
|
||||||
|
timeFormat.setLenient(false);
|
||||||
|
Date date = timeFormat.parse(startTime);
|
||||||
|
selectedTime.set(Calendar.HOUR_OF_DAY, date.getHours());
|
||||||
|
selectedTime.set(Calendar.MINUTE, date.getMinutes());
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//时间选择器
|
||||||
|
TimePickerView pvTime = new TimePickerBuilder(mContext, new OnTimeSelectListener() {
|
||||||
|
@Override
|
||||||
|
public void onTimeSelect(Date date, View v) {
|
||||||
|
//用于提交接口
|
||||||
|
weekList.get(mWeekAdapter.getmPos()).getTimeData().get(position).
|
||||||
|
setStartTime(ZYTimeUtils.getStrTimeData_H_M(date));
|
||||||
|
mTimeAdapter.notifyItemChanged(position);
|
||||||
|
}
|
||||||
|
}).setType(times)
|
||||||
|
.setCancelColor(mContext.getColor(R.color.color_999999))
|
||||||
|
.setSubmitColor(mContext.getColor(R.color.color_zhu))
|
||||||
|
.setTextColorCenter(mContext.getColor(R.color.color_zhu))
|
||||||
|
.setDate(selectedTime)
|
||||||
|
.build();
|
||||||
|
pvTime.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void commitConfig(){
|
/**
|
||||||
if (!checkConfigFinish()) {
|
* 输入浇水时间
|
||||||
return;
|
* @param position
|
||||||
}
|
*/
|
||||||
// mRemoteConfigEntity 为空,说明是新增场景
|
|
||||||
if (mRemoteConfigEntity == null) {
|
|
||||||
mPresenter.saveConfig(mConfigEntity);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// mRemoteConfigEntity 不为空,说明是更新场景
|
|
||||||
if (isConfigChanged()) {
|
|
||||||
// TODO: 触发更新接口,调用 mPresenter.updateConfig(mConfigEntity)
|
|
||||||
mPresenter.updateConfig(mConfigEntity);
|
|
||||||
} else {
|
|
||||||
ToastUtil.showShort(mContext, "配置没有变化,无需保存");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void inputDuration(int position) {
|
private void inputDuration(int position) {
|
||||||
|
WaterPlanWeekEntity.TimeDataBean timeData = weekList.get(mWeekAdapter.getmPos()).getTimeData().get(position);
|
||||||
showEditDialog(getString(R.string.device_work_times_title),
|
showEditDialog(getString(R.string.device_work_times_title),
|
||||||
getString(R.string.input_water_plan_time),
|
getString(R.string.input_water_plan_time),
|
||||||
mConfigEntity.getDetails().get(position).getDurationMin() == 0 ?
|
timeData.getDurationMin() == 0 ? "" : timeData.getDurationMin() + "",
|
||||||
"" : mConfigEntity.getDetails().get(position).getDurationMin() + "",
|
|
||||||
true,
|
true,
|
||||||
getString(R.string.cancel_text),
|
getString(R.string.cancel_text),
|
||||||
getString(R.string.confirm_text),
|
getString(R.string.confirm_text),
|
||||||
BaseFragment.INPUT_TYPE_NUMBER,
|
BaseFragment.INPUT_TYPE_NUMBER,
|
||||||
new BaseActivity.OnDialogClick() {
|
new BaseActivity.OnDialogClick() {
|
||||||
@Override
|
@Override
|
||||||
public void onCancelClick() {
|
public void onCancelClick() {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirmClisk() {
|
public void onConfirmClisk() {}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onConfirmClisk(String content) {
|
public void onConfirmClisk(String content) {
|
||||||
if(Integer.parseInt(content) <= 0){
|
if(TextUtils.isEmpty(content)){
|
||||||
ToastUtil.showShort(mContext, getString(R.string.input_water_plan_time_error));
|
ToastUtil.showShort(mContext, getString(R.string.input_water_plan_time_error));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mConfigEntity.getDetails().get(position).setDurationMin(Integer.parseInt(content));
|
if (Integer.parseInt(content) <= 0) {
|
||||||
mWeekAdapter.notifyItemChanged(position);
|
ToastUtil.showShort(mContext, getString(R.string.input_water_plan_time_error));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
timeData.setDurationMin(Integer.parseInt(content));
|
||||||
|
mTimeAdapter.notifyItemChanged(position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -223,138 +597,113 @@ public class WaterConfigFragment extends BaseFragment<WaterConfigFragmentLayoutB
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void selectStartTime(int position) {
|
|
||||||
boolean times[] = {false, false, false, true, true, false};
|
|
||||||
//时间选择器
|
|
||||||
TimePickerView pvTime = new TimePickerBuilder(mContext, new OnTimeSelectListener() {
|
|
||||||
@Override
|
|
||||||
public void onTimeSelect(Date date, View v) {
|
|
||||||
//用于提交接口
|
|
||||||
mConfigEntity.getDetails().get(position).setStartTime(ZYTimeUtils.getStrTimeData_H_M(date));
|
|
||||||
mWeekAdapter.notifyItemChanged(position);
|
|
||||||
}
|
|
||||||
}).setType(times)
|
|
||||||
.setCancelColor(mContext.getColor(R.color.color_999999))
|
|
||||||
.setSubmitColor(mContext.getColor(R.color.color_zhu))
|
|
||||||
.setTextColorCenter(mContext.getColor(R.color.color_zhu))
|
|
||||||
.build();
|
|
||||||
pvTime.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setClick(View view) {
|
|
||||||
view.setOnClickListener(this::onClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 比较本地配置和远程配置是否有变化
|
* 侧滑相关
|
||||||
* @return true 表示有变化,false 表示无变化
|
|
||||||
*/
|
*/
|
||||||
public boolean isConfigChanged() {
|
// 创建菜单:
|
||||||
if (mRemoteConfigEntity == null || mRemoteConfigEntity.getDetails() == null) {
|
SwipeMenuCreator mSwipeMenuCreator = new SwipeMenuCreator() {
|
||||||
return true;
|
@Override
|
||||||
|
public void onCreateMenu(SwipeMenu leftMenu, SwipeMenu rightMenu, int position) {
|
||||||
|
SwipeMenuItem deleteItem = new SwipeMenuItem(mContext);
|
||||||
|
deleteItem.setBackground(mContext.getResources().getDrawable(R.drawable.shape_item_delete_bg));
|
||||||
|
deleteItem.setText(getString(R.string.button_delete));
|
||||||
|
deleteItem.setTextColor(mContext.getResources().getColor(R.color.white));
|
||||||
|
deleteItem.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
|
||||||
|
deleteItem.setWidth((int) mContext.getResources().getDimension(R.dimen.dp_90));
|
||||||
|
// 各种文字和图标属性设置。
|
||||||
|
rightMenu.addMenuItem(deleteItem); // 在Item右侧添加一个菜单。
|
||||||
}
|
}
|
||||||
// 比对排程名称
|
};
|
||||||
if (!equalsString(mConfigEntity.getName(), mRemoteConfigEntity.getName())) {
|
|
||||||
return true;
|
// 菜单点击监听。
|
||||||
}
|
OnItemMenuClickListener mItemMenuClickListener = new OnItemMenuClickListener() {
|
||||||
List<WaterPlanWeekEntity.DetailsBean> localDetails = mConfigEntity.getDetails();
|
@Override
|
||||||
List<WaterPlanWeekEntity.DetailsBean> remoteDetails = mRemoteConfigEntity.getDetails();
|
public void onItemClick(SwipeMenuBridge menuBridge, int position) {
|
||||||
for (int i = 0; i < localDetails.size(); i++) {
|
// 先关闭菜单
|
||||||
WaterPlanWeekEntity.DetailsBean local = localDetails.get(i);
|
menuBridge.closeMenu();
|
||||||
WaterPlanWeekEntity.DetailsBean remote = remoteDetails.get(i);
|
// 左/右菜单
|
||||||
// 勾选状态下对比状态、时间、时长
|
int direction = menuBridge.getDirection();
|
||||||
if ("1".equals(local.getStatus())) {
|
// 点击的是第几个菜单
|
||||||
if (!equalsString(local.getStatus(), remote.getStatus())
|
int menuPosition = menuBridge.getPosition();
|
||||||
|| !equalsString(local.getStartTime(), ZYTimeUtils.formatHHmm(remote.getStartTime()))
|
// 只处理右侧菜单
|
||||||
|| local.getDurationMin() != remote.getDurationMin()) {
|
if (direction == SwipeRecyclerView.RIGHT_DIRECTION) {
|
||||||
return true;
|
if (menuPosition == 0) {
|
||||||
}
|
weekList.get(mWeekAdapter.getmPos()).getTimeData().remove(position);
|
||||||
} else {
|
if(mTimeAdapter != null){
|
||||||
// 未勾选状态下只对比勾选状态,不关心时间/时长
|
mTimeAdapter.notifyItemRemoved(position);
|
||||||
if (!equalsString(local.getStatus(), remote.getStatus())) {
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
};
|
||||||
}
|
|
||||||
|
|
||||||
private boolean equalsString(String s1, String s2) {
|
|
||||||
if (s1 == null && s2 == null) return true;
|
|
||||||
if (s1 == null || s2 == null) return false;
|
|
||||||
return s1.equals(s2);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查配置信息是否完成
|
* 新增
|
||||||
* @return
|
* @param entity
|
||||||
*/
|
*/
|
||||||
public boolean checkConfigFinish() {
|
|
||||||
if(TextUtils.isEmpty(viewBinding.etPlanName.getText().toString())){
|
|
||||||
ToastUtil.showShort(mContext,getString(R.string.plan_name_text_empty_hint));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
List<WaterPlanWeekEntity.DetailsBean> list = mConfigEntity.getDetails();
|
|
||||||
//是否勾选了排程日期
|
|
||||||
boolean isSelectOne = false;
|
|
||||||
if(list != null){
|
|
||||||
for(WaterPlanWeekEntity.DetailsBean bean : list){
|
|
||||||
if(bean.getStatus().equals("1")){
|
|
||||||
isSelectOne = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(!isSelectOne){
|
|
||||||
ToastUtil.showShort(mContext,getString(R.string.plan_week_empty_hint));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
//是否配置了排程日期的时间
|
|
||||||
boolean isPlanConfig = false;
|
|
||||||
for(WaterPlanWeekEntity.DetailsBean bean : list){
|
|
||||||
if(bean.getStatus().equals("1")){
|
|
||||||
if((TextUtils.isEmpty(bean.getStartTime()) ||
|
|
||||||
bean.getDurationMin() == 0)){
|
|
||||||
ToastUtil.showShort(mContext,"请完成" + bean.getWeekName() + "的时间配置");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getWaterConfigListSuccess(List<WaterPlanWeekEntity> list,int total) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void saveConfigSuccess(WaterPlanWeekEntity entity) {
|
public void saveConfigSuccess(WaterPlanWeekEntity entity) {
|
||||||
ToastUtil.showShort(mContext, "排程新增成功");
|
ToastUtil.showShort(mContext, getString(R.string.schedule_add_success));
|
||||||
isConfigSave = true;
|
isConfigSubmitted = true;
|
||||||
// 把接口返回的 ID 设置到 mConfigEntity,便于后续更新操作
|
// 把接口返回的 ID 设置到 mConfigEntity,便于后续更新操作
|
||||||
mConfigEntity.setId(entity.getId());
|
mLocalEntity.setId(entity.getId());
|
||||||
// 把 details 中每个 bean 的 id 也设置到 mConfigEntity,便于后续更新操作
|
// 把 details 中每个 bean 的 id 也设置到 mConfigEntity,便于后续更新操作
|
||||||
if (entity.getDetails() != null && mConfigEntity.getDetails() != null) {
|
if (entity.getDetails() != null && mLocalEntity.getDetails() != null) {
|
||||||
for (int i = 0; i < entity.getDetails().size() && i < mConfigEntity.getDetails().size(); i++) {
|
for (int i = 0; i < entity.getDetails().size() && i < mLocalEntity.getDetails().size(); i++) {
|
||||||
mConfigEntity.getDetails().get(i).setId(entity.getDetails().get(i).getId());
|
mLocalEntity.getDetails().get(i).setId(entity.getDetails().get(i).getId());
|
||||||
|
mLocalEntity.getDetails().get(i).setStatus(entity.getDetails().get(i).getStatus());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//接口请求之后返回的数据,方便后面做对比
|
//接口请求之后返回的数据,方便后面做对比
|
||||||
mRemoteConfigEntity = entity;
|
mRemoteEntity = entity;
|
||||||
if (getActivity() instanceof AddWaterPlanActivity) {
|
if (getActivity() instanceof AddWaterPlanActivity) {
|
||||||
((AddWaterPlanActivity) getActivity()).onConfigSaved(entity);
|
((AddWaterPlanActivity) getActivity()).onConfigSaved(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新排程成功
|
* 更新
|
||||||
* @param entity
|
* @param entity
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void updateConfigSuccess(WaterPlanWeekEntity entity) {
|
public void updateConfigSuccess(WaterPlanWeekEntity entity) {
|
||||||
ToastUtil.showShort(mContext, "排程更新成功");
|
ToastUtil.showShort(mContext, getString(R.string.schedule_update_success));
|
||||||
mRemoteConfigEntity = entity;
|
mRemoteEntity = entity;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// private List<WaterPlanWeekEntity.DeviceEntity> getSelectedDevices() {
|
||||||
|
// if (getActivity() instanceof AddWaterPlanActivity) {
|
||||||
|
// return ((AddWaterPlanActivity) getActivity()).getSelectedDevices();
|
||||||
|
// }
|
||||||
|
// return new ArrayList<>();
|
||||||
|
// }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WaterPlanPresenter createPresenter() {
|
||||||
|
return new WaterPlanPresenter(new WaterPlanImpl());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onNetChange(int netModel) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void showError(String message) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void logOut(BaseBean bean) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void getWaterConfigListSuccess(List<WaterPlanWeekEntity> list, int total) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -388,25 +737,4 @@ public class WaterConfigFragment extends BaseFragment<WaterConfigFragmentLayoutB
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WaterPlanPresenter createPresenter() {
|
|
||||||
return new WaterPlanPresenter(new WaterPlanImpl());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNetChange(int netModel) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showError(String message) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logOut(BaseBean bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,715 +0,0 @@
|
|||||||
package com.ckkj.water.plan;
|
|
||||||
|
|
||||||
import android.os.Bundle;
|
|
||||||
import android.text.Editable;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
import android.text.TextWatcher;
|
|
||||||
import android.view.View;
|
|
||||||
import android.view.ViewGroup;
|
|
||||||
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import com.bigkoo.pickerview.builder.TimePickerBuilder;
|
|
||||||
import com.bigkoo.pickerview.listener.OnTimeSelectListener;
|
|
||||||
import com.bigkoo.pickerview.view.TimePickerView;
|
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
||||||
import com.ckkj.water.R;
|
|
||||||
import com.ckkj.water.base.BaseActivity;
|
|
||||||
import com.ckkj.water.base.BaseFragment;
|
|
||||||
import com.ckkj.water.databinding.WaterConfigFragmentLayoutBinding;
|
|
||||||
import com.ckkj.water.databinding.WaterConfigFragmentLayoutCopyBinding;
|
|
||||||
import com.ckkj.water.index.entity.WaterDeviceEntity;
|
|
||||||
import com.ckkj.water.network.BaseBean;
|
|
||||||
import com.ckkj.water.plan.adapter.WaterPlanTimeDataAdapter;
|
|
||||||
import com.ckkj.water.plan.adapter.WaterPlanWeekAdapter;
|
|
||||||
import com.ckkj.water.plan.adapter.WaterPlanWeekAdapter_copy;
|
|
||||||
import com.ckkj.water.plan.entity.WaterPlanWeekEntity;
|
|
||||||
import com.ckkj.water.plan.mvp.WaterPlanContract;
|
|
||||||
import com.ckkj.water.plan.mvp.WaterPlanImpl;
|
|
||||||
import com.ckkj.water.plan.mvp.WaterPlanPresenter;
|
|
||||||
import com.ckkj.water.utils.show.ToastUtil;
|
|
||||||
import com.ckkj.water.utils.time.ZYTimeUtils;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.yanzhenjie.recyclerview.OnItemMenuClickListener;
|
|
||||||
import com.yanzhenjie.recyclerview.SwipeMenu;
|
|
||||||
import com.yanzhenjie.recyclerview.SwipeMenuBridge;
|
|
||||||
import com.yanzhenjie.recyclerview.SwipeMenuCreator;
|
|
||||||
import com.yanzhenjie.recyclerview.SwipeMenuItem;
|
|
||||||
import com.yanzhenjie.recyclerview.SwipeRecyclerView;
|
|
||||||
import com.yanzhenjie.recyclerview.widget.DefaultItemDecoration;
|
|
||||||
|
|
||||||
import java.text.SimpleDateFormat;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
public class WaterConfigFragment_copy extends BaseFragment<WaterConfigFragmentLayoutCopyBinding, WaterPlanPresenter>
|
|
||||||
implements WaterPlanContract.WaterPlanView {
|
|
||||||
//本地新增排程时的实体
|
|
||||||
private WaterPlanWeekEntity mLocalEntity;
|
|
||||||
//新增之后返回的实体
|
|
||||||
private WaterPlanWeekEntity mRemoteEntity;
|
|
||||||
private List<WaterPlanWeekEntity.DetailsBean> weekList = new ArrayList<>();
|
|
||||||
private List<WaterPlanWeekEntity.TimeDataBean> timeList = new ArrayList<>();
|
|
||||||
private WaterPlanWeekAdapter_copy mWeekAdapter;
|
|
||||||
private WaterPlanTimeDataAdapter mTimeAdapter;
|
|
||||||
private RecyclerView.ItemDecoration itemDecoration;
|
|
||||||
private boolean isConfigSubmitted = false;
|
|
||||||
//当下是否编辑模式
|
|
||||||
private boolean mIsEditMode = false;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void initData(Bundle state) {
|
|
||||||
// 设置菜单创建器。
|
|
||||||
viewBinding.rvTimes.setSwipeMenuCreator(mSwipeMenuCreator);
|
|
||||||
viewBinding.rvTimes.setOnItemMenuClickListener(mItemMenuClickListener);
|
|
||||||
itemDecoration = new DefaultItemDecoration
|
|
||||||
(mContext.getColor(R.color.transparent),20,40);
|
|
||||||
viewBinding.rvTimes.addItemDecoration(itemDecoration);
|
|
||||||
List<WaterPlanWeekEntity.DetailsBean> list = new ArrayList<>();
|
|
||||||
for(int i = 0; i < 7; i++){
|
|
||||||
WaterPlanWeekEntity.DetailsBean bean = new WaterPlanWeekEntity.DetailsBean();
|
|
||||||
WaterPlanWeekEntity.TimeDataBean timeData = new WaterPlanWeekEntity.TimeDataBean();
|
|
||||||
List<WaterPlanWeekEntity.TimeDataBean> timeDataList = new ArrayList<>();
|
|
||||||
timeDataList.add(timeData);
|
|
||||||
bean.setTimeData(timeDataList);
|
|
||||||
bean.setWeekday(i + 1);
|
|
||||||
bean.setStatus("1");
|
|
||||||
bean.setWeekName(ZYTimeUtils.getWeekName(i,mContext));
|
|
||||||
bean.setTriggerType("0");
|
|
||||||
list.add(bean);
|
|
||||||
}
|
|
||||||
weekList = list;
|
|
||||||
//这里先处理新增,后面再处理编辑
|
|
||||||
mLocalEntity = new WaterPlanWeekEntity();
|
|
||||||
mLocalEntity.setStatus("1");
|
|
||||||
mLocalEntity.setDetails(weekList);
|
|
||||||
//顶部周一、周二。。。。。
|
|
||||||
mWeekAdapter = new WaterPlanWeekAdapter_copy(mContext, R.layout.plan_period_item,list);
|
|
||||||
viewBinding.rvWeek.setAdapter(mWeekAdapter);
|
|
||||||
//周期对应的 时间配置
|
|
||||||
List<WaterPlanWeekEntity.TimeDataBean> timeList = weekList.get(0).getTimeData();
|
|
||||||
mTimeAdapter = new WaterPlanTimeDataAdapter(mContext,R.layout.include_plan_time_item_layout,timeList);
|
|
||||||
viewBinding.rvTimes.setAdapter(mTimeAdapter);
|
|
||||||
initListener();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void initListener() {
|
|
||||||
setClick(viewBinding.tvCommit);
|
|
||||||
setClick(viewBinding.imgAdd);
|
|
||||||
setClick(viewBinding.switchButton);
|
|
||||||
//头部 周一~周日
|
|
||||||
mWeekAdapter.setOnItemClickListener(new BaseQuickAdapter.OnItemClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(BaseQuickAdapter adapter, View view, int position) {
|
|
||||||
mWeekAdapter.setSelPos(position);
|
|
||||||
List<WaterPlanWeekEntity.TimeDataBean> timeList = weekList.get(position).getTimeData();
|
|
||||||
mTimeAdapter.setNewData(timeList);
|
|
||||||
viewBinding.switchButton.setChecked(weekList.get(position).getStatus().equals("1"));
|
|
||||||
}
|
|
||||||
});
|
|
||||||
//周期对应的 时间配置
|
|
||||||
mTimeAdapter.setOnItemChildClickListener(new BaseQuickAdapter.OnItemChildClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemChildClick(BaseQuickAdapter adapter, View view, int position) {
|
|
||||||
switch (view.getId()){
|
|
||||||
case R.id.tv_select_time:
|
|
||||||
selectStartTime(position);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.tv_plan_duration:
|
|
||||||
inputDuration(position);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
//输入框监听
|
|
||||||
viewBinding.editPlanName.addTextChangedListener(new TextWatcher() {
|
|
||||||
@Override
|
|
||||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onTextChanged(CharSequence s, int start, int before, int count) {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void afterTextChanged(Editable s) {
|
|
||||||
String planName = "";
|
|
||||||
if(!TextUtils.isEmpty(s.toString())){
|
|
||||||
planName = s.toString();
|
|
||||||
}
|
|
||||||
mLocalEntity.setName(planName);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private void setClick(View view) {
|
|
||||||
view.setOnClickListener(this::onClick);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onClick(View v){
|
|
||||||
int selPos = mWeekAdapter.getmPos();
|
|
||||||
switch (v.getId()){
|
|
||||||
|
|
||||||
case R.id.img_add:
|
|
||||||
isConfigSubmitted = false;
|
|
||||||
WaterPlanWeekEntity.TimeDataBean timeDataAdd = new WaterPlanWeekEntity.TimeDataBean();
|
|
||||||
weekList.get(selPos).getTimeData().add(timeDataAdd);
|
|
||||||
mTimeAdapter.notifyItemInserted(weekList.get(selPos).getTimeData().size() - 1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.switch_button:
|
|
||||||
if(weekList.get(selPos).getStatus().equals("0")){
|
|
||||||
weekList.get(selPos).setStatus("1");
|
|
||||||
viewBinding.switchButton.setChecked(true);
|
|
||||||
}else{
|
|
||||||
weekList.get(selPos).setStatus("0");
|
|
||||||
viewBinding.switchButton.setChecked(false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case R.id.tv_commit:
|
|
||||||
// 如果已经保存过(mRemoteEntity 不为空),则走更新逻辑;否则走新增逻辑
|
|
||||||
if (mRemoteEntity != null) {
|
|
||||||
updateConfig();
|
|
||||||
} else {
|
|
||||||
validateAndSave();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isConfigSubmitted() {
|
|
||||||
return isConfigSubmitted;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取当前排程名称
|
|
||||||
* @return 排程名称
|
|
||||||
*/
|
|
||||||
public String getPlanName() {
|
|
||||||
if (mLocalEntity != null) {
|
|
||||||
return mLocalEntity.getName();
|
|
||||||
}
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查是否至少配置了一天的时间
|
|
||||||
* @return true表示有时间配置,false表示没有配置任何时间
|
|
||||||
*/
|
|
||||||
public boolean hasTimeConfig() {
|
|
||||||
for (WaterPlanWeekEntity.DetailsBean dayBean : weekList) {
|
|
||||||
List<WaterPlanWeekEntity.TimeDataBean> timeDataList = dayBean.getTimeData();
|
|
||||||
if (timeDataList != null && !timeDataList.isEmpty()) {
|
|
||||||
for (WaterPlanWeekEntity.TimeDataBean timeData : timeDataList) {
|
|
||||||
if (!TextUtils.isEmpty(timeData.getStartTime()) && timeData.getDurationMin() > 0) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验并保存配置(供外部调用)
|
|
||||||
* @return true表示校验通过并已提交保存,false表示校验失败
|
|
||||||
*/
|
|
||||||
public boolean commitConfig() {
|
|
||||||
return validateAndSave();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新配置(用于数据变更后调用)
|
|
||||||
* @return true表示校验通过并已提交更新,false表示校验失败
|
|
||||||
*/
|
|
||||||
public boolean updateConfig() {
|
|
||||||
if (!validateConfig()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// 调用更新接口
|
|
||||||
if(mLocalEntity != null){
|
|
||||||
mPresenter.updateConfig(mLocalEntity);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置编辑模式的排程数据
|
|
||||||
* @param entity 从详情页传来的排程数据
|
|
||||||
*/
|
|
||||||
public void setEditEntity(WaterPlanWeekEntity entity) {
|
|
||||||
if (entity == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
mIsEditMode = true;
|
|
||||||
// 深拷贝数据到 mConfigEntity,用于本地编辑
|
|
||||||
mLocalEntity = cloneEntity(entity);
|
|
||||||
// 保存远程原始数据,用于后续变化检测
|
|
||||||
mRemoteEntity = entity;
|
|
||||||
isConfigSubmitted = true;
|
|
||||||
|
|
||||||
// 初始化 UI
|
|
||||||
viewBinding.editPlanName.setText(entity.getName());
|
|
||||||
// 更新周配置列表的显示,使用 mConfigEntity.getDetails() 保证数据一致
|
|
||||||
if (mLocalEntity.getDetails() != null) {
|
|
||||||
weekList = mLocalEntity.getDetails();
|
|
||||||
mWeekAdapter.setNewData(mLocalEntity.getDetails());
|
|
||||||
mTimeAdapter.setNewData(weekList.get(mWeekAdapter.getmPos()).getTimeData());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 深拷贝 WaterPlanWeekEntity
|
|
||||||
*/
|
|
||||||
private WaterPlanWeekEntity cloneEntity(WaterPlanWeekEntity source) {
|
|
||||||
if (source == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
WaterPlanWeekEntity target = new WaterPlanWeekEntity();
|
|
||||||
target.setId(source.getId());
|
|
||||||
target.setName(source.getName());
|
|
||||||
target.setStatus(source.getStatus());
|
|
||||||
|
|
||||||
if (source.getDetails() != null) {
|
|
||||||
List<WaterPlanWeekEntity.DetailsBean> detailsList = new ArrayList<>();
|
|
||||||
for (WaterPlanWeekEntity.DetailsBean bean : source.getDetails()) {
|
|
||||||
WaterPlanWeekEntity.DetailsBean newBean = new WaterPlanWeekEntity.DetailsBean();
|
|
||||||
List<WaterPlanWeekEntity.TimeDataBean> timeDataList = new ArrayList<>();
|
|
||||||
for(WaterPlanWeekEntity.TimeDataBean timeDataBean : bean.getTimeData()){
|
|
||||||
WaterPlanWeekEntity.TimeDataBean newTimeDataBean = new WaterPlanWeekEntity.TimeDataBean();
|
|
||||||
newTimeDataBean.setStartTime(ZYTimeUtils.formatHHmm(timeDataBean.getStartTime()));
|
|
||||||
newTimeDataBean.setDurationMin(timeDataBean.getDurationMin());
|
|
||||||
timeDataList.add(newTimeDataBean);
|
|
||||||
}
|
|
||||||
newBean.setTimeData(timeDataList);
|
|
||||||
newBean.setId(bean.getId());
|
|
||||||
newBean.setWeekday(bean.getWeekday());
|
|
||||||
newBean.setWeekName(ZYTimeUtils.getWeekName(bean.getWeekday() - 1,mContext));
|
|
||||||
newBean.setStatus(bean.getStatus());
|
|
||||||
detailsList.add(newBean);
|
|
||||||
}
|
|
||||||
target.setDetails(detailsList);
|
|
||||||
}
|
|
||||||
|
|
||||||
return target;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验配置
|
|
||||||
* @return true表示校验通过,false表示校验失败
|
|
||||||
*/
|
|
||||||
private boolean validateConfig() {
|
|
||||||
if(TextUtils.isEmpty(viewBinding.editPlanName.getText().toString())){
|
|
||||||
ToastUtil.showShort(mContext,getString(R.string.plan_name_text_empty_hint));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// 检查七天的所有时间配置是否全部为空
|
|
||||||
boolean allTimeEmpty = true;
|
|
||||||
for (WaterPlanWeekEntity.DetailsBean dayBean : weekList) {
|
|
||||||
List<WaterPlanWeekEntity.TimeDataBean> timeDataList = dayBean.getTimeData();
|
|
||||||
if (timeDataList != null && !timeDataList.isEmpty()) {
|
|
||||||
for (WaterPlanWeekEntity.TimeDataBean timeData : timeDataList) {
|
|
||||||
if (!TextUtils.isEmpty(timeData.getStartTime()) && timeData.getDurationMin() > 0) {
|
|
||||||
allTimeEmpty = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!allTimeEmpty) break;
|
|
||||||
}
|
|
||||||
if (allTimeEmpty) {
|
|
||||||
ToastUtil.showShort(mContext, getString(R.string.schedule_select_at_least_one_day));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// 校验每一天内的时间是否有冲突
|
|
||||||
String conflictMsg = checkTimeConflict();
|
|
||||||
if (conflictMsg != null) {
|
|
||||||
ToastUtil.showShort(mContext, conflictMsg);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验配置并保存(新增)
|
|
||||||
* @return true表示校验通过并已提交保存,false表示校验失败
|
|
||||||
*/
|
|
||||||
private boolean validateAndSave() {
|
|
||||||
if (!validateConfig()) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if(mLocalEntity != null){
|
|
||||||
mPresenter.saveConfig(mLocalEntity);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取远程实体(用于AddWaterPlanActivity比对)
|
|
||||||
* @return mRemoteEntity
|
|
||||||
*/
|
|
||||||
public WaterPlanWeekEntity getRemoteEntity() {
|
|
||||||
return mRemoteEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取本地实体(用于AddWaterPlanActivity比对)
|
|
||||||
* @return mLocalEntity
|
|
||||||
*/
|
|
||||||
public WaterPlanWeekEntity getLocalEntity() {
|
|
||||||
return mLocalEntity;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查本地数据是否与远程数据有变更
|
|
||||||
* @return true表示有变更,false表示无变更
|
|
||||||
*/
|
|
||||||
public boolean hasDataChanged() {
|
|
||||||
if (mRemoteEntity == null || mLocalEntity == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 比对排程名称
|
|
||||||
String localName = mLocalEntity.getName();
|
|
||||||
String remoteName = mRemoteEntity.getName();
|
|
||||||
if (!TextUtils.isEmpty(localName) && !localName.equals(remoteName)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 比对排程状态
|
|
||||||
String localStatus = mLocalEntity.getStatus();
|
|
||||||
String remoteStatus = mRemoteEntity.getStatus();
|
|
||||||
if (!TextUtils.isEmpty(localStatus) && !localStatus.equals(remoteStatus)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 比对 details 列表
|
|
||||||
List<WaterPlanWeekEntity.DetailsBean> localDetails = mLocalEntity.getDetails();
|
|
||||||
List<WaterPlanWeekEntity.DetailsBean> remoteDetails = mRemoteEntity.getDetails();
|
|
||||||
|
|
||||||
if (localDetails == null && remoteDetails == null) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (localDetails == null || remoteDetails == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (localDetails.size() != remoteDetails.size()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 逐个比对每个 DetailsBean
|
|
||||||
for (int i = 0; i < localDetails.size(); i++) {
|
|
||||||
WaterPlanWeekEntity.DetailsBean localDetail = localDetails.get(i);
|
|
||||||
WaterPlanWeekEntity.DetailsBean remoteDetail = remoteDetails.get(i);
|
|
||||||
|
|
||||||
// 比对 status
|
|
||||||
String localDetailStatus = localDetail.getStatus();
|
|
||||||
String remoteDetailStatus = remoteDetail.getStatus();
|
|
||||||
if (!TextUtils.isEmpty(localDetailStatus) && !localDetailStatus.equals(remoteDetailStatus)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 比对 triggerType
|
|
||||||
String localTriggerType = localDetail.getTriggerType();
|
|
||||||
String remoteTriggerType = remoteDetail.getTriggerType();
|
|
||||||
if (!TextUtils.isEmpty(localTriggerType) && !localTriggerType.equals(remoteTriggerType)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 比对 timeData 列表
|
|
||||||
List<WaterPlanWeekEntity.TimeDataBean> localTimeData = localDetail.getTimeData();
|
|
||||||
List<WaterPlanWeekEntity.TimeDataBean> remoteTimeData = remoteDetail.getTimeData();
|
|
||||||
|
|
||||||
if (localTimeData == null && remoteTimeData == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (localTimeData == null || remoteTimeData == null) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if (localTimeData.size() != remoteTimeData.size()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 逐个比对 TimeDataBean
|
|
||||||
for (int j = 0; j < localTimeData.size(); j++) {
|
|
||||||
WaterPlanWeekEntity.TimeDataBean localTime = localTimeData.get(j);
|
|
||||||
WaterPlanWeekEntity.TimeDataBean remoteTime = remoteTimeData.get(j);
|
|
||||||
|
|
||||||
// 比对 startTime
|
|
||||||
String localStartTime = localTime.getStartTime();
|
|
||||||
String remoteStartTime = remoteTime.getStartTime();
|
|
||||||
if (!TextUtils.isEmpty(localStartTime) && !localStartTime.equals(remoteStartTime)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 比对 durationMin
|
|
||||||
if (localTime.getDurationMin() != remoteTime.getDurationMin()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 校验每一天内的时间配置是否有冲突
|
|
||||||
* @return null表示无冲突,返回具体提示信息表示有冲突
|
|
||||||
*/
|
|
||||||
private String checkTimeConflict() {
|
|
||||||
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm", Locale.getDefault());
|
|
||||||
|
|
||||||
for (int dayIndex = 0; dayIndex < weekList.size(); dayIndex++) {
|
|
||||||
WaterPlanWeekEntity.DetailsBean dayBean = weekList.get(dayIndex);
|
|
||||||
List<WaterPlanWeekEntity.TimeDataBean> timeDataList = dayBean.getTimeData();
|
|
||||||
|
|
||||||
if (timeDataList == null || timeDataList.isEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 收集该天所有有效的时间段(开始时间 + 结束时间)
|
|
||||||
List<long[]> periods = new ArrayList<>();
|
|
||||||
for (WaterPlanWeekEntity.TimeDataBean timeData : timeDataList) {
|
|
||||||
if (TextUtils.isEmpty(timeData.getStartTime()) || timeData.getDurationMin() <= 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Date startDate = sdf.parse(timeData.getStartTime());
|
|
||||||
long startMinutes = startDate.getHours() * 60 + startDate.getMinutes();
|
|
||||||
long endMinutes = startMinutes + timeData.getDurationMin();
|
|
||||||
periods.add(new long[]{startMinutes, endMinutes});
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查是否有冲突
|
|
||||||
for (int i = 0; i < periods.size(); i++) {
|
|
||||||
for (int j = i + 1; j < periods.size(); j++) {
|
|
||||||
long[] p1 = periods.get(i);
|
|
||||||
long[] p2 = periods.get(j);
|
|
||||||
// 冲突条件:一个段的开始时间在另一个段的结束时间之前(即有重叠)
|
|
||||||
// 不冲突:p1.end <= p2.start 或 p2.end <= p1.start
|
|
||||||
if (!(p1[1] <= p2[0] || p2[1] <= p1[0])) {
|
|
||||||
String dayName = dayBean.getWeekName();
|
|
||||||
return dayName + getString(R.string.schedule_time_conflict);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 选择开始时间
|
|
||||||
* @param position
|
|
||||||
*/
|
|
||||||
private void selectStartTime(int position) {
|
|
||||||
boolean times[] = {false, false, false, true, true, false};
|
|
||||||
//时间选择器
|
|
||||||
TimePickerView pvTime = new TimePickerBuilder(mContext, new OnTimeSelectListener() {
|
|
||||||
@Override
|
|
||||||
public void onTimeSelect(Date date, View v) {
|
|
||||||
//用于提交接口
|
|
||||||
weekList.get(mWeekAdapter.getmPos()).getTimeData().get(position).
|
|
||||||
setStartTime(ZYTimeUtils.getStrTimeData_H_M(date));
|
|
||||||
mTimeAdapter.notifyItemChanged(position);
|
|
||||||
}
|
|
||||||
}).setType(times)
|
|
||||||
.setCancelColor(mContext.getColor(R.color.color_999999))
|
|
||||||
.setSubmitColor(mContext.getColor(R.color.color_zhu))
|
|
||||||
.setTextColorCenter(mContext.getColor(R.color.color_zhu))
|
|
||||||
.build();
|
|
||||||
pvTime.show();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 输入浇水时间
|
|
||||||
* @param position
|
|
||||||
*/
|
|
||||||
private void inputDuration(int position) {
|
|
||||||
WaterPlanWeekEntity.TimeDataBean timeData = weekList.get(mWeekAdapter.getmPos()).getTimeData().get(position);
|
|
||||||
showEditDialog(getString(R.string.device_work_times_title),
|
|
||||||
getString(R.string.input_water_plan_time),
|
|
||||||
timeData.getDurationMin() == 0 ? "" : timeData.getDurationMin() + "",
|
|
||||||
true,
|
|
||||||
getString(R.string.cancel_text),
|
|
||||||
getString(R.string.confirm_text),
|
|
||||||
BaseFragment.INPUT_TYPE_NUMBER,
|
|
||||||
new BaseActivity.OnDialogClick() {
|
|
||||||
@Override
|
|
||||||
public void onCancelClick() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConfirmClisk() {}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onConfirmClisk(String content) {
|
|
||||||
if (Integer.parseInt(content) <= 0) {
|
|
||||||
ToastUtil.showShort(mContext, getString(R.string.input_water_plan_time_error));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
timeData.setDurationMin(Integer.parseInt(content));
|
|
||||||
mTimeAdapter.notifyItemChanged(position);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onView1Click() {
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 侧滑相关
|
|
||||||
*/
|
|
||||||
// 创建菜单:
|
|
||||||
SwipeMenuCreator mSwipeMenuCreator = new SwipeMenuCreator() {
|
|
||||||
@Override
|
|
||||||
public void onCreateMenu(SwipeMenu leftMenu, SwipeMenu rightMenu, int position) {
|
|
||||||
SwipeMenuItem deleteItem = new SwipeMenuItem(mContext);
|
|
||||||
deleteItem.setBackground(mContext.getResources().getDrawable(R.drawable.shape_item_delete_bg));
|
|
||||||
deleteItem.setText(getString(R.string.button_delete));
|
|
||||||
deleteItem.setTextColor(mContext.getResources().getColor(R.color.white));
|
|
||||||
deleteItem.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
|
|
||||||
deleteItem.setWidth((int) mContext.getResources().getDimension(R.dimen.dp_90));
|
|
||||||
// 各种文字和图标属性设置。
|
|
||||||
rightMenu.addMenuItem(deleteItem); // 在Item右侧添加一个菜单。
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// 菜单点击监听。
|
|
||||||
OnItemMenuClickListener mItemMenuClickListener = new OnItemMenuClickListener() {
|
|
||||||
@Override
|
|
||||||
public void onItemClick(SwipeMenuBridge menuBridge, int position) {
|
|
||||||
// 先关闭菜单
|
|
||||||
menuBridge.closeMenu();
|
|
||||||
// 左/右菜单
|
|
||||||
int direction = menuBridge.getDirection();
|
|
||||||
// 点击的是第几个菜单
|
|
||||||
int menuPosition = menuBridge.getPosition();
|
|
||||||
// 只处理右侧菜单
|
|
||||||
if (direction == SwipeRecyclerView.RIGHT_DIRECTION) {
|
|
||||||
if (menuPosition == 0) {
|
|
||||||
weekList.get(mWeekAdapter.getmPos()).getTimeData().remove(position);
|
|
||||||
if(mTimeAdapter != null){
|
|
||||||
mTimeAdapter.notifyItemRemoved(position);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 新增
|
|
||||||
* @param entity
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void saveConfigSuccess(WaterPlanWeekEntity entity) {
|
|
||||||
ToastUtil.showShort(mContext, getString(R.string.schedule_add_success));
|
|
||||||
isConfigSubmitted = true;
|
|
||||||
// 把接口返回的 ID 设置到 mConfigEntity,便于后续更新操作
|
|
||||||
mLocalEntity.setId(entity.getId());
|
|
||||||
// 把 details 中每个 bean 的 id 也设置到 mConfigEntity,便于后续更新操作
|
|
||||||
if (entity.getDetails() != null && mLocalEntity.getDetails() != null) {
|
|
||||||
for (int i = 0; i < entity.getDetails().size() && i < mLocalEntity.getDetails().size(); i++) {
|
|
||||||
mLocalEntity.getDetails().get(i).setId(entity.getDetails().get(i).getId());
|
|
||||||
mLocalEntity.getDetails().get(i).setStatus(entity.getDetails().get(i).getStatus());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//接口请求之后返回的数据,方便后面做对比
|
|
||||||
mRemoteEntity = entity;
|
|
||||||
if (getActivity() instanceof AddWaterPlanActivity) {
|
|
||||||
((AddWaterPlanActivity) getActivity()).onConfigSaved(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 更新
|
|
||||||
* @param entity
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void updateConfigSuccess(WaterPlanWeekEntity entity) {
|
|
||||||
ToastUtil.showShort(mContext, getString(R.string.schedule_update_success));
|
|
||||||
mRemoteEntity = entity;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// private List<WaterPlanWeekEntity.DeviceEntity> getSelectedDevices() {
|
|
||||||
// if (getActivity() instanceof AddWaterPlanActivity) {
|
|
||||||
// return ((AddWaterPlanActivity) getActivity()).getSelectedDevices();
|
|
||||||
// }
|
|
||||||
// return new ArrayList<>();
|
|
||||||
// }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public WaterPlanPresenter createPresenter() {
|
|
||||||
return new WaterPlanPresenter(new WaterPlanImpl());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNetChange(int netModel) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void showError(String message) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void logOut(BaseBean bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getWaterConfigListSuccess(List<WaterPlanWeekEntity> list, int total) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void updatePlanStatusSuccess(BaseBean bean, String status) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getPlanDetailInfo(WaterPlanWeekEntity entity) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void getPlanBindDeviceList(WaterDeviceEntity bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void planBindDeviceSuccess(BaseBean bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void deletePlanSuccess(BaseBean bean) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void planUnbindDeviceSuccess(BaseBean bean, int position) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.ckkj.water.plan;
|
package com.ckkj.water.plan;
|
||||||
|
|
||||||
import static android.view.View.INVISIBLE;
|
import static android.view.View.INVISIBLE;
|
||||||
|
import static android.view.View.VISIBLE;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
@@ -51,6 +52,7 @@ public class WaterPlanFragment extends BaseFragment<WaterPlanFragmentBinding, Wa
|
|||||||
.init();
|
.init();
|
||||||
viewBinding.includedTitle.imgBack.setVisibility(INVISIBLE);
|
viewBinding.includedTitle.imgBack.setVisibility(INVISIBLE);
|
||||||
viewBinding.includedTitle.tvTitle.setText(getString(R.string.plan_title));
|
viewBinding.includedTitle.tvTitle.setText(getString(R.string.plan_title));
|
||||||
|
viewBinding.includedNoresult.tvAddPlan.setVisibility(VISIBLE);
|
||||||
initListener();
|
initListener();
|
||||||
mAdapter = new WaterPlanListAdapter(mContext,R.layout.water_plan_list_item,mPlanList);
|
mAdapter = new WaterPlanListAdapter(mContext,R.layout.water_plan_list_item,mPlanList);
|
||||||
viewBinding.rvPlans.setAdapter(mAdapter);
|
viewBinding.rvPlans.setAdapter(mAdapter);
|
||||||
@@ -110,6 +112,7 @@ public class WaterPlanFragment extends BaseFragment<WaterPlanFragmentBinding, Wa
|
|||||||
private void initListener() {
|
private void initListener() {
|
||||||
setClick(viewBinding.tvAdd);
|
setClick(viewBinding.tvAdd);
|
||||||
setClick(viewBinding.includedNoresult.btnRefresh);
|
setClick(viewBinding.includedNoresult.btnRefresh);
|
||||||
|
setClick(viewBinding.includedNoresult.tvAddPlan);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setClick(View view) {
|
private void setClick(View view) {
|
||||||
@@ -119,6 +122,7 @@ public class WaterPlanFragment extends BaseFragment<WaterPlanFragmentBinding, Wa
|
|||||||
public void onClick(View v){
|
public void onClick(View v){
|
||||||
switch (v.getId()){
|
switch (v.getId()){
|
||||||
case R.id.tv_add:
|
case R.id.tv_add:
|
||||||
|
case R.id.tv_add_plan:
|
||||||
goTo(mContext, AddWaterPlanActivity.class,null);
|
goTo(mContext, AddWaterPlanActivity.class,null);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -148,7 +152,7 @@ public class WaterPlanFragment extends BaseFragment<WaterPlanFragmentBinding, Wa
|
|||||||
if (mAdapter.getItemCount() >= total || pageList.size() == 0) {
|
if (mAdapter.getItemCount() >= total || pageList.size() == 0) {
|
||||||
// 使用 post 延迟调用,避免内部状态冲突导致的循环调用
|
// 使用 post 延迟调用,避免内部状态冲突导致的循环调用
|
||||||
viewBinding.refresh.postDelayed(() -> viewBinding.refresh.setNoMoreData(true), 300);
|
viewBinding.refresh.postDelayed(() -> viewBinding.refresh.setNoMoreData(true), 300);
|
||||||
viewBinding.relNoMore.setVisibility(View.VISIBLE); // 自定义底部提示"暂无更多数据"
|
viewBinding.relNoMore.setVisibility(VISIBLE); // 自定义底部提示"暂无更多数据"
|
||||||
} else {
|
} else {
|
||||||
viewBinding.refresh.setNoMoreData(false);
|
viewBinding.refresh.setNoMoreData(false);
|
||||||
viewBinding.relNoMore.setVisibility(View.GONE);
|
viewBinding.relNoMore.setVisibility(View.GONE);
|
||||||
@@ -156,11 +160,11 @@ public class WaterPlanFragment extends BaseFragment<WaterPlanFragmentBinding, Wa
|
|||||||
|
|
||||||
// 5. 控制空布局和内容显示
|
// 5. 控制空布局和内容显示
|
||||||
if (mAdapter.getItemCount() != 0) {
|
if (mAdapter.getItemCount() != 0) {
|
||||||
viewBinding.refresh.setVisibility(View.VISIBLE);
|
viewBinding.refresh.setVisibility(VISIBLE);
|
||||||
viewBinding.relNoresult.setVisibility(View.GONE);
|
viewBinding.relNoresult.setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
viewBinding.refresh.setVisibility(View.GONE);
|
viewBinding.refresh.setVisibility(View.GONE);
|
||||||
viewBinding.relNoresult.setVisibility(View.VISIBLE);
|
viewBinding.relNoresult.setVisibility(VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
package com.ckkj.water.plate.adapter;
|
package com.ckkj.water.plan.adapter;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.ckkj.water.plan.adapter;
|
package com.ckkj.water.plan.adapter;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.view.View;
|
||||||
import android.widget.CheckBox;
|
import android.widget.CheckBox;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
@@ -24,8 +25,19 @@ public class WaterPlanListAdapter extends BaseQuickAdapter<WaterPlanWeekEntity,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void convert(BaseViewHolder helper, WaterPlanWeekEntity item) {
|
protected void convert(BaseViewHolder helper, WaterPlanWeekEntity item) {
|
||||||
|
View viewStatus = helper.getView(R.id.view_status_dot);
|
||||||
helper.setText(R.id.tv_device_name, item.getName());
|
helper.setText(R.id.tv_device_name, item.getName());
|
||||||
helper.setText(R.id.tv_device_serial, item.getId());
|
helper.setText(R.id.tv_device_serial, item.getId());
|
||||||
|
helper.setText(R.id.tv_device_status, item.getStatus().equals("0") ?
|
||||||
|
mContext.getString(R.string.closed) :
|
||||||
|
mContext.getString(R.string.device_status_working));
|
||||||
|
if(item.getStatus().equals("0")){
|
||||||
|
helper.setTextColor(R.id.tv_device_status,mContext.getResources().getColor(R.color.color_999999));
|
||||||
|
viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_status_dot_999999));
|
||||||
|
}else{
|
||||||
|
helper.setTextColor(R.id.tv_device_status,mContext.getResources().getColor(R.color.color_24B326));
|
||||||
|
viewStatus.setBackground(mContext.getResources().getDrawable(R.drawable.shape_status_dot_green));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,114 +0,0 @@
|
|||||||
//package com.ckkj.water.plate;
|
|
||||||
//
|
|
||||||
//import android.os.Bundle;
|
|
||||||
//import android.view.View;
|
|
||||||
//
|
|
||||||
//import androidx.annotation.NonNull;
|
|
||||||
//import androidx.fragment.app.Fragment;
|
|
||||||
//
|
|
||||||
//import com.ckkj.water.AppConfig;
|
|
||||||
//import com.ckkj.water.R;
|
|
||||||
//import com.ckkj.water.base.BaseFragment;
|
|
||||||
//import com.ckkj.water.databinding.PlateFragmentBinding;
|
|
||||||
//import com.ckkj.water.login.LoginActivity;
|
|
||||||
//import com.ckkj.water.network.BaseBean;
|
|
||||||
//import com.ckkj.water.plate.adapter.ViewPagerAdapter;
|
|
||||||
//import com.ckkj.water.plate.entity.BaziResultBean;
|
|
||||||
//import com.ckkj.water.plate.entity.BaziSaveSuccessEntity;
|
|
||||||
//import com.ckkj.water.plate.entity.PaipanHistoryEntity;
|
|
||||||
//import com.ckkj.water.plate.mvp.PlateContract;
|
|
||||||
//import com.ckkj.water.plate.mvp.PlateImpl;
|
|
||||||
//import com.ckkj.water.plate.mvp.PlatePresenter;
|
|
||||||
//
|
|
||||||
//import java.util.ArrayList;
|
|
||||||
//import java.util.List;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * @author fengxiaoyang
|
|
||||||
// * @date 2025/7/30
|
|
||||||
// * @description TODO: 排盘页面
|
|
||||||
// */
|
|
||||||
//
|
|
||||||
//public class PlateFragment extends BaseFragment<PlateFragmentBinding, PlatePresenter>
|
|
||||||
// implements PlateContract.PlateView {
|
|
||||||
// private List<Fragment> mFragmentList = new ArrayList<>();
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public PlatePresenter createPresenter() {
|
|
||||||
// return new PlatePresenter(new PlateImpl());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void initData(Bundle state) {
|
|
||||||
// viewBinding.includedTitle.imgBack.setVisibility(View.GONE);
|
|
||||||
// viewBinding.includedTitle.tvTitle.setText("信息录入");
|
|
||||||
// ViewPagerAdapter adapter = new ViewPagerAdapter(this, mFragmentList);
|
|
||||||
// viewBinding.viewpage.setAdapter(adapter);
|
|
||||||
// viewBinding.tvPaipan.setSelected(true);
|
|
||||||
// viewBinding.viewpage.setCurrentItem(0);
|
|
||||||
// //viewpage2 特有的 api,禁止滑动
|
|
||||||
// viewBinding.viewpage.setUserInputEnabled(false);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onNetChange(int netModel) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void showError(String message) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void logOut(BaseBean bean) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void getPaipanResult(BaziResultBean bean) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void saveBaziResultSuccess(BaziSaveSuccessEntity bean) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void getHistorySuccess(PaipanHistoryEntity entity) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void deletePaipanHistorySuccess(int pos) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onStreamMessageReceived(String messageChunk) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onStreamComplete(String complateMsg) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void commitReportSuccess(BaseBean bean) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onPermissionsGranted(int requestCode, @NonNull List<String> perms) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onPermissionsDenied(int requestCode, @NonNull List<String> perms) {
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -1,40 +0,0 @@
|
|||||||
package com.ckkj.water.plate.adapter;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Color;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
||||||
import com.chad.library.adapter.base.BaseViewHolder;
|
|
||||||
import com.ckkj.water.R;
|
|
||||||
import com.ckkj.water.utils.helper.FiveElementsHelper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fengxiaoyang
|
|
||||||
* @date 2025/8/6
|
|
||||||
* @description TODO: 描述该类的作用
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class CangGanAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
|
|
||||||
private Context mContext;
|
|
||||||
private List<String> mDzGodList;
|
|
||||||
public CangGanAdapter(Context context, int layoutResId, @Nullable List<String> data,List<String> dzGodList) {
|
|
||||||
super(layoutResId, data);
|
|
||||||
this.mContext = context;
|
|
||||||
this.mDzGodList = dzGodList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setmDzGodList(List<String> mDzGodList) {
|
|
||||||
this.mDzGodList = mDzGodList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void convert(BaseViewHolder holder, String item) {
|
|
||||||
holder.setText(R.id.tv_cg_gan,item);
|
|
||||||
holder.setTextColor(R.id.tv_cg_gan, Color.parseColor(FiveElementsHelper.getElementInfo(item).get("color")));
|
|
||||||
holder.setText(R.id.tv_cg_shishen,mDzGodList.get(holder.getLayoutPosition()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
package com.ckkj.water.plate.adapter;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
|
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
||||||
import com.chad.library.adapter.base.BaseViewHolder;
|
|
||||||
import com.ckkj.water.R;
|
|
||||||
import com.ckkj.water.plate.entity.BaziResultBean;
|
|
||||||
import com.ckkj.water.utils.helper.ShiShenCalculator;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fengxiaoyang
|
|
||||||
* @date 2025/8/5
|
|
||||||
* @description TODO: 描述该类的作用
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class DayunAdapter extends BaseQuickAdapter<BaziResultBean.DetailInfoDTO.DayunInfoDTO, BaseViewHolder> {
|
|
||||||
private Context mContext;
|
|
||||||
private int mSelPos = -1;
|
|
||||||
public DayunAdapter(Context context,int layoutResId, @Nullable List<BaziResultBean.DetailInfoDTO.DayunInfoDTO> data,
|
|
||||||
BaziResultBean.DetailInfoDTO.SizhuInfoDTO sizhuInfoDTO) {
|
|
||||||
super(layoutResId, data);
|
|
||||||
this.mContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getmSelPos() {
|
|
||||||
return mSelPos;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void convert(BaseViewHolder holder, BaziResultBean.DetailInfoDTO.DayunInfoDTO item) {
|
|
||||||
holder.setText(R.id.tv_year,item.getDayunStartYear() + "");
|
|
||||||
if(holder.getLayoutPosition() != 0){
|
|
||||||
holder.setText(R.id.tv_age,item.getDayunStartAge() + "岁");
|
|
||||||
holder.setText(R.id.tv_gan_value,ShiShenCalculator.getAbbreviation(item.getDayunShishen()));
|
|
||||||
holder.setText(R.id.tv_zhi_value,ShiShenCalculator.getAbbreviation(item.getDayunYearDzGod().get(0)));
|
|
||||||
holder.setGone(R.id.tv_gan_value,true);
|
|
||||||
holder.setGone(R.id.tv_zhi_value,true);
|
|
||||||
holder.setGone(R.id.tv_zhi_key,true);
|
|
||||||
holder.setText(R.id.tv_gan_key,item.getDayunYearTg());
|
|
||||||
holder.setText(R.id.tv_zhi_key,item.getDayunYearDz());
|
|
||||||
}else{
|
|
||||||
int dyStart = item.getDayunStartYear();
|
|
||||||
int dyEnd = item.getDayunEndYear();
|
|
||||||
if(dyStart > dyEnd){
|
|
||||||
holder.setText(R.id.tv_age,"0岁");
|
|
||||||
}else if(dyStart == dyEnd){
|
|
||||||
holder.setText(R.id.tv_age,"1岁");
|
|
||||||
}else{
|
|
||||||
holder.setText(R.id.tv_age,item.getDayunStartAge() + "-" + item.getDayunEndAge() + "岁");
|
|
||||||
}
|
|
||||||
holder.setGone(R.id.tv_gan_value,false);
|
|
||||||
holder.setGone(R.id.tv_zhi_value,false);
|
|
||||||
holder.setText(R.id.tv_gan_key,item.getDayunTongxian());
|
|
||||||
holder.setGone(R.id.tv_zhi_key,false);
|
|
||||||
holder.setGone(R.id.tv_zhi_value,false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(holder.getLayoutPosition() == mSelPos){
|
|
||||||
holder.setBackgroundColor(R.id.ll_item, ContextCompat.getColor(mContext,R.color.divider));
|
|
||||||
}else{
|
|
||||||
holder.setBackgroundColor(R.id.ll_item, ContextCompat.getColor(mContext,R.color.white));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelPostion(int pos){
|
|
||||||
this.mSelPos = pos;
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,167 +0,0 @@
|
|||||||
package com.ckkj.water.plate.adapter;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Color;
|
|
||||||
import android.text.TextUtils;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
||||||
import com.chad.library.adapter.base.BaseViewHolder;
|
|
||||||
import com.ckkj.water.R;
|
|
||||||
import com.ckkj.water.plate.entity.BaziResultBean;
|
|
||||||
import com.ckkj.water.utils.helper.FiveElementsHelper;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fengxiaoyang
|
|
||||||
* @date 2025/8/6
|
|
||||||
* @description 大运、流年、流月柱状图适配器
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class DayunColumnAdapter extends BaseQuickAdapter<BaziResultBean.DetailInfoDTO.DayunInfoDTO, BaseViewHolder> {
|
|
||||||
private Context mContext;
|
|
||||||
private int mDayunTypeCode = 100;
|
|
||||||
private CangGanAdapter mCangganAdapter;
|
|
||||||
private ShenshaAdapter mShenshaAdapter;
|
|
||||||
private int mSelectXiaoyunPos = -1;
|
|
||||||
|
|
||||||
public DayunColumnAdapter(Context context, int layoutResId,
|
|
||||||
@Nullable List<BaziResultBean.DetailInfoDTO.DayunInfoDTO> data,
|
|
||||||
int typeCode) {
|
|
||||||
super(layoutResId, data);
|
|
||||||
this.mContext = context;
|
|
||||||
this.mDayunTypeCode = typeCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void convert(BaseViewHolder holder, BaziResultBean.DetailInfoDTO.DayunInfoDTO item) {
|
|
||||||
RecyclerView rvDatas = holder.getView(R.id.rv_canggan);
|
|
||||||
RecyclerView rvShenShaData = holder.getView(R.id.rv_shensha_data);
|
|
||||||
holder.setGone(R.id.viewline,true);
|
|
||||||
|
|
||||||
switch (mDayunTypeCode) {
|
|
||||||
case 100: // 大运
|
|
||||||
// 第一个item(bornBean)童限 的特殊处理
|
|
||||||
holder.setText(R.id.tv_shishen, item.isTongXian() ?
|
|
||||||
item.getXiaoyunInfo().get(0).getXiaoyunShishen() : item.getDayunShishen());
|
|
||||||
holder.setText(R.id.tv_tg, item.isTongXian() ?
|
|
||||||
item.getXiaoyunInfo().get(0).getXiaoyunYearTg() : item.getDayunYearTg());
|
|
||||||
holder.setText(R.id.tv_dz, item.isTongXian() ?
|
|
||||||
item.getXiaoyunInfo().get(0).getXiaoyunYearDz() : item.getDayunYearDz());
|
|
||||||
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo
|
|
||||||
(item.isTongXian() ?
|
|
||||||
item.getXiaoyunInfo().get(0).getXiaoyunYearTg() : item.getDayunYearTg()).get("color")));
|
|
||||||
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo
|
|
||||||
(item.isTongXian() ?
|
|
||||||
item.getXiaoyunInfo().get(0).getXiaoyunYearTg() : item.getDayunYearTg()).get("color")));
|
|
||||||
holder.setText(R.id.tv_xingyun, item.isTongXian() ?
|
|
||||||
item.getXiaoyunInfo().get(0).getXiaoyunDzStarCs() : item.getDayunDzStarCs());
|
|
||||||
holder.setText(R.id.tv_zizuo, item.isTongXian() ?
|
|
||||||
item.getXiaoyunInfo().get(0).getXiaoyunDzSelfCs() : item.getDayunDzSelfCs());
|
|
||||||
holder.setText(R.id.tv_kongwang, item.isTongXian() ?
|
|
||||||
item.getXiaoyunInfo().get(0).getXiaoyunKongwang() : item.getDayunKongwang());
|
|
||||||
holder.setText(R.id.tv_nayin, item.isTongXian() ?
|
|
||||||
item.getXiaoyunInfo().get(0).getXiaoyunNayin() : item.getDayunNayin());
|
|
||||||
// bornBean可能没有藏干和神煞数据,需要特殊处理
|
|
||||||
if (mCangganAdapter == null) {
|
|
||||||
mCangganAdapter = new CangGanAdapter(mContext,
|
|
||||||
R.layout.paipan_canggan_item,
|
|
||||||
item.isTongXian() ? item.getXiaoyunInfo().get(0).getXiaoyunYearCg() : item.getDayunYearCg(),
|
|
||||||
item.isTongXian() ? item.getXiaoyunInfo().get(0).getXiaoyunDzGod() : item.getDayunYearDzGod());
|
|
||||||
rvDatas.setAdapter(mCangganAdapter);
|
|
||||||
} else {
|
|
||||||
mCangganAdapter.setNewData(item.isTongXian() ?
|
|
||||||
item.getXiaoyunInfo().get(0).getXiaoyunYearCg() : item.getDayunYearCg());
|
|
||||||
mCangganAdapter.setmDzGodList(item.isTongXian() ?
|
|
||||||
item.getXiaoyunInfo().get(0).getXiaoyunDzGod() : item.getDayunYearDzGod());
|
|
||||||
}
|
|
||||||
List<String> shenshaList = new ArrayList<>();
|
|
||||||
if (item.isTongXian()) {
|
|
||||||
String shensha = item.getXiaoyunInfo().get(0).getXiaoyunShensha();
|
|
||||||
if (!TextUtils.isEmpty(shensha)) {
|
|
||||||
shenshaList = Arrays.asList(shensha.split(" "));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
String shensha = item.getDayunShensha();
|
|
||||||
if (!TextUtils.isEmpty(shensha)) {
|
|
||||||
shenshaList = Arrays.asList(shensha.split(" "));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mShenshaAdapter == null) {
|
|
||||||
mShenshaAdapter = new ShenshaAdapter(mContext, R.layout.paipan_shensha_item, shenshaList);
|
|
||||||
rvShenShaData.setAdapter(mShenshaAdapter);
|
|
||||||
} else {
|
|
||||||
mShenshaAdapter.setNewData(shenshaList);
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 200: // 流年
|
|
||||||
BaziResultBean.DetailInfoDTO.DayunInfoDTO.XiaoyunInfoDTO xiaoyunEntity = item.getXiaoyunInfo().get(mSelectXiaoyunPos);
|
|
||||||
// 第一个item(bornBean)的特殊处理
|
|
||||||
holder.setText(R.id.tv_shishen, xiaoyunEntity.getXiaoyunShishen());
|
|
||||||
holder.setText(R.id.tv_tg, xiaoyunEntity.getXiaoyunYearTg());
|
|
||||||
holder.setText(R.id.tv_dz, xiaoyunEntity.getXiaoyunYearDz());
|
|
||||||
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo(xiaoyunEntity.getXiaoyunYearTg()).get("color")));
|
|
||||||
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo(xiaoyunEntity.getXiaoyunYearDz()).get("color")));
|
|
||||||
holder.setText(R.id.tv_xingyun, xiaoyunEntity.getXiaoyunDzStarCs());
|
|
||||||
holder.setText(R.id.tv_zizuo, xiaoyunEntity.getXiaoyunDzSelfCs());
|
|
||||||
holder.setText(R.id.tv_kongwang, xiaoyunEntity.getXiaoyunKongwang());
|
|
||||||
holder.setText(R.id.tv_nayin, xiaoyunEntity.getXiaoyunNayin());
|
|
||||||
|
|
||||||
// bornBean的流年数据可能为空,需要特殊处理
|
|
||||||
if (mCangganAdapter == null) {
|
|
||||||
mCangganAdapter = new CangGanAdapter(mContext, R.layout.paipan_canggan_item,
|
|
||||||
xiaoyunEntity.getXiaoyunYearCg(), xiaoyunEntity.getXiaoyunDzGod());
|
|
||||||
rvDatas.setAdapter(mCangganAdapter);
|
|
||||||
}else{
|
|
||||||
mCangganAdapter.setNewData(xiaoyunEntity.getXiaoyunYearCg());
|
|
||||||
mCangganAdapter.setmDzGodList(xiaoyunEntity.getXiaoyunDzGod());
|
|
||||||
}
|
|
||||||
if (mShenshaAdapter == null) {
|
|
||||||
String shensha = xiaoyunEntity.getXiaoyunShensha();
|
|
||||||
mShenshaAdapter = new ShenshaAdapter(mContext, R.layout.paipan_shensha_item, Arrays.asList(shensha.split(" ")));
|
|
||||||
rvShenShaData.setAdapter(mShenshaAdapter);
|
|
||||||
}else{
|
|
||||||
String shensha = xiaoyunEntity.getXiaoyunShensha();
|
|
||||||
mShenshaAdapter.setNewData(Arrays.asList(shensha.split(" ")));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case 300: // 流月
|
|
||||||
// 第一个item(bornBean)的特殊处理
|
|
||||||
holder.setText(R.id.tv_shishen, "小运");
|
|
||||||
holder.setText(R.id.tv_tg, item.getDayunYearTg());
|
|
||||||
holder.setText(R.id.tv_dz, item.getDayunYearDz());
|
|
||||||
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo(item.getDayunYearTg()).get("color")));
|
|
||||||
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo(item.getDayunYearDz()).get("color")));
|
|
||||||
holder.setText(R.id.tv_xingyun, "");
|
|
||||||
holder.setText(R.id.tv_zizuo, "");
|
|
||||||
holder.setText(R.id.tv_kongwang, "");
|
|
||||||
holder.setText(R.id.tv_nayin, "");
|
|
||||||
|
|
||||||
// bornBean的流月数据可能为空,需要特殊处理
|
|
||||||
if (mCangganAdapter == null) {
|
|
||||||
mCangganAdapter = new CangGanAdapter(mContext, R.layout.paipan_canggan_item,
|
|
||||||
Arrays.asList(), Arrays.asList());
|
|
||||||
rvDatas.setAdapter(mCangganAdapter);
|
|
||||||
}
|
|
||||||
if (mShenshaAdapter == null) {
|
|
||||||
mShenshaAdapter = new ShenshaAdapter(mContext, R.layout.paipan_shensha_item, Arrays.asList());
|
|
||||||
rvShenShaData.setAdapter(mShenshaAdapter);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setColumnCode(int code,int xiaoyunPos) {
|
|
||||||
mDayunTypeCode = code;
|
|
||||||
mSelectXiaoyunPos = xiaoyunPos;
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
package com.ckkj.water.plate.adapter;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Color;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
||||||
import com.chad.library.adapter.base.BaseViewHolder;
|
|
||||||
import com.ckkj.water.R;
|
|
||||||
import com.ckkj.water.plate.entity.BaziResultBean;
|
|
||||||
import com.ckkj.water.utils.helper.FiveElementsHelper;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fengxiaoyang
|
|
||||||
* @date 2025/8/7
|
|
||||||
* @description TODO: 描述该类的作用
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class LiuNianColumnAdapter extends BaseQuickAdapter
|
|
||||||
<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO, BaseViewHolder> {
|
|
||||||
private CangGanAdapter mCangganAdapter;
|
|
||||||
private ShenshaAdapter mShenshaAdapter;
|
|
||||||
|
|
||||||
|
|
||||||
private Context mContext;
|
|
||||||
private List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.XiaoyunInfoDTO> xiaoyunInfo;
|
|
||||||
|
|
||||||
public LiuNianColumnAdapter(Context context, int layoutResId,
|
|
||||||
@Nullable List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO> data,
|
|
||||||
List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.XiaoyunInfoDTO> xiaoyunInfo) {
|
|
||||||
super(layoutResId, data);
|
|
||||||
this.mContext = context;
|
|
||||||
this.xiaoyunInfo = xiaoyunInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void convert(BaseViewHolder holder, BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO item) {
|
|
||||||
RecyclerView rvDatas = holder.getView(R.id.rv_canggan);
|
|
||||||
RecyclerView rvShenShaData = holder.getView(R.id.rv_shensha_data);
|
|
||||||
// 第一个item(bornBean)的特殊处理
|
|
||||||
holder.setText(R.id.tv_shishen, item.getLiunianShishen());
|
|
||||||
holder.setText(R.id.tv_tg, item.getLiunianYearTg());
|
|
||||||
holder.setText(R.id.tv_dz, item.getLiunianYearDz());
|
|
||||||
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo(item.getLiunianYearTg()).get("color")));
|
|
||||||
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo(item.getLiunianYearDz()).get("color")));
|
|
||||||
holder.setText(R.id.tv_xingyun, item.getLiunianDzStarCs());
|
|
||||||
holder.setText(R.id.tv_zizuo, item.getLiunianDzSelfCs());
|
|
||||||
holder.setText(R.id.tv_kongwang, item.getLiunianKongwang());
|
|
||||||
holder.setText(R.id.tv_nayin, item.getLiunianNayin());
|
|
||||||
|
|
||||||
// bornBean的流年数据可能为空,需要特殊处理
|
|
||||||
if (mCangganAdapter == null) {
|
|
||||||
mCangganAdapter = new CangGanAdapter(mContext, R.layout.paipan_canggan_item,
|
|
||||||
item.getLiunianYearCg(), item.getLiunianDzGod());
|
|
||||||
rvDatas.setAdapter(mCangganAdapter);
|
|
||||||
}else{
|
|
||||||
mCangganAdapter.setNewData(item.getLiunianYearCg());
|
|
||||||
mCangganAdapter.setmDzGodList(item.getLiunianDzGod());
|
|
||||||
}
|
|
||||||
if (mShenshaAdapter == null) {
|
|
||||||
mShenshaAdapter = new ShenshaAdapter(mContext, R.layout.paipan_shensha_item, Arrays.asList(item.getLiunianShensha().split(" ")));
|
|
||||||
rvShenShaData.setAdapter(mShenshaAdapter);
|
|
||||||
}else{
|
|
||||||
String shensha = item.getLiunianShensha();
|
|
||||||
mShenshaAdapter.setNewData(Arrays.asList(shensha.split(" ")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setXiaoyunDatas(List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.XiaoyunInfoDTO> xiaoyunInfoDTOList) {
|
|
||||||
this.xiaoyunInfo = xiaoyunInfoDTOList;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,75 +0,0 @@
|
|||||||
package com.ckkj.water.plate.adapter;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Color;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
||||||
import com.chad.library.adapter.base.BaseViewHolder;
|
|
||||||
import com.ckkj.water.R;
|
|
||||||
import com.ckkj.water.plate.entity.BaziResultBean;
|
|
||||||
import com.ckkj.water.utils.helper.FiveElementsHelper;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fengxiaoyang
|
|
||||||
* @date 2025/8/7
|
|
||||||
* @description TODO: 描述该类的作用
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class LiuYueColumnAdapter extends BaseQuickAdapter
|
|
||||||
<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO.LiuyueInfoDTO, BaseViewHolder> {
|
|
||||||
private CangGanAdapter mCangganAdapter;
|
|
||||||
private ShenshaAdapter mShenshaAdapter;
|
|
||||||
|
|
||||||
|
|
||||||
private Context mContext;
|
|
||||||
private List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.XiaoyunInfoDTO> xiaoyunInfo;
|
|
||||||
|
|
||||||
public LiuYueColumnAdapter(Context context, int layoutResId,
|
|
||||||
@Nullable List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO.LiuyueInfoDTO> data) {
|
|
||||||
super(layoutResId, data);
|
|
||||||
this.mContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void convert(BaseViewHolder holder, BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO.LiuyueInfoDTO item) {
|
|
||||||
RecyclerView rvDatas = holder.getView(R.id.rv_canggan);
|
|
||||||
RecyclerView rvShenShaData = holder.getView(R.id.rv_shensha_data);
|
|
||||||
// 第一个item(bornBean)的特殊处理
|
|
||||||
holder.setText(R.id.tv_shishen, item.getLiuyueShishen());
|
|
||||||
holder.setText(R.id.tv_tg, item.getLiuyueMonthTg());
|
|
||||||
holder.setText(R.id.tv_dz, item.getLiuyueMonthDz());
|
|
||||||
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo(item.getLiuyueMonthTg()).get("color")));
|
|
||||||
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo(item.getLiuyueMonthDz()).get("color")));
|
|
||||||
holder.setText(R.id.tv_xingyun, item.getLiuyueDzStarCs());
|
|
||||||
holder.setText(R.id.tv_zizuo, item.getLiuyueDzSelfCs());
|
|
||||||
holder.setText(R.id.tv_kongwang, item.getLiuyueKongwang());
|
|
||||||
holder.setText(R.id.tv_nayin, item.getLiuyueNayin());
|
|
||||||
|
|
||||||
// bornBean的流年数据可能为空,需要特殊处理
|
|
||||||
if (mCangganAdapter == null) {
|
|
||||||
mCangganAdapter = new CangGanAdapter(mContext, R.layout.paipan_canggan_item,
|
|
||||||
item.getLiuyueMonthCg(), item.getLiuyueMonthDzGod());
|
|
||||||
rvDatas.setAdapter(mCangganAdapter);
|
|
||||||
}else{
|
|
||||||
mCangganAdapter.setNewData(item.getLiuyueMonthCg());
|
|
||||||
mCangganAdapter.setmDzGodList(item.getLiuyueMonthDzGod());
|
|
||||||
}
|
|
||||||
if (mShenshaAdapter == null) {
|
|
||||||
mShenshaAdapter = new ShenshaAdapter(mContext, R.layout.paipan_shensha_item, Arrays.asList(item.getLiuyueShensha().split(" ")));
|
|
||||||
rvShenShaData.setAdapter(mShenshaAdapter);
|
|
||||||
}else{
|
|
||||||
String shensha = item.getLiuyueShensha();
|
|
||||||
mShenshaAdapter.setNewData(Arrays.asList(shensha.split(" ")));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// public void setXiaoyunDatas(List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.XiaoyunInfoDTO> xiaoyunInfoDTOList) {
|
|
||||||
// this.xiaoyunInfo = xiaoyunInfoDTOList;
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package com.ckkj.water.plate.adapter;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
|
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
||||||
import com.chad.library.adapter.base.BaseViewHolder;
|
|
||||||
import com.ckkj.water.R;
|
|
||||||
import com.ckkj.water.plate.entity.BaziResultBean;
|
|
||||||
import com.ckkj.water.utils.helper.ShiShenCalculator;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fengxiaoyang
|
|
||||||
* @date 2025/8/6
|
|
||||||
* @description TODO: 描述该类的作用
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class LiunianAdapter extends BaseQuickAdapter<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO, BaseViewHolder> {
|
|
||||||
private Context mContext;
|
|
||||||
private int mSelPos = -1;
|
|
||||||
private List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.XiaoyunInfoDTO> xiaoyunList =
|
|
||||||
new ArrayList<>();
|
|
||||||
|
|
||||||
|
|
||||||
public LiunianAdapter(Context context, int layoutResId,
|
|
||||||
@Nullable List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO> data,
|
|
||||||
List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.XiaoyunInfoDTO> xiaoyunInfo) {
|
|
||||||
super(layoutResId, data);
|
|
||||||
this.mContext = context;
|
|
||||||
this.xiaoyunList = xiaoyunInfo;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void convert(BaseViewHolder holder, BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO item) {
|
|
||||||
holder.setText(R.id.tv_year,item.getLiunianYear() + "");
|
|
||||||
holder.setGone(R.id.tv_age,false);
|
|
||||||
holder.setText(R.id.tv_gan_value, ShiShenCalculator.getAbbreviation(item.getLiunianTgGod()));
|
|
||||||
holder.setText(R.id.tv_zhi_value,ShiShenCalculator.getAbbreviation(item.getLiunianDzGod().get(0)));
|
|
||||||
holder.setText(R.id.tv_gan_key,item.getLiunianYearTg());
|
|
||||||
holder.setText(R.id.tv_zhi_key,item.getLiunianYearDz());
|
|
||||||
holder.setGone(R.id.tv_xiaoyun,true);
|
|
||||||
holder.setText(R.id.tv_xiaoyun,xiaoyunList.get(holder.getLayoutPosition()).getXiaoyunGanzhi());
|
|
||||||
if(holder.getLayoutPosition() == mSelPos){
|
|
||||||
holder.setBackgroundColor(R.id.ll_item, ContextCompat.getColor(mContext,R.color.divider));
|
|
||||||
}else{
|
|
||||||
holder.setBackgroundColor(R.id.ll_item, ContextCompat.getColor(mContext,R.color.white));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelPostion(int pos){
|
|
||||||
this.mSelPos = pos;
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getmSelPos() {
|
|
||||||
return mSelPos;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,64 +0,0 @@
|
|||||||
package com.ckkj.water.plate.adapter;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.core.content.ContextCompat;
|
|
||||||
|
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
||||||
import com.chad.library.adapter.base.BaseViewHolder;
|
|
||||||
import com.ckkj.water.R;
|
|
||||||
import com.ckkj.water.plate.entity.BaziResultBean;
|
|
||||||
import com.ckkj.water.utils.helper.ShiShenCalculator;
|
|
||||||
import com.ckkj.water.utils.time.ZYTimeUtils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fengxiaoyang
|
|
||||||
* @date 2025/8/6
|
|
||||||
* @description TODO: 描述该类的作用
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class LiuyueAdapter extends BaseQuickAdapter<BaziResultBean.DetailInfoDTO.DayunInfoDTO.
|
|
||||||
LiunianInfoDTO.LiuyueInfoDTO, BaseViewHolder> {
|
|
||||||
private Context mContext;
|
|
||||||
private int mSelPos = -1;
|
|
||||||
private List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO.LiunianJieqiDTO> jieqiList =
|
|
||||||
new ArrayList<>();
|
|
||||||
public LiuyueAdapter(Context context,int layoutResId, @Nullable List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO.LiuyueInfoDTO> data,
|
|
||||||
List<BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO.LiunianJieqiDTO> jieqiList) {
|
|
||||||
super(layoutResId, data);
|
|
||||||
this.mContext = context;
|
|
||||||
this.jieqiList = jieqiList;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void convert(BaseViewHolder holder, BaziResultBean.DetailInfoDTO.DayunInfoDTO.LiunianInfoDTO.LiuyueInfoDTO item) {
|
|
||||||
holder.setText(R.id.tv_year,jieqiList.get(holder.getLayoutPosition()).getJieqiName());
|
|
||||||
holder.setGone(R.id.tv_age,true);
|
|
||||||
//节气日期转换
|
|
||||||
String jieqiDate = ZYTimeUtils.formatToMonthDay(jieqiList.get(holder.getLayoutPosition()).getJieqiSolarYmdhms());
|
|
||||||
holder.setText(R.id.tv_age, jieqiDate);
|
|
||||||
holder.setText(R.id.tv_gan_value, ShiShenCalculator.getAbbreviation(item.getLiuyueMonthTgGod()));
|
|
||||||
holder.setText(R.id.tv_zhi_value,ShiShenCalculator.getAbbreviation(item.getLiuyueMonthDzGod().get(0)));
|
|
||||||
holder.setText(R.id.tv_gan_key,item.getLiuyueMonthTg());
|
|
||||||
holder.setText(R.id.tv_zhi_key,item.getLiuyueMonthDz());
|
|
||||||
holder.setGone(R.id.tv_xiaoyun,false);
|
|
||||||
if(holder.getLayoutPosition() == mSelPos){
|
|
||||||
holder.setBackgroundColor(R.id.ll_item, ContextCompat.getColor(mContext,R.color.divider));
|
|
||||||
}else{
|
|
||||||
holder.setBackgroundColor(R.id.ll_item, ContextCompat.getColor(mContext,R.color.white));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelPostion(int pos){
|
|
||||||
this.mSelPos = pos;
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getmSelPos() {
|
|
||||||
return mSelPos;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,60 +0,0 @@
|
|||||||
package com.ckkj.water.plate.adapter;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Color;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
||||||
import com.chad.library.adapter.base.BaseViewHolder;
|
|
||||||
import com.ckkj.water.R;
|
|
||||||
import com.ckkj.water.plate.entity.PaipanHistoryEntity;
|
|
||||||
import com.ckkj.water.utils.click.ClickUtil;
|
|
||||||
import com.ckkj.water.utils.helper.FiveElementsHelper;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fengxiaoyang
|
|
||||||
* @date 2025/8/9
|
|
||||||
* @description TODO: 描述该类的作用
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class PaipanHistoryAdapter extends BaseQuickAdapter<PaipanHistoryEntity.RecordsDTO, BaseViewHolder> {
|
|
||||||
private Context mContext;
|
|
||||||
public PaipanHistoryAdapter(Context context,int layoutResId, @Nullable List<PaipanHistoryEntity.RecordsDTO> data) {
|
|
||||||
super(layoutResId, data);
|
|
||||||
this.mContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void convert(BaseViewHolder holder, PaipanHistoryEntity.RecordsDTO item) {
|
|
||||||
String []nianArr = item.getNianZhu().split(",");
|
|
||||||
String []yueArr = item.getYueZhu().split(",");
|
|
||||||
String []riArr = item.getRiZhu().split(",");
|
|
||||||
String []shiArr = item.getShiZhu().split(",");
|
|
||||||
holder.setText(R.id.tv_nian_tg,nianArr[0]);
|
|
||||||
holder.setText(R.id.tv_nian_dz,nianArr[1]);
|
|
||||||
holder.setText(R.id.tv_yue_tg,yueArr[0]);
|
|
||||||
holder.setText(R.id.tv_yue_dz,yueArr[1]);
|
|
||||||
holder.setText(R.id.tv_ri_tg,riArr[0]);
|
|
||||||
holder.setText(R.id.tv_ri_dz,riArr[1]);
|
|
||||||
holder.setText(R.id.tv_shi_tg,shiArr[0]);
|
|
||||||
holder.setText(R.id.tv_shi_dz,shiArr[1]);
|
|
||||||
holder.setTextColor(R.id.tv_nian_tg, Color.parseColor(FiveElementsHelper.getElementInfo(nianArr[0]).get("color")));
|
|
||||||
holder.setTextColor(R.id.tv_nian_dz, Color.parseColor(FiveElementsHelper.getElementInfo(nianArr[1]).get("color")));
|
|
||||||
holder.setTextColor(R.id.tv_yue_tg, Color.parseColor(FiveElementsHelper.getElementInfo(yueArr[0]).get("color")));
|
|
||||||
holder.setTextColor(R.id.tv_yue_dz, Color.parseColor(FiveElementsHelper.getElementInfo(yueArr[1]).get("color")));
|
|
||||||
holder.setTextColor(R.id.tv_ri_tg, Color.parseColor(FiveElementsHelper.getElementInfo(riArr[0]).get("color")));
|
|
||||||
holder.setTextColor(R.id.tv_ri_dz, Color.parseColor(FiveElementsHelper.getElementInfo(riArr[1]).get("color")));
|
|
||||||
holder.setTextColor(R.id.tv_shi_tg, Color.parseColor(FiveElementsHelper.getElementInfo(shiArr[0]).get("color")));
|
|
||||||
holder.setTextColor(R.id.tv_shi_dz, Color.parseColor(FiveElementsHelper.getElementInfo(shiArr[1]).get("color")));
|
|
||||||
holder.setText(R.id.tv_user_name,item.getName());
|
|
||||||
holder.setText(R.id.tv_user_sex,Integer.parseInt(item.getGender()) == 0 ? "男":"女");
|
|
||||||
holder.setText(R.id.tv_user_birthtime,Integer.parseInt(item.getBirthType()) == 1 ?
|
|
||||||
"公历:" + item.getYangLiBirthTime():
|
|
||||||
"农历:" + item.getYinLiBirthTime());
|
|
||||||
ClickUtil.addClickPart(holder.getView(R.id.img_delete),80);
|
|
||||||
holder.addOnClickListener(R.id.img_delete);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
package com.ckkj.water.plate.adapter;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
|
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
||||||
import com.chad.library.adapter.base.BaseViewHolder;
|
|
||||||
import com.ckkj.water.R;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fengxiaoyang
|
|
||||||
* @date 2025/8/6
|
|
||||||
* @description TODO: 描述该类的作用
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class ShenshaAdapter extends BaseQuickAdapter<String, BaseViewHolder> {
|
|
||||||
private Context mContext;
|
|
||||||
public ShenshaAdapter(Context context,int layoutResId, @Nullable List<String> data) {
|
|
||||||
super(layoutResId, data);
|
|
||||||
this.mContext = context;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void convert(BaseViewHolder helper, String item) {
|
|
||||||
helper.setText(R.id.tv_shensha_value,item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,128 +0,0 @@
|
|||||||
package com.ckkj.water.plate.adapter;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.graphics.Color;
|
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
|
||||||
|
|
||||||
import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
||||||
import com.chad.library.adapter.base.BaseViewHolder;
|
|
||||||
import com.ckkj.water.R;
|
|
||||||
import com.ckkj.water.plate.entity.BaziResultBean;
|
|
||||||
import com.ckkj.water.utils.helper.FiveElementsHelper;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fengxiaoyang
|
|
||||||
* @date 2025/8/6
|
|
||||||
* @description TODO: 描述该类的作用
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class SizhuAdapter extends BaseQuickAdapter<BaziResultBean.DetailInfoDTO.SizhuInfoDTO, BaseViewHolder> {
|
|
||||||
private Context mContext;
|
|
||||||
private int mSizhuTypeCode = 100;
|
|
||||||
private CangGanAdapter mCangganAdapter;
|
|
||||||
private ShenshaAdapter mShenshaAdapter;
|
|
||||||
public SizhuAdapter(Context context,int layoutResId,
|
|
||||||
@Nullable List<BaziResultBean.DetailInfoDTO.SizhuInfoDTO> data,
|
|
||||||
int typeCode) {
|
|
||||||
super(layoutResId, data);
|
|
||||||
this.mContext = context;
|
|
||||||
this.mSizhuTypeCode = typeCode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void convert(BaseViewHolder holder, BaziResultBean.DetailInfoDTO.SizhuInfoDTO item) {
|
|
||||||
RecyclerView rvDatas = holder.getView(R.id.rv_canggan);
|
|
||||||
RecyclerView rvShenShaData = holder.getView(R.id.rv_shensha_data);
|
|
||||||
switch (mSizhuTypeCode){
|
|
||||||
case 100: // 年柱
|
|
||||||
holder.setText(R.id.tv_shishen,item.getYear().getTgGod());
|
|
||||||
holder.setText(R.id.tv_tg,item.getYear().getTg());
|
|
||||||
holder.setText(R.id.tv_dz,item.getYear().getDz());
|
|
||||||
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo(item.getYear().getTg()).get("color")));
|
|
||||||
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo(item.getYear().getDz()).get("color")));
|
|
||||||
holder.setText(R.id.tv_xingyun,item.getYear().getDzStarCs());
|
|
||||||
holder.setText(R.id.tv_zizuo,item.getYear().getDzSelfCs());
|
|
||||||
holder.setText(R.id.tv_kongwang,item.getYear().getKw());
|
|
||||||
holder.setText(R.id.tv_nayin,item.getYear().getNy());
|
|
||||||
if(mCangganAdapter == null){
|
|
||||||
mCangganAdapter = new CangGanAdapter(mContext,R.layout.paipan_canggan_item,
|
|
||||||
item.getYear().getCg(), item.getYear().getDzGod());
|
|
||||||
rvDatas.setAdapter(mCangganAdapter);
|
|
||||||
}
|
|
||||||
if(mShenshaAdapter == null){
|
|
||||||
List<String> shenshaList = Arrays.asList(item.getYear().getShensha().split(" "));
|
|
||||||
mShenshaAdapter = new ShenshaAdapter(mContext,R.layout.paipan_shensha_item,shenshaList);
|
|
||||||
rvShenShaData.setAdapter(mShenshaAdapter);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 200: // 月柱
|
|
||||||
holder.setText(R.id.tv_shishen,item.getMonth().getTgGod());
|
|
||||||
holder.setText(R.id.tv_tg,item.getMonth().getTg());
|
|
||||||
holder.setText(R.id.tv_dz,item.getMonth().getDz());
|
|
||||||
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo(item.getMonth().getTg()).get("color")));
|
|
||||||
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo(item.getMonth().getDz()).get("color")));
|
|
||||||
holder.setText(R.id.tv_xingyun,item.getMonth().getDzStarCs());
|
|
||||||
holder.setText(R.id.tv_zizuo,item.getMonth().getDzSelfCs());
|
|
||||||
holder.setText(R.id.tv_kongwang,item.getMonth().getKw());
|
|
||||||
holder.setText(R.id.tv_nayin,item.getMonth().getNy());
|
|
||||||
if(mCangganAdapter == null){
|
|
||||||
mCangganAdapter = new CangGanAdapter(mContext,R.layout.paipan_canggan_item,
|
|
||||||
item.getMonth().getCg(), item.getMonth().getDzGod());
|
|
||||||
rvDatas.setAdapter(mCangganAdapter);
|
|
||||||
}
|
|
||||||
if(mShenshaAdapter == null){
|
|
||||||
List<String> shenshaList = Arrays.asList(item.getMonth().getShensha().split(" "));
|
|
||||||
mShenshaAdapter = new ShenshaAdapter(mContext,R.layout.paipan_shensha_item,shenshaList);
|
|
||||||
rvShenShaData.setAdapter(mShenshaAdapter);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 300: // 日柱
|
|
||||||
holder.setText(R.id.tv_shishen,item.getDay().getTgGod());
|
|
||||||
holder.setText(R.id.tv_tg,item.getDay().getTg());
|
|
||||||
holder.setText(R.id.tv_dz,item.getDay().getDz());
|
|
||||||
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo(item.getDay().getTg()).get("color")));
|
|
||||||
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo(item.getDay().getDz()).get("color")));
|
|
||||||
holder.setText(R.id.tv_xingyun,item.getDay().getDzStarCs());
|
|
||||||
holder.setText(R.id.tv_zizuo,item.getDay().getDzSelfCs());
|
|
||||||
holder.setText(R.id.tv_kongwang,item.getDay().getKw());
|
|
||||||
holder.setText(R.id.tv_nayin,item.getDay().getNy());
|
|
||||||
if(mCangganAdapter == null){
|
|
||||||
mCangganAdapter = new CangGanAdapter(mContext,R.layout.paipan_canggan_item,
|
|
||||||
item.getDay().getCg(), item.getDay().getDzGod());
|
|
||||||
rvDatas.setAdapter(mCangganAdapter);
|
|
||||||
}
|
|
||||||
if(mShenshaAdapter == null){
|
|
||||||
List<String> shenshaList = Arrays.asList(item.getDay().getShensha().split(" "));
|
|
||||||
mShenshaAdapter = new ShenshaAdapter(mContext,R.layout.paipan_shensha_item,shenshaList);
|
|
||||||
rvShenShaData.setAdapter(mShenshaAdapter);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 400: // 时柱
|
|
||||||
holder.setText(R.id.tv_shishen,item.getHour().getTgGod());
|
|
||||||
holder.setText(R.id.tv_tg,item.getHour().getTg());
|
|
||||||
holder.setText(R.id.tv_dz,item.getHour().getDz());
|
|
||||||
holder.setTextColor(R.id.tv_tg, Color.parseColor(FiveElementsHelper.getElementInfo(item.getHour().getTg()).get("color")));
|
|
||||||
holder.setTextColor(R.id.tv_dz, Color.parseColor(FiveElementsHelper.getElementInfo(item.getHour().getDz()).get("color")));
|
|
||||||
holder.setText(R.id.tv_xingyun,item.getHour().getDzStarCs());
|
|
||||||
holder.setText(R.id.tv_zizuo,item.getHour().getDzSelfCs());
|
|
||||||
holder.setText(R.id.tv_kongwang,item.getHour().getKw());
|
|
||||||
holder.setText(R.id.tv_nayin,item.getHour().getNy());
|
|
||||||
if(mCangganAdapter == null){
|
|
||||||
mCangganAdapter = new CangGanAdapter(mContext,R.layout.paipan_canggan_item,
|
|
||||||
item.getHour().getCg(), item.getHour().getDzGod());
|
|
||||||
rvDatas.setAdapter(mCangganAdapter);
|
|
||||||
}
|
|
||||||
if(mShenshaAdapter == null){
|
|
||||||
List<String> shenshaList = Arrays.asList(item.getHour().getShensha().split(" "));
|
|
||||||
mShenshaAdapter = new ShenshaAdapter(mContext,R.layout.paipan_shensha_item,shenshaList);
|
|
||||||
rvShenShaData.setAdapter(mShenshaAdapter);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -1,661 +0,0 @@
|
|||||||
package com.ckkj.water.plate.entity;
|
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fengxiaoyang
|
|
||||||
* @date 2025/8/5
|
|
||||||
* @description TODO: 描述该类的作用
|
|
||||||
*/
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public class BaziResultBean implements Serializable {
|
|
||||||
|
|
||||||
@SerializedName("base_info")
|
|
||||||
private BaseInfoDTO baseInfo;
|
|
||||||
@SerializedName("detail_info")
|
|
||||||
private DetailInfoDTO detailInfo;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class BaseInfoDTO implements Serializable {
|
|
||||||
@SerializedName("sex")
|
|
||||||
private String sex;
|
|
||||||
@SerializedName("name")
|
|
||||||
private String name;
|
|
||||||
@SerializedName("gongli")
|
|
||||||
private String gongli;
|
|
||||||
@SerializedName("nongli")
|
|
||||||
private String nongli;
|
|
||||||
@SerializedName("qiyun")
|
|
||||||
private String qiyun;
|
|
||||||
@SerializedName("jiaoyun")
|
|
||||||
private String jiaoyun;
|
|
||||||
@SerializedName("taiyuan")
|
|
||||||
private String taiyuan;
|
|
||||||
@SerializedName("taiyuan_nayin")
|
|
||||||
private String taiyuanNayin;
|
|
||||||
@SerializedName("taixi")
|
|
||||||
private String taixi;
|
|
||||||
@SerializedName("taixi_nayin")
|
|
||||||
private String taixiNayin;
|
|
||||||
@SerializedName("minggong")
|
|
||||||
private String minggong;
|
|
||||||
@SerializedName("minggong_nayin")
|
|
||||||
private String minggongNayin;
|
|
||||||
@SerializedName("shengong")
|
|
||||||
private String shengong;
|
|
||||||
@SerializedName("shengong_nayin")
|
|
||||||
private String shengongNayin;
|
|
||||||
@SerializedName("shengxiao")
|
|
||||||
private String shengxiao;
|
|
||||||
@SerializedName("xingzuo")
|
|
||||||
private String xingzuo;
|
|
||||||
@SerializedName("siling")
|
|
||||||
private String siling;
|
|
||||||
@SerializedName("jiaoyun_mang")
|
|
||||||
private String jiaoyunMang;
|
|
||||||
@SerializedName("xingxiu")
|
|
||||||
private String xingxiu;
|
|
||||||
@SerializedName("minggua")
|
|
||||||
private MingguaDTO minggua;
|
|
||||||
@SerializedName("wuxing_wangdu")
|
|
||||||
private String wuxingWangdu;
|
|
||||||
@SerializedName("tiangan_liuyi")
|
|
||||||
private String tianganLiuyi;
|
|
||||||
@SerializedName("dizhi_liuyi")
|
|
||||||
private String dizhiLiuyi;
|
|
||||||
@SerializedName("zhengge")
|
|
||||||
private String zhengge;
|
|
||||||
@SerializedName("xiyongshen")
|
|
||||||
private XiyongshenDTO xiyongshen;
|
|
||||||
@SerializedName("wuxing_xiji")
|
|
||||||
private String wuxingXiji;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class MingguaDTO implements Serializable {
|
|
||||||
@SerializedName("minggua_name")
|
|
||||||
private String mingguaName;
|
|
||||||
@SerializedName("minggua_fangwei")
|
|
||||||
private String mingguaFangwei;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class XiyongshenDTO implements Serializable {
|
|
||||||
@SerializedName("qiangruo")
|
|
||||||
private String qiangruo;
|
|
||||||
@SerializedName("xiyongshen")
|
|
||||||
private String xiyongshen;
|
|
||||||
@SerializedName("jishen")
|
|
||||||
private String jishen;
|
|
||||||
@SerializedName("xiyongshen_desc")
|
|
||||||
private String xiyongshenDesc;
|
|
||||||
@SerializedName("jin_number")
|
|
||||||
private Integer jinNumber;
|
|
||||||
@SerializedName("mu_number")
|
|
||||||
private Integer muNumber;
|
|
||||||
@SerializedName("shui_number")
|
|
||||||
private Integer shuiNumber;
|
|
||||||
@SerializedName("huo_number")
|
|
||||||
private Integer huoNumber;
|
|
||||||
@SerializedName("tu_number")
|
|
||||||
private Integer tuNumber;
|
|
||||||
@SerializedName("zidang")
|
|
||||||
private Integer zidang;
|
|
||||||
@SerializedName("yidang")
|
|
||||||
private Integer yidang;
|
|
||||||
@SerializedName("zidang_percent")
|
|
||||||
private String zidangPercent;
|
|
||||||
@SerializedName("yidang_percent")
|
|
||||||
private String yidangPercent;
|
|
||||||
@SerializedName("tonglei")
|
|
||||||
private String tonglei;
|
|
||||||
@SerializedName("yilei")
|
|
||||||
private String yilei;
|
|
||||||
@SerializedName("rizhu_tiangan")
|
|
||||||
private String rizhuTiangan;
|
|
||||||
@SerializedName("jin_score")
|
|
||||||
private Integer jinScore;
|
|
||||||
@SerializedName("mu_score")
|
|
||||||
private Integer muScore;
|
|
||||||
@SerializedName("shui_score")
|
|
||||||
private Integer shuiScore;
|
|
||||||
@SerializedName("huo_score")
|
|
||||||
private Integer huoScore;
|
|
||||||
@SerializedName("tu_score")
|
|
||||||
private Integer tuScore;
|
|
||||||
@SerializedName("jin_score_percent")
|
|
||||||
private String jinScorePercent;
|
|
||||||
@SerializedName("mu_score_percent")
|
|
||||||
private String muScorePercent;
|
|
||||||
@SerializedName("shui_score_percent")
|
|
||||||
private String shuiScorePercent;
|
|
||||||
@SerializedName("huo_score_percent")
|
|
||||||
private String huoScorePercent;
|
|
||||||
@SerializedName("tu_score_percent")
|
|
||||||
private String tuScorePercent;
|
|
||||||
@SerializedName("yinyang")
|
|
||||||
private String yinyang;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class DetailInfoDTO implements Serializable {
|
|
||||||
@SerializedName("dayun_info")
|
|
||||||
private List<DayunInfoDTO> dayunInfo;
|
|
||||||
@SerializedName("dayun_born_info")
|
|
||||||
private DayunInfoDTO dayunBornInfo;
|
|
||||||
@SerializedName("sizhu_info")
|
|
||||||
private SizhuInfoDTO sizhuInfo;
|
|
||||||
@SerializedName("taishen_info")
|
|
||||||
private TaishenInfoDTO taishenInfo;
|
|
||||||
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class SizhuInfoDTO implements Serializable {
|
|
||||||
@SerializedName("year")
|
|
||||||
private YearDTO year;
|
|
||||||
@SerializedName("month")
|
|
||||||
private MonthDTO month;
|
|
||||||
@SerializedName("day")
|
|
||||||
private DayDTO day;
|
|
||||||
@SerializedName("hour")
|
|
||||||
private HourDTO hour;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class YearDTO implements Serializable {
|
|
||||||
@SerializedName("tg_god")
|
|
||||||
private String tgGod;
|
|
||||||
@SerializedName("tg")
|
|
||||||
private String tg;
|
|
||||||
@SerializedName("dz")
|
|
||||||
private String dz;
|
|
||||||
@SerializedName("cg")
|
|
||||||
private List<String> cg;
|
|
||||||
@SerializedName("dz_god")
|
|
||||||
private List<String> dzGod;
|
|
||||||
@SerializedName("dz_star_cs")
|
|
||||||
private String dzStarCs;
|
|
||||||
@SerializedName("dz_self_cs")
|
|
||||||
private String dzSelfCs;
|
|
||||||
@SerializedName("kw")
|
|
||||||
private String kw;
|
|
||||||
@SerializedName("ny")
|
|
||||||
private String ny;
|
|
||||||
@SerializedName("wx")
|
|
||||||
private String wx;
|
|
||||||
@SerializedName("xun")
|
|
||||||
private String xun;
|
|
||||||
@SerializedName("shensha")
|
|
||||||
private String shensha;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class MonthDTO implements Serializable {
|
|
||||||
@SerializedName("tg_god")
|
|
||||||
private String tgGod;
|
|
||||||
@SerializedName("tg")
|
|
||||||
private String tg;
|
|
||||||
@SerializedName("dz")
|
|
||||||
private String dz;
|
|
||||||
@SerializedName("cg")
|
|
||||||
private List<String> cg;
|
|
||||||
@SerializedName("dz_god")
|
|
||||||
private List<String> dzGod;
|
|
||||||
@SerializedName("dz_star_cs")
|
|
||||||
private String dzStarCs;
|
|
||||||
@SerializedName("dz_self_cs")
|
|
||||||
private String dzSelfCs;
|
|
||||||
@SerializedName("kw")
|
|
||||||
private String kw;
|
|
||||||
@SerializedName("ny")
|
|
||||||
private String ny;
|
|
||||||
@SerializedName("wx")
|
|
||||||
private String wx;
|
|
||||||
@SerializedName("xun")
|
|
||||||
private String xun;
|
|
||||||
@SerializedName("shensha")
|
|
||||||
private String shensha;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class DayDTO implements Serializable {
|
|
||||||
@SerializedName("tg_god")
|
|
||||||
private String tgGod;
|
|
||||||
@SerializedName("tg")
|
|
||||||
private String tg;
|
|
||||||
@SerializedName("dz")
|
|
||||||
private String dz;
|
|
||||||
@SerializedName("cg")
|
|
||||||
private List<String> cg;
|
|
||||||
@SerializedName("dz_god")
|
|
||||||
private List<String> dzGod;
|
|
||||||
@SerializedName("dz_star_cs")
|
|
||||||
private String dzStarCs;
|
|
||||||
@SerializedName("dz_self_cs")
|
|
||||||
private String dzSelfCs;
|
|
||||||
@SerializedName("kw")
|
|
||||||
private String kw;
|
|
||||||
@SerializedName("ny")
|
|
||||||
private String ny;
|
|
||||||
@SerializedName("wx")
|
|
||||||
private String wx;
|
|
||||||
@SerializedName("xun")
|
|
||||||
private String xun;
|
|
||||||
@SerializedName("shensha")
|
|
||||||
private String shensha;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class HourDTO implements Serializable {
|
|
||||||
@SerializedName("tg_god")
|
|
||||||
private String tgGod;
|
|
||||||
@SerializedName("tg")
|
|
||||||
private String tg;
|
|
||||||
@SerializedName("dz")
|
|
||||||
private String dz;
|
|
||||||
@SerializedName("cg")
|
|
||||||
private List<String> cg;
|
|
||||||
@SerializedName("dz_god")
|
|
||||||
private List<String> dzGod;
|
|
||||||
@SerializedName("dz_star_cs")
|
|
||||||
private String dzStarCs;
|
|
||||||
@SerializedName("dz_self_cs")
|
|
||||||
private String dzSelfCs;
|
|
||||||
@SerializedName("kw")
|
|
||||||
private String kw;
|
|
||||||
@SerializedName("ny")
|
|
||||||
private String ny;
|
|
||||||
@SerializedName("wx")
|
|
||||||
private String wx;
|
|
||||||
@SerializedName("xun")
|
|
||||||
private String xun;
|
|
||||||
@SerializedName("shensha")
|
|
||||||
private String shensha;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class TaishenInfoDTO implements Serializable {
|
|
||||||
@SerializedName("taiyuan")
|
|
||||||
private TaiyuanDTO taiyuan;
|
|
||||||
@SerializedName("taixi")
|
|
||||||
private TaixiDTO taixi;
|
|
||||||
@SerializedName("minggong")
|
|
||||||
private MinggongDTO minggong;
|
|
||||||
@SerializedName("shengong")
|
|
||||||
private ShengongDTO shengong;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class TaiyuanDTO implements Serializable {
|
|
||||||
@SerializedName("ganzhi")
|
|
||||||
private String ganzhi;
|
|
||||||
@SerializedName("xun")
|
|
||||||
private String xun;
|
|
||||||
@SerializedName("kongwang")
|
|
||||||
private String kongwang;
|
|
||||||
@SerializedName("changsheng")
|
|
||||||
private String changsheng;
|
|
||||||
@SerializedName("gan")
|
|
||||||
private String gan;
|
|
||||||
@SerializedName("zhi")
|
|
||||||
private String zhi;
|
|
||||||
@SerializedName("dz_cg")
|
|
||||||
private List<String> dzCg;
|
|
||||||
@SerializedName("tg_god")
|
|
||||||
private String tgGod;
|
|
||||||
@SerializedName("dz_god")
|
|
||||||
private List<String> dzGod;
|
|
||||||
@SerializedName("dz_star_cs")
|
|
||||||
private String dzStarCs;
|
|
||||||
@SerializedName("dz_self_cs")
|
|
||||||
private String dzSelfCs;
|
|
||||||
@SerializedName("nayin")
|
|
||||||
private String nayin;
|
|
||||||
@SerializedName("wuxing")
|
|
||||||
private String wuxing;
|
|
||||||
@SerializedName("tg_liuyi")
|
|
||||||
private String tgLiuyi;
|
|
||||||
@SerializedName("dz_liuyi")
|
|
||||||
private String dzLiuyi;
|
|
||||||
@SerializedName("shensha")
|
|
||||||
private String shensha;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class TaixiDTO implements Serializable {
|
|
||||||
@SerializedName("ganzhi")
|
|
||||||
private String ganzhi;
|
|
||||||
@SerializedName("xun")
|
|
||||||
private String xun;
|
|
||||||
@SerializedName("kongwang")
|
|
||||||
private String kongwang;
|
|
||||||
@SerializedName("changsheng")
|
|
||||||
private String changsheng;
|
|
||||||
@SerializedName("gan")
|
|
||||||
private String gan;
|
|
||||||
@SerializedName("zhi")
|
|
||||||
private String zhi;
|
|
||||||
@SerializedName("dz_cg")
|
|
||||||
private List<String> dzCg;
|
|
||||||
@SerializedName("tg_god")
|
|
||||||
private String tgGod;
|
|
||||||
@SerializedName("dz_god")
|
|
||||||
private List<String> dzGod;
|
|
||||||
@SerializedName("dz_star_cs")
|
|
||||||
private String dzStarCs;
|
|
||||||
@SerializedName("dz_self_cs")
|
|
||||||
private String dzSelfCs;
|
|
||||||
@SerializedName("nayin")
|
|
||||||
private String nayin;
|
|
||||||
@SerializedName("wuxing")
|
|
||||||
private String wuxing;
|
|
||||||
@SerializedName("tg_liuyi")
|
|
||||||
private String tgLiuyi;
|
|
||||||
@SerializedName("dz_liuyi")
|
|
||||||
private String dzLiuyi;
|
|
||||||
@SerializedName("shensha")
|
|
||||||
private String shensha;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class MinggongDTO implements Serializable {
|
|
||||||
@SerializedName("ganzhi")
|
|
||||||
private String ganzhi;
|
|
||||||
@SerializedName("xun")
|
|
||||||
private String xun;
|
|
||||||
@SerializedName("kongwang")
|
|
||||||
private String kongwang;
|
|
||||||
@SerializedName("changsheng")
|
|
||||||
private String changsheng;
|
|
||||||
@SerializedName("gan")
|
|
||||||
private String gan;
|
|
||||||
@SerializedName("zhi")
|
|
||||||
private String zhi;
|
|
||||||
@SerializedName("dz_cg")
|
|
||||||
private List<String> dzCg;
|
|
||||||
@SerializedName("tg_god")
|
|
||||||
private String tgGod;
|
|
||||||
@SerializedName("dz_god")
|
|
||||||
private List<String> dzGod;
|
|
||||||
@SerializedName("dz_star_cs")
|
|
||||||
private String dzStarCs;
|
|
||||||
@SerializedName("dz_self_cs")
|
|
||||||
private String dzSelfCs;
|
|
||||||
@SerializedName("nayin")
|
|
||||||
private String nayin;
|
|
||||||
@SerializedName("wuxing")
|
|
||||||
private String wuxing;
|
|
||||||
@SerializedName("tg_liuyi")
|
|
||||||
private String tgLiuyi;
|
|
||||||
@SerializedName("dz_liuyi")
|
|
||||||
private String dzLiuyi;
|
|
||||||
@SerializedName("shensha")
|
|
||||||
private String shensha;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class ShengongDTO implements Serializable {
|
|
||||||
@SerializedName("ganzhi")
|
|
||||||
private String ganzhi;
|
|
||||||
@SerializedName("xun")
|
|
||||||
private String xun;
|
|
||||||
@SerializedName("kongwang")
|
|
||||||
private String kongwang;
|
|
||||||
@SerializedName("changsheng")
|
|
||||||
private String changsheng;
|
|
||||||
@SerializedName("gan")
|
|
||||||
private String gan;
|
|
||||||
@SerializedName("zhi")
|
|
||||||
private String zhi;
|
|
||||||
@SerializedName("dz_cg")
|
|
||||||
private List<String> dzCg;
|
|
||||||
@SerializedName("tg_god")
|
|
||||||
private String tgGod;
|
|
||||||
@SerializedName("dz_god")
|
|
||||||
private List<String> dzGod;
|
|
||||||
@SerializedName("dz_star_cs")
|
|
||||||
private String dzStarCs;
|
|
||||||
@SerializedName("dz_self_cs")
|
|
||||||
private String dzSelfCs;
|
|
||||||
@SerializedName("nayin")
|
|
||||||
private String nayin;
|
|
||||||
@SerializedName("wuxing")
|
|
||||||
private String wuxing;
|
|
||||||
@SerializedName("tg_liuyi")
|
|
||||||
private String tgLiuyi;
|
|
||||||
@SerializedName("dz_liuyi")
|
|
||||||
private String dzLiuyi;
|
|
||||||
@SerializedName("shensha")
|
|
||||||
private String shensha;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class DayunInfoDTO implements Serializable {
|
|
||||||
@SerializedName("dayun_is_tongxian")
|
|
||||||
private boolean isTongXian = false;
|
|
||||||
@SerializedName("dayun_tongxian")
|
|
||||||
private String dayunTongxian;
|
|
||||||
@SerializedName("dayun_index")
|
|
||||||
private Integer dayunIndex;
|
|
||||||
@SerializedName("dayun_start_year")
|
|
||||||
private Integer dayunStartYear;
|
|
||||||
@SerializedName("dayun_start_age")
|
|
||||||
private Integer dayunStartAge;
|
|
||||||
@SerializedName("dayun_end_year")
|
|
||||||
private Integer dayunEndYear;
|
|
||||||
@SerializedName("dayun_end_age")
|
|
||||||
private Integer dayunEndAge;
|
|
||||||
@SerializedName("dayun_start_ganzhi")
|
|
||||||
private String dayunStartGanzhi;
|
|
||||||
@SerializedName("dayun_xun")
|
|
||||||
private String dayunXun;
|
|
||||||
@SerializedName("dayun_kongwang")
|
|
||||||
private String dayunKongwang;
|
|
||||||
@SerializedName("dayun_shishen")
|
|
||||||
private String dayunShishen;
|
|
||||||
@SerializedName("dayun_changsheng")
|
|
||||||
private String dayunChangsheng;
|
|
||||||
@SerializedName("dayun_year_tg")
|
|
||||||
private String dayunYearTg;
|
|
||||||
@SerializedName("dayun_year_dz")
|
|
||||||
private String dayunYearDz;
|
|
||||||
@SerializedName("dayun_year_cg")
|
|
||||||
private List<String> dayunYearCg;
|
|
||||||
@SerializedName("dayun_year_tg_god")
|
|
||||||
private String dayunYearTgGod;
|
|
||||||
@SerializedName("dayun_year_dz_god")
|
|
||||||
private List<String> dayunYearDzGod;
|
|
||||||
@SerializedName("dayun_dz_star_cs")
|
|
||||||
private String dayunDzStarCs;
|
|
||||||
@SerializedName("dayun_dz_self_cs")
|
|
||||||
private String dayunDzSelfCs;
|
|
||||||
@SerializedName("dayun_nayin")
|
|
||||||
private String dayunNayin;
|
|
||||||
@SerializedName("dayun_wuxing")
|
|
||||||
private String dayunWuxing;
|
|
||||||
@SerializedName("dayun_tg_liuyi")
|
|
||||||
private String dayunTgLiuyi;
|
|
||||||
@SerializedName("dayun_dz_liuyi")
|
|
||||||
private String dayunDzLiuyi;
|
|
||||||
@SerializedName("liunian_info")
|
|
||||||
private List<LiunianInfoDTO> liunianInfo;
|
|
||||||
@SerializedName("xiaoyun_info")
|
|
||||||
private List<XiaoyunInfoDTO> xiaoyunInfo;
|
|
||||||
@SerializedName("dayun_shensha")
|
|
||||||
private String dayunShensha;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class LiunianInfoDTO implements Serializable {
|
|
||||||
@SerializedName("liunian_index")
|
|
||||||
private Integer liunianIndex;
|
|
||||||
@SerializedName("liunian_year")
|
|
||||||
private Integer liunianYear;
|
|
||||||
@SerializedName("liunian_age")
|
|
||||||
private Integer liunianAge;
|
|
||||||
@SerializedName("liunian_ganzhi")
|
|
||||||
private String liunianGanzhi;
|
|
||||||
@SerializedName("liunian_xun")
|
|
||||||
private String liunianXun;
|
|
||||||
@SerializedName("liunian_kongwang")
|
|
||||||
private String liunianKongwang;
|
|
||||||
@SerializedName("liunian_shishen")
|
|
||||||
private String liunianShishen;
|
|
||||||
@SerializedName("liunian_changsheng")
|
|
||||||
private String liunianChangsheng;
|
|
||||||
@SerializedName("liunian_jieqi")
|
|
||||||
private List<LiunianJieqiDTO> liunianJieqi;
|
|
||||||
@SerializedName("liunian_year_tg")
|
|
||||||
private String liunianYearTg;
|
|
||||||
@SerializedName("liunian_year_dz")
|
|
||||||
private String liunianYearDz;
|
|
||||||
@SerializedName("liunian_year_cg")
|
|
||||||
private List<String> liunianYearCg;
|
|
||||||
@SerializedName("liunian_tg_god")
|
|
||||||
private String liunianTgGod;
|
|
||||||
@SerializedName("liunian_dz_god")
|
|
||||||
private List<String> liunianDzGod;
|
|
||||||
@SerializedName("liunian_dz_star_cs")
|
|
||||||
private String liunianDzStarCs;
|
|
||||||
@SerializedName("liunian_dz_self_cs")
|
|
||||||
private String liunianDzSelfCs;
|
|
||||||
@SerializedName("liunian_nayin")
|
|
||||||
private String liunianNayin;
|
|
||||||
@SerializedName("liunian_wuxing")
|
|
||||||
private String liunianWuxing;
|
|
||||||
@SerializedName("liunian_tg_liuyi")
|
|
||||||
private String liunianTgLiuyi;
|
|
||||||
@SerializedName("liunian_dz_liuyi")
|
|
||||||
private String liunianDzLiuyi;
|
|
||||||
@SerializedName("liunian_shensha")
|
|
||||||
private String liunianShensha;
|
|
||||||
@SerializedName("liuyue_info")
|
|
||||||
private List<LiuyueInfoDTO> liuyueInfo;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class LiunianJieqiDTO implements Serializable {
|
|
||||||
@SerializedName("jieqi_name")
|
|
||||||
private String jieqiName;
|
|
||||||
@SerializedName("jieqi_solar_ymdhms")
|
|
||||||
private String jieqiSolarYmdhms;
|
|
||||||
@SerializedName("jieqi_lunar_ymdhms_isleap")
|
|
||||||
private String jieqiLunarYmdhmsIsleap;
|
|
||||||
@SerializedName("jieqi_lunar_ymdhms")
|
|
||||||
private String jieqiLunarYmdhms;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class LiuyueInfoDTO implements Serializable {
|
|
||||||
@SerializedName("liuyue_index")
|
|
||||||
private Integer liuyueIndex;
|
|
||||||
@SerializedName("liuyue_month")
|
|
||||||
private String liuyueMonth;
|
|
||||||
@SerializedName("liuyue_ganzhi")
|
|
||||||
private String liuyueGanzhi;
|
|
||||||
@SerializedName("liuyue_xun")
|
|
||||||
private String liuyueXun;
|
|
||||||
@SerializedName("liuyue_kongwang")
|
|
||||||
private String liuyueKongwang;
|
|
||||||
@SerializedName("liuyue_shishen")
|
|
||||||
private String liuyueShishen;
|
|
||||||
@SerializedName("liuyue_changsheng")
|
|
||||||
private String liuyueChangsheng;
|
|
||||||
@SerializedName("liuyue_month_tg")
|
|
||||||
private String liuyueMonthTg;
|
|
||||||
@SerializedName("liuyue_month_dz")
|
|
||||||
private String liuyueMonthDz;
|
|
||||||
@SerializedName("liuyue_month_cg")
|
|
||||||
private List<String> liuyueMonthCg;
|
|
||||||
@SerializedName("liuyue_month_tg_god")
|
|
||||||
private String liuyueMonthTgGod;
|
|
||||||
@SerializedName("liuyue_month_dz_god")
|
|
||||||
private List<String> liuyueMonthDzGod;
|
|
||||||
@SerializedName("liuyue_dz_star_cs")
|
|
||||||
private String liuyueDzStarCs;
|
|
||||||
@SerializedName("liuyue_dz_self_cs")
|
|
||||||
private String liuyueDzSelfCs;
|
|
||||||
@SerializedName("liuyue_nayin")
|
|
||||||
private String liuyueNayin;
|
|
||||||
@SerializedName("liuyue_wuxing")
|
|
||||||
private String liuyueWuxing;
|
|
||||||
@SerializedName("liuyue_tg_liuyi")
|
|
||||||
private String liuyueTgLiuyi;
|
|
||||||
@SerializedName("liuyue_dz_liuyi")
|
|
||||||
private String liuyueDzLiuyi;
|
|
||||||
@SerializedName("liuyue_shensha")
|
|
||||||
private String liuyueShensha;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class XiaoyunInfoDTO implements Serializable {
|
|
||||||
@SerializedName("xiaoyun_index")
|
|
||||||
private Integer xiaoyunIndex;
|
|
||||||
@SerializedName("xiaoyun_year")
|
|
||||||
private Integer xiaoyunYear;
|
|
||||||
@SerializedName("xiaoyun_age")
|
|
||||||
private Integer xiaoyunAge;
|
|
||||||
@SerializedName("xiaoyun_ganzhi")
|
|
||||||
private String xiaoyunGanzhi;
|
|
||||||
@SerializedName("xiaoyun_xun")
|
|
||||||
private String xiaoyunXun;
|
|
||||||
@SerializedName("xiaoyun_kongwang")
|
|
||||||
private String xiaoyunKongwang;
|
|
||||||
@SerializedName("xiaoyun_shishen")
|
|
||||||
private String xiaoyunShishen;
|
|
||||||
@SerializedName("xiaoyun_changsheng")
|
|
||||||
private String xiaoyunChangsheng;
|
|
||||||
@SerializedName("xiaoyun_year_tg")
|
|
||||||
private String xiaoyunYearTg;
|
|
||||||
@SerializedName("xiaoyun_year_dz")
|
|
||||||
private String xiaoyunYearDz;
|
|
||||||
@SerializedName("xiaoyun_year_cg")
|
|
||||||
private List<String> xiaoyunYearCg;
|
|
||||||
@SerializedName("xiaoyun_tg_god")
|
|
||||||
private String xiaoyunTgGod;
|
|
||||||
@SerializedName("xiaoyun_dz_god")
|
|
||||||
private List<String> xiaoyunDzGod;
|
|
||||||
@SerializedName("xiaoyun_dz_star_cs")
|
|
||||||
private String xiaoyunDzStarCs;
|
|
||||||
@SerializedName("xiaoyun_dz_self_cs")
|
|
||||||
private String xiaoyunDzSelfCs;
|
|
||||||
@SerializedName("xiaoyun_nayin")
|
|
||||||
private String xiaoyunNayin;
|
|
||||||
@SerializedName("xiaoyun_wuxing")
|
|
||||||
private String xiaoyunWuxing;
|
|
||||||
@SerializedName("xiaoyun_tg_liuyi")
|
|
||||||
private String xiaoyunTgLiuyi;
|
|
||||||
@SerializedName("xiaoyun_dz_liuyi")
|
|
||||||
private String xiaoyunDzLiuyi;
|
|
||||||
@SerializedName("xiaoyun_shensha")
|
|
||||||
private String xiaoyunShensha;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
package com.ckkj.water.plate.entity;
|
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fengxiaoyang
|
|
||||||
* @date 2025/8/11
|
|
||||||
* @description TODO: 描述该类的作用
|
|
||||||
*/
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public class BaziSaveSuccessEntity implements Serializable {
|
|
||||||
|
|
||||||
@SerializedName("recordId")
|
|
||||||
private String recordId;
|
|
||||||
@SerializedName("savedData")
|
|
||||||
private SavedDataDTO savedData;
|
|
||||||
@SerializedName("message")
|
|
||||||
private String message;
|
|
||||||
@SerializedName("saveTime")
|
|
||||||
private String saveTime;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class SavedDataDTO {
|
|
||||||
@SerializedName("recordId")
|
|
||||||
private String recordId;
|
|
||||||
@SerializedName("birthPlace")
|
|
||||||
private String birthPlace;
|
|
||||||
@SerializedName("gender")
|
|
||||||
private String gender;
|
|
||||||
@SerializedName("yinLiBirthTime")
|
|
||||||
private String yinLiBirthTime;
|
|
||||||
@SerializedName("siZhu")
|
|
||||||
private SiZhuDTO siZhu;
|
|
||||||
@SerializedName("name")
|
|
||||||
private String name;
|
|
||||||
@SerializedName("yangLiBirthTime")
|
|
||||||
private String yangLiBirthTime;
|
|
||||||
@SerializedName("openSolarTime")
|
|
||||||
private String openSolarTime;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class SiZhuDTO {
|
|
||||||
@SerializedName("yueZhu")
|
|
||||||
private String yueZhu;
|
|
||||||
@SerializedName("shiZhu")
|
|
||||||
private String shiZhu;
|
|
||||||
@SerializedName("riZhu")
|
|
||||||
private String riZhu;
|
|
||||||
@SerializedName("nianZhu")
|
|
||||||
private String nianZhu;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
package com.ckkj.water.plate.entity;
|
|
||||||
|
|
||||||
public class PaipanCache {
|
|
||||||
private static BaziResultBean cachedResult;
|
|
||||||
|
|
||||||
public static void set(BaziResultBean result) {
|
|
||||||
cachedResult = result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static BaziResultBean get() {
|
|
||||||
return cachedResult;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void clear() {
|
|
||||||
cachedResult = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,76 +0,0 @@
|
|||||||
package com.ckkj.water.plate.entity;
|
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
import lombok.NoArgsConstructor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fengxiaoyang
|
|
||||||
* @date 2025/8/9
|
|
||||||
* @description TODO: 描述该类的作用
|
|
||||||
*/
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public class PaipanHistoryEntity implements Serializable {
|
|
||||||
|
|
||||||
@SerializedName("total")
|
|
||||||
private Integer total;
|
|
||||||
@SerializedName("pages")
|
|
||||||
private Integer pages;
|
|
||||||
@SerializedName("records")
|
|
||||||
private List<RecordsDTO> records;
|
|
||||||
@SerializedName("hasNextPage")
|
|
||||||
private Boolean hasNextPage;
|
|
||||||
@SerializedName("pageSize")
|
|
||||||
private Integer pageSize;
|
|
||||||
@SerializedName("hasPreviousPage")
|
|
||||||
private Boolean hasPreviousPage;
|
|
||||||
@SerializedName("userId")
|
|
||||||
private Long userId;
|
|
||||||
@SerializedName("pageNum")
|
|
||||||
private Integer pageNum;
|
|
||||||
|
|
||||||
@NoArgsConstructor
|
|
||||||
@Data
|
|
||||||
public static class RecordsDTO implements Serializable{
|
|
||||||
@SerializedName("id")
|
|
||||||
private String id;
|
|
||||||
@SerializedName("userId")
|
|
||||||
private Long userId;
|
|
||||||
@SerializedName("name")
|
|
||||||
private String name;
|
|
||||||
@SerializedName("gender")
|
|
||||||
private String gender;
|
|
||||||
@SerializedName("birthType")
|
|
||||||
private String birthType;
|
|
||||||
@SerializedName("yangLiBirthTime")
|
|
||||||
private String yangLiBirthTime;
|
|
||||||
@SerializedName("yinLiBirthTime")
|
|
||||||
private String yinLiBirthTime;
|
|
||||||
@SerializedName("birthPlace")
|
|
||||||
private String birthPlace;
|
|
||||||
@SerializedName("openSolarTime")
|
|
||||||
private String openSolarTime;
|
|
||||||
@SerializedName("nianZhu")
|
|
||||||
private String nianZhu;
|
|
||||||
@SerializedName("yueZhu")
|
|
||||||
private String yueZhu;
|
|
||||||
@SerializedName("riZhu")
|
|
||||||
private String riZhu;
|
|
||||||
@SerializedName("shiZhu")
|
|
||||||
private String shiZhu;
|
|
||||||
@SerializedName("apiStatus")
|
|
||||||
private Integer apiStatus;
|
|
||||||
@SerializedName("apiMessage")
|
|
||||||
private String apiMessage;
|
|
||||||
@SerializedName("requestIp")
|
|
||||||
private String requestIp;
|
|
||||||
@SerializedName("remark")
|
|
||||||
private Object remark;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,63 +0,0 @@
|
|||||||
package com.ckkj.water.plate.mvp;
|
|
||||||
|
|
||||||
import com.ckkj.water.base.IView;
|
|
||||||
import com.ckkj.water.network.BaseBean;
|
|
||||||
import com.ckkj.water.plate.entity.BaziResultBean;
|
|
||||||
import com.ckkj.water.plate.entity.BaziSaveSuccessEntity;
|
|
||||||
import com.ckkj.water.plate.entity.PaipanHistoryEntity;
|
|
||||||
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fengxiaoyang
|
|
||||||
* @date 2025/7/30
|
|
||||||
* @description TODO: 描述该类的作用
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class PlateContract {
|
|
||||||
public interface CallBack<T> {
|
|
||||||
void success(T msg);
|
|
||||||
void fail(String msg);
|
|
||||||
}
|
|
||||||
public interface DataModel{
|
|
||||||
//保存八字排盘结果
|
|
||||||
void saveUserBirthInfo(JSONObject json, CallBack callBack);
|
|
||||||
//开始排盘
|
|
||||||
void startPaiPanByYfjApi(Map<String,Object> map , CallBack callBack);
|
|
||||||
//获取排盘结果
|
|
||||||
void getPaipanHistoryList(Map<String,Object> map, CallBack callBack);
|
|
||||||
//删除记录
|
|
||||||
void deleteRecordByID(Map<String,Object> map, CallBack callBack);
|
|
||||||
//根据八字排盘结果,ai 解析
|
|
||||||
void aiParseBaziResult(JSONObject json, CallBack callBack);
|
|
||||||
//发送消息给 AI
|
|
||||||
void sendMsgToAi(JSONObject json, AiStreamCallback callBack);
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface AiStreamCallback {
|
|
||||||
void onMessage(String messageChunk); // 每次返回一段内容
|
|
||||||
void onError(String error);
|
|
||||||
void onComplete(String complateContent); // 结束
|
|
||||||
void onSessionReceived(String sessionId); // 新增:接收sessionId
|
|
||||||
void loginLost();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface PlateView extends IView {
|
|
||||||
//排盘成功
|
|
||||||
void getPaipanResult(BaziResultBean bean);
|
|
||||||
//保存八字成功
|
|
||||||
void saveBaziResultSuccess(BaziSaveSuccessEntity bean);
|
|
||||||
//历史记录
|
|
||||||
void getHistorySuccess(PaipanHistoryEntity entity);
|
|
||||||
//删除成功
|
|
||||||
void deletePaipanHistorySuccess(int pos);
|
|
||||||
// 新增流式回调方法
|
|
||||||
void onStreamMessageReceived(String messageChunk);
|
|
||||||
//完成
|
|
||||||
void onStreamComplete(String complateMsg);
|
|
||||||
//提交举报完成
|
|
||||||
void commitReportSuccess(BaseBean bean);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,424 +0,0 @@
|
|||||||
package com.ckkj.water.plate.mvp;
|
|
||||||
|
|
||||||
import static android.content.ContentValues.TAG;
|
|
||||||
|
|
||||||
import android.os.Handler;
|
|
||||||
import android.os.Looper;
|
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import com.ckkj.water.AppConfig;
|
|
||||||
import com.ckkj.water.network.BaseBean;
|
|
||||||
import com.ckkj.water.network.BaseYfjApiBean;
|
|
||||||
import com.ckkj.water.network.NetWorkManager;
|
|
||||||
import com.ckkj.water.plate.entity.BaziResultBean;
|
|
||||||
import com.ckkj.water.plate.entity.BaziSaveSuccessEntity;
|
|
||||||
import com.ckkj.water.plate.entity.PaipanHistoryEntity;
|
|
||||||
|
|
||||||
import org.json.JSONObject;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import io.reactivex.Observer;
|
|
||||||
import io.reactivex.android.schedulers.AndroidSchedulers;
|
|
||||||
import io.reactivex.annotations.NonNull;
|
|
||||||
import io.reactivex.disposables.Disposable;
|
|
||||||
import io.reactivex.schedulers.Schedulers;
|
|
||||||
import okhttp3.Call;
|
|
||||||
import okhttp3.Callback;
|
|
||||||
import okhttp3.OkHttpClient;
|
|
||||||
import okhttp3.Request;
|
|
||||||
import okhttp3.Response;
|
|
||||||
import org.json.JSONException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author fengxiaoyang
|
|
||||||
* @date 2025/7/30
|
|
||||||
* @description TODO: 描述该类的作用
|
|
||||||
*/
|
|
||||||
|
|
||||||
public class PlateImpl implements PlateContract.DataModel{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 保存八字排盘记录
|
|
||||||
* @param json
|
|
||||||
* @param callBack
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void saveUserBirthInfo(JSONObject json, PlateContract.CallBack callBack) {
|
|
||||||
try {
|
|
||||||
NetWorkManager.getRequest().startPaipan(NetWorkManager.getToken(), NetWorkManager.toRequestBody(json))
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.unsubscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(new Observer<BaseBean<BaziSaveSuccessEntity>>() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(@NonNull BaseBean<BaziSaveSuccessEntity> bean) {
|
|
||||||
if (bean.getCode() == 200) {
|
|
||||||
callBack.success(bean.getData());
|
|
||||||
} else {
|
|
||||||
callBack.fail(bean.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(@NonNull Throwable e) {
|
|
||||||
callBack.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排盘数据,调用三方 api
|
|
||||||
* @param map
|
|
||||||
* @param callBack
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void startPaiPanByYfjApi(Map<String, Object> map, PlateContract.CallBack callBack) {
|
|
||||||
try {
|
|
||||||
// 使用getNoBaseUrlRequest()调用第三方API,因为API URL是完整的
|
|
||||||
NetWorkManager.getNoBaseUrlRequest().startPaipanByYfj(NetWorkManager.getToken(), map)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.unsubscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(new Observer<BaseYfjApiBean<BaziResultBean>>() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(@NonNull BaseYfjApiBean<BaziResultBean> bean) {
|
|
||||||
if (bean.getErrcode() == 0) {
|
|
||||||
// 成功返回数据
|
|
||||||
callBack.success(bean.getData());
|
|
||||||
} else {
|
|
||||||
// API返回错误
|
|
||||||
callBack.fail(bean.getErrmsg());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(@NonNull Throwable e) {
|
|
||||||
callBack.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
callBack.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 排盘历史记录
|
|
||||||
* @param map
|
|
||||||
* @param callBack
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void getPaipanHistoryList(Map<String, Object> map, PlateContract.CallBack callBack) {
|
|
||||||
try {
|
|
||||||
NetWorkManager.getRequest().getPaipanHistoryList(NetWorkManager.getToken())
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.unsubscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(new Observer<BaseBean<PaipanHistoryEntity>>() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(@NonNull BaseBean<PaipanHistoryEntity> bean) {
|
|
||||||
if(bean.getCode() == 200){
|
|
||||||
callBack.success(bean.getData());
|
|
||||||
}else{
|
|
||||||
callBack.fail(bean.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(@NonNull Throwable e) {
|
|
||||||
callBack.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 删除记录
|
|
||||||
* @param map
|
|
||||||
* @param callBack
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void deleteRecordByID(Map<String, Object> map, PlateContract.CallBack callBack) {
|
|
||||||
try {
|
|
||||||
NetWorkManager.getRequest().deletePaipanRecordById(NetWorkManager.getToken(),map)
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.unsubscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(new Observer<BaseBean>() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(@NonNull BaseBean bean) {
|
|
||||||
if(bean.getCode() == 200){
|
|
||||||
callBack.success(bean);
|
|
||||||
}else{
|
|
||||||
callBack.fail(bean.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(@NonNull Throwable e) {
|
|
||||||
callBack.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 八字排盘结果,AI 解析
|
|
||||||
* @param json
|
|
||||||
* @param callBack
|
|
||||||
*/
|
|
||||||
@Override
|
|
||||||
public void aiParseBaziResult(JSONObject json, PlateContract.CallBack callBack) {
|
|
||||||
try {
|
|
||||||
NetWorkManager.getRequest().aiParesBaziResult(NetWorkManager.getToken(), NetWorkManager.toRequestBody(json))
|
|
||||||
.subscribeOn(Schedulers.io())
|
|
||||||
.unsubscribeOn(Schedulers.io())
|
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
|
||||||
.subscribe(new Observer<BaseBean>() {
|
|
||||||
@Override
|
|
||||||
public void onSubscribe(@NonNull Disposable d) {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onNext(@NonNull BaseBean bean) {
|
|
||||||
if (bean.getCode() == 200) {
|
|
||||||
callBack.success(bean.getData());
|
|
||||||
} else {
|
|
||||||
callBack.fail(bean.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onError(@NonNull Throwable e) {
|
|
||||||
callBack.fail(e.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onComplete() {
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* AI解盘
|
|
||||||
* @param json
|
|
||||||
* @param callBack
|
|
||||||
*/
|
|
||||||
private final OkHttpClient client = new OkHttpClient();
|
|
||||||
private Call currentCall = null; // 新增:保存当前请求的Call对象
|
|
||||||
private volatile boolean isRequestStopped = false; // 新增:标记是否已停止请求
|
|
||||||
@Override
|
|
||||||
public void sendMsgToAi(JSONObject json, PlateContract.AiStreamCallback callBack) {
|
|
||||||
try {
|
|
||||||
String finalUrl = AppConfig.BASE_URL + "mobile/paiPan/ai";
|
|
||||||
Log.d(TAG, "Request URL: " + finalUrl);
|
|
||||||
|
|
||||||
Request request = new Request.Builder()
|
|
||||||
.addHeader("Authorization", "Bearer " + AppConfig.USER_TOKEN)
|
|
||||||
.post(NetWorkManager.toRequestBody(json))
|
|
||||||
.url(finalUrl)
|
|
||||||
.build();
|
|
||||||
|
|
||||||
currentCall = client.newCall(request);
|
|
||||||
isRequestStopped = false;
|
|
||||||
|
|
||||||
currentCall.enqueue(new Callback() {
|
|
||||||
@Override
|
|
||||||
public void onFailure(Call call, IOException e) {
|
|
||||||
if (isRequestStopped) return; // 如果已停止,不处理失败回调
|
|
||||||
new Handler(Looper.getMainLooper()).post(() -> {
|
|
||||||
if (callBack != null) callBack.onError(e.getMessage());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onResponse(Call call, Response response) {
|
|
||||||
if (isRequestStopped) return;
|
|
||||||
|
|
||||||
if (!response.isSuccessful()) {
|
|
||||||
new Handler(Looper.getMainLooper()).post(() -> {
|
|
||||||
if (callBack != null) callBack.onError("请求失败: " + response.code());
|
|
||||||
});
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
InputStream inputStream = response.body().byteStream();
|
|
||||||
BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
|
|
||||||
|
|
||||||
try {
|
|
||||||
// 处理SSE流式数据
|
|
||||||
handleSSEStream(reader, callBack);
|
|
||||||
} catch (Exception e) {
|
|
||||||
new Handler(Looper.getMainLooper()).post(() -> {
|
|
||||||
if (callBack != null) callBack.onError("解析异常: " + e.getMessage());
|
|
||||||
});
|
|
||||||
} finally {
|
|
||||||
try {
|
|
||||||
reader.close();
|
|
||||||
response.close();
|
|
||||||
} catch (IOException ignored) {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (Exception e) {
|
|
||||||
new Handler(Looper.getMainLooper()).post(() -> {
|
|
||||||
if (callBack != null) callBack.onError("请求异常: " + e.getMessage());
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理SSE流式数据
|
|
||||||
*/
|
|
||||||
private void handleSSEStream(BufferedReader reader, PlateContract.AiStreamCallback callBack) throws IOException {
|
|
||||||
String line;
|
|
||||||
StringBuilder currentEvent = new StringBuilder();
|
|
||||||
String currentEventType = null;
|
|
||||||
|
|
||||||
while ((line = reader.readLine()) != null && !isRequestStopped) {
|
|
||||||
if (line.trim().isEmpty()) {
|
|
||||||
// 空行表示一个事件结束,处理当前事件
|
|
||||||
if (currentEventType != null && currentEvent.length() > 0) {
|
|
||||||
processEvent(currentEventType, currentEvent.toString(), callBack);
|
|
||||||
currentEvent.setLength(0);
|
|
||||||
currentEventType = null;
|
|
||||||
}
|
|
||||||
} else if (line.startsWith("event:")) {
|
|
||||||
// 事件类型
|
|
||||||
currentEventType = line.substring(6).trim();
|
|
||||||
} else if (line.startsWith("data:")) {
|
|
||||||
// 事件数据
|
|
||||||
String data = line.substring(5).trim();
|
|
||||||
currentEvent.append(data);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 处理最后一个事件
|
|
||||||
if (currentEventType != null && currentEvent.length() > 0) {
|
|
||||||
processEvent(currentEventType, currentEvent.toString(), callBack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 处理单个事件
|
|
||||||
*/
|
|
||||||
private void processEvent(String eventType, String data, PlateContract.AiStreamCallback callBack) {
|
|
||||||
new Handler(Looper.getMainLooper()).post(() -> {
|
|
||||||
try {
|
|
||||||
switch (eventType) {
|
|
||||||
case "start":
|
|
||||||
// 开始事件,可以在这里做一些初始化
|
|
||||||
Log.d(TAG, "AI解盘开始: " + data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "paiPanInfo":
|
|
||||||
// 排盘信息事件
|
|
||||||
Log.d(TAG, "排盘信息: " + data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "api-info":
|
|
||||||
// API信息事件
|
|
||||||
Log.d(TAG, "API信息: " + data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "chunk":
|
|
||||||
// 内容块事件,这是主要的文本内容
|
|
||||||
try {
|
|
||||||
JSONObject chunkData = new JSONObject(data);
|
|
||||||
String content = chunkData.optString("content", "");
|
|
||||||
boolean hasNewline = chunkData.optBoolean("hasNewline", false);
|
|
||||||
boolean isMarkdown = chunkData.optBoolean("isMarkdown", false);
|
|
||||||
|
|
||||||
// 发送内容块到回调
|
|
||||||
if (callBack != null && !content.isEmpty()) {
|
|
||||||
callBack.onMessage(content);
|
|
||||||
}
|
|
||||||
} catch (JSONException e) {
|
|
||||||
Log.e(TAG, "解析chunk数据失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "request-id":
|
|
||||||
// 请求ID事件
|
|
||||||
Log.d(TAG, "请求ID: " + data);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "complete":
|
|
||||||
// 完成事件
|
|
||||||
Log.d(TAG, "AI解盘完成: " + data);
|
|
||||||
if (callBack != null) {
|
|
||||||
callBack.onComplete(data);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
Log.d(TAG, "未知事件类型: " + eventType + ", 数据: " + data);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
Log.e(TAG, "处理事件失败: " + e.getMessage());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 停止当前请求
|
|
||||||
*/
|
|
||||||
public void stopCurrentRequest() {
|
|
||||||
isRequestStopped = true;
|
|
||||||
if (currentCall != null && !currentCall.isCanceled()) {
|
|
||||||
currentCall.cancel();
|
|
||||||
currentCall = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,225 +0,0 @@
|
|||||||
//package com.ckkj.water.plate.mvp;
|
|
||||||
//
|
|
||||||
//import com.ckkj.water.base.BasePresenter;
|
|
||||||
//import com.ckkj.water.network.BaseBean;
|
|
||||||
//import com.ckkj.water.plate.entity.BaziResultBean;
|
|
||||||
//import com.ckkj.water.plate.entity.BaziSaveSuccessEntity;
|
|
||||||
//import com.ckkj.water.plate.entity.PaipanHistoryEntity;
|
|
||||||
//
|
|
||||||
//import org.json.JSONException;
|
|
||||||
//import org.json.JSONObject;
|
|
||||||
//
|
|
||||||
//import java.util.HashMap;
|
|
||||||
//import java.util.Map;
|
|
||||||
//
|
|
||||||
///**
|
|
||||||
// * @author fengxiaoyang
|
|
||||||
// * @date 2025/7/30
|
|
||||||
// * @description TODO: 描述该类的作用
|
|
||||||
// */
|
|
||||||
//
|
|
||||||
//public class PlatePresenter extends BasePresenter<PlateContract.PlateView> {
|
|
||||||
// private PlateImpl impl;
|
|
||||||
//
|
|
||||||
// public PlatePresenter(PlateImpl impl) {
|
|
||||||
// this.impl = impl;
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 排盘,直接调用缘份居 Api
|
|
||||||
// * @param map
|
|
||||||
// */
|
|
||||||
// public void startPaiPan(Map<String, Object> map) {
|
|
||||||
// impl.startPaiPanByYfjApi(map, new PlateContract.CallBack<BaziResultBean>() {
|
|
||||||
// @Override
|
|
||||||
// public void success(BaziResultBean entity) {
|
|
||||||
// if(PlatePresenter.this.getView() != null){
|
|
||||||
// if(PlatePresenter.this.getView() != null){
|
|
||||||
// PlatePresenter.this.getView().getPaipanResult(entity);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void fail(String msg) {
|
|
||||||
// if(PlatePresenter.this.getView() != null){
|
|
||||||
// PlatePresenter.this.getView().showError(msg);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 上传八字结果
|
|
||||||
// *
|
|
||||||
// * @param result
|
|
||||||
// * @param cityData
|
|
||||||
// * @param timeType
|
|
||||||
// */
|
|
||||||
// public void uploadBaziResult(BaziResultBean result, CityDataEntity cityData, int timeType) {
|
|
||||||
// try {
|
|
||||||
// BaziResultBean.BaseInfoDTO baseInfoDTO = result.getBaseInfo();
|
|
||||||
// BaziResultBean.DetailInfoDTO.SizhuInfoDTO sizhuInfoDTO = result.getDetailInfo().getSizhuInfo();
|
|
||||||
// JSONObject json = new JSONObject();
|
|
||||||
// json.put("name",baseInfoDTO.getName());
|
|
||||||
// json.put("gender",baseInfoDTO.getSex().equals("乾造")? "0" : "1");
|
|
||||||
// json.put("birthType",timeType == 2001 ? "1":"0");
|
|
||||||
// json.put("yangLiBirthTime",baseInfoDTO.getGongli());
|
|
||||||
// json.put("yinLiBirthTime",baseInfoDTO.getNongli());
|
|
||||||
// json.put("birthPlace",cityData == null ? "北京市": cityData.getCityName());
|
|
||||||
// json.put("province",cityData == null ? "北京市": cityData.getProvinceName());
|
|
||||||
// json.put("city",cityData == null ? "北京": cityData.getCityName());
|
|
||||||
// json.put("openSolarTime","2");
|
|
||||||
// json.put("nianZhu",sizhuInfoDTO.getYear().getTg() + "," + sizhuInfoDTO.getYear().getDz());
|
|
||||||
// json.put("yueZhu",sizhuInfoDTO.getMonth().getTg() + "," + sizhuInfoDTO.getMonth().getDz());
|
|
||||||
// json.put("riZhu",sizhuInfoDTO.getDay().getTg() + "," + sizhuInfoDTO.getDay().getDz());
|
|
||||||
// json.put("shiZhu",sizhuInfoDTO.getHour().getTg() + "," + sizhuInfoDTO.getHour().getDz());
|
|
||||||
// impl.saveUserBirthInfo(json, new PlateContract.CallBack<BaziSaveSuccessEntity>() {
|
|
||||||
// @Override
|
|
||||||
// public void success(BaziSaveSuccessEntity bean) {
|
|
||||||
// if(PlatePresenter.this.getView() != null){
|
|
||||||
// if(PlatePresenter.this.getView() != null){
|
|
||||||
// PlatePresenter.this.getView().saveBaziResultSuccess(bean);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void fail(String msg) {
|
|
||||||
// if(PlatePresenter.this.getView() != null){
|
|
||||||
// if(PlatePresenter.this.getView() != null){
|
|
||||||
// PlatePresenter.this.getView().showError(msg);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// } catch (JSONException e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 获取历史运势
|
|
||||||
// * @param page
|
|
||||||
// */
|
|
||||||
// public void getHistoryDatas(int page) {
|
|
||||||
// Map<String, Object> map = new HashMap<>();
|
|
||||||
// map.put("pageNum", page);
|
|
||||||
// map.put("pageSize", 10);
|
|
||||||
// impl.getPaipanHistoryList(map, new PlateContract.CallBack<PaipanHistoryEntity>() {
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void success(PaipanHistoryEntity entity) {
|
|
||||||
// if(PlatePresenter.this.getView() != null){
|
|
||||||
// PlatePresenter.this.getView().getHistorySuccess(entity);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void fail(String msg) {
|
|
||||||
// if(PlatePresenter.this.getView() != null){
|
|
||||||
// PlatePresenter.this.getView().showError(msg);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 删除记录
|
|
||||||
// * @param id
|
|
||||||
// */
|
|
||||||
// public void deleteRecordByID(String id,int pos) {
|
|
||||||
// Map<String, Object> map = new HashMap<>();
|
|
||||||
// map.put("recordId", id);
|
|
||||||
// impl.deleteRecordByID(map, new PlateContract.CallBack<BaseBean>() {
|
|
||||||
// @Override
|
|
||||||
// public void success(BaseBean bean) {
|
|
||||||
// if(PlatePresenter.this.getView() != null){
|
|
||||||
// PlatePresenter.this.getView().deletePaipanHistorySuccess(pos);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void fail(String msg) {
|
|
||||||
// if(PlatePresenter.this.getView() != null){
|
|
||||||
// PlatePresenter.this.getView().showError(msg);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * ai 分析八字
|
|
||||||
// * @param mSaveEntity
|
|
||||||
// */
|
|
||||||
// public void AiParseBaziResult(BaziSaveSuccessEntity mSaveEntity) {
|
|
||||||
// try {
|
|
||||||
// JSONObject json = new JSONObject();
|
|
||||||
// json.put("resultId", mSaveEntity.getRecordId());
|
|
||||||
// impl.sendMsgToAi(json, new PlateContract.AiStreamCallback() {
|
|
||||||
// @Override
|
|
||||||
// public void onMessage(String messageChunk) {
|
|
||||||
// if (PlatePresenter.this.getView() != null) {
|
|
||||||
// PlatePresenter.this.getView().onStreamMessageReceived(messageChunk);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onError(String error) {
|
|
||||||
// if (PlatePresenter.this.getView() != null) {
|
|
||||||
// PlatePresenter.this.getView().showError(error);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onComplete(String complateContent) {
|
|
||||||
// if (PlatePresenter.this.getView() != null) {
|
|
||||||
// PlatePresenter.this.getView().onStreamComplete(complateContent);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void onSessionReceived(String sessionId) {
|
|
||||||
// // 这个回调在当前场景下可能不需要,但保留接口一致性
|
|
||||||
// // Log.d("PlatePresenter", "Session received: " + sessionId);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void loginLost() {
|
|
||||||
// if (PlatePresenter.this.getView() != null) {
|
|
||||||
// // 处理登录失效的情况
|
|
||||||
// // 这里可以根据需要跳转到登录页面
|
|
||||||
// // Log.w("PlatePresenter", "Login lost");
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// } catch (JSONException e) {
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// /**
|
|
||||||
// * 举报
|
|
||||||
// * @param reason
|
|
||||||
// */
|
|
||||||
// public void commitReport(String reason) {
|
|
||||||
// Map<String, Object> map = new HashMap<>();
|
|
||||||
// map.put("content", reason);
|
|
||||||
// new IndexImpl().commitReport(map, new IndexContract.CallBack<BaseBean>() {
|
|
||||||
// @Override
|
|
||||||
// public void success(BaseBean bean) {
|
|
||||||
// if (PlatePresenter.this.getView() != null) {
|
|
||||||
// PlatePresenter.this.getView().commitReportSuccess(bean);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// @Override
|
|
||||||
// public void fail(String msg) {
|
|
||||||
// if (PlatePresenter.this.getView() != null) {
|
|
||||||
// PlatePresenter.this.getView().showError(msg);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@@ -2,7 +2,7 @@ package com.ckkj.water.utils;
|
|||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
public class ClickUtils {
|
public class FastClickUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Android优雅地处理按钮重复点击的几种方法
|
* Android优雅地处理按钮重复点击的几种方法
|
||||||
@@ -4,8 +4,7 @@ import android.content.Context;
|
|||||||
|
|
||||||
import com.ckkj.water.AppConfig;
|
import com.ckkj.water.AppConfig;
|
||||||
import com.ckkj.water.ConstantUtil;
|
import com.ckkj.water.ConstantUtil;
|
||||||
import com.ckkj.water.base.entity.MineUserInfoBean;
|
import com.ckkj.water.mine.entity.MineUserInfoBean;
|
||||||
import com.ckkj.water.base.entity.UserInfoEntity;
|
|
||||||
import com.ckkj.water.login.entity.LoginEntity;
|
import com.ckkj.water.login.entity.LoginEntity;
|
||||||
import com.ckkj.water.utils.dataUtil.SharePreUtil;
|
import com.ckkj.water.utils.dataUtil.SharePreUtil;
|
||||||
|
|
||||||
|
|||||||
5
app/src/main/res/drawable/shape_status_dot_red.xml
Normal file
5
app/src/main/res/drawable/shape_status_dot_red.xml
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<shape xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:shape="oval">
|
||||||
|
<solid android:color="@color/color_E60000" />
|
||||||
|
</shape>
|
||||||
@@ -12,7 +12,7 @@
|
|||||||
android:background="@color/white">
|
android:background="@color/white">
|
||||||
<include
|
<include
|
||||||
android:id="@+id/include_title"
|
android:id="@+id/include_title"
|
||||||
layout="@layout/include_activity_back_layout"/>
|
layout="@layout/include_activity_back_whitebg_layout"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
|||||||
@@ -2,66 +2,31 @@
|
|||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent">
|
android:layout_height="match_parent"
|
||||||
|
android:background="@color/mainBackgroundColor">
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/rl_title"
|
android:id="@+id/rl_title"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/white">
|
android:background="@color/mainBackgroundColor">
|
||||||
<include
|
<include
|
||||||
android:id="@+id/include_title"
|
android:id="@+id/include_title"
|
||||||
layout="@layout/include_activity_back_layout"/>
|
layout="@layout/include_activity_back_whitebg_layout"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/rl_change_phone"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/dp_48"
|
|
||||||
android:layout_marginLeft="@dimen/dp_12"
|
|
||||||
android:layout_marginRight="@dimen/dp_12">
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:textColor="@color/color_333333"
|
|
||||||
android:text="我的账号"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_marginLeft="10dp"/>
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_user_phone"
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="13sp"
|
|
||||||
android:textColor="@color/color_666666"
|
|
||||||
android:text=""
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_marginRight="@dimen/dp_10"
|
|
||||||
android:layout_toLeftOf="@+id/img_point_right1"/>
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/img_point_right1"
|
|
||||||
android:layout_width="@dimen/dp_15"
|
|
||||||
android:layout_height="@dimen/dp_15"
|
|
||||||
android:src="@mipmap/img_point_right_gray"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_centerVertical="true"/>
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0.5dp"
|
|
||||||
android:background="@color/color_gray2"
|
|
||||||
android:layout_alignParentBottom="true"/>
|
|
||||||
</RelativeLayout>
|
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/rl_check_version"
|
android:id="@+id/rl_check_version"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/dp_48"
|
android:layout_height="@dimen/dp_52"
|
||||||
android:layout_marginLeft="@dimen/dp_12"
|
android:layout_marginLeft="@dimen/dp_12"
|
||||||
android:layout_marginRight="@dimen/dp_12">
|
android:layout_marginRight="@dimen/dp_12">
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textColor="@color/color_333333"
|
android:textColor="@color/textPrimaryColor"
|
||||||
android:text="检查更新"
|
android:text="检查更新"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginLeft="10dp"/>
|
android:layout_marginLeft="10dp"/>
|
||||||
@@ -71,7 +36,7 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
android:textColor="@color/color_ff999999"
|
android:textColor="@color/color_ff999999"
|
||||||
android:text="version 1.2.3"
|
android:text=""
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginRight="@dimen/dp_12"
|
android:layout_marginRight="@dimen/dp_12"
|
||||||
android:layout_toLeftOf="@+id/img_point_right2"/>
|
android:layout_toLeftOf="@+id/img_point_right2"/>
|
||||||
@@ -92,14 +57,14 @@
|
|||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/rl_set_cache"
|
android:id="@+id/rl_set_cache"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/dp_48"
|
android:layout_height="@dimen/dp_52"
|
||||||
android:layout_marginLeft="@dimen/dp_12"
|
android:layout_marginLeft="@dimen/dp_12"
|
||||||
android:layout_marginRight="@dimen/dp_12">
|
android:layout_marginRight="@dimen/dp_12">
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textColor="@color/color_333333"
|
android:textColor="@color/textPrimaryColor"
|
||||||
android:text="清除缓存"
|
android:text="清除缓存"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginLeft="10dp"/>
|
android:layout_marginLeft="10dp"/>
|
||||||
@@ -126,44 +91,18 @@
|
|||||||
android:background="@color/color_gray2"
|
android:background="@color/color_gray2"
|
||||||
android:layout_alignParentBottom="true"/>
|
android:layout_alignParentBottom="true"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
<RelativeLayout
|
|
||||||
android:id="@+id/rl_commit_service"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/dp_48"
|
|
||||||
android:layout_marginLeft="@dimen/dp_12"
|
|
||||||
android:layout_marginRight="@dimen/dp_12">
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:textColor="@color/color_333333"
|
|
||||||
android:text="问题反馈"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:layout_marginLeft="10dp"/>
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/img_point_right7"
|
|
||||||
android:layout_width="@dimen/dp_15"
|
|
||||||
android:layout_height="@dimen/dp_15"
|
|
||||||
android:src="@mipmap/img_point_right_gray"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_centerVertical="true"/>
|
|
||||||
<View
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="0.5dp"
|
|
||||||
android:background="@color/color_gray2"
|
|
||||||
android:layout_alignParentBottom="true"/>
|
|
||||||
</RelativeLayout>
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/rl_user_agreement"
|
android:id="@+id/rl_user_agreement"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/dp_48"
|
android:layout_height="@dimen/dp_52"
|
||||||
android:layout_marginLeft="@dimen/dp_12"
|
android:layout_marginLeft="@dimen/dp_12"
|
||||||
android:layout_marginRight="@dimen/dp_12">
|
android:layout_marginRight="@dimen/dp_12">
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textColor="@color/color_333333"
|
android:textColor="@color/textPrimaryColor"
|
||||||
android:text="用户协议"
|
android:text="用户协议"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginLeft="10dp"/>
|
android:layout_marginLeft="10dp"/>
|
||||||
@@ -184,14 +123,14 @@
|
|||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/rl_user_privacy"
|
android:id="@+id/rl_user_privacy"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/dp_48"
|
android:layout_height="@dimen/dp_52"
|
||||||
android:layout_marginLeft="@dimen/dp_12"
|
android:layout_marginLeft="@dimen/dp_12"
|
||||||
android:layout_marginRight="@dimen/dp_12">
|
android:layout_marginRight="@dimen/dp_12">
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textColor="@color/color_333333"
|
android:textColor="@color/textPrimaryColor"
|
||||||
android:text="隐私政策"
|
android:text="隐私政策"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginLeft="10dp"/>
|
android:layout_marginLeft="10dp"/>
|
||||||
@@ -212,14 +151,14 @@
|
|||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/rl_log_off"
|
android:id="@+id/rl_log_off"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="@dimen/dp_48"
|
android:layout_height="@dimen/dp_52"
|
||||||
android:layout_marginLeft="@dimen/dp_12"
|
android:layout_marginLeft="@dimen/dp_12"
|
||||||
android:layout_marginRight="@dimen/dp_12">
|
android:layout_marginRight="@dimen/dp_12">
|
||||||
<TextView
|
<TextView
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textColor="@color/color_333333"
|
android:textColor="@color/textPrimaryColor"
|
||||||
android:text="注销账号"
|
android:text="注销账号"
|
||||||
android:layout_centerVertical="true"
|
android:layout_centerVertical="true"
|
||||||
android:layout_marginLeft="10dp"/>
|
android:layout_marginLeft="10dp"/>
|
||||||
@@ -245,7 +184,7 @@
|
|||||||
android:layout_marginTop="@dimen/dp_10"
|
android:layout_marginTop="@dimen/dp_10"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
android:textColor="@color/color_666666"
|
android:textColor="@color/color_666666"
|
||||||
android:text="如有问题,请联系我们: kunyanzhiyao@outlook.com"
|
android:text="如有问题,请联系我们: sales@watex.com.cn"
|
||||||
android:layout_centerVertical="true"/>
|
android:layout_centerVertical="true"/>
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
android:paddingHorizontal="@dimen/dp_5"
|
android:paddingHorizontal="@dimen/dp_5"
|
||||||
android:layout_marginTop="@dimen/dp_5"
|
android:layout_marginTop="@dimen/dp_5"
|
||||||
tools:listitem="@layout/scan_ble_device_item"
|
tools:listitem="@layout/scan_ble_device_item"
|
||||||
app:spanCount="4"
|
app:spanCount="2"
|
||||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
|
||||||
android:visibility="gone"/>
|
android:visibility="gone"/>
|
||||||
|
|
||||||
|
|||||||
@@ -16,211 +16,223 @@
|
|||||||
android:id="@+id/included_title"
|
android:id="@+id/included_title"
|
||||||
layout="@layout/include_activity_back_whitebg_layout" />
|
layout="@layout/include_activity_back_whitebg_layout" />
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
<TextView
|
<ScrollView
|
||||||
android:id="@+id/tv_device_status"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content">
|
||||||
android:gravity="center"
|
|
||||||
android:textSize="48sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:text="工作中"
|
|
||||||
android:textColor="@color/color_zhu"/>
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_device_update_time"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/dp_4"
|
|
||||||
android:gravity="center"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:text="更新时间:5-1 08:30"
|
|
||||||
android:textColor="@color/color_666666"/>
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:layout_marginTop="@dimen/dp_26">
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/linear_bt"
|
|
||||||
android:layout_width="@dimen/dp_67"
|
|
||||||
android:layout_height="@dimen/dp_67"
|
|
||||||
android:gravity="center"
|
|
||||||
android:background="@drawable/shape_device_ctrl_green_cor12">
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/img_ble"
|
|
||||||
android:layout_width="@dimen/dp_24"
|
|
||||||
android:layout_height="@dimen/dp_24"
|
|
||||||
android:src="@mipmap/icon_ctrl_bt_white"/>
|
|
||||||
</LinearLayout>
|
|
||||||
<LinearLayout
|
|
||||||
android:id="@+id/linear_wifi"
|
|
||||||
android:layout_width="@dimen/dp_67"
|
|
||||||
android:layout_height="@dimen/dp_67"
|
|
||||||
android:layout_marginLeft="@dimen/dp_22"
|
|
||||||
android:gravity="center"
|
|
||||||
android:background="@drawable/shape_device_ctrl_green_cor12">
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/img_wifi_logo"
|
|
||||||
android:layout_width="@dimen/dp_24"
|
|
||||||
android:layout_height="@dimen/dp_24"
|
|
||||||
android:src="@mipmap/icon_ctrl_wifi_white"/>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<FrameLayout
|
|
||||||
android:id="@+id/linear_bat"
|
|
||||||
android:layout_width="@dimen/dp_67"
|
|
||||||
android:layout_height="@dimen/dp_67"
|
|
||||||
android:layout_marginLeft="@dimen/dp_22"
|
|
||||||
android:background="@drawable/shape_device_ctrl_white_cor12">
|
|
||||||
|
|
||||||
<View
|
|
||||||
android:id="@+id/view_center"
|
|
||||||
android:layout_width="@dimen/dp_0_5"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_gravity="center"/>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/img_bat_status"
|
|
||||||
android:layout_width="@dimen/dp_24"
|
|
||||||
android:layout_height="@dimen/dp_24"
|
|
||||||
android:layout_gravity="center"
|
|
||||||
android:src="@mipmap/icon_ctrl_batt_red"/>
|
|
||||||
|
|
||||||
</FrameLayout>
|
|
||||||
</LinearLayout>
|
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:cardCornerRadius="16dp"
|
|
||||||
app:cardElevation="4dp"
|
|
||||||
android:layout_marginHorizontal="@dimen/dp_20"
|
|
||||||
android:layout_marginTop="@dimen/dp_20">
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_horizontal">
|
||||||
android:paddingVertical="@dimen/dp_15">
|
<TextView
|
||||||
<LinearLayout
|
android:id="@+id/tv_device_status"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textSize="48sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:text="工作中"
|
||||||
|
android:textColor="@color/color_zhu"/>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_device_update_time"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/dp_4"
|
||||||
|
android:gravity="center"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:text="更新时间:5-1 08:30"
|
||||||
|
android:textColor="@color/color_666666"/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
android:gravity="center_vertical">
|
android:layout_marginTop="@dimen/dp_26">
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/linear_bt"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="@dimen/dp_67"
|
||||||
android:textSize="14sp"
|
android:layout_height="@dimen/dp_67"
|
||||||
android:textStyle="bold"
|
android:gravity="center"
|
||||||
android:textColor="@color/textPrimaryColor"
|
android:background="@drawable/shape_device_ctrl_green_cor12">
|
||||||
android:text="@string/device_work_progress_title"
|
<ImageView
|
||||||
android:layout_marginLeft="@dimen/dp_30"/>
|
android:id="@+id/img_ble"
|
||||||
|
android:layout_width="@dimen/dp_24"
|
||||||
|
android:layout_height="@dimen/dp_24"
|
||||||
|
android:src="@mipmap/icon_ctrl_bt_white"/>
|
||||||
|
</LinearLayout>
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/linear_wifi"
|
||||||
|
android:layout_width="@dimen/dp_67"
|
||||||
|
android:layout_height="@dimen/dp_67"
|
||||||
|
android:layout_marginLeft="@dimen/dp_22"
|
||||||
|
android:gravity="center"
|
||||||
|
android:background="@drawable/shape_device_ctrl_green_cor12">
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/img_wifi_logo"
|
||||||
|
android:layout_width="@dimen/dp_24"
|
||||||
|
android:layout_height="@dimen/dp_24"
|
||||||
|
android:src="@mipmap/icon_ctrl_wifi_white"/>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<FrameLayout
|
||||||
android:layout_width="wrap_content"
|
android:id="@+id/linear_bat"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="@dimen/dp_67"
|
||||||
android:textSize="12sp"
|
android:layout_height="@dimen/dp_67"
|
||||||
android:textColor="@color/color_666666"
|
android:layout_marginLeft="@dimen/dp_22"
|
||||||
android:text="@string/device_work_progress_tips"
|
android:background="@drawable/shape_device_ctrl_white_cor12">
|
||||||
android:layout_marginLeft="@dimen/dp_5"/>
|
|
||||||
|
<View
|
||||||
|
android:id="@+id/view_center"
|
||||||
|
android:layout_width="@dimen/dp_0_5"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_gravity="center"/>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/img_bat_status"
|
||||||
|
android:layout_width="@dimen/dp_24"
|
||||||
|
android:layout_height="@dimen/dp_24"
|
||||||
|
android:layout_gravity="center"
|
||||||
|
android:src="@mipmap/icon_ctrl_batt_red"/>
|
||||||
|
|
||||||
|
</FrameLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<!--自定义progress-->
|
|
||||||
<ProgressBar
|
|
||||||
android:id="@+id/progress_work"
|
|
||||||
style="@android:style/Widget.ProgressBar.Horizontal"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="@dimen/dp_20"
|
|
||||||
android:layout_marginHorizontal="@dimen/dp_30"
|
|
||||||
android:layout_marginTop="@dimen/dp_25"
|
|
||||||
android:max="100"
|
|
||||||
android:progress="60"
|
|
||||||
android:progressDrawable="@drawable/device_progress_bg"
|
|
||||||
android:progressTint="@null"/>
|
|
||||||
</LinearLayout>
|
|
||||||
</androidx.cardview.widget.CardView>
|
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<androidx.cardview.widget.CardView
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:cardCornerRadius="16dp"
|
|
||||||
app:cardElevation="4dp"
|
|
||||||
android:layout_marginHorizontal="@dimen/dp_20"
|
|
||||||
android:layout_marginTop="@dimen/dp_20">
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:orientation="vertical"
|
|
||||||
android:gravity="center_vertical"
|
|
||||||
android:paddingVertical="@dimen/dp_15">
|
|
||||||
<RelativeLayout
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingHorizontal="@dimen/dp_30">
|
app:cardCornerRadius="16dp"
|
||||||
<TextView
|
app:cardElevation="4dp"
|
||||||
android:layout_width="wrap_content"
|
android:layout_marginHorizontal="@dimen/dp_20"
|
||||||
android:layout_height="wrap_content"
|
android:layout_marginTop="@dimen/dp_20">
|
||||||
android:layout_centerVertical="true"
|
<LinearLayout
|
||||||
android:textSize="14sp"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/textPrimaryColor"
|
|
||||||
android:text="@string/device_work_times_title"/>
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_alignParentRight="true"
|
|
||||||
android:layout_centerVertical="true"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:textColor="@color/color_666666"
|
|
||||||
android:text="30min"
|
|
||||||
android:layout_marginLeft="@dimen/dp_5"/>
|
|
||||||
</RelativeLayout>
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/rv_time_list"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_gravity="center_horizontal"
|
|
||||||
android:paddingHorizontal="@dimen/dp_5"
|
|
||||||
tools:listitem="@layout/device_work_time_item"
|
|
||||||
app:spanCount="4"
|
|
||||||
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"/>
|
|
||||||
<LinearLayout
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:layout_marginTop="@dimen/dp_10"
|
|
||||||
android:paddingVertical="@dimen/dp_6"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:background="@drawable/shape_f9f9f9_corner_5"
|
|
||||||
android:layout_marginHorizontal="@dimen/dp_10">
|
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_work_duartion"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:paddingLeft="@dimen/dp_5"
|
android:orientation="vertical"
|
||||||
android:layout_weight="3"
|
android:gravity="center_vertical"
|
||||||
android:background="@null"
|
android:paddingVertical="@dimen/dp_15">
|
||||||
android:textSize="14sp"
|
<LinearLayout
|
||||||
android:textColorHint="@color/text_hint_theme_color"
|
android:layout_width="match_parent"
|
||||||
android:hint="@string/device_custom_work_time"/>
|
android:layout_height="wrap_content"
|
||||||
<TextView
|
android:orientation="horizontal"
|
||||||
android:layout_width="wrap_content"
|
android:gravity="center_vertical">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_progress_percent"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginVertical="@dimen/dp_2"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/textPrimaryColor"
|
||||||
|
android:text="@string/device_work_progress_title"
|
||||||
|
android:layout_marginLeft="@dimen/dp_30"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/color_666666"
|
||||||
|
android:text="@string/device_work_progress_tips"
|
||||||
|
android:layout_marginLeft="@dimen/dp_5"/>
|
||||||
|
</LinearLayout>
|
||||||
|
<!--自定义progress-->
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progress_work"
|
||||||
|
style="@android:style/Widget.ProgressBar.Horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/dp_20"
|
||||||
|
android:layout_marginHorizontal="@dimen/dp_30"
|
||||||
|
android:layout_marginTop="@dimen/dp_25"
|
||||||
|
android:max="100"
|
||||||
|
android:progress="0"
|
||||||
|
android:progressDrawable="@drawable/device_progress_bg"
|
||||||
|
android:progressTint="@null"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
|
||||||
|
<androidx.cardview.widget.CardView
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:cardCornerRadius="16dp"
|
||||||
|
app:cardElevation="4dp"
|
||||||
|
android:layout_marginHorizontal="@dimen/dp_20"
|
||||||
|
android:layout_marginTop="@dimen/dp_20">
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginRight="@dimen/dp_5"
|
android:orientation="vertical"
|
||||||
android:textSize="12sp"
|
android:gravity="center_vertical"
|
||||||
android:textColor="@color/color_666666"
|
android:paddingVertical="@dimen/dp_15">
|
||||||
android:text="min"/>
|
<RelativeLayout
|
||||||
</LinearLayout>
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingHorizontal="@dimen/dp_30">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/textPrimaryColor"
|
||||||
|
android:text="@string/device_work_times_title"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_alignParentRight="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/color_666666"
|
||||||
|
android:text="30min"
|
||||||
|
android:layout_marginLeft="@dimen/dp_5"/>
|
||||||
|
</RelativeLayout>
|
||||||
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/rv_time_list"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
android:paddingHorizontal="@dimen/dp_5"
|
||||||
|
tools:listitem="@layout/device_work_time_item"
|
||||||
|
app:spanCount="4"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"/>
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/dp_10"
|
||||||
|
android:paddingVertical="@dimen/dp_6"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:background="@drawable/shape_f9f9f9_corner_5"
|
||||||
|
android:layout_marginHorizontal="@dimen/dp_10">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_work_duartion"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:paddingLeft="@dimen/dp_5"
|
||||||
|
android:layout_weight="3"
|
||||||
|
android:background="@null"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColorHint="@color/text_hint_theme_color"
|
||||||
|
android:hint="@string/device_custom_work_time"/>
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginRight="@dimen/dp_5"
|
||||||
|
android:textSize="12sp"
|
||||||
|
android:textColor="@color/color_666666"
|
||||||
|
android:text="min"/>
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
</androidx.cardview.widget.CardView>
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_confirm"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:textSize="14sp"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:text="@string/device_control_start"
|
||||||
|
android:background="@drawable/shape_green_button_bg"
|
||||||
|
android:paddingVertical="@dimen/dp_10"
|
||||||
|
android:layout_marginHorizontal="@dimen/dp_20"
|
||||||
|
android:layout_marginTop="@dimen/dp_40"
|
||||||
|
android:gravity="center"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</androidx.cardview.widget.CardView>
|
</ScrollView>
|
||||||
<TextView
|
|
||||||
android:id="@+id/tv_confirm"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
android:textSize="14sp"
|
|
||||||
android:textColor="@color/white"
|
|
||||||
android:text="@string/device_control_start"
|
|
||||||
android:background="@drawable/shape_green_button_bg"
|
|
||||||
android:paddingVertical="@dimen/dp_10"
|
|
||||||
android:layout_marginHorizontal="@dimen/dp_20"
|
|
||||||
android:layout_marginTop="@dimen/dp_40"
|
|
||||||
android:gravity="center"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
@@ -91,14 +91,22 @@
|
|||||||
android:src="@mipmap/icon_phone_code"/>
|
android:src="@mipmap/icon_phone_code"/>
|
||||||
<EditText
|
<EditText
|
||||||
android:id="@+id/et_input_psd"
|
android:id="@+id/et_input_psd"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="8"
|
||||||
android:layout_marginLeft="@dimen/dp_5"
|
android:layout_marginLeft="@dimen/dp_5"
|
||||||
android:background="@null"
|
android:background="@null"
|
||||||
|
android:inputType="textPassword"
|
||||||
android:textSize="14sp"
|
android:textSize="14sp"
|
||||||
android:textColorHint="@color/textPrimaryColor"
|
android:textColorHint="@color/textPrimaryColor"
|
||||||
android:textColor="@color/textPrimaryColor"
|
android:textColor="@color/textPrimaryColor"
|
||||||
android:hint="@string/input_wifi_psd_tip"/>
|
android:hint="@string/input_wifi_psd_tip"/>
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/img_psd_show_hide"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:src="@mipmap/icon_psd_hide"/>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|||||||
@@ -134,5 +134,27 @@
|
|||||||
android:layout_marginRight="@dimen/dp_23"
|
android:layout_marginRight="@dimen/dp_23"
|
||||||
android:layout_alignParentRight="true"/>
|
android:layout_alignParentRight="true"/>
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/rl_reset_device"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="@dimen/dp_45"
|
||||||
|
android:visibility="gone">
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginLeft="@dimen/dp_20"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:textColor="@color/textPrimaryColor"
|
||||||
|
android:text="@string/restore_factory_settings"/>
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/img_point5"
|
||||||
|
android:layout_width="@dimen/dp_7"
|
||||||
|
android:layout_height="@dimen/dp_13"
|
||||||
|
android:src="@mipmap/icon_point_right"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:layout_marginRight="@dimen/dp_23"
|
||||||
|
android:layout_alignParentRight="true"/>
|
||||||
|
</RelativeLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user