Commit 3c1674970c472345bd6349a2761a84eddac430c1
1 parent
d627d27c
1 优化修改音箱名称逻辑
Showing
7 changed files
with
22 additions
and
14 deletions
config.gradle
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/presenter/ChangeDeviceNamePresenter.java
| ... | ... | @@ -30,7 +30,7 @@ public class ChangeDeviceNamePresenter extends MvpBasePresenter<ChangeDeviceName |
| 30 | 30 | |
| 31 | 31 | private String TAG = "ChangeDeviceNamePresenter"; |
| 32 | 32 | |
| 33 | - public void changeDeviceName(Activity context, String deviceId, String newName, OnResponseListener onResponseListener) { | |
| 33 | + public void changeDeviceName(Activity context, String deviceId, String oldName, String newName, OnResponseListener onResponseListener) { | |
| 34 | 34 | if (null == getView()) { |
| 35 | 35 | return; |
| 36 | 36 | } |
| ... | ... | @@ -38,6 +38,8 @@ public class ChangeDeviceNamePresenter extends MvpBasePresenter<ChangeDeviceName |
| 38 | 38 | Map<String, String> map = new HashMap<>(); |
| 39 | 39 | map.put("devId", deviceId); |
| 40 | 40 | map.put("newName", newName); |
| 41 | + map.put("oldName", oldName); | |
| 42 | + | |
| 41 | 43 | Logic.create(map) |
| 42 | 44 | .action(new Logic.Action<Map<String, String>, APIBaseInfo>() { |
| 43 | 45 | @Override |
| ... | ... | @@ -67,7 +69,7 @@ public class ChangeDeviceNamePresenter extends MvpBasePresenter<ChangeDeviceName |
| 67 | 69 | return; |
| 68 | 70 | } |
| 69 | 71 | QMUITipDialogUtil.dismessDialog(); |
| 70 | - AlertUtil.showDeftToast(context,s); | |
| 72 | + AlertUtil.showDeftToast(context, s); | |
| 71 | 73 | } |
| 72 | 74 | }) |
| 73 | 75 | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/ChangeDeviceNameView.java
| ... | ... | @@ -14,6 +14,7 @@ import com.hannesdorfmann.mosby3.mvp.MvpView; |
| 14 | 14 | public class ChangeDeviceNameView implements MvpView { |
| 15 | 15 | private ChangeDeviceNameFragment fragment; |
| 16 | 16 | private String deviceId; |
| 17 | + private String oldName; | |
| 17 | 18 | |
| 18 | 19 | public ChangeDeviceNameView(ChangeDeviceNameFragment fragment) { |
| 19 | 20 | this.fragment = fragment; |
| ... | ... | @@ -23,9 +24,10 @@ public class ChangeDeviceNameView implements MvpView { |
| 23 | 24 | return fragment == null ? null : fragment.getActivity(); |
| 24 | 25 | } |
| 25 | 26 | |
| 26 | - public void initView(String deviceId) { | |
| 27 | + public void initView(String deviceId, String oldName) { | |
| 27 | 28 | setBtnCantClick(); |
| 28 | 29 | this.deviceId = deviceId; |
| 30 | + this.oldName = oldName; | |
| 29 | 31 | //编辑框 |
| 30 | 32 | fragment.binding.etName.addTextChangedListener(new TextWatcher() { |
| 31 | 33 | @Override |
| ... | ... | @@ -60,10 +62,10 @@ public class ChangeDeviceNameView implements MvpView { |
| 60 | 62 | fragment.binding.btnNext.setOnClickListener(new View.OnClickListener() { |
| 61 | 63 | @Override |
| 62 | 64 | public void onClick(View view) { |
| 63 | - if ("0".equals(fragment.binding.btnNext.getTag().toString())){ | |
| 65 | + if ("0".equals(fragment.binding.btnNext.getTag().toString())) { | |
| 64 | 66 | return; |
| 65 | 67 | } |
| 66 | - fragment.getPresenter().changeDeviceName(getContext(), deviceId, fragment.binding.etName.getText().toString(), new ChangeDeviceNamePresenter.OnResponseListener() { | |
| 68 | + fragment.getPresenter().changeDeviceName(getContext(), deviceId,oldName, fragment.binding.etName.getText().toString(), new ChangeDeviceNamePresenter.OnResponseListener() { | |
| 67 | 69 | @Override |
| 68 | 70 | public void onSuccess() { |
| 69 | 71 | if (null != getContext()) { | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/DeviceManagerFragmentView.java
| ... | ... | @@ -91,7 +91,7 @@ public class DeviceManagerFragmentView implements MvpView { |
| 91 | 91 | @Override |
| 92 | 92 | public void onClick(View view) { |
| 93 | 93 | if (currentUser.getIsMaster() == FamilyListBean.THE_HOST) { |
| 94 | - ChangeDeviceNameActivity.startActivity(getContext(), currentDeviceInfo.getMcid()); | |
| 94 | + ChangeDeviceNameActivity.startActivity(getContext(), deviceDetail.getSN(),deviceDetail.getDeviceName()); | |
| 95 | 95 | } else { |
| 96 | 96 | AlertUtil.showDeftToast(getContext(), getContext().getResources().getString(R.string.change_device_no_pression_tip)); |
| 97 | 97 | } | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/activity/ChangeDeviceNameActivity.java
| ... | ... | @@ -33,16 +33,18 @@ public class ChangeDeviceNameActivity extends AppCompatActivity { |
| 33 | 33 | binding = DataBindingUtil.setContentView(this, R.layout.activity_change_device_name); |
| 34 | 34 | if (null!=getIntent().getExtras()){ |
| 35 | 35 | String deviceId=getIntent().getExtras().getString("deviceId"); |
| 36 | - if (!TextUtils.isEmpty(deviceId)){ | |
| 37 | - getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, ChangeDeviceNameFragment.newInstance(deviceId)).commitAllowingStateLoss(); | |
| 36 | + String oldName=getIntent().getExtras().getString("oldName"); | |
| 37 | + if (!TextUtils.isEmpty(deviceId)&&!TextUtils.isEmpty(oldName)){ | |
| 38 | + getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, ChangeDeviceNameFragment.newInstance(deviceId,oldName)).commitAllowingStateLoss(); | |
| 38 | 39 | } |
| 39 | 40 | } |
| 40 | 41 | |
| 41 | 42 | } |
| 42 | 43 | |
| 43 | - public static void startActivity(Activity activity,String deviceId) { | |
| 44 | + public static void startActivity(Activity activity,String deviceId,String oldName) { | |
| 44 | 45 | Intent intent = new Intent(activity, ChangeDeviceNameActivity.class); |
| 45 | 46 | intent.putExtra("deviceId",deviceId); |
| 47 | + intent.putExtra("oldName",oldName); | |
| 46 | 48 | activity.startActivity(intent); |
| 47 | 49 | } |
| 48 | 50 | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/activity/ConnBluetoothSuccessActivity.java
| ... | ... | @@ -100,7 +100,7 @@ public class ConnBluetoothSuccessActivity extends AppCompatActivity { |
| 100 | 100 | @Override |
| 101 | 101 | public void onClick(View view) { |
| 102 | 102 | if (null != networkResultBean && !TextUtils.isEmpty(networkResultBean.getMainctl())) { |
| 103 | - ChangeDeviceNameActivity.startActivity(ConnBluetoothSuccessActivity.this, networkResultBean.getMainctl()); | |
| 103 | + ChangeDeviceNameActivity.startActivity(ConnBluetoothSuccessActivity.this, networkResultBean.getMainctl(),""); | |
| 104 | 104 | } |
| 105 | 105 | } |
| 106 | 106 | }); | ... | ... |
module_xiaojiaSoundBox/src/main/java/com/cnlive/strike/xiaojiaspeaker/ui/fragment/ChangeDeviceNameFragment.java
| ... | ... | @@ -15,10 +15,11 @@ import com.cnlive.strike.xiaojiaspeaker.frame.presenter.ChangeDeviceNamePresente |
| 15 | 15 | import com.cnlive.strike.xiaojiaspeaker.frame.view.ChangeDeviceNameView; |
| 16 | 16 | |
| 17 | 17 | public class ChangeDeviceNameFragment extends MvpBindingFragment<ChangeDeviceNameView, ChangeDeviceNamePresenter, Object, FragmentChangeDeviceNameBinding> { |
| 18 | - public static ChangeDeviceNameFragment newInstance(String deviceId) { | |
| 18 | + public static ChangeDeviceNameFragment newInstance(String deviceId,String oldName) { | |
| 19 | 19 | ChangeDeviceNameFragment fragment = new ChangeDeviceNameFragment(); |
| 20 | 20 | Bundle bundle = new Bundle(); |
| 21 | 21 | bundle.putString("deviceId",deviceId); |
| 22 | + bundle.putString("oldName",oldName); | |
| 22 | 23 | fragment.setArguments(bundle); |
| 23 | 24 | return fragment; |
| 24 | 25 | } |
| ... | ... | @@ -41,8 +42,9 @@ public class ChangeDeviceNameFragment extends MvpBindingFragment<ChangeDeviceNam |
| 41 | 42 | if (null != getMvpView()) { |
| 42 | 43 | if (null != getArguments()) { |
| 43 | 44 | String deviceId= getArguments().getString("deviceId"); |
| 44 | - if (!TextUtils.isEmpty(deviceId)) { | |
| 45 | - getMvpView().initView(deviceId); | |
| 45 | + String oldName= getArguments().getString("oldName"); | |
| 46 | + if (!TextUtils.isEmpty(deviceId)&&!TextUtils.isEmpty(oldName)) { | |
| 47 | + getMvpView().initView(deviceId,oldName); | |
| 46 | 48 | } |
| 47 | 49 | } |
| 48 | 50 | } | ... | ... |