Commit d6c3ecde010924b687069b6e5f66d3c85ce48854
1 parent
4fc05a61
1 优化基类
Showing
71 changed files
with
4375 additions
and
77 deletions
Too many changes to show.
To preserve performance only 71 of 401 files are displayed.
app/strike/build.gradle
| @@ -159,6 +159,7 @@ dependencies { | @@ -159,6 +159,7 @@ dependencies { | ||
| 159 | implementation project(path: ':cloud:user') | 159 | implementation project(path: ':cloud:user') |
| 160 | 160 | ||
| 161 | implementation project(path: ':core:imageload') | 161 | implementation project(path: ':core:imageload') |
| 162 | + compile project(path: ':module:xiaojiasoundbox') | ||
| 162 | // implementation project(path: ':core:util') | 163 | // implementation project(path: ':core:util') |
| 163 | // implementation project(path: ':core:encipher') | 164 | // implementation project(path: ':core:encipher') |
| 164 | // implementation project(path: ':cloud:user') | 165 | // implementation project(path: ':cloud:user') |
cloud/user/src/main/java/com/cnlive/strike/user/network/api/BaseRequest.java renamed to app/strike/src/BaseRequest.java
app/strike/src/main/java/com/cnlive/strike/MyActivity.java
| 1 | package com.cnlive.strike; | 1 | package com.cnlive.strike; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | +import android.content.Intent; | ||
| 5 | +import android.text.TextUtils; | ||
| 6 | + | ||
| 4 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; | 7 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; |
| 8 | +import com.cnlive.strike.user.auth.UserService; | ||
| 9 | +import com.cnlive.strike.xiaojiaspeaker.commonInfo.XiaoJIaCommInfo; | ||
| 10 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.AllDeviceActivity; | ||
| 5 | 11 | ||
| 6 | 12 | ||
| 7 | public class MyActivity extends BaseActivity { | 13 | public class MyActivity extends BaseActivity { |
| @@ -13,10 +19,35 @@ public class MyActivity extends BaseActivity { | @@ -13,10 +19,35 @@ public class MyActivity extends BaseActivity { | ||
| 13 | 19 | ||
| 14 | @Override | 20 | @Override |
| 15 | protected void initView() { | 21 | protected void initView() { |
| 16 | - getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyFragment()).commitAllowingStateLoss(); | 22 | +// getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyFragment()).commitAllowingStateLoss(); |
| 23 | + initXiaoJiaSoundBoxData(); | ||
| 24 | + startActivity(new Intent(MyActivity.this,AllDeviceActivity.class)); | ||
| 17 | } | 25 | } |
| 18 | 26 | ||
| 19 | @Override | 27 | @Override |
| 20 | protected void initData() { | 28 | protected void initData() { |
| 21 | } | 29 | } |
| 30 | + | ||
| 31 | + /** | ||
| 32 | + * 初始化小家音箱数据 | ||
| 33 | + */ | ||
| 34 | + private void initXiaoJiaSoundBoxData() { | ||
| 35 | +// XiaoJIaCommInfo.setUserId(this, "10514333"); | ||
| 36 | +// XiaoJIaCommInfo.setUserPhone(this, "18301489586"); | ||
| 37 | + if (!TextUtils.isEmpty(UserService.getUid(this))) { | ||
| 38 | + XiaoJIaCommInfo.setUserId(this, UserService.getUid(this)); | ||
| 39 | + } | ||
| 40 | + if (null == UserService.getInstance(this).getAppAccount()) { | ||
| 41 | + return; | ||
| 42 | + } | ||
| 43 | + if (null != UserService.getInstance(this).getAppAccount().getMobile() && !TextUtils.isEmpty(UserService.getInstance(this).getAppAccount().getMobile())) { | ||
| 44 | + XiaoJIaCommInfo.setUserPhone(this, UserService.getInstance(this).getAppAccount().getMobile()); | ||
| 45 | + } | ||
| 46 | + if (!TextUtils.isEmpty(UserService.getInstance(this).getAppAccount().getFaceUrl())) { | ||
| 47 | + XiaoJIaCommInfo.setUserIcon(this, UserService.getInstance(this).getAppAccount().getFaceUrl()); | ||
| 48 | + } | ||
| 49 | + if (!TextUtils.isEmpty(UserService.getInstance(this).getAppAccount().getNickName())) { | ||
| 50 | + XiaoJIaCommInfo.setUserNickName(this, UserService.getInstance(this).getAppAccount().getNickName()); | ||
| 51 | + } | ||
| 52 | + } | ||
| 22 | } | 53 | } |
app/strike/src/main/java/com/cnlive/strike/MyFragment.java
| @@ -4,9 +4,7 @@ package com.cnlive.strike; | @@ -4,9 +4,7 @@ package com.cnlive.strike; | ||
| 4 | import android.Manifest; | 4 | import android.Manifest; |
| 5 | import android.os.Bundle; | 5 | import android.os.Bundle; |
| 6 | import android.util.Log; | 6 | import android.util.Log; |
| 7 | -import android.view.LayoutInflater; | ||
| 8 | import android.view.View; | 7 | import android.view.View; |
| 9 | -import android.view.ViewGroup; | ||
| 10 | import android.widget.TextView; | 8 | import android.widget.TextView; |
| 11 | 9 | ||
| 12 | import com.cnlive.core.libs.base.frame.fragment.BaseFragment; | 10 | import com.cnlive.core.libs.base.frame.fragment.BaseFragment; |
| @@ -15,16 +13,13 @@ import com.cnlive.core.network.BaseResult; | @@ -15,16 +13,13 @@ import com.cnlive.core.network.BaseResult; | ||
| 15 | import com.cnlive.core.network.HttpConn; | 13 | import com.cnlive.core.network.HttpConn; |
| 16 | import com.cnlive.core.network.NetCallBack; | 14 | import com.cnlive.core.network.NetCallBack; |
| 17 | import com.cnlive.core.libs.base.util.StatusBarConfig; | 15 | import com.cnlive.core.libs.base.util.StatusBarConfig; |
| 18 | -import com.cnlive.strike.network.BaseRequest; | 16 | +import com.cnlive.core.network.request.BaseRequest; |
| 19 | import com.cnlive.strike.network.api.ApiService; | 17 | import com.cnlive.strike.network.api.ApiService; |
| 20 | import com.cnlive.strike.network.bean.LetHimNoSeeBean; | 18 | import com.cnlive.strike.network.bean.LetHimNoSeeBean; |
| 21 | import com.cnlive.strike.network.bean.TestBean; | 19 | import com.cnlive.strike.network.bean.TestBean; |
| 22 | import com.me.yokeyword.fragmentation.anim.DefaultVerticalAnimator; | 20 | import com.me.yokeyword.fragmentation.anim.DefaultVerticalAnimator; |
| 23 | import com.me.yokeyword.fragmentation.anim.FragmentAnimator; | 21 | import com.me.yokeyword.fragmentation.anim.FragmentAnimator; |
| 24 | 22 | ||
| 25 | -import androidx.annotation.NonNull; | ||
| 26 | -import androidx.annotation.Nullable; | ||
| 27 | - | ||
| 28 | import java.util.HashMap; | 23 | import java.util.HashMap; |
| 29 | import java.util.Map; | 24 | import java.util.Map; |
| 30 | 25 |
app/strike/src/main/java/com/cnlive/strike/MyFragment1.java
| 1 | package com.cnlive.strike; | 1 | package com.cnlive.strike; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | -import android.os.Bundle; | ||
| 5 | import android.util.Log; | 4 | import android.util.Log; |
| 6 | -import android.view.LayoutInflater; | ||
| 7 | import android.view.View; | 5 | import android.view.View; |
| 8 | -import android.view.ViewGroup; | ||
| 9 | - | ||
| 10 | -import androidx.annotation.NonNull; | ||
| 11 | -import androidx.annotation.Nullable; | ||
| 12 | 6 | ||
| 13 | import com.cnlive.core.libs.base.frame.fragment.BaseFragment; | 7 | import com.cnlive.core.libs.base.frame.fragment.BaseFragment; |
| 14 | import com.cnlive.core.libs.base.util.StatusBarConfig; | 8 | import com.cnlive.core.libs.base.util.StatusBarConfig; |
| 15 | import com.cnlive.core.network.HttpConn; | 9 | import com.cnlive.core.network.HttpConn; |
| 16 | import com.cnlive.core.network.NetCallBack; | 10 | import com.cnlive.core.network.NetCallBack; |
| 17 | -import com.cnlive.strike.network.BaseRequest; | 11 | +import com.cnlive.core.network.request.BaseRequest; |
| 18 | import com.cnlive.strike.network.api.ApiService; | 12 | import com.cnlive.strike.network.api.ApiService; |
| 19 | import com.cnlive.strike.network.bean.TestBean; | 13 | import com.cnlive.strike.network.bean.TestBean; |
| 20 | 14 |
app/strike/src/main/java/com/cnlive/strike/demo/activity/DemoActivity.java
| @@ -77,7 +77,7 @@ public class DemoActivity extends BaseActivity { | @@ -77,7 +77,7 @@ public class DemoActivity extends BaseActivity { | ||
| 77 | //px2dp | 77 | //px2dp |
| 78 | px2dp(10); | 78 | px2dp(10); |
| 79 | 79 | ||
| 80 | - loadRootFragment(R.id.fl_container, new MyFragment()); | 80 | + loadRootFragment(new MyFragment()); |
| 81 | 81 | ||
| 82 | // String[] permissions = new String[]{Manifest.permission.ACCESS_FINE_LOCATION, | 82 | // String[] permissions = new String[]{Manifest.permission.ACCESS_FINE_LOCATION, |
| 83 | // Manifest.permission.ACCESS_COARSE_LOCATION}; | 83 | // Manifest.permission.ACCESS_COARSE_LOCATION}; |
build.gradle
| @@ -108,8 +108,8 @@ allprojects { | @@ -108,8 +108,8 @@ allprojects { | ||
| 108 | imput("implementation", project, moudle.core_base) | 108 | imput("implementation", project, moudle.core_base) |
| 109 | 109 | ||
| 110 | //Tripartite Base | 110 | //Tripartite Base |
| 111 | -// for (String moudle : base_librarys) imput('implementation', project, moudle) | ||
| 112 | - for (String moudle : base_librarys) imput('api', project, moudle) | 111 | + for (String moudle : base_librarys) imput('implementation', project, moudle) |
| 112 | +// for (String moudle : base_librarys) imput('api', project, moudle) | ||
| 113 | for (String moudle : base_compilers) imput('annotationProcessor', project, moudle) | 113 | for (String moudle : base_compilers) imput('annotationProcessor', project, moudle) |
| 114 | 114 | ||
| 115 | } | 115 | } |
| @@ -144,4 +144,11 @@ task clean(type: Delete) { | @@ -144,4 +144,11 @@ task clean(type: Delete) { | ||
| 144 | ext { | 144 | ext { |
| 145 | libEmoj = '2.0.9' | 145 | libEmoj = '2.0.9' |
| 146 | libMediaPicker = '1.5.8' | 146 | libMediaPicker = '1.5.8' |
| 147 | + // loading动画 | ||
| 148 | + avi = "2.1.3" | ||
| 149 | + //蓝牙 | ||
| 150 | + BleLib="2.3.4" | ||
| 151 | + //动画大全 | ||
| 152 | + viewAnimationsEasing='2.0@aar' | ||
| 153 | + viewAnimationsAndroid='2.3@aar' | ||
| 147 | } | 154 | } |
cloud/user/src/main/java/com/cnlive/strike/user/UserUtilAction.java
| @@ -7,11 +7,11 @@ import android.text.TextUtils; | @@ -7,11 +7,11 @@ import android.text.TextUtils; | ||
| 7 | import com.cnlive.core.libs.base.application.AppConfig; | 7 | import com.cnlive.core.libs.base.application.AppConfig; |
| 8 | import com.cnlive.core.network.BaseResult; | 8 | import com.cnlive.core.network.BaseResult; |
| 9 | import com.cnlive.core.network.HttpConn; | 9 | import com.cnlive.core.network.HttpConn; |
| 10 | -import com.cnlive.strike.user.network.api.ApiBaseServiceOpen; | ||
| 11 | -import com.cnlive.strike.user.network.api.BaseRequest; | ||
| 12 | -import com.cnlive.strike.user.network.model.FaceData; | ||
| 13 | -import com.cnlive.strike.user.network.model.TokenData; | ||
| 14 | -import com.cnlive.strike.user.network.model.UserData; | 10 | +import com.cnlive.core.network.UserData; |
| 11 | +import com.cnlive.core.network.api.ApiBaseServiceOpen; | ||
| 12 | +import com.cnlive.core.network.request.BaseRequest; | ||
| 13 | +import com.cnlive.core.network.FaceData; | ||
| 14 | +import com.cnlive.core.network.TokenData; | ||
| 15 | 15 | ||
| 16 | import java.io.File; | 16 | import java.io.File; |
| 17 | import java.util.ArrayList; | 17 | import java.util.ArrayList; |
cloud/user/src/main/java/com/cnlive/strike/user/auth/UserService.java
| @@ -13,7 +13,7 @@ import com.cnlive.core.libs.base.util.SharedPreferencesHelper; | @@ -13,7 +13,7 @@ import com.cnlive.core.libs.base.util.SharedPreferencesHelper; | ||
| 13 | import com.cnlive.strike.user.R; | 13 | import com.cnlive.strike.user.R; |
| 14 | import com.cnlive.strike.user.model.CNLiveUserInfo; | 14 | import com.cnlive.strike.user.model.CNLiveUserInfo; |
| 15 | import com.cnlive.strike.user.model.CNLiveUserInfoExt; | 15 | import com.cnlive.strike.user.model.CNLiveUserInfoExt; |
| 16 | -import com.cnlive.strike.user.network.model.UserData; | 16 | +import com.cnlive.core.network.UserData; |
| 17 | import com.google.gson.Gson; | 17 | import com.google.gson.Gson; |
| 18 | 18 | ||
| 19 | import java.util.HashMap; | 19 | import java.util.HashMap; |
cloud/user/src/main/java/com/cnlive/strike/user/frame/presenter/FirstLoginPresenter.java
| @@ -11,9 +11,9 @@ import com.cnlive.strike.user.R; | @@ -11,9 +11,9 @@ import com.cnlive.strike.user.R; | ||
| 11 | import com.cnlive.strike.user.UserUtilAction; | 11 | import com.cnlive.strike.user.UserUtilAction; |
| 12 | import com.cnlive.strike.user.auth.UserService; | 12 | import com.cnlive.strike.user.auth.UserService; |
| 13 | import com.cnlive.strike.user.frame.view.FirstLoginView; | 13 | import com.cnlive.strike.user.frame.view.FirstLoginView; |
| 14 | -import com.cnlive.strike.user.network.model.FaceData; | ||
| 15 | -import com.cnlive.strike.user.network.model.TokenData; | ||
| 16 | -import com.cnlive.strike.user.network.model.UserData; | 14 | +import com.cnlive.core.network.FaceData; |
| 15 | +import com.cnlive.core.network.TokenData; | ||
| 16 | +import com.cnlive.core.network.UserData; | ||
| 17 | import com.cnlive.strike.user.router.user.UserOfflineUtil; | 17 | import com.cnlive.strike.user.router.user.UserOfflineUtil; |
| 18 | 18 | ||
| 19 | import java.io.File; | 19 | import java.io.File; |
cloud/user/src/main/java/com/cnlive/strike/user/frame/view/FirstLoginView.java
| @@ -63,8 +63,6 @@ public class FirstLoginView extends BaseView { | @@ -63,8 +63,6 @@ public class FirstLoginView extends BaseView { | ||
| 63 | successInfo.setTagMsg(fragment.tagMsg); | 63 | successInfo.setTagMsg(fragment.tagMsg); |
| 64 | EventBus.getDefault().post(new UserEventMsg(UserEventMsg.LOGIN_SUCCESS, successInfo)); | 64 | EventBus.getDefault().post(new UserEventMsg(UserEventMsg.LOGIN_SUCCESS, successInfo)); |
| 65 | 65 | ||
| 66 | - | ||
| 67 | - | ||
| 68 | // Intent intent = new Intent(getContext(), MainTestActivity.class); | 66 | // Intent intent = new Intent(getContext(), MainTestActivity.class); |
| 69 | // if (!TextUtils.isEmpty(fragment.tagMsg)) | 67 | // if (!TextUtils.isEmpty(fragment.tagMsg)) |
| 70 | // intent.putExtra("classifyTagMsg", fragment.tagMsg); | 68 | // intent.putExtra("classifyTagMsg", fragment.tagMsg); |
cloud/user/src/main/java/com/cnlive/strike/user/router/user/UserAction.java
| @@ -5,22 +5,17 @@ import android.app.Activity; | @@ -5,22 +5,17 @@ import android.app.Activity; | ||
| 5 | import android.content.Context; | 5 | import android.content.Context; |
| 6 | import android.net.Uri; | 6 | import android.net.Uri; |
| 7 | import android.text.TextUtils; | 7 | import android.text.TextUtils; |
| 8 | -import android.util.Log; | ||
| 9 | 8 | ||
| 10 | import com.cnlive.core.network.BaseResult; | 9 | import com.cnlive.core.network.BaseResult; |
| 11 | import com.cnlive.core.network.HttpConn; | 10 | import com.cnlive.core.network.HttpConn; |
| 12 | import com.cnlive.core.network.NetCallBack; | 11 | import com.cnlive.core.network.NetCallBack; |
| 13 | -import com.cnlive.core.network.ServerException; | 12 | +import com.cnlive.core.network.UserData; |
| 14 | import com.cnlive.strike.user.UserUtilAction; | 13 | import com.cnlive.strike.user.UserUtilAction; |
| 15 | import com.cnlive.strike.user.auth.UserService; | 14 | import com.cnlive.strike.user.auth.UserService; |
| 16 | import com.cnlive.strike.user.model.CNLiveUserInfo; | 15 | import com.cnlive.strike.user.model.CNLiveUserInfo; |
| 17 | -import com.cnlive.strike.user.network.api.BaseRequest; | ||
| 18 | -import com.cnlive.strike.user.network.model.UserData; | ||
| 19 | 16 | ||
| 20 | import io.reactivex.Observable; | 17 | import io.reactivex.Observable; |
| 21 | -import io.reactivex.ObservableSource; | ||
| 22 | import io.reactivex.disposables.Disposable; | 18 | import io.reactivex.disposables.Disposable; |
| 23 | -import io.reactivex.functions.Function; | ||
| 24 | 19 | ||
| 25 | 20 | ||
| 26 | public class UserAction { | 21 | public class UserAction { |
core/base/src/main/java/com/cnlive/core/libs/base/arouter/QrService.java
0 → 100644
| 1 | +package com.cnlive.core.libs.base.arouter; | ||
| 2 | + | ||
| 3 | +import android.graphics.Bitmap; | ||
| 4 | + | ||
| 5 | +import androidx.annotation.Nullable; | ||
| 6 | + | ||
| 7 | +import com.alibaba.android.arouter.facade.template.IProvider; | ||
| 8 | + | ||
| 9 | +/** | ||
| 10 | + * 作者: 吴奎庆 | ||
| 11 | + * <p> | ||
| 12 | + * 时间: 2019/6/18 | ||
| 13 | + * <p> | ||
| 14 | + * 简介: 生成二维码调用的服务 | ||
| 15 | + */ | ||
| 16 | +public interface QrService extends IProvider { | ||
| 17 | + String PATH = "/app/qrservice"; | ||
| 18 | + String NAME = "app_qrservice"; | ||
| 19 | + String GROUP = "appqr"; | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 生成二维码的逻辑(带图标) | ||
| 23 | + * | ||
| 24 | + * @param content | ||
| 25 | + * @param size 宽高 | ||
| 26 | + * @param logoBitmap 图标的bitmap | ||
| 27 | + * @param logoPercent 百分比 | ||
| 28 | + * @return | ||
| 29 | + */ | ||
| 30 | + Bitmap createQrIconBitMap(String content, int size, @Nullable Bitmap logoBitmap, float logoPercent); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 生成不带图标的二维码 | ||
| 34 | + * | ||
| 35 | + * @param content 内容 | ||
| 36 | + * @param size 二维码大小 单位px | ||
| 37 | + * @return | ||
| 38 | + */ | ||
| 39 | + Bitmap createQRNoIconBitmap(@Nullable String content, int size); | ||
| 40 | + | ||
| 41 | +} |
core/base/src/main/java/com/cnlive/core/libs/base/arouter/im/FriendListData.java
0 → 100644
| 1 | +package com.cnlive.core.libs.base.arouter.im; | ||
| 2 | + | ||
| 3 | +public class FriendListData { | ||
| 4 | + | ||
| 5 | + private String friendId; | ||
| 6 | + private String friendFaceUrl; | ||
| 7 | + private String friendNickName; | ||
| 8 | + private String friendRemark; | ||
| 9 | + private String friendCustomInfoJson; | ||
| 10 | + | ||
| 11 | + public String getFriendId() { | ||
| 12 | + return friendId; | ||
| 13 | + } | ||
| 14 | + | ||
| 15 | + public void setFriendId(String friendId) { | ||
| 16 | + this.friendId = friendId; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + public String getFriendFaceUrl() { | ||
| 20 | + return friendFaceUrl; | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public void setFriendFaceUrl(String friendFaceUrl) { | ||
| 24 | + this.friendFaceUrl = friendFaceUrl; | ||
| 25 | + } | ||
| 26 | + | ||
| 27 | + public String getFriendNickName() { | ||
| 28 | + return friendNickName; | ||
| 29 | + } | ||
| 30 | + | ||
| 31 | + public void setFriendNickName(String friendNickName) { | ||
| 32 | + this.friendNickName = friendNickName; | ||
| 33 | + } | ||
| 34 | + | ||
| 35 | + public String getFriendRemark() { | ||
| 36 | + return friendRemark; | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + public void setFriendRemark(String friendRemark) { | ||
| 40 | + this.friendRemark = friendRemark; | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + public String getFriendCustomInfoJson() { | ||
| 44 | + return friendCustomInfoJson; | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + public void setFriendCustomInfoJson(String friendCustomInfoJson) { | ||
| 48 | + this.friendCustomInfoJson = friendCustomInfoJson; | ||
| 49 | + } | ||
| 50 | +} |
core/base/src/main/java/com/cnlive/core/libs/base/arouter/im/ImOpenService.java
0 → 100644
| 1 | +package com.cnlive.core.libs.base.arouter.im; | ||
| 2 | + | ||
| 3 | +import com.alibaba.android.arouter.facade.template.IProvider; | ||
| 4 | + | ||
| 5 | +import java.util.List; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * IM相关的对外接口 | ||
| 9 | + */ | ||
| 10 | +public interface ImOpenService extends IProvider { | ||
| 11 | + //获取好友列表 | ||
| 12 | + void getFriendList(CNValueCallBack<List<FriendListData>> callBack); | ||
| 13 | + | ||
| 14 | + //是否已经加入了群组,注:本地数据判断 | ||
| 15 | + boolean hasJoinGroup(String groupId); | ||
| 16 | + | ||
| 17 | + interface CNCallBack { | ||
| 18 | + void onError(int errorCode, String errorMsg); | ||
| 19 | + | ||
| 20 | + void onSuccess(); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + interface CNValueCallBack<T> { | ||
| 24 | + void onError(int var1, String var2); | ||
| 25 | + | ||
| 26 | + void onSuccess(T var1); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | +} |
core/base/src/main/java/com/cnlive/core/libs/base/frame/activity/BaseActivity.java
| 1 | package com.cnlive.core.libs.base.frame.activity; | 1 | package com.cnlive.core.libs.base.frame.activity; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | +import android.app.Activity; | ||
| 4 | import android.content.Context; | 5 | import android.content.Context; |
| 5 | import android.content.DialogInterface; | 6 | import android.content.DialogInterface; |
| 6 | import android.content.Intent; | 7 | import android.content.Intent; |
| @@ -287,6 +288,14 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -287,6 +288,14 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 287 | StatusBarUtil.setColor(this, ContextCompat.getColor(this, color), statusBarAlpha); | 288 | StatusBarUtil.setColor(this, ContextCompat.getColor(this, color), statusBarAlpha); |
| 288 | } | 289 | } |
| 289 | 290 | ||
| 291 | + public void setTransparentForWindow(Activity activity) { | ||
| 292 | + StatusBarUtil.setTransparentForWindow(activity); | ||
| 293 | + } | ||
| 294 | + | ||
| 295 | + public void addTranslucentView(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha) { | ||
| 296 | + StatusBarUtil.addTranslucentView(activity, statusBarAlpha); | ||
| 297 | + } | ||
| 298 | + | ||
| 290 | /** | 299 | /** |
| 291 | * 设置状态栏字体颜色 | 300 | * 设置状态栏字体颜色 |
| 292 | */ | 301 | */ |
| @@ -431,6 +440,29 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -431,6 +440,29 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 431 | } | 440 | } |
| 432 | 441 | ||
| 433 | /** | 442 | /** |
| 443 | + * 请求权限 | ||
| 444 | + * <p> | ||
| 445 | + * 警告:此处除了用户拒绝外,唯一可能出现无法获取权限或失败的情况是在AndroidManifest.xml中未声明权限信息 | ||
| 446 | + * Android6.0+即便需要动态请求权限(重点)但不代表着不需要在AndroidManifest.xml中进行声明。 | ||
| 447 | + * | ||
| 448 | + * @param permissions 请求的权限 | ||
| 449 | + * @param onPermissionResponseListener 回调监听器 | ||
| 450 | + */ | ||
| 451 | + public void requestPermission(String[] permissions, String defineTip, OnPermissionResponseListener | ||
| 452 | + onPermissionResponseListener) { | ||
| 453 | + this.userSetDefinePermissionTip = defineTip; | ||
| 454 | + this.onPermissionResponseListener = onPermissionResponseListener; | ||
| 455 | + if (checkPermissions(permissions)) { | ||
| 456 | + if (onPermissionResponseListener != null) { | ||
| 457 | + onPermissionResponseListener.onSuccess(permissions); | ||
| 458 | + } | ||
| 459 | + } else { | ||
| 460 | + List<String> needPermissions = getDeniedPermissions(permissions); | ||
| 461 | + ActivityCompat.requestPermissions(this, needPermissions.toArray(new String[needPermissions.size()]), DEFAULT_REQUEST_CODE_PERMISSION); | ||
| 462 | + } | ||
| 463 | + } | ||
| 464 | + | ||
| 465 | + /** | ||
| 434 | * 自定义权限申请码 | 466 | * 自定义权限申请码 |
| 435 | * | 467 | * |
| 436 | * @param requestCode | 468 | * @param requestCode |
| @@ -778,6 +810,16 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | @@ -778,6 +810,16 @@ public abstract class BaseActivity<V extends BaseView, P extends BasePresenter<V | ||
| 778 | } | 810 | } |
| 779 | 811 | ||
| 780 | /****************************************以下为可选方法(Optional methods)******************************************************/ | 812 | /****************************************以下为可选方法(Optional methods)******************************************************/ |
| 813 | + /** | ||
| 814 | + * 加载根Fragment, 即Activity内的第一个Fragment 或 Fragment内的第一个子Fragment | ||
| 815 | + * <p> | ||
| 816 | + * root_container 容器id | ||
| 817 | + * | ||
| 818 | + * @param toFragment 目标Fragment | ||
| 819 | + */ | ||
| 820 | + public void loadRootFragment(@NonNull ISupportFragment toFragment) { | ||
| 821 | + mDelegate.loadRootFragment(R.id.root_container, toFragment); | ||
| 822 | + } | ||
| 781 | 823 | ||
| 782 | /** | 824 | /** |
| 783 | * 加载根Fragment, 即Activity内的第一个Fragment 或 Fragment内的第一个子Fragment | 825 | * 加载根Fragment, 即Activity内的第一个Fragment 或 Fragment内的第一个子Fragment |
core/base/src/main/java/com/cnlive/core/libs/base/frame/fragment/BaseFragment.java
| @@ -189,6 +189,14 @@ public abstract class BaseFragment<V extends BaseView, P extends BasePresenter<V | @@ -189,6 +189,14 @@ public abstract class BaseFragment<V extends BaseView, P extends BasePresenter<V | ||
| 189 | me.setStatusBarColor(color, statusBarAlpha); | 189 | me.setStatusBarColor(color, statusBarAlpha); |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | + public void setTransparentForWindow(Activity activity) { | ||
| 193 | + me.setTransparentForWindow(activity); | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + public void addTranslucentView(Activity activity, @IntRange(from = 0, to = 255) int statusBarAlpha) { | ||
| 197 | + me.addTranslucentView(activity, statusBarAlpha); | ||
| 198 | + } | ||
| 199 | + | ||
| 192 | @Override | 200 | @Override |
| 193 | public void onDestroy() { | 201 | public void onDestroy() { |
| 194 | mDelegate.onDestroy(); | 202 | mDelegate.onDestroy(); |
| @@ -250,6 +258,11 @@ public abstract class BaseFragment<V extends BaseView, P extends BasePresenter<V | @@ -250,6 +258,11 @@ public abstract class BaseFragment<V extends BaseView, P extends BasePresenter<V | ||
| 250 | me.requestPermission(requestCode, defineTip, permissions, onPermissionResponseListener); | 258 | me.requestPermission(requestCode, defineTip, permissions, onPermissionResponseListener); |
| 251 | } | 259 | } |
| 252 | 260 | ||
| 261 | + public void requestPermission(String[] permissions, String defineTip, OnPermissionResponseListener | ||
| 262 | + onPermissionResponseListener) { | ||
| 263 | + me.requestPermission(permissions, defineTip, onPermissionResponseListener); | ||
| 264 | + } | ||
| 265 | + | ||
| 253 | public void requestPermission(int requestCode, @StringRes int defineTip, String[] | 266 | public void requestPermission(int requestCode, @StringRes int defineTip, String[] |
| 254 | permissions, OnPermissionResponseListener onPermissionResponseListener) { | 267 | permissions, OnPermissionResponseListener onPermissionResponseListener) { |
| 255 | me.requestPermission(requestCode, defineTip, permissions, onPermissionResponseListener); | 268 | me.requestPermission(requestCode, defineTip, permissions, onPermissionResponseListener); |
| @@ -335,6 +348,12 @@ public abstract class BaseFragment<V extends BaseView, P extends BasePresenter<V | @@ -335,6 +348,12 @@ public abstract class BaseFragment<V extends BaseView, P extends BasePresenter<V | ||
| 335 | mDelegate.setUserVisibleHint(isVisibleToUser); | 348 | mDelegate.setUserVisibleHint(isVisibleToUser); |
| 336 | } | 349 | } |
| 337 | 350 | ||
| 351 | + public void finish() { | ||
| 352 | + if (null != me) { | ||
| 353 | + me.finish(); | ||
| 354 | + } | ||
| 355 | + } | ||
| 356 | + | ||
| 338 | /*************************************log******************************************/ | 357 | /*************************************log******************************************/ |
| 339 | public void logError(Object info) { | 358 | public void logError(Object info) { |
| 340 | Logger.e(TAG, info); | 359 | Logger.e(TAG, info); |
core/base/src/main/java/com/cnlive/core/libs/base/util/CheckUtil.java
| 1 | package com.cnlive.core.libs.base.util; | 1 | package com.cnlive.core.libs.base.util; |
| 2 | 2 | ||
| 3 | import android.app.Activity; | 3 | import android.app.Activity; |
| 4 | +import android.content.Context; | ||
| 4 | import android.content.Intent; | 5 | import android.content.Intent; |
| 5 | import android.content.pm.PackageManager; | 6 | import android.content.pm.PackageManager; |
| 7 | +import android.location.LocationManager; | ||
| 6 | import android.net.Uri; | 8 | import android.net.Uri; |
| 7 | import android.os.PowerManager; | 9 | import android.os.PowerManager; |
| 8 | import android.provider.Settings; | 10 | import android.provider.Settings; |
| 9 | import android.widget.Toast; | 11 | import android.widget.Toast; |
| 10 | 12 | ||
| 13 | + | ||
| 14 | +import com.cnlive.strike.base.R; | ||
| 15 | + | ||
| 11 | import static android.content.Context.POWER_SERVICE; | 16 | import static android.content.Context.POWER_SERVICE; |
| 12 | 17 | ||
| 13 | public class CheckUtil { | 18 | public class CheckUtil { |
| 19 | + /** | ||
| 20 | + * 判断GPS是否开启,GPS或者AGPS开启一个就认为是开启的 | ||
| 21 | + * | ||
| 22 | + * @param context | ||
| 23 | + * @return true 表示开启 | ||
| 24 | + */ | ||
| 25 | + public static final boolean isOPenGps(final Context context) { | ||
| 26 | + try { | ||
| 27 | + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { | ||
| 28 | + LocationManager locationManager | ||
| 29 | + = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE); | ||
| 30 | + // 通过GPS卫星定位,定位级别可以精确到街(通过24颗卫星定位,在室外和空旷的地方定位准确、速度快) | ||
| 31 | + boolean gps = locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER); | ||
| 32 | + // 通过WLAN或移动网络(3G/2G)确定的位置(也称作AGPS,辅助GPS定位。主要用于在室内或遮盖物(建筑群或茂密的深林等)密集的地方定位) | ||
| 33 | + boolean network = locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER); | ||
| 34 | + if (gps) { | ||
| 35 | + return true; | ||
| 36 | + } else { | ||
| 37 | + return false; | ||
| 38 | + } | ||
| 39 | + } else { | ||
| 40 | + return true; | ||
| 41 | + } | ||
| 42 | + } catch (Exception e) { | ||
| 43 | + //异常就返回true | ||
| 44 | + return true; | ||
| 45 | + } | ||
| 46 | + } | ||
| 14 | 47 | ||
| 48 | + public static void openGPS(Activity context) { | ||
| 49 | + //开启GPS | ||
| 50 | + try { | ||
| 51 | + Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS); | ||
| 52 | + context.startActivityForResult(intent, 10); | ||
| 53 | + Toast.makeText(context, context.getString(R.string.open_gps_tip), Toast.LENGTH_LONG).show(); | ||
| 54 | + } catch (Exception e) { | ||
| 55 | + Toast.makeText(context, "请手动打开GPS", Toast.LENGTH_LONG).show(); | ||
| 56 | + } | ||
| 57 | + } | ||
| 15 | /** | 58 | /** |
| 16 | * 锤子手机不能检测电池白名单,会崩溃 | 59 | * 锤子手机不能检测电池白名单,会崩溃 |
| 17 | * | 60 | * |
core/base/src/main/java/com/cnlive/core/libs/base/util/SimpleDES.java
0 → 100644
| 1 | +package com.cnlive.core.libs.base.util; | ||
| 2 | + | ||
| 3 | +import android.util.Base64; | ||
| 4 | + | ||
| 5 | +import java.security.Key; | ||
| 6 | + | ||
| 7 | +import javax.crypto.Cipher; | ||
| 8 | +import javax.crypto.SecretKeyFactory; | ||
| 9 | +import javax.crypto.spec.DESKeySpec; | ||
| 10 | + | ||
| 11 | +import static javax.crypto.Cipher.getInstance; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * 加密工具 | ||
| 15 | + */ | ||
| 16 | +public class SimpleDES { | ||
| 17 | + //key 的长度得大于8 | ||
| 18 | + public static final String DES_KEY = "cnliveIm"; | ||
| 19 | + private static String encoding = "UTF-8"; | ||
| 20 | + | ||
| 21 | + /** | ||
| 22 | + * 加密字符串 | ||
| 23 | + */ | ||
| 24 | + public static String ebotongEncrypto(String str, String key) { | ||
| 25 | + String result = str; | ||
| 26 | + if (str != null && str.length() > 0) { | ||
| 27 | + try { | ||
| 28 | + byte[] encodeByte = symmetricEncrypto(str.getBytes(encoding), key); | ||
| 29 | + result = Base64.encodeToString(encodeByte, Base64.DEFAULT); | ||
| 30 | + | ||
| 31 | + } catch (Exception e) { | ||
| 32 | + // e.printStackTrace(); | ||
| 33 | + } | ||
| 34 | + } | ||
| 35 | + return result; | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + /** | ||
| 39 | + * 解密字符串 | ||
| 40 | + */ | ||
| 41 | + public static String ebotongDecrypto(String str, String key) { | ||
| 42 | + String result = str; | ||
| 43 | + if (str != null && str.length() > 0) { | ||
| 44 | + try { | ||
| 45 | + byte[] encodeByte = Base64.decode(str, Base64.DEFAULT); | ||
| 46 | + | ||
| 47 | + byte[] decoder = symmetricDecrypto(encodeByte, key); | ||
| 48 | + result = new String(decoder, encoding); | ||
| 49 | + } catch (Exception e) { | ||
| 50 | + // e.printStackTrace(); | ||
| 51 | + } | ||
| 52 | + } | ||
| 53 | + return result; | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + /** | ||
| 57 | + * 加密byte[] | ||
| 58 | + */ | ||
| 59 | + public static byte[] ebotongEncrypto(byte[] str, String key) { | ||
| 60 | + byte[] result = null; | ||
| 61 | + if (str != null && str.length > 0) { | ||
| 62 | + try { | ||
| 63 | + byte[] encodeByte = symmetricEncrypto(str, key); | ||
| 64 | + result = Base64.encode(encodeByte, Base64.DEFAULT); | ||
| 65 | + | ||
| 66 | + } catch (Exception e) { | ||
| 67 | + // e.printStackTrace(); | ||
| 68 | + } | ||
| 69 | + } | ||
| 70 | + return result; | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + /** | ||
| 74 | + * 解密byte[] | ||
| 75 | + */ | ||
| 76 | + public static byte[] ebotongDecrypto(byte[] str, String key) { | ||
| 77 | + byte[] result = null; | ||
| 78 | + if (str != null && str.length > 0) { | ||
| 79 | + try { | ||
| 80 | + | ||
| 81 | + byte[] encodeByte = Base64.decode(new String(str, encoding), Base64.DEFAULT); | ||
| 82 | + //byte[] encodeByte = base64decoder.decodeBuffer(new String(str)); | ||
| 83 | + byte[] decoder = symmetricDecrypto(encodeByte, key); | ||
| 84 | + result = new String(decoder).getBytes(encoding); | ||
| 85 | + result = new String(decoder).getBytes(); | ||
| 86 | + } catch (Exception e) { | ||
| 87 | + // e.printStackTrace(); | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + return result; | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * 对称加密字节数组并返回 | ||
| 95 | + * | ||
| 96 | + * @param byteSource 需要加密的数据 | ||
| 97 | + * @return 经过加密的数据 | ||
| 98 | + * @throws Exception | ||
| 99 | + */ | ||
| 100 | + public static byte[] symmetricEncrypto(byte[] byteSource, String sKey) throws Exception { | ||
| 101 | + try { | ||
| 102 | + int mode = Cipher.ENCRYPT_MODE; | ||
| 103 | + SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); | ||
| 104 | + byte[] keyData = sKey.getBytes(); | ||
| 105 | + DESKeySpec keySpec = new DESKeySpec(keyData); | ||
| 106 | + Key key = keyFactory.generateSecret(keySpec); | ||
| 107 | + Cipher cipher = getInstance("DES"); | ||
| 108 | + cipher.init(mode, key); | ||
| 109 | + | ||
| 110 | + return cipher.doFinal(byteSource); | ||
| 111 | + } catch (Exception e) { | ||
| 112 | + return null; | ||
| 113 | + } | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + /** | ||
| 117 | + * 对称解密字节数组并返回 | ||
| 118 | + * | ||
| 119 | + * @param byteSource 需要解密的数据 | ||
| 120 | + * @return 经过解密的数据 | ||
| 121 | + * @throws Exception | ||
| 122 | + */ | ||
| 123 | + public static byte[] symmetricDecrypto(byte[] byteSource, String sKey) throws Exception { | ||
| 124 | + try { | ||
| 125 | + int mode = Cipher.DECRYPT_MODE; | ||
| 126 | + SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES"); | ||
| 127 | + byte[] keyData = sKey.getBytes(); | ||
| 128 | + DESKeySpec keySpec = new DESKeySpec(keyData); | ||
| 129 | + Key key = keyFactory.generateSecret(keySpec); | ||
| 130 | + Cipher cipher = getInstance("DES"); | ||
| 131 | + cipher.init(mode, key); | ||
| 132 | + return cipher.doFinal(byteSource); | ||
| 133 | + } catch (Exception e) { | ||
| 134 | + return null; | ||
| 135 | + } | ||
| 136 | + } | ||
| 137 | +} |
core/base/src/main/res/drawable-hdpi/wufalianjie.png
0 → 100644
9.37 KB
core/base/src/main/res/drawable-xhdpi/wufalianjie.png
0 → 100644
13.3 KB
core/base/src/main/res/drawable-xxhdpi/wufalianjie.png
0 → 100644
13.3 KB
core/base/src/main/res/layout/base_activity_main.xml
| 1 | <?xml version="1.0" encoding="utf-8"?> | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | <FrameLayout | 2 | <FrameLayout |
| 3 | - android:id="@+id/fl_container" | 3 | + android:id="@+id/root_container" |
| 4 | xmlns:android="http://schemas.android.com/apk/res/android" | 4 | xmlns:android="http://schemas.android.com/apk/res/android" |
| 5 | android:layout_width="match_parent" | 5 | android:layout_width="match_parent" |
| 6 | android:layout_height="match_parent"/> | 6 | android:layout_height="match_parent"/> |
| 7 | \ No newline at end of file | 7 | \ No newline at end of file |
core/base/src/main/res/values/ids.xml
| @@ -5,4 +5,6 @@ | @@ -5,4 +5,6 @@ | ||
| 5 | <!-- --> | 5 | <!-- --> |
| 6 | <item name="hierarchy" type="id"></item> | 6 | <item name="hierarchy" type="id"></item> |
| 7 | <item name="isexpand" type="id"></item> | 7 | <item name="isexpand" type="id"></item> |
| 8 | + <!-- --> | ||
| 9 | + <item name="rightBtn" type="id" /> | ||
| 8 | </resources> | 10 | </resources> |
| 9 | \ No newline at end of file | 11 | \ No newline at end of file |
core/base/src/main/res/values/strings.xml
| @@ -18,4 +18,16 @@ | @@ -18,4 +18,16 @@ | ||
| 18 | <!-- --> | 18 | <!-- --> |
| 19 | <string name="fragmentation_stack_view">Stack</string> | 19 | <string name="fragmentation_stack_view">Stack</string> |
| 20 | <string name="fragmentation_stack_help">*: Not in backStack\n☀: Visible</string> | 20 | <string name="fragmentation_stack_help">*: Not in backStack\n☀: Visible</string> |
| 21 | + <!-- --> | ||
| 22 | + <string name="open_gps_tip">为确保功能正常使用,请开启GPS!</string> | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + <string name="msg_empty_page">您现在还没有相关内容哦</string> | ||
| 26 | + <string name="msg_failed_network_detail">别紧张,试试看刷新页面~</string> | ||
| 27 | + <string name="msg_failed_network_title">无法连接网络</string> | ||
| 28 | + <string name="msg_failed_network_toast">网络连接失败,请稍后再试!</string> | ||
| 29 | + <string name="msg_failed_noresponse">无数据</string> | ||
| 30 | + <string name="msg_failed_other_detail">别紧张,试试看刷新页面~</string> | ||
| 31 | + <string name="msg_failed_other_title">接口请求错误</string> | ||
| 32 | + <string name="msg_failed_other_toast">接口请求失败,请稍后再试!</string> | ||
| 21 | </resources> | 33 | </resources> |
core/network/src/main/java/com/cnlive/core/network/BaseObserver.java
| 1 | package com.cnlive.core.network; | 1 | package com.cnlive.core.network; |
| 2 | 2 | ||
| 3 | import android.content.Context; | 3 | import android.content.Context; |
| 4 | -import android.util.Log; | ||
| 5 | 4 | ||
| 6 | import io.reactivex.Observer; | 5 | import io.reactivex.Observer; |
| 7 | import io.reactivex.disposables.Disposable; | 6 | import io.reactivex.disposables.Disposable; |
| @@ -45,7 +44,7 @@ public abstract class BaseObserver<T> implements Observer<T> { | @@ -45,7 +44,7 @@ public abstract class BaseObserver<T> implements Observer<T> { | ||
| 45 | } else { | 44 | } else { |
| 46 | //状态码不对 | 45 | //状态码不对 |
| 47 | try { | 46 | try { |
| 48 | - onCodeError(baseResult.getErrorCode(), baseResult.getErrorMessage()); | 47 | + onCodeError(baseResult.getErrorCode(), baseResult.getMessage()); |
| 49 | } catch (Exception e) { | 48 | } catch (Exception e) { |
| 50 | e.printStackTrace(); | 49 | e.printStackTrace(); |
| 51 | } | 50 | } |
core/network/src/main/java/com/cnlive/core/network/BaseResult.java
| @@ -25,7 +25,7 @@ public class BaseResult<T> { | @@ -25,7 +25,7 @@ public class BaseResult<T> { | ||
| 25 | this.errorCode = errorCode; | 25 | this.errorCode = errorCode; |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | - public String getErrorMessage() { | 28 | + public String getMessage() { |
| 29 | return errorMessage; | 29 | return errorMessage; |
| 30 | } | 30 | } |
| 31 | 31 |
cloud/user/src/main/java/com/cnlive/strike/user/network/model/FaceData.java renamed to core/network/src/main/java/com/cnlive/core/network/FaceData.java
core/network/src/main/java/com/cnlive/core/network/HttpConn.java
| 1 | package com.cnlive.core.network; | 1 | package com.cnlive.core.network; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | -import android.content.Context; | ||
| 5 | -import android.util.Log; | ||
| 6 | - | ||
| 7 | import com.cnlive.core.libs.base.application.BaseApplication; | 4 | import com.cnlive.core.libs.base.application.BaseApplication; |
| 8 | import com.cnlive.core.libs.base.network.manager.SubscriptionManager; | 5 | import com.cnlive.core.libs.base.network.manager.SubscriptionManager; |
| 9 | import com.cnlive.core.network.util.NetworkUtil; | 6 | import com.cnlive.core.network.util.NetworkUtil; |
| 10 | 7 | ||
| 11 | -import java.util.ArrayList; | ||
| 12 | -import java.util.HashMap; | ||
| 13 | -import java.util.List; | ||
| 14 | - | ||
| 15 | import io.reactivex.Observable; | 8 | import io.reactivex.Observable; |
| 16 | import io.reactivex.android.schedulers.AndroidSchedulers; | 9 | import io.reactivex.android.schedulers.AndroidSchedulers; |
| 17 | import io.reactivex.disposables.Disposable; | 10 | import io.reactivex.disposables.Disposable; |
| 18 | -import io.reactivex.functions.Function; | ||
| 19 | import io.reactivex.schedulers.Schedulers; | 11 | import io.reactivex.schedulers.Schedulers; |
| 20 | 12 | ||
| 21 | /** | 13 | /** |
| @@ -175,7 +167,7 @@ public class HttpConn { | @@ -175,7 +167,7 @@ public class HttpConn { | ||
| 175 | // } | 167 | // } |
| 176 | // } else { | 168 | // } else { |
| 177 | // if (null != callBack) { | 169 | // if (null != callBack) { |
| 178 | -// callBack.onFailure(baseResult.getErrorCode(), baseResult.getErrorMessage()); | 170 | +// callBack.onFailure(baseResult.getErrorCode(), baseResult.getMessage()); |
| 179 | // } | 171 | // } |
| 180 | // } | 172 | // } |
| 181 | // } else { | 173 | // } else { |
| @@ -238,7 +230,7 @@ public class HttpConn { | @@ -238,7 +230,7 @@ public class HttpConn { | ||
| 238 | //// } | 230 | //// } |
| 239 | //// } else { | 231 | //// } else { |
| 240 | //// if (null != callBack) { | 232 | //// if (null != callBack) { |
| 241 | -//// callBack.onFailure(tBaseResponse.getErrorCode(), tBaseResponse.getErrorMessage()); | 233 | +//// callBack.onFailure(tBaseResponse.getErrorCode(), tBaseResponse.getMessage()); |
| 242 | //// } | 234 | //// } |
| 243 | //// } | 235 | //// } |
| 244 | // } | 236 | // } |
| @@ -268,7 +260,7 @@ public class HttpConn { | @@ -268,7 +260,7 @@ public class HttpConn { | ||
| 268 | public static <T> Observable error(T t) { | 260 | public static <T> Observable error(T t) { |
| 269 | if (t instanceof BaseResult) { | 261 | if (t instanceof BaseResult) { |
| 270 | BaseResult baseResult = (BaseResult) t; | 262 | BaseResult baseResult = (BaseResult) t; |
| 271 | - return Observable.error(new ServerException(baseResult.getErrorCode(), baseResult.getErrorMessage())); | 263 | + return Observable.error(new ServerException(baseResult.getErrorCode(), baseResult.getMessage())); |
| 272 | } | 264 | } |
| 273 | return null; | 265 | return null; |
| 274 | } | 266 | } |
cloud/user/src/main/java/com/cnlive/strike/user/network/model/TokenData.java renamed to core/network/src/main/java/com/cnlive/core/network/TokenData.java
cloud/user/src/main/java/com/cnlive/strike/user/network/model/UserData.java renamed to core/network/src/main/java/com/cnlive/core/network/UserData.java
cloud/user/src/main/java/com/cnlive/strike/user/network/api/ApiBaseServiceOpen.java renamed to core/network/src/main/java/com/cnlive/core/network/api/ApiBaseServiceOpen.java
| 1 | -package com.cnlive.strike.user.network.api; | 1 | +package com.cnlive.core.network.api; |
| 2 | + | ||
| 3 | + | ||
| 2 | 4 | ||
| 3 | 5 | ||
| 4 | import com.cnlive.core.network.BaseResult; | 6 | import com.cnlive.core.network.BaseResult; |
| 5 | -import com.cnlive.strike.user.network.model.FaceData; | ||
| 6 | -import com.cnlive.strike.user.network.model.TokenData; | ||
| 7 | -import com.cnlive.strike.user.network.model.UserData; | 7 | +import com.cnlive.core.network.FaceData; |
| 8 | +import com.cnlive.core.network.TokenData; | ||
| 9 | +import com.cnlive.core.network.UserData; | ||
| 8 | 10 | ||
| 9 | import java.util.List; | 11 | import java.util.List; |
| 10 | import java.util.Map; | 12 | import java.util.Map; |
| @@ -137,7 +139,7 @@ public interface ApiBaseServiceOpen { | @@ -137,7 +139,7 @@ public interface ApiBaseServiceOpen { | ||
| 137 | @Multipart | 139 | @Multipart |
| 138 | @POST("open/api2/user/updateUserFaceById") | 140 | @POST("open/api2/user/updateUserFaceById") |
| 139 | Observable<BaseResult<FaceData>> updateUserFace(@PartMap Map<String, RequestBody> map, | 141 | Observable<BaseResult<FaceData>> updateUserFace(@PartMap Map<String, RequestBody> map, |
| 140 | - @Part List<MultipartBody.Part> params); | 142 | + @Part List<MultipartBody.Part> params); |
| 141 | 143 | ||
| 142 | 144 | ||
| 143 | 145 |
cloud/user/src/main/java/com/cnlive/strike/user/network/model/StorageInfoData.java renamed to core/network/src/main/java/com/cnlive/core/network/model/StorageInfoData.java
cloud/user/src/main/java/com/cnlive/strike/user/network/model/TimeStampInfo.java renamed to core/network/src/main/java/com/cnlive/core/network/model/TimeStampInfo.java
app/strike/src/main/java/com/cnlive/strike/network/BaseRequest.java renamed to core/network/src/main/java/com/cnlive/core/network/request/BaseRequest.java
| 1 | -package com.cnlive.strike.network; | 1 | +package com.cnlive.core.network.request; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | import android.text.TextUtils; | 4 | import android.text.TextUtils; |
| @@ -11,9 +11,11 @@ import java.util.List; | @@ -11,9 +11,11 @@ import java.util.List; | ||
| 11 | 11 | ||
| 12 | import okhttp3.Interceptor; | 12 | import okhttp3.Interceptor; |
| 13 | 13 | ||
| 14 | +import com.cnlive.core.network.api.ApiBaseServiceOpen; | ||
| 15 | + | ||
| 14 | /** | 16 | /** |
| 15 | * 基本请求 | 17 | * 基本请求 |
| 16 | - * ys | 18 | + * ys |
| 17 | */ | 19 | */ |
| 18 | public class BaseRequest { | 20 | public class BaseRequest { |
| 19 | private String userSetUrl; | 21 | private String userSetUrl; |
| @@ -23,14 +25,29 @@ public class BaseRequest { | @@ -23,14 +25,29 @@ public class BaseRequest { | ||
| 23 | private long writeTimeout;//写入超时 | 25 | private long writeTimeout;//写入超时 |
| 24 | private List<Interceptor> interceptorList;//拦截器 | 26 | private List<Interceptor> interceptorList;//拦截器 |
| 25 | private String baseUrl = "http://gank.io/api/data/"; | 27 | private String baseUrl = "http://gank.io/api/data/"; |
| 26 | - private final String SP_CMS_URL_DEBUT = "http://cmstest.cnlive.com:8768/"; | ||
| 27 | - private final String SP_CMS_URL = "http://cms.cnlive.com:8768/"; | 28 | + private final String CMS_DEBUG_URL = "http://cmstest.cnlive.com:8768/"; |
| 29 | + private final String CMS_URL = "http://cms.cnlive.com:8768/"; | ||
| 28 | //网++ 接口域名 | 30 | //网++ 接口域名 |
| 29 | - public final String SP_BASE_URL = "https://apiwjj.cnlive.com/"; | 31 | + public final String BASE_URL = "https://apiwjj.cnlive.com/"; |
| 30 | //网++ 测试环境 接口域名 | 32 | //网++ 测试环境 接口域名 |
| 31 | - public final String SP_DEBUG_URL = "http://apiwjjtest.cnlive.com/"; | 33 | + public final String BASE_DEBUG_URL = "http://apiwjjtest.cnlive.com/"; |
| 32 | //OPEN API 接口域名 | 34 | //OPEN API 接口域名 |
| 33 | - private final String SP_OPEN_URL = "https://api.cnlive.com/"; | 35 | + private final String OPEN_URL = "https://api.cnlive.com/"; |
| 36 | + | ||
| 37 | + /** | ||
| 38 | + * 初始化接口地址 | ||
| 39 | + */ | ||
| 40 | + private String initBaseUrl(Class clazz) { | ||
| 41 | + if (AppConfig.isDebug()) { | ||
| 42 | + baseUrl = BASE_DEBUG_URL;//还原初始地址 | ||
| 43 | + if (clazz == ApiBaseServiceOpen.class) { | ||
| 44 | + return OPEN_URL; | ||
| 45 | + } | ||
| 46 | + } else { | ||
| 47 | + baseUrl = BASE_URL; | ||
| 48 | + } | ||
| 49 | + return baseUrl; | ||
| 50 | + } | ||
| 34 | 51 | ||
| 35 | /** | 52 | /** |
| 36 | * 构造函数初始化 | 53 | * 构造函数初始化 |
| @@ -78,16 +95,6 @@ public class BaseRequest { | @@ -78,16 +95,6 @@ public class BaseRequest { | ||
| 78 | 95 | ||
| 79 | 96 | ||
| 80 | /** | 97 | /** |
| 81 | - * 初始化接口地址 | ||
| 82 | - */ | ||
| 83 | - private String initBaseUrl(Class clzz) { | ||
| 84 | - if (AppConfig.isDebug()) { | ||
| 85 | - baseUrl = SP_DEBUG_URL;//还原初始地址 | ||
| 86 | - } | ||
| 87 | - return baseUrl; | ||
| 88 | - } | ||
| 89 | - | ||
| 90 | - /** | ||
| 91 | * 设置连接地址 | 98 | * 设置连接地址 |
| 92 | * | 99 | * |
| 93 | * @param url | 100 | * @param url |
core/network/src/main/java/com/cnlive/core/network/request/HttpConfig.java
| @@ -5,5 +5,4 @@ public class HttpConfig { | @@ -5,5 +5,4 @@ public class HttpConfig { | ||
| 5 | public static final int READ_TIMEOUT = 20;//读取超时时间(秒) | 5 | public static final int READ_TIMEOUT = 20;//读取超时时间(秒) |
| 6 | public static final int WRITE_TIMEOUT = 20;//设置写入超时时间(秒) | 6 | public static final int WRITE_TIMEOUT = 20;//设置写入超时时间(秒) |
| 7 | 7 | ||
| 8 | - | ||
| 9 | } | 8 | } |
module/xiaojiasoundbox/.gitignore
0 → 100644
| 1 | +/build |
module/xiaojiasoundbox/build.gradle
0 → 100644
| 1 | +apply plugin: 'com.android.library' | ||
| 2 | + | ||
| 3 | +android { | ||
| 4 | +// compileSdkVersion 29 | ||
| 5 | +// buildToolsVersion "29.0.2" | ||
| 6 | +// | ||
| 7 | +// | ||
| 8 | +// defaultConfig { | ||
| 9 | +// minSdkVersion 16 | ||
| 10 | +// targetSdkVersion 29 | ||
| 11 | +// versionCode 1 | ||
| 12 | +// versionName "1.0" | ||
| 13 | +// | ||
| 14 | +// testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" | ||
| 15 | +// consumerProguardFiles 'consumer-rules.pro' | ||
| 16 | +// } | ||
| 17 | +// | ||
| 18 | +// buildTypes { | ||
| 19 | +// release { | ||
| 20 | +// minifyEnabled false | ||
| 21 | +// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' | ||
| 22 | +// } | ||
| 23 | +// } | ||
| 24 | + dataBinding { | ||
| 25 | + enabled true | ||
| 26 | + } | ||
| 27 | +} | ||
| 28 | + | ||
| 29 | +dependencies { | ||
| 30 | + implementation fileTree(dir: 'libs', include: ['*.jar']) | ||
| 31 | + | ||
| 32 | + implementation 'androidx.appcompat:appcompat:1.1.0' | ||
| 33 | + testImplementation 'junit:junit:4.12' | ||
| 34 | + androidTestImplementation 'androidx.test.ext:junit:1.1.1' | ||
| 35 | + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ||
| 36 | + | ||
| 37 | + implementation project(path: ':core:network') | ||
| 38 | + | ||
| 39 | + // loading动画 | ||
| 40 | + implementation "com.wang.avi:library:$rootProject.avi" | ||
| 41 | + // 蓝牙相关 | ||
| 42 | + implementation "com.clj.fastble:FastBleLib:$rootProject.BleLib" | ||
| 43 | + // loading动画 | ||
| 44 | + implementation "com.wang.avi:library:$rootProject.avi" | ||
| 45 | + // 动画大全 | ||
| 46 | + implementation "com.daimajia.easing:library:$rootProject.viewAnimationsEasing" | ||
| 47 | + implementation "com.daimajia.androidanimations:library:$rootProject.viewAnimationsAndroid" | ||
| 48 | + | ||
| 49 | +} |
module/xiaojiasoundbox/consumer-rules.pro
0 → 100644
module/xiaojiasoundbox/proguard-rules.pro
0 → 100644
| 1 | +# Add project specific ProGuard rules here. | ||
| 2 | +# You can control the set of applied configuration files using the | ||
| 3 | +# proguardFiles setting in build.gradle. | ||
| 4 | +# | ||
| 5 | +# For more details, see | ||
| 6 | +# http://developer.android.com/guide/developing/tools/proguard.html | ||
| 7 | + | ||
| 8 | +# If your project uses WebView with JS, uncomment the following | ||
| 9 | +# and specify the fully qualified class name to the JavaScript interface | ||
| 10 | +# class: | ||
| 11 | +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
| 12 | +# public *; | ||
| 13 | +#} | ||
| 14 | + | ||
| 15 | +# Uncomment this to preserve the line number information for | ||
| 16 | +# debugging stack traces. | ||
| 17 | +#-keepattributes SourceFile,LineNumberTable | ||
| 18 | + | ||
| 19 | +# If you keep the line number information, uncomment this to | ||
| 20 | +# hide the original source file name. | ||
| 21 | +#-renamesourcefileattribute SourceFile |
module/xiaojiasoundbox/src/androidTest/java/com/cnlive/strike/xiaojiasoundbox/ExampleInstrumentedTest.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiasoundbox; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | + | ||
| 5 | +import androidx.test.platform.app.InstrumentationRegistry; | ||
| 6 | +import androidx.test.ext.junit.runners.AndroidJUnit4; | ||
| 7 | + | ||
| 8 | +import org.junit.Test; | ||
| 9 | +import org.junit.runner.RunWith; | ||
| 10 | + | ||
| 11 | +import static org.junit.Assert.*; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * Instrumented test, which will execute on an Android device. | ||
| 15 | + * | ||
| 16 | + * @see <a href="http://d.android.com/tools/testing">Testing documentation</a> | ||
| 17 | + */ | ||
| 18 | +@RunWith(AndroidJUnit4.class) | ||
| 19 | +public class ExampleInstrumentedTest { | ||
| 20 | + @Test | ||
| 21 | + public void useAppContext() { | ||
| 22 | + // Context of the app under test. | ||
| 23 | + Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext(); | ||
| 24 | + | ||
| 25 | + assertEquals("com.cnlive.strike.xiaojiasoundbox.test", appContext.getPackageName()); | ||
| 26 | + } | ||
| 27 | +} |
module/xiaojiasoundbox/src/main/AndroidManifest.xml
0 → 100644
| 1 | +<?xml version="1.0" encoding="utf-8"?> | ||
| 2 | +<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
| 3 | + xmlns:tools="http://schemas.android.com/tools" | ||
| 4 | + package="com.cnlive.strike.xiaojiaspeaker"> | ||
| 5 | + <!-- wifi --> | ||
| 6 | + <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> | ||
| 7 | + <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" /> | ||
| 8 | + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> | ||
| 9 | + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
| 10 | + <uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" /> | ||
| 11 | + <uses-permission | ||
| 12 | + android:name="android.permission.WRITE_SECURE_SETTINGS" | ||
| 13 | + tools:ignore="ProtectedPermissions" /> <!-- 蓝牙 --> | ||
| 14 | + <uses-permission android:name="android.permission.BLUETOOTH" /> | ||
| 15 | + <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <!-- wifi和蓝牙都要 --> | ||
| 16 | + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> | ||
| 17 | + <uses-permission android:name="android.permission.INTERNET" /> | ||
| 18 | + | ||
| 19 | + <application> | ||
| 20 | + <activity | ||
| 21 | + android:name=".ui.activity.ConnFailActivity" | ||
| 22 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 23 | + android:screenOrientation="portrait"></activity> | ||
| 24 | + <activity | ||
| 25 | + android:name=".ui.activity.RemoteControlActivity" | ||
| 26 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 27 | + android:screenOrientation="portrait" /> | ||
| 28 | + <activity | ||
| 29 | + android:name=".ui.activity.ShareFriendActivity" | ||
| 30 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 31 | + android:screenOrientation="portrait" /> | ||
| 32 | + <activity | ||
| 33 | + android:name=".ui.activity.InvitFriendActivity" | ||
| 34 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 35 | + android:screenOrientation="portrait" /> | ||
| 36 | + <activity | ||
| 37 | + android:name=".ui.activity.DeviceInfoActivity" | ||
| 38 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 39 | + android:screenOrientation="portrait" /> | ||
| 40 | + <activity | ||
| 41 | + android:name=".ui.activity.UserManagerActivity" | ||
| 42 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 43 | + android:screenOrientation="portrait" /> | ||
| 44 | + <activity | ||
| 45 | + android:name=".ui.activity.ChangeDeviceNameActivity" | ||
| 46 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 47 | + android:screenOrientation="portrait" /> | ||
| 48 | + <activity | ||
| 49 | + android:name=".ui.activity.DeviceDetailActivity" | ||
| 50 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 51 | + android:screenOrientation="portrait" /> | ||
| 52 | + <activity | ||
| 53 | + android:name=".ui.activity.SetFriendsRoleActivity" | ||
| 54 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 55 | + android:screenOrientation="portrait" /> | ||
| 56 | + <activity | ||
| 57 | + android:name=".ui.activity.SelectIMFriendActivity" | ||
| 58 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 59 | + android:screenOrientation="portrait" /> | ||
| 60 | + <activity | ||
| 61 | + android:name=".ui.activity.FirmwareUpdateActivity" | ||
| 62 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 63 | + android:screenOrientation="portrait" /> | ||
| 64 | + <activity | ||
| 65 | + android:name=".ui.activity.DeviceManagerActivity" | ||
| 66 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 67 | + android:screenOrientation="portrait" /> | ||
| 68 | + <activity | ||
| 69 | + android:name=".ui.activity.DeviceInstructionActivity" | ||
| 70 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 71 | + android:screenOrientation="portrait" /> | ||
| 72 | + <activity | ||
| 73 | + android:name=".ui.activity.AllDeviceActivity" | ||
| 74 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 75 | + android:screenOrientation="portrait" /> | ||
| 76 | + <activity | ||
| 77 | + android:name=".ui.activity.ConnBluetoothSuccessActivity" | ||
| 78 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 79 | + android:screenOrientation="portrait" /> | ||
| 80 | + <activity | ||
| 81 | + android:name=".ui.activity.SelectWifiActivity" | ||
| 82 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 83 | + android:screenOrientation="portrait" /> | ||
| 84 | + <activity | ||
| 85 | + android:name=".ui.activity.BlueToothStep2Activity" | ||
| 86 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 87 | + android:screenOrientation="portrait" /> | ||
| 88 | + <activity | ||
| 89 | + android:name=".ui.activity.BlueToothStep1Activity" | ||
| 90 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 91 | + android:screenOrientation="portrait" /> | ||
| 92 | + <activity | ||
| 93 | + android:name=".ui.activity.BlueToothHelpActivity" | ||
| 94 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 95 | + android:screenOrientation="portrait" /> | ||
| 96 | + <activity | ||
| 97 | + android:name=".ui.activity.SearchDeviceActivity" | ||
| 98 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 99 | + android:screenOrientation="portrait" /> | ||
| 100 | + <activity | ||
| 101 | + android:name=".ui.activity.BluetoothConnActivity" | ||
| 102 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 103 | + android:screenOrientation="portrait" /> | ||
| 104 | + <activity | ||
| 105 | + android:name=".ui.activity.ChangeWifiActivity" | ||
| 106 | + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation" | ||
| 107 | + android:screenOrientation="portrait" /> | ||
| 108 | + </application> | ||
| 109 | + | ||
| 110 | +</manifest> | ||
| 0 | \ No newline at end of file | 111 | \ No newline at end of file |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/commonInfo/XiaoJIaCommInfo.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.commonInfo; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | + | ||
| 5 | +import com.cnlive.strike.xiaojiaspeaker.util.MySpHelper; | ||
| 6 | + | ||
| 7 | +/** | ||
| 8 | + * 公共参数 | ||
| 9 | + * | ||
| 10 | + * @author ys | ||
| 11 | + */ | ||
| 12 | +public class XiaoJIaCommInfo { | ||
| 13 | + //用户ID | ||
| 14 | + private static final String KEY_USER_ID = "xiaojia_UserId"; | ||
| 15 | + //是否显示礼物弹窗 | ||
| 16 | + private static final String KEY_CONN_SUCCESS_GIF = "xiaojia_conn_success_gif"; | ||
| 17 | + // 设备sn | ||
| 18 | + private static final String KEY_SN = "xiaojia_sn"; | ||
| 19 | + //当前token | ||
| 20 | + private static final String KEY_TOKEN = "xiaojia_token"; | ||
| 21 | + //家庭云id | ||
| 22 | + private static final String KEY_FAMILY_ID = "xiaojia_family_id"; | ||
| 23 | + //移动id | ||
| 24 | + private static final String KEY_CMCC_ID = "xiaojia_cmcc_id"; | ||
| 25 | + //用户手机号 | ||
| 26 | + private static final String KEY_USER_PHONE = "xiaojia_user_phone"; | ||
| 27 | + // 用户头像 | ||
| 28 | + private static final String KEY_USER_ICON = "xiaojia_user_icon"; | ||
| 29 | + // 用户昵称 | ||
| 30 | + private static final String KEY_USER_NICK_NAME = "xiaojia_user_nick"; | ||
| 31 | + // 是否绑定 | ||
| 32 | + private static final String KEY_USER_IS_BIND = "xiaojia_user_is_bind"; | ||
| 33 | + // 远程控制开关状态 | ||
| 34 | + private static final String KEY_REMOTE_SWITCH_STATE = "xiaojia_remote_switch_state"; | ||
| 35 | + | ||
| 36 | + private static final int MyCurrentMode = Context.MODE_MULTI_PROCESS; | ||
| 37 | + | ||
| 38 | + public static void setRemoteSwitchState(Context context, boolean isOpen) { | ||
| 39 | + MySpHelper.getInstance(context, MyCurrentMode).putBoolean(KEY_REMOTE_SWITCH_STATE, isOpen); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + public static boolean getRemoteSwitchState(Context context) { | ||
| 43 | + if (getUserIsBind(context)) { | ||
| 44 | + return MySpHelper.getInstance(context, MyCurrentMode).getBoolean(KEY_REMOTE_SWITCH_STATE, false); | ||
| 45 | + } else { | ||
| 46 | + return false; | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public static void setUserIsBind(Context context, boolean isBind) { | ||
| 51 | + MySpHelper.getInstance(context, MyCurrentMode).putBoolean(KEY_USER_IS_BIND, isBind); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public static boolean getUserIsBind(Context context) { | ||
| 55 | + return MySpHelper.getInstance(context, MyCurrentMode).getBoolean(KEY_USER_IS_BIND, false); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public static void setUserNickName(Context context, String userIcon) { | ||
| 59 | + MySpHelper.getInstance(context, MyCurrentMode).putString(KEY_USER_NICK_NAME, userIcon); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + public static String getUserNickName(Context context) { | ||
| 63 | + return MySpHelper.getInstance(context, MyCurrentMode).getString(KEY_USER_NICK_NAME, ""); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + public static void setUserIcon(Context context, String userIcon) { | ||
| 67 | + MySpHelper.getInstance(context, MyCurrentMode).putString(KEY_USER_ICON, userIcon); | ||
| 68 | + } | ||
| 69 | + | ||
| 70 | + public static String getUserIcon(Context context) { | ||
| 71 | + return MySpHelper.getInstance(context, MyCurrentMode).getString(KEY_USER_ICON, ""); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + public static void setUserPhone(Context context, String userPhone) { | ||
| 75 | + MySpHelper.getInstance(context, MyCurrentMode).putString(KEY_USER_PHONE, userPhone); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + public static String getUserPhone(Context context) { | ||
| 79 | + return MySpHelper.getInstance(context, MyCurrentMode).getString(KEY_USER_PHONE, ""); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + public static void setCMCCId(Context context, String cmccId) { | ||
| 83 | + MySpHelper.getInstance(context, MyCurrentMode).putString(KEY_CMCC_ID, cmccId); | ||
| 84 | + } | ||
| 85 | + | ||
| 86 | + public static String getCMCCId(Context context) { | ||
| 87 | + return MySpHelper.getInstance(context, MyCurrentMode).getString(KEY_CMCC_ID, ""); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + | ||
| 91 | + public static void setFamilyId(Context context, String familyId) { | ||
| 92 | + MySpHelper.getInstance(context, MyCurrentMode).putString(KEY_FAMILY_ID, familyId); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + public static String getFamilyId(Context context) { | ||
| 96 | + return MySpHelper.getInstance(context, MyCurrentMode).getString(KEY_FAMILY_ID, ""); | ||
| 97 | + } | ||
| 98 | + | ||
| 99 | + // | ||
| 100 | + public static void setToken(Context context, String token) { | ||
| 101 | + MySpHelper.getInstance(context, MyCurrentMode).putString(KEY_TOKEN, token); | ||
| 102 | + } | ||
| 103 | + | ||
| 104 | + public static String getToken(Context context) { | ||
| 105 | + return MySpHelper.getInstance(context, MyCurrentMode).getString(KEY_TOKEN, ""); | ||
| 106 | + } | ||
| 107 | + | ||
| 108 | + public static String getSN(Context context) { | ||
| 109 | + return MySpHelper.getInstance(context, MyCurrentMode).getString(KEY_SN, ""); | ||
| 110 | + } | ||
| 111 | + | ||
| 112 | + public static void setSN(Context context, String sn) { | ||
| 113 | + MySpHelper.getInstance(context, MyCurrentMode).putString(KEY_SN, sn); | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + public static boolean getIsShowConnGift(Context context) { | ||
| 117 | + return MySpHelper.getInstance(context, MyCurrentMode).getBoolean(KEY_CONN_SUCCESS_GIF, true); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + public static void setIsShowConnGift(Context context, boolean isShow) { | ||
| 121 | + MySpHelper.getInstance(context, MyCurrentMode).putBoolean(KEY_CONN_SUCCESS_GIF, isShow); | ||
| 122 | + } | ||
| 123 | + | ||
| 124 | + /** | ||
| 125 | + * @param context | ||
| 126 | + * @param uid | ||
| 127 | + */ | ||
| 128 | + public static void setUserId(Context context, String uid) { | ||
| 129 | + MySpHelper.getInstance(context, MyCurrentMode).putString(KEY_USER_ID, uid); | ||
| 130 | + } | ||
| 131 | + | ||
| 132 | + /** | ||
| 133 | + * @param context | ||
| 134 | + */ | ||
| 135 | + public static String getUserId(Context context) { | ||
| 136 | + return MySpHelper.getInstance(context, MyCurrentMode).getString(KEY_USER_ID, ""); | ||
| 137 | + } | ||
| 138 | + | ||
| 139 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/constants/BlufiConstants.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.constants; | ||
| 2 | + | ||
| 3 | +import java.util.UUID; | ||
| 4 | + | ||
| 5 | +public final class BlufiConstants { | ||
| 6 | + public static final String BLUFI_PREFIX = "HEMU"; | ||
| 7 | + | ||
| 8 | + public static final UUID UUID_WIFI_SERVICE = UUID.fromString("00001111-0000-1000-8000-00805f9b34fb"); | ||
| 9 | + public static final UUID UUID_WRITE_CHARACTERISTIC = UUID.fromString("00002222-0000-1000-8000-00805f9b34fb"); | ||
| 10 | + public static final UUID UUID_NOTIFY_CHARACTERISTIC = UUID.fromString("0000a007-0000-1000-8000-00805f9b34fb"); | ||
| 11 | + | ||
| 12 | + public static final String KEY_BLE_DEVICES = "key_ble_devices"; | ||
| 13 | + | ||
| 14 | + public static final String KEY_CONFIGURE_PARAM = "configure_param"; | ||
| 15 | + public static final String KEY_CONFIGURE_MULTITHREAD = "configure_multithread"; | ||
| 16 | + | ||
| 17 | + public static final int DEFAULT_MTU_LENGTH = 60; | ||
| 18 | + public static final int MIN_MTU_LENGTH = 30; | ||
| 19 | + | ||
| 20 | + public static final int POST_DATA_LENGTH_LESS = 16; | ||
| 21 | + | ||
| 22 | + public static final String PREF_MESH_IDS_NAME = "espblufi_mesh_ids"; | ||
| 23 | + // 音箱返回状态 | ||
| 24 | + public static final String SSID_RECEIVED = "ssid received"; | ||
| 25 | + public static final String WIFI_LINKING = "WiFi Linking"; | ||
| 26 | + public static final String BIND_SUCCESS = "bind success"; | ||
| 27 | + public static final String WIFI_LINK_FAIL = "WiFi Link Fail"; | ||
| 28 | + public static final String BIND_FAIL = "bind faild"; | ||
| 29 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/constants/XiaoJiaConst.java
0 → 100644
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/presenter/AllDeviceFragmentPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.presenter; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.content.Context; | ||
| 5 | +import android.util.Log; | ||
| 6 | +import android.view.View; | ||
| 7 | + | ||
| 8 | +import com.cnlive.core.libs.base.frame.presenter.BasePresenter; | ||
| 9 | +import com.cnlive.core.network.BaseResult; | ||
| 10 | +import com.cnlive.core.network.HttpConn; | ||
| 11 | +import com.cnlive.core.network.NetCallBack; | ||
| 12 | +import com.cnlive.core.network.request.BaseRequest; | ||
| 13 | +import com.cnlive.strike.xiaojiaspeaker.frame.view.AllDeviceFragmentView; | ||
| 14 | +import com.cnlive.strike.xiaojiaspeaker.netWork.ApiServiceXiaoJia; | ||
| 15 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.FamilyListBean; | ||
| 16 | +import java.util.HashMap; | ||
| 17 | +import java.util.Map; | ||
| 18 | + | ||
| 19 | + | ||
| 20 | +public class AllDeviceFragmentPresenter extends BasePresenter<AllDeviceFragmentView> { | ||
| 21 | + public void getFamilyList(Context context, String sid, String phone) { | ||
| 22 | + ifViewAttached(view -> view.showLoadingView()); | ||
| 23 | + Map<String, String> map = new HashMap<>(); | ||
| 24 | + map.put("sid", sid); | ||
| 25 | + map.put("phone", phone); | ||
| 26 | + HttpConn.action( | ||
| 27 | + BaseRequest.init() | ||
| 28 | + .service(ApiServiceXiaoJia.class) | ||
| 29 | + .getFamilyList(map), | ||
| 30 | + new NetCallBack<BaseResult<FamilyListBean>>() { | ||
| 31 | + @Override | ||
| 32 | + public void onRequestState(int state) { | ||
| 33 | + | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + @Override | ||
| 37 | + public void onSuccess(BaseResult<FamilyListBean> data) { | ||
| 38 | + ifViewAttached(view -> view.hideLoadingView()); | ||
| 39 | + ifViewAttached(view -> view.initAllDeviceList(data.getData())); | ||
| 40 | + } | ||
| 41 | + | ||
| 42 | + @Override | ||
| 43 | + public void onFailure(String errCode, String errMsg) { | ||
| 44 | + //显示重试 | ||
| 45 | + ifViewAttached(view -> view.showRetryView(Integer.parseInt(errCode), new View.OnClickListener() { | ||
| 46 | + @Override | ||
| 47 | + public void onClick(View view) { | ||
| 48 | + getFamilyList(context, sid, phone); | ||
| 49 | + } | ||
| 50 | + })); | ||
| 51 | + } | ||
| 52 | + } | ||
| 53 | + ); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + | ||
| 57 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/presenter/ChangeDeviceNamePresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.presenter; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.util.Log; | ||
| 5 | + | ||
| 6 | +import com.cnlive.core.libs.base.frame.presenter.BasePresenter; | ||
| 7 | +import com.cnlive.core.libs.base.util.AlertUtil; | ||
| 8 | +import com.cnlive.core.network.BaseResult; | ||
| 9 | +import com.cnlive.core.network.HttpConn; | ||
| 10 | +import com.cnlive.core.network.NetCallBack; | ||
| 11 | +import com.cnlive.core.network.request.BaseRequest; | ||
| 12 | +import com.cnlive.strike.xiaojiaspeaker.frame.view.ChangeDeviceNameView; | ||
| 13 | +import com.cnlive.strike.xiaojiaspeaker.model.message.EventMsg; | ||
| 14 | +import com.cnlive.strike.xiaojiaspeaker.netWork.ApiServiceXiaoJia; | ||
| 15 | +import com.cnlive.strike.xiaojiaspeaker.util.QMUITipDialogUtil; | ||
| 16 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | ||
| 17 | + | ||
| 18 | +import org.greenrobot.eventbus.EventBus; | ||
| 19 | + | ||
| 20 | +import java.util.HashMap; | ||
| 21 | +import java.util.Map; | ||
| 22 | + | ||
| 23 | +import io.reactivex.disposables.Disposable; | ||
| 24 | + | ||
| 25 | +public class ChangeDeviceNamePresenter extends BasePresenter<ChangeDeviceNameView> { | ||
| 26 | + | ||
| 27 | + private String TAG = "ChangeDeviceNamePresenter"; | ||
| 28 | + | ||
| 29 | + public void changeDeviceName(Activity context, String deviceId, String oldName, String newName, OnResponseListener onResponseListener) { | ||
| 30 | + if (null == getView()) { | ||
| 31 | + return; | ||
| 32 | + } | ||
| 33 | + QMUITipDialogUtil.loadingDialog(context, "请稍后...", false); | ||
| 34 | + Map<String, String> map = new HashMap<>(); | ||
| 35 | + map.put("devId", deviceId); | ||
| 36 | + map.put("newName", newName); | ||
| 37 | + map.put("oldName", oldName); | ||
| 38 | + HttpConn.action( | ||
| 39 | + BaseRequest.init() | ||
| 40 | + .service(ApiServiceXiaoJia.class) | ||
| 41 | + .changeDeviceName(map), new NetCallBack<BaseResult>() { | ||
| 42 | + @Override | ||
| 43 | + public void onRequestState(int state) { | ||
| 44 | + | ||
| 45 | + } | ||
| 46 | + | ||
| 47 | + @Override | ||
| 48 | + public void onSuccess(BaseResult data) { | ||
| 49 | + EventBus.getDefault().post(new EventMsg(EventMsg.CHANGE_DEVICE_NAME_SUCCESS, newName)); | ||
| 50 | + QMUITipDialogUtil.dismessDialog(); | ||
| 51 | + AlertUtil.showDeftToast(context, "保存成功"); | ||
| 52 | + onResponseListener.onSuccess(); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + @Override | ||
| 56 | + public void onFailure(String errCode, String errMsg) { | ||
| 57 | + QMUITipDialogUtil.dismessDialog(); | ||
| 58 | + AlertUtil.showDeftToast(context, errMsg); | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + ); | ||
| 62 | + } | ||
| 63 | + | ||
| 64 | + public interface OnResponseListener { | ||
| 65 | + void onSuccess(); | ||
| 66 | + } | ||
| 67 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/presenter/ChangeWifiFragmentPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.presenter; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | + | ||
| 5 | +import com.cnlive.core.libs.base.frame.presenter.BasePresenter; | ||
| 6 | +import com.cnlive.core.libs.base.util.AlertUtil; | ||
| 7 | +import com.cnlive.core.network.BaseResult; | ||
| 8 | +import com.cnlive.core.network.HttpConn; | ||
| 9 | +import com.cnlive.core.network.NetCallBack; | ||
| 10 | +import com.cnlive.core.network.request.BaseRequest; | ||
| 11 | +import com.cnlive.strike.xiaojiaspeaker.frame.view.ChangeWifiFragmentView; | ||
| 12 | +import com.cnlive.strike.xiaojiaspeaker.netWork.ApiServiceXiaoJia; | ||
| 13 | +import com.cnlive.strike.xiaojiaspeaker.util.QMUITipDialogUtil; | ||
| 14 | + | ||
| 15 | +import java.util.HashMap; | ||
| 16 | +import java.util.Map; | ||
| 17 | + | ||
| 18 | +public class ChangeWifiFragmentPresenter extends BasePresenter<ChangeWifiFragmentView> { | ||
| 19 | + private String TAG = "ChangeWifiFragmentPresenter"; | ||
| 20 | + | ||
| 21 | + | ||
| 22 | + public void changeWifi(Activity context, String devId, String wifiName, String wifiPasswd, String wifiMac, OnResponseListener onResponseListener) { | ||
| 23 | + if (null == getView()) { | ||
| 24 | + return; | ||
| 25 | + } | ||
| 26 | + QMUITipDialogUtil.loadingDialog(context, "请稍后...", false); | ||
| 27 | + Map<String, String> map = new HashMap<>(); | ||
| 28 | + map.put("devId", devId); | ||
| 29 | + map.put("name", wifiName); | ||
| 30 | + map.put("passwd", wifiPasswd); | ||
| 31 | + map.put("mac", wifiMac); | ||
| 32 | + HttpConn.action( | ||
| 33 | + BaseRequest.init() | ||
| 34 | + .service(ApiServiceXiaoJia.class) | ||
| 35 | + .changeWiFi(map), new NetCallBack<BaseResult>() { | ||
| 36 | + @Override | ||
| 37 | + public void onRequestState(int state) { | ||
| 38 | + | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + @Override | ||
| 42 | + public void onSuccess(BaseResult data) { | ||
| 43 | + QMUITipDialogUtil.dismessDialog(); | ||
| 44 | + AlertUtil.showDeftToast(context, data.getMessage()); | ||
| 45 | + if (null != onResponseListener) { | ||
| 46 | + onResponseListener.onSuccess(); | ||
| 47 | + } | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @Override | ||
| 51 | + public void onFailure(String errCode, String errMsg) { | ||
| 52 | + QMUITipDialogUtil.dismessDialog(); | ||
| 53 | + AlertUtil.showDeftToast(context, errMsg); | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + ); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + | ||
| 60 | + public interface OnResponseListener { | ||
| 61 | + void onSuccess(); | ||
| 62 | + } | ||
| 63 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/presenter/DeviceDetailPresenter.java
0 → 100644
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/presenter/DeviceManagerFragmentPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.presenter; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.view.View; | ||
| 5 | + | ||
| 6 | +import com.cnlive.core.libs.base.frame.presenter.BasePresenter; | ||
| 7 | +import com.cnlive.core.libs.base.util.AlertUtil; | ||
| 8 | +import com.cnlive.core.network.BaseResult; | ||
| 9 | +import com.cnlive.core.network.HttpConn; | ||
| 10 | +import com.cnlive.core.network.NetCallBack; | ||
| 11 | +import com.cnlive.core.network.request.BaseRequest; | ||
| 12 | +import com.cnlive.strike.xiaojiaspeaker.frame.view.DeviceManagerFragmentView; | ||
| 13 | +import com.cnlive.strike.xiaojiaspeaker.model.message.EventMsg; | ||
| 14 | +import com.cnlive.strike.xiaojiaspeaker.netWork.ApiServiceXiaoJia; | ||
| 15 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.DeviceDetail; | ||
| 16 | +import com.cnlive.strike.xiaojiaspeaker.util.QMUITipDialogUtil; | ||
| 17 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | ||
| 18 | + | ||
| 19 | +import org.greenrobot.eventbus.EventBus; | ||
| 20 | + | ||
| 21 | +import java.util.HashMap; | ||
| 22 | +import java.util.Map; | ||
| 23 | + | ||
| 24 | +import io.reactivex.disposables.Disposable; | ||
| 25 | + | ||
| 26 | +public class DeviceManagerFragmentPresenter extends BasePresenter<DeviceManagerFragmentView> { | ||
| 27 | + public void deleteDevice(Context context, String deviceId, String oldName) { | ||
| 28 | + if (null == getView()) { | ||
| 29 | + return; | ||
| 30 | + } | ||
| 31 | + QMUITipDialogUtil.loadingDialog(context, "请稍后", false); | ||
| 32 | + Map<String, String> map = new HashMap<>(); | ||
| 33 | + map.put("devId", deviceId); | ||
| 34 | + map.put("oldName", oldName); | ||
| 35 | + HttpConn.action( | ||
| 36 | + BaseRequest.init() | ||
| 37 | + .service(ApiServiceXiaoJia.class) | ||
| 38 | + .deleteDevice(map), new NetCallBack<BaseResult>() { | ||
| 39 | + @Override | ||
| 40 | + public void onRequestState(int state) { | ||
| 41 | + | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + @Override | ||
| 45 | + public void onSuccess(BaseResult data) { | ||
| 46 | + QMUITipDialogUtil.dismessDialog(); | ||
| 47 | + EventBus.getDefault().post(new EventMsg(EventMsg.DELETE_DEVICE_NAME_SUCCESS, null)); | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @Override | ||
| 51 | + public void onFailure(String errCode, String errMsg) { | ||
| 52 | + QMUITipDialogUtil.dismessDialog(); | ||
| 53 | + AlertUtil.showDeftToast(context, errMsg); | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + ); | ||
| 57 | + } | ||
| 58 | + | ||
| 59 | + | ||
| 60 | + /** | ||
| 61 | + * 获取设备信息 | ||
| 62 | + * | ||
| 63 | + * @param context | ||
| 64 | + * @param deviceId | ||
| 65 | + */ | ||
| 66 | + public void getDeviceDetailMsg(Context context, String deviceId) { | ||
| 67 | + if (null == getView()) { | ||
| 68 | + return; | ||
| 69 | + } | ||
| 70 | + getView().showLoadingView(); | ||
| 71 | + Map<String, String> map = new HashMap<>(); | ||
| 72 | + map.put("devId", deviceId); | ||
| 73 | + HttpConn.action( | ||
| 74 | + BaseRequest.init() | ||
| 75 | + .service(ApiServiceXiaoJia.class) | ||
| 76 | + .getDeviceDetailMsg(map), new NetCallBack<BaseResult<DeviceDetail>>() { | ||
| 77 | + @Override | ||
| 78 | + public void onRequestState(int state) { | ||
| 79 | + | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + @Override | ||
| 83 | + public void onSuccess(BaseResult<DeviceDetail> data) { | ||
| 84 | + ifViewAttached(view -> view.hideLoadingView()); | ||
| 85 | + ifViewAttached(view -> view.initData(data.getData())); | ||
| 86 | + } | ||
| 87 | + | ||
| 88 | + @Override | ||
| 89 | + public void onFailure(String errCode, String errMsg) { | ||
| 90 | + //显示重试 | ||
| 91 | + ifViewAttached(view -> view.showRetryView(Integer.parseInt(errCode), new View.OnClickListener() { | ||
| 92 | + @Override | ||
| 93 | + public void onClick(View view) { | ||
| 94 | + getDeviceDetailMsg(context, deviceId); | ||
| 95 | + } | ||
| 96 | + })); | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | + ); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/presenter/FirmwareUpdateFragmentPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.presenter; | ||
| 2 | + | ||
| 3 | +import com.cnlive.strike.xiaojiaspeaker.frame.view.FirmwareUpdateFragmentView; | ||
| 4 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | ||
| 5 | + | ||
| 6 | +public class FirmwareUpdateFragmentPresenter extends MvpBasePresenter<FirmwareUpdateFragmentView> { | ||
| 7 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/presenter/InvitFriendPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.presenter; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.util.Log; | ||
| 5 | +import android.view.View; | ||
| 6 | + | ||
| 7 | +import com.cnlive.core.libs.base.frame.presenter.BasePresenter; | ||
| 8 | +import com.cnlive.core.network.BaseResult; | ||
| 9 | +import com.cnlive.core.network.HttpConn; | ||
| 10 | +import com.cnlive.core.network.NetCallBack; | ||
| 11 | +import com.cnlive.core.network.request.BaseRequest; | ||
| 12 | +import com.cnlive.strike.xiaojiaspeaker.frame.view.InvitFriendView; | ||
| 13 | +import com.cnlive.strike.xiaojiaspeaker.netWork.ApiServiceXiaoJia; | ||
| 14 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.RoleNetBean; | ||
| 15 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | ||
| 16 | + | ||
| 17 | +import java.util.HashMap; | ||
| 18 | +import java.util.Map; | ||
| 19 | + | ||
| 20 | +import io.reactivex.disposables.Disposable; | ||
| 21 | + | ||
| 22 | +public class InvitFriendPresenter extends BasePresenter<InvitFriendView> { | ||
| 23 | + | ||
| 24 | + private String TAG = "InvitFriendPresenter"; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 获取角色列表 | ||
| 28 | + * | ||
| 29 | + * @param context | ||
| 30 | + * @param sids | ||
| 31 | + * @param familyId | ||
| 32 | + */ | ||
| 33 | + public void getSetRoleList(Context context, String sids, String familyId) { | ||
| 34 | + if (null == getView()) { | ||
| 35 | + return; | ||
| 36 | + } | ||
| 37 | + getView().showLoadingView(); | ||
| 38 | + Map<String, String> map = new HashMap<>(); | ||
| 39 | + map.put("sids", sids); | ||
| 40 | + map.put("familyId", familyId); | ||
| 41 | + HttpConn.action( | ||
| 42 | + BaseRequest.init() | ||
| 43 | + .service(ApiServiceXiaoJia.class) | ||
| 44 | + .getSetRoleList(map), new NetCallBack<BaseResult<RoleNetBean>>() { | ||
| 45 | + @Override | ||
| 46 | + public void onRequestState(int state) { | ||
| 47 | + | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + @Override | ||
| 51 | + public void onSuccess(BaseResult<RoleNetBean> data) { | ||
| 52 | + ifViewAttached(view -> view.hideLoadingView()); | ||
| 53 | + ifViewAttached(view -> view.setData(data.getData())); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @Override | ||
| 57 | + public void onFailure(String errCode, String errMsg) { | ||
| 58 | + //显示重试 | ||
| 59 | + ifViewAttached(view -> view.hideLoadingView()); | ||
| 60 | + getView().hideLoadingView(); | ||
| 61 | + ifViewAttached(view -> view.showRetryView(Integer.parseInt(errCode), new View.OnClickListener() { | ||
| 62 | + @Override | ||
| 63 | + public void onClick(View view) { | ||
| 64 | + getSetRoleList(context, sids, familyId); | ||
| 65 | + } | ||
| 66 | + })); | ||
| 67 | + } | ||
| 68 | + } | ||
| 69 | + ); | ||
| 70 | + } | ||
| 71 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/presenter/SearchDevicefragmentPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.presenter; | ||
| 2 | + | ||
| 3 | +import com.cnlive.strike.xiaojiaspeaker.frame.view.SearchDevicefragmentView; | ||
| 4 | +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | ||
| 5 | + | ||
| 6 | +public class SearchDevicefragmentPresenter extends MvpBasePresenter<SearchDevicefragmentView> { | ||
| 7 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/presenter/SelectIMFriendPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.presenter; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.view.View; | ||
| 5 | + | ||
| 6 | +import com.cnlive.core.libs.base.frame.presenter.BasePresenter; | ||
| 7 | +import com.cnlive.core.network.BaseResult; | ||
| 8 | +import com.cnlive.core.network.HttpConn; | ||
| 9 | +import com.cnlive.core.network.NetCallBack; | ||
| 10 | +import com.cnlive.core.network.request.BaseRequest; | ||
| 11 | +import com.cnlive.strike.xiaojiaspeaker.frame.view.SelectIMFriendView; | ||
| 12 | +import com.cnlive.strike.xiaojiaspeaker.netWork.ApiServiceXiaoJia; | ||
| 13 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.XiaoJiaContactInfo; | ||
| 14 | + | ||
| 15 | +import java.util.HashMap; | ||
| 16 | +import java.util.Map; | ||
| 17 | + | ||
| 18 | +import io.reactivex.disposables.Disposable; | ||
| 19 | + | ||
| 20 | +public class SelectIMFriendPresenter extends BasePresenter<SelectIMFriendView> { | ||
| 21 | + | ||
| 22 | + private String TAG = "SelectIMFriendPresenter"; | ||
| 23 | + | ||
| 24 | + public void getFamilyMember(Context context, String familyId) { | ||
| 25 | + if (null == getView()) { | ||
| 26 | + return; | ||
| 27 | + } | ||
| 28 | + Map<String, String> map = new HashMap<>(); | ||
| 29 | + map.put("familyId", familyId); | ||
| 30 | + HttpConn.action( | ||
| 31 | + BaseRequest.init() | ||
| 32 | + .service(ApiServiceXiaoJia.class) | ||
| 33 | + .getFamilyMember(map), new NetCallBack<BaseResult<XiaoJiaContactInfo>>() { | ||
| 34 | + @Override | ||
| 35 | + public void onRequestState(int state) { | ||
| 36 | + | ||
| 37 | + } | ||
| 38 | + | ||
| 39 | + @Override | ||
| 40 | + public void onSuccess(BaseResult<XiaoJiaContactInfo> data) { | ||
| 41 | + ifViewAttached(view -> view.getIMData(data.getData())); | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + @Override | ||
| 45 | + public void onFailure(String errCode, String errMsg) { | ||
| 46 | + ifViewAttached(view -> view.hideLoadingView()); | ||
| 47 | + ifViewAttached(view -> view.showRetryView(Integer.parseInt(errCode), new View.OnClickListener() { | ||
| 48 | + @Override | ||
| 49 | + public void onClick(View view) { | ||
| 50 | + getFamilyMember(context, familyId); | ||
| 51 | + } | ||
| 52 | + })); | ||
| 53 | + | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + ); | ||
| 57 | + } | ||
| 58 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/presenter/SelectWifiFragmentPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.presenter; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | + | ||
| 5 | +import com.cnlive.core.libs.base.frame.presenter.BasePresenter; | ||
| 6 | +import com.cnlive.core.libs.base.util.AlertUtil; | ||
| 7 | +import com.cnlive.core.network.BaseResult; | ||
| 8 | +import com.cnlive.core.network.HttpConn; | ||
| 9 | +import com.cnlive.core.network.NetCallBack; | ||
| 10 | +import com.cnlive.core.network.request.BaseRequest; | ||
| 11 | +import com.cnlive.strike.xiaojiaspeaker.frame.view.SelectWifiFragmentView; | ||
| 12 | +import com.cnlive.strike.xiaojiaspeaker.model.message.EventMsg; | ||
| 13 | +import com.cnlive.strike.xiaojiaspeaker.netWork.ApiServiceXiaoJia; | ||
| 14 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.NetworkResultBean; | ||
| 15 | +import com.cnlive.strike.xiaojiaspeaker.util.QMUITipDialogUtil; | ||
| 16 | + | ||
| 17 | +import org.greenrobot.eventbus.EventBus; | ||
| 18 | + | ||
| 19 | +import java.util.HashMap; | ||
| 20 | +import java.util.Map; | ||
| 21 | + | ||
| 22 | +public class SelectWifiFragmentPresenter extends BasePresenter<SelectWifiFragmentView> { | ||
| 23 | + | ||
| 24 | + | ||
| 25 | + public void queryConfigDeviceNetResult(Activity context, String familyId, OnResponseListener onResponseListener) { | ||
| 26 | + Map<String, String> map = new HashMap<>(); | ||
| 27 | + map.put("familyId", familyId); | ||
| 28 | + HttpConn.action( | ||
| 29 | + BaseRequest.init() | ||
| 30 | + .service(ApiServiceXiaoJia.class) | ||
| 31 | + .getNetworkResult(map), new NetCallBack<BaseResult<NetworkResultBean>>() { | ||
| 32 | + @Override | ||
| 33 | + public void onRequestState(int state) { | ||
| 34 | + | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + @Override | ||
| 38 | + public void onSuccess(BaseResult<NetworkResultBean> data) { | ||
| 39 | + QMUITipDialogUtil.dismessDialog(); | ||
| 40 | + if (null != onResponseListener) { | ||
| 41 | + onResponseListener.onSuccess(data.getData()); | ||
| 42 | + } | ||
| 43 | + EventBus.getDefault().post(new EventMsg(EventMsg.CONFIG_NET_SUCCESS, null)); | ||
| 44 | + } | ||
| 45 | + | ||
| 46 | + @Override | ||
| 47 | + public void onFailure(String errCode, String errMsg) { | ||
| 48 | + //显示重试 | ||
| 49 | + QMUITipDialogUtil.dismessDialog(); | ||
| 50 | + AlertUtil.showDeftToast(context, errMsg); | ||
| 51 | + } | ||
| 52 | + } | ||
| 53 | + ); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + | ||
| 57 | +// /** | ||
| 58 | +// * 查询配网情况(这个是调用移动的接口) | ||
| 59 | +// * | ||
| 60 | +// * @param context | ||
| 61 | +// * @param param | ||
| 62 | +// */ | ||
| 63 | +// public void queryConfigDeviceNetResult(Activity context, ConfigDeviceNetParam param) { | ||
| 64 | +// CmccRequest.getInstance(ApiServiceCMCC.class) | ||
| 65 | +// .queryDeviceConfigNet(param) | ||
| 66 | +// .enqueue(new Callback<ConfigDeviceNetResult>() { | ||
| 67 | +// @Override | ||
| 68 | +// public void onResponse(Call<ConfigDeviceNetResult> call, Response<ConfigDeviceNetResult> response) { | ||
| 69 | +// if (null == getView()) { | ||
| 70 | +// return; | ||
| 71 | +// } | ||
| 72 | +// QMUITipDialogUtil.dismessDialog(); | ||
| 73 | +// ConfigDeviceNetResult result = response.body(); | ||
| 74 | +// //响应成功 | ||
| 75 | +// if (CmccRequest.SUCCRSS == result.getResult()) { | ||
| 76 | +// Log.e(TAG, "onResponse: "); | ||
| 77 | +// if ("success".equals(result.getData().getResult())) { | ||
| 78 | +// context.finish(); | ||
| 79 | +// ConnBluetoothSuccessActivity.startActivity(context); | ||
| 80 | +// } else { | ||
| 81 | +// AlertUtil.showDeftToast(context, "配网失败,请稍后重试"); | ||
| 82 | +// } | ||
| 83 | +// } else { | ||
| 84 | +// //响应失败 | ||
| 85 | +// AlertUtil.showDeftToast(context, "配网失败,请稍后重试"); | ||
| 86 | +// } | ||
| 87 | +// } | ||
| 88 | +// | ||
| 89 | +// @Override | ||
| 90 | +// public void onFailure(Call<ConfigDeviceNetResult> call, Throwable t) { | ||
| 91 | +// QMUITipDialogUtil.dismessDialog(); | ||
| 92 | +// } | ||
| 93 | +// }); | ||
| 94 | +// } | ||
| 95 | + | ||
| 96 | + public interface OnResponseListener { | ||
| 97 | + void onSuccess(NetworkResultBean networkResultBean); | ||
| 98 | + } | ||
| 99 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/presenter/SetFriendsRolePresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.presenter; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.view.View; | ||
| 5 | + | ||
| 6 | +import com.cnlive.core.libs.base.frame.presenter.BasePresenter; | ||
| 7 | +import com.cnlive.core.libs.base.util.AlertUtil; | ||
| 8 | +import com.cnlive.core.network.BaseResult; | ||
| 9 | +import com.cnlive.core.network.HttpConn; | ||
| 10 | +import com.cnlive.core.network.NetCallBack; | ||
| 11 | +import com.cnlive.core.network.request.BaseRequest; | ||
| 12 | +import com.cnlive.strike.xiaojiaspeaker.frame.view.SetFriendsRoleView; | ||
| 13 | +import com.cnlive.strike.xiaojiaspeaker.model.message.EventMsg; | ||
| 14 | +import com.cnlive.strike.xiaojiaspeaker.netWork.ApiServiceXiaoJia; | ||
| 15 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.RoleNetBean; | ||
| 16 | +import com.cnlive.strike.xiaojiaspeaker.util.QMUITipDialogUtil; | ||
| 17 | + | ||
| 18 | +import org.greenrobot.eventbus.EventBus; | ||
| 19 | + | ||
| 20 | +import java.util.HashMap; | ||
| 21 | +import java.util.Map; | ||
| 22 | + | ||
| 23 | +public class SetFriendsRolePresenter extends BasePresenter<SetFriendsRoleView> { | ||
| 24 | + | ||
| 25 | + | ||
| 26 | + | ||
| 27 | +// public void queryConfigDeviceNetResult(Activity context, String contactsInvite) { | ||
| 28 | +// InvitFamilyBean1 bean1 = new InvitFamilyBean1(); | ||
| 29 | +// bean1.setType("2"); | ||
| 30 | +// bean1.setContactsInvite(GsonUtil.jsonToList(contactsInvite, InvitFamilyBean1.ContactsInviteBean.class)); | ||
| 31 | +// | ||
| 32 | +// CmccRequest.getInstance(context, ApiServiceCMCC.class) | ||
| 33 | +// .invitFamilyMember(bean1) | ||
| 34 | +// .enqueue(new Callback<APIBaseInfo>() { | ||
| 35 | +// @Override | ||
| 36 | +// public void onResponse(Call<APIBaseInfo> call, Response<APIBaseInfo> response) { | ||
| 37 | +// if (null == getView()) { | ||
| 38 | +// return; | ||
| 39 | +// } | ||
| 40 | +// QMUITipDialogUtil.dismessDialog(); | ||
| 41 | +//// ConfigDeviceNetResult result = response.body(); | ||
| 42 | +//// //响应成功 | ||
| 43 | +//// if (CmccRequest.SUCCRSS == result.getResult()) { | ||
| 44 | +//// Log.e(TAG, "onResponse: "); | ||
| 45 | +//// if ("success".equals(result.getData().getResult())) { | ||
| 46 | +//// context.finish(); | ||
| 47 | +//// ConnBluetoothSuccessActivity.startActivity(context); | ||
| 48 | +//// } else { | ||
| 49 | +//// AlertUtil.showDeftToast(context, "配网失败,请稍后重试"); | ||
| 50 | +//// } | ||
| 51 | +//// } else { | ||
| 52 | +//// //响应失败 | ||
| 53 | +//// AlertUtil.showDeftToast(context, "配网失败,请稍后重试"); | ||
| 54 | +//// } | ||
| 55 | +// } | ||
| 56 | +// | ||
| 57 | +// @Override | ||
| 58 | +// public void onFailure(Call<APIBaseInfo> call, Throwable t) { | ||
| 59 | +// if (null==getView()){ | ||
| 60 | +// return; | ||
| 61 | +// } | ||
| 62 | +// QMUITipDialogUtil.dismessDialog(); | ||
| 63 | +// } | ||
| 64 | +// }); | ||
| 65 | +// } | ||
| 66 | + | ||
| 67 | + /** | ||
| 68 | + * 设置家庭角色 | ||
| 69 | + * | ||
| 70 | + * @param context | ||
| 71 | + * @param contactsInvite | ||
| 72 | + */ | ||
| 73 | + public void invitFamilyMember(Context context, String contactsInvite) { | ||
| 74 | + if (null == getView()) { | ||
| 75 | + return; | ||
| 76 | + } | ||
| 77 | + QMUITipDialogUtil.loadingDialog(context, "请稍后", true); | ||
| 78 | + Map<String, String> map = new HashMap<>(); | ||
| 79 | + map.put("type", "2");//联系人邀请 | ||
| 80 | + map.put("contactsInvite", contactsInvite); | ||
| 81 | + HttpConn.action( | ||
| 82 | + BaseRequest.init() | ||
| 83 | + .service(ApiServiceXiaoJia.class) | ||
| 84 | + .invitFamilyMember(map), new NetCallBack<BaseResult>() { | ||
| 85 | + @Override | ||
| 86 | + public void onRequestState(int state) { | ||
| 87 | + | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + @Override | ||
| 91 | + public void onSuccess(BaseResult data) { | ||
| 92 | + QMUITipDialogUtil.dismessDialog(); | ||
| 93 | + AlertUtil.showDeftToast(context, "邀请成功"); | ||
| 94 | + EventBus.getDefault().post(new EventMsg(EventMsg.INVIT_FRIEND_SUCCESS, null)); | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + @Override | ||
| 98 | + public void onFailure(String errCode, String errMsg) { | ||
| 99 | + QMUITipDialogUtil.dismessDialog(); | ||
| 100 | + AlertUtil.showDeftToast(context, errCode); | ||
| 101 | + //有角色被占用 | ||
| 102 | + if ("4313".equals(errCode)) { | ||
| 103 | + EventBus.getDefault().post(new EventMsg(EventMsg.HAS_ROLE_USED, null)); | ||
| 104 | + } | ||
| 105 | + } | ||
| 106 | + } | ||
| 107 | + ); | ||
| 108 | + } | ||
| 109 | + | ||
| 110 | + | ||
| 111 | + /** | ||
| 112 | + * 获取用户角色 | ||
| 113 | + * | ||
| 114 | + * @param context | ||
| 115 | + * @param sids | ||
| 116 | + * @param familyId | ||
| 117 | + */ | ||
| 118 | + public void getSetRoleList(Context context, String sids, String familyId) { | ||
| 119 | + if (null == getView()) { | ||
| 120 | + return; | ||
| 121 | + } | ||
| 122 | + getView().showLoadingView(); | ||
| 123 | + Map<String, String> map = new HashMap<>(); | ||
| 124 | + map.put("sids", sids); | ||
| 125 | + map.put("familyId", familyId); | ||
| 126 | + HttpConn.action( | ||
| 127 | + BaseRequest.init() | ||
| 128 | + .service(ApiServiceXiaoJia.class) | ||
| 129 | + .getSetRoleList(map), new NetCallBack<BaseResult<RoleNetBean>>() { | ||
| 130 | + @Override | ||
| 131 | + public void onRequestState(int state) { | ||
| 132 | + | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + @Override | ||
| 136 | + public void onSuccess(BaseResult<RoleNetBean> data) { | ||
| 137 | + ifViewAttached(view -> view.hideLoadingView()); | ||
| 138 | + ifViewAttached(view -> view.initView(data.getData())); | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + @Override | ||
| 142 | + public void onFailure(String errCode, String errMsg) { | ||
| 143 | + //显示重试 | ||
| 144 | + ifViewAttached(view -> view.showRetryView(Integer.parseInt(errCode), new View.OnClickListener() { | ||
| 145 | + @Override | ||
| 146 | + public void onClick(View view) { | ||
| 147 | + getSetRoleList(context, sids, familyId); | ||
| 148 | + } | ||
| 149 | + })); | ||
| 150 | + | ||
| 151 | + } | ||
| 152 | + } | ||
| 153 | + ); | ||
| 154 | + } | ||
| 155 | + | ||
| 156 | + public interface OnResposeListener { | ||
| 157 | + void onSuccess(); | ||
| 158 | + } | ||
| 159 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/presenter/UserManagerPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.presenter; | ||
| 2 | + | ||
| 3 | +import android.content.Context; | ||
| 4 | +import android.text.TextUtils; | ||
| 5 | +import android.view.View; | ||
| 6 | + | ||
| 7 | +import com.cnlive.core.libs.base.frame.presenter.BasePresenter; | ||
| 8 | +import com.cnlive.core.libs.base.util.AlertUtil; | ||
| 9 | +import com.cnlive.core.network.BaseResult; | ||
| 10 | +import com.cnlive.core.network.HttpConn; | ||
| 11 | +import com.cnlive.core.network.NetCallBack; | ||
| 12 | +import com.cnlive.core.network.request.BaseRequest; | ||
| 13 | +import com.cnlive.strike.xiaojiaspeaker.frame.view.UserManagerView; | ||
| 14 | +import com.cnlive.strike.xiaojiaspeaker.netWork.ApiServiceXiaoJia; | ||
| 15 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.FamilyRoleBean; | ||
| 16 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.RoleNetBean; | ||
| 17 | +import com.cnlive.strike.xiaojiaspeaker.util.QMUITipDialogUtil; | ||
| 18 | + | ||
| 19 | +import java.util.HashMap; | ||
| 20 | +import java.util.Map; | ||
| 21 | + | ||
| 22 | +public class UserManagerPresenter extends BasePresenter<UserManagerView> { | ||
| 23 | + | ||
| 24 | + private String TAG = "UserManagerPresenter"; | ||
| 25 | + | ||
| 26 | + /** | ||
| 27 | + * 修改成员角色 | ||
| 28 | + * | ||
| 29 | + * @param context | ||
| 30 | + * @param sid | ||
| 31 | + * @param familyId | ||
| 32 | + * @param role | ||
| 33 | + */ | ||
| 34 | + public void changeMemberRole(Context context, String sid, String familyId, String role, OnResposeListener onResposeListener) { | ||
| 35 | + if (null == getView()) { | ||
| 36 | + return; | ||
| 37 | + } | ||
| 38 | + QMUITipDialogUtil.loadingDialog(context, "请稍后...", false); | ||
| 39 | + Map<String, String> map = new HashMap<>(); | ||
| 40 | + map.put("sid", sid); | ||
| 41 | + map.put("familyId", familyId); | ||
| 42 | + if (!TextUtils.isEmpty(role)) { | ||
| 43 | + map.put("role", role); | ||
| 44 | + } | ||
| 45 | + HttpConn.action( | ||
| 46 | + BaseRequest.init() | ||
| 47 | + .service(ApiServiceXiaoJia.class) | ||
| 48 | + .changeMemberRole(map), new NetCallBack<BaseResult>() { | ||
| 49 | + @Override | ||
| 50 | + public void onRequestState(int state) { | ||
| 51 | + | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @Override | ||
| 55 | + public void onSuccess(BaseResult data) { | ||
| 56 | + QMUITipDialogUtil.dismessDialog(); | ||
| 57 | + if (null != onResposeListener) { | ||
| 58 | + onResposeListener.onSuccess(); | ||
| 59 | + } | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public void onFailure(String errCode, String errMsg) { | ||
| 64 | + QMUITipDialogUtil.dismessDialog(); | ||
| 65 | + AlertUtil.showDeftToast(context,errMsg); | ||
| 66 | + } | ||
| 67 | + } | ||
| 68 | + ); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + /** | ||
| 72 | + * 获取角色列表 | ||
| 73 | + * | ||
| 74 | + * @param context | ||
| 75 | + * @param sid | ||
| 76 | + * @param familyId | ||
| 77 | + * @param phone | ||
| 78 | + */ | ||
| 79 | + public void getFamilyRole(Context context, String sid, String familyId, String phone) { | ||
| 80 | + if (null == getView()) { | ||
| 81 | + return; | ||
| 82 | + } | ||
| 83 | + getView().showLoadingView(); | ||
| 84 | + Map<String, String> map = new HashMap<>(); | ||
| 85 | + map.put("sid", sid); | ||
| 86 | + map.put("familyId", familyId); | ||
| 87 | + map.put("phone", phone); | ||
| 88 | + HttpConn.action( | ||
| 89 | + BaseRequest.init() | ||
| 90 | + .service(ApiServiceXiaoJia.class) | ||
| 91 | + .getFamilyRole(map), new NetCallBack<BaseResult<FamilyRoleBean>>() { | ||
| 92 | + @Override | ||
| 93 | + public void onRequestState(int state) { | ||
| 94 | + | ||
| 95 | + } | ||
| 96 | + | ||
| 97 | + @Override | ||
| 98 | + public void onSuccess(BaseResult<FamilyRoleBean> data) { | ||
| 99 | + ifViewAttached(view -> view.hideLoadingView()); | ||
| 100 | + ifViewAttached(view -> view.initView(data.getData())); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + @Override | ||
| 104 | + public void onFailure(String errCode, String errMsg) { | ||
| 105 | + //显示重试 | ||
| 106 | + ifViewAttached(view -> view.showRetryView(Integer.parseInt(errCode), new View.OnClickListener() { | ||
| 107 | + @Override | ||
| 108 | + public void onClick(View view) { | ||
| 109 | + getFamilyRole(context, sid, familyId, phone); | ||
| 110 | + } | ||
| 111 | + })); | ||
| 112 | + } | ||
| 113 | + } | ||
| 114 | + ); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + | ||
| 118 | + public void getSetRoleList(Context context, String sids, String familyId, FamilyRoleBean.FamilyRoleListBean bean) { | ||
| 119 | + if (null == getView()) { | ||
| 120 | + return; | ||
| 121 | + } | ||
| 122 | + QMUITipDialogUtil.loadingDialog(context, "请稍后...", false); | ||
| 123 | + Map<String, String> map = new HashMap<>(); | ||
| 124 | + map.put("sids", sids); | ||
| 125 | + map.put("familyId", familyId); | ||
| 126 | + HttpConn.action( | ||
| 127 | + BaseRequest.init() | ||
| 128 | + .service(ApiServiceXiaoJia.class) | ||
| 129 | + .getSetRoleList(map), new NetCallBack<BaseResult<RoleNetBean>>() { | ||
| 130 | + @Override | ||
| 131 | + public void onRequestState(int state) { | ||
| 132 | + | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + @Override | ||
| 136 | + public void onSuccess(BaseResult<RoleNetBean> data) { | ||
| 137 | + QMUITipDialogUtil.dismessDialog(); | ||
| 138 | + ifViewAttached(view -> view.initRoleDialog(data.getData(), bean)); | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | + @Override | ||
| 142 | + public void onFailure(String errCode, String errMsg) { | ||
| 143 | + QMUITipDialogUtil.dismessDialog(); | ||
| 144 | + AlertUtil.showDeftToast(context,errMsg); | ||
| 145 | + } | ||
| 146 | + } | ||
| 147 | + ); | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + public interface OnResposeListener { | ||
| 151 | + void onSuccess(); | ||
| 152 | + } | ||
| 153 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/AllDeviceFragmentView.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.view; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.util.Log; | ||
| 5 | +import android.view.View; | ||
| 6 | + | ||
| 7 | +import androidx.recyclerview.widget.LinearLayoutManager; | ||
| 8 | + | ||
| 9 | +import com.cnlive.core.libs.base.frame.view.BaseView; | ||
| 10 | +import com.cnlive.strike.xiaojiaspeaker.R; | ||
| 11 | +import com.cnlive.strike.xiaojiaspeaker.commonInfo.XiaoJIaCommInfo; | ||
| 12 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.FamilyListBean; | ||
| 13 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.BlueToothStep1Activity; | ||
| 14 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.DeviceDetailActivity; | ||
| 15 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.RemoteControlActivity; | ||
| 16 | +import com.cnlive.strike.xiaojiaspeaker.ui.adapter.AllDeviceAdapter; | ||
| 17 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.AllDeviceFragment; | ||
| 18 | +import com.qmuiteam.qmui.alpha.QMUIAlphaImageButton; | ||
| 19 | + | ||
| 20 | +import java.util.ArrayList; | ||
| 21 | +import java.util.List; | ||
| 22 | + | ||
| 23 | +public class AllDeviceFragmentView extends BaseView { | ||
| 24 | + private AllDeviceFragment fragment; | ||
| 25 | + private AllDeviceAdapter adapter; | ||
| 26 | + private List<FamilyListBean.UsersBeanX.DeviceListBean> allDeviceInfoList; | ||
| 27 | + private FamilyListBean familyListBean; | ||
| 28 | + private QMUIAlphaImageButton remoteButton;//远程控制按钮 | ||
| 29 | + | ||
| 30 | + public AllDeviceFragmentView(AllDeviceFragment fragment) { | ||
| 31 | + this.fragment = fragment; | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + public Activity getContext() { | ||
| 35 | + return fragment == null ? null : fragment.getActivity(); | ||
| 36 | + } | ||
| 37 | + | ||
| 38 | + public void initView() { | ||
| 39 | + if (null == remoteButton) { | ||
| 40 | + remoteButton = fragment.binding.topbar.addRightImageButton(R.drawable.icon_xiaojia_menu, R.id.right_menu); | ||
| 41 | + remoteButton.setOnClickListener(new View.OnClickListener() { | ||
| 42 | + @Override | ||
| 43 | + public void onClick(View v) { | ||
| 44 | + //远程控制 | ||
| 45 | + RemoteControlActivity.startActivity(getContext()); | ||
| 46 | + } | ||
| 47 | + }); | ||
| 48 | + } | ||
| 49 | + remoteButton.setVisibility(View.GONE); | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public void initAllDeviceList(FamilyListBean familyListBean) { | ||
| 53 | + this.familyListBean = familyListBean; | ||
| 54 | + this.allDeviceInfoList = new ArrayList<>(); | ||
| 55 | + if (null != familyListBean && null != familyListBean.getUsers()) { | ||
| 56 | + int index = 0; | ||
| 57 | + for (FamilyListBean.UsersBeanX usersBean : familyListBean.getUsers()) { | ||
| 58 | + | ||
| 59 | + //存储自己为主人的家庭 | ||
| 60 | + if (FamilyListBean.THE_HOST == usersBean.getIsMaster()) { | ||
| 61 | + Log.e(TAG, "getId: " + usersBean.getUserId()); | ||
| 62 | + Log.e(TAG, "getToken: " + usersBean.getToken()); | ||
| 63 | + //存储家庭id | ||
| 64 | + XiaoJIaCommInfo.setFamilyId(getContext(), usersBean.getId()); | ||
| 65 | + //存储移动id(用于配网) | ||
| 66 | + XiaoJIaCommInfo.setCMCCId(getContext(), usersBean.getUserId()); | ||
| 67 | + //存储移动token | ||
| 68 | + XiaoJIaCommInfo.setToken(getContext(), usersBean.getToken()); | ||
| 69 | + } | ||
| 70 | + | ||
| 71 | + for (FamilyListBean.UsersBeanX.DeviceListBean deviceListBean : usersBean.getDeviceList()) { | ||
| 72 | + deviceListBean.setParentPosition(index); | ||
| 73 | + } | ||
| 74 | + //存储移动id | ||
| 75 | + if (null != usersBean.getDeviceList()) { | ||
| 76 | + this.allDeviceInfoList.addAll(usersBean.getDeviceList()); | ||
| 77 | + } | ||
| 78 | + index++; | ||
| 79 | + } | ||
| 80 | + } | ||
| 81 | + if (null == allDeviceInfoList || allDeviceInfoList.size() == 0) { | ||
| 82 | + XiaoJIaCommInfo.setUserIsBind(getContext(), false); | ||
| 83 | + initTopBarBtn(false); | ||
| 84 | + | ||
| 85 | + } else { | ||
| 86 | + XiaoJIaCommInfo.setUserIsBind(getContext(), true); | ||
| 87 | + initTopBarBtn(true); | ||
| 88 | + } | ||
| 89 | + adapter = new AllDeviceAdapter(getContext(), allDeviceInfoList); | ||
| 90 | + fragment.binding.rvAllDevice.setLayoutManager(new LinearLayoutManager(getContext())); | ||
| 91 | + fragment.binding.rvAllDevice.setAdapter(adapter); | ||
| 92 | + adapter.setOnAddClickListener(new AllDeviceAdapter.OnAddClickListener() { | ||
| 93 | + @Override | ||
| 94 | + public void onAddClick() { | ||
| 95 | + BlueToothStep1Activity.startActivity(fragment.getActivity()); | ||
| 96 | + } | ||
| 97 | + }); | ||
| 98 | + adapter.setOnItemClickListener(new AllDeviceAdapter.OnItemClickListener() { | ||
| 99 | + @Override | ||
| 100 | + public void onItemClick(int position, FamilyListBean.UsersBeanX.DeviceListBean AllDeviceInfo) { | ||
| 101 | + DeviceDetailActivity.startActivity(fragment.getActivity(), AllDeviceInfo, familyListBean.getUsers().get(AllDeviceInfo.getParentPosition())); | ||
| 102 | + } | ||
| 103 | + }); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + | ||
| 107 | + /** | ||
| 108 | + * 显示loading | ||
| 109 | + */ | ||
| 110 | + public void showLoadingView() { | ||
| 111 | + if (fragment.binding.emptyLayout == null) { | ||
| 112 | + return; | ||
| 113 | + } | ||
| 114 | + fragment.binding.emptyLayout.show(true); | ||
| 115 | + } | ||
| 116 | + | ||
| 117 | + /** | ||
| 118 | + * 隐藏loading | ||
| 119 | + */ | ||
| 120 | + public void hideLoadingView() { | ||
| 121 | + if (fragment.binding.emptyLayout == null) { | ||
| 122 | + return; | ||
| 123 | + } | ||
| 124 | + fragment.binding.emptyLayout.hide(); | ||
| 125 | + } | ||
| 126 | + | ||
| 127 | + /** | ||
| 128 | + * 显示重试页面 | ||
| 129 | + * | ||
| 130 | + * @param errorCode | ||
| 131 | + * @param listener | ||
| 132 | + */ | ||
| 133 | + public void showRetryView(int errorCode, View.OnClickListener listener) { | ||
| 134 | + //显示空视图 | ||
| 135 | + fragment.binding.emptyLayout.setVisibility(View.VISIBLE); | ||
| 136 | + | ||
| 137 | + if (fragment.binding.emptyLayout == null) return; | ||
| 138 | + String titleText = ""; | ||
| 139 | + String detailText = ""; | ||
| 140 | + if (errorCode == -3) { | ||
| 141 | + titleText = getContext().getString(R.string.msg_failed_network_title); | ||
| 142 | + detailText = getContext().getString(R.string.msg_failed_network_detail); | ||
| 143 | + } else { | ||
| 144 | + titleText = getContext().getString(R.string.msg_failed_other_title); | ||
| 145 | + detailText = getContext().getString(R.string.msg_failed_other_detail); | ||
| 146 | + } | ||
| 147 | + fragment.binding.emptyLayout.show(false, titleText, detailText, getContext().getString(R.string.retry), R.drawable.wufalianjie, listener); | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + public void initTopBarBtn(boolean isShowRemote) { | ||
| 151 | + | ||
| 152 | + if (isShowRemote) { | ||
| 153 | + //控制 | ||
| 154 | + remoteButton.setVisibility(View.VISIBLE); | ||
| 155 | + }else { | ||
| 156 | + remoteButton.setVisibility(View.GONE); | ||
| 157 | + } | ||
| 158 | + } | ||
| 159 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/ChangeDeviceNameView.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.view; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.text.Editable; | ||
| 5 | +import android.text.TextWatcher; | ||
| 6 | +import android.view.View; | ||
| 7 | + | ||
| 8 | +import androidx.core.content.ContextCompat; | ||
| 9 | + | ||
| 10 | +import com.cnlive.core.libs.base.frame.view.BaseView; | ||
| 11 | +import com.cnlive.strike.xiaojiaspeaker.R; | ||
| 12 | +import com.cnlive.strike.xiaojiaspeaker.frame.presenter.ChangeDeviceNamePresenter; | ||
| 13 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.ChangeDeviceNameFragment; | ||
| 14 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 15 | + | ||
| 16 | +public class ChangeDeviceNameView extends BaseView { | ||
| 17 | + private ChangeDeviceNameFragment fragment; | ||
| 18 | + private String deviceId; | ||
| 19 | + private String oldName; | ||
| 20 | + | ||
| 21 | + public ChangeDeviceNameView(ChangeDeviceNameFragment fragment) { | ||
| 22 | + this.fragment = fragment; | ||
| 23 | + } | ||
| 24 | + | ||
| 25 | + public Activity getContext() { | ||
| 26 | + return fragment == null ? null : fragment.getActivity(); | ||
| 27 | + } | ||
| 28 | + | ||
| 29 | + public void initView(String deviceId, String oldName) { | ||
| 30 | + setBtnCantClick(); | ||
| 31 | + this.deviceId = deviceId; | ||
| 32 | + this.oldName = oldName; | ||
| 33 | + //编辑框 | ||
| 34 | + fragment.binding.etName.addTextChangedListener(new TextWatcher() { | ||
| 35 | + @Override | ||
| 36 | + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { | ||
| 37 | + | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + @Override | ||
| 41 | + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { | ||
| 42 | + if (null != charSequence && charSequence.length() > 2) { | ||
| 43 | + fragment.binding.ivClose.setVisibility(View.VISIBLE); | ||
| 44 | + setBtnClick(); | ||
| 45 | + } else { | ||
| 46 | + fragment.binding.ivClose.setVisibility(View.GONE); | ||
| 47 | + setBtnCantClick(); | ||
| 48 | + } | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + @Override | ||
| 52 | + public void afterTextChanged(Editable editable) { | ||
| 53 | + | ||
| 54 | + } | ||
| 55 | + }); | ||
| 56 | + //清除按钮点击事件 | ||
| 57 | + fragment.binding.ivClose.setOnClickListener(new View.OnClickListener() { | ||
| 58 | + @Override | ||
| 59 | + public void onClick(View view) { | ||
| 60 | + fragment.binding.etName.setText(""); | ||
| 61 | + } | ||
| 62 | + }); | ||
| 63 | + //设置音箱名称 | ||
| 64 | + fragment.binding.btnNext.setOnClickListener(new View.OnClickListener() { | ||
| 65 | + @Override | ||
| 66 | + public void onClick(View view) { | ||
| 67 | + if ("0".equals(fragment.binding.btnNext.getTag().toString())) { | ||
| 68 | + return; | ||
| 69 | + } | ||
| 70 | + fragment.getPresenter().changeDeviceName(getContext(), deviceId,oldName, fragment.binding.etName.getText().toString(), new ChangeDeviceNamePresenter.OnResponseListener() { | ||
| 71 | + @Override | ||
| 72 | + public void onSuccess() { | ||
| 73 | + if (null != getContext()) { | ||
| 74 | + getContext().finish(); | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + }); | ||
| 78 | + } | ||
| 79 | + }); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + | ||
| 83 | + /** | ||
| 84 | + * 设置绑定按钮不可点击 | ||
| 85 | + */ | ||
| 86 | + private void setBtnCantClick() { | ||
| 87 | + fragment.binding.btnNext.setClickable(false); | ||
| 88 | + fragment.binding.btnNext.setFocusable(false); | ||
| 89 | + fragment.binding.btnNext.setTag("0"); | ||
| 90 | + fragment.binding.btnNext.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_xiaojia_btn_press)); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + /** | ||
| 94 | + * 设置绑定按钮可点击 | ||
| 95 | + */ | ||
| 96 | + private void setBtnClick() { | ||
| 97 | + fragment.binding.btnNext.setClickable(true); | ||
| 98 | + fragment.binding.btnNext.setFocusable(true); | ||
| 99 | + fragment.binding.btnNext.setTag("1"); | ||
| 100 | + fragment.binding.btnNext.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.selector_xiaojia_btn_green)); | ||
| 101 | + } | ||
| 102 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/ChangeWifiFragmentView.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.view; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.graphics.Typeface; | ||
| 5 | +import android.net.wifi.ScanResult; | ||
| 6 | +import android.text.TextUtils; | ||
| 7 | +import android.util.Log; | ||
| 8 | +import android.view.View; | ||
| 9 | + | ||
| 10 | +import androidx.core.content.ContextCompat; | ||
| 11 | +import androidx.recyclerview.widget.LinearLayoutManager; | ||
| 12 | + | ||
| 13 | +import com.cnlive.core.libs.base.frame.view.BaseView; | ||
| 14 | +import com.cnlive.core.libs.base.util.AlertUtil; | ||
| 15 | +import com.cnlive.strike.xiaojiaspeaker.R; | ||
| 16 | +import com.cnlive.strike.xiaojiaspeaker.frame.presenter.ChangeWifiFragmentPresenter; | ||
| 17 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.FamilyListBean; | ||
| 18 | +import com.cnlive.strike.xiaojiaspeaker.ui.adapter.WifiRecycleAdapter; | ||
| 19 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.ChangeWifiFragment; | ||
| 20 | +import com.cnlive.strike.xiaojiaspeaker.ui.widget.TipDialog; | ||
| 21 | +import com.cnlive.strike.xiaojiaspeaker.ui.widget.WifiPwdDialog; | ||
| 22 | +import com.cnlive.strike.xiaojiaspeaker.util.WifiUtils; | ||
| 23 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 24 | + | ||
| 25 | +import java.util.ArrayList; | ||
| 26 | +import java.util.List; | ||
| 27 | + | ||
| 28 | +public class ChangeWifiFragmentView extends BaseView { | ||
| 29 | + private ChangeWifiFragment fragment; | ||
| 30 | + private WifiRecycleAdapter adapter; | ||
| 31 | + private List<ScanResult> results = new ArrayList<>(); | ||
| 32 | + private WifiUtils wifiUtils; | ||
| 33 | + private WifiPwdDialog wifiPwdDialog; | ||
| 34 | + private TipDialog errorDialog; | ||
| 35 | + private String SSID; | ||
| 36 | + private String BSSID; | ||
| 37 | + private FamilyListBean.UsersBeanX currentUser; | ||
| 38 | + private String sn; | ||
| 39 | + | ||
| 40 | + public ChangeWifiFragmentView(ChangeWifiFragment fragment) { | ||
| 41 | + this.fragment = fragment; | ||
| 42 | + wifiUtils = new WifiUtils(fragment.getActivity()); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public Activity getContext() { | ||
| 46 | + return fragment == null ? null : fragment.getActivity(); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + public void initWifiList(String sn, FamilyListBean.UsersBeanX currentUser) { | ||
| 50 | + this.currentUser = currentUser; | ||
| 51 | + this.sn = sn; | ||
| 52 | + showLoading(); | ||
| 53 | + initWifiPwdDialog(); | ||
| 54 | + initErrorDialog(); | ||
| 55 | + if (null == adapter) { | ||
| 56 | + adapter = new WifiRecycleAdapter(getContext(), results); | ||
| 57 | + fragment.binding.rvWifi.setLayoutManager(new LinearLayoutManager(getContext())); | ||
| 58 | + fragment.binding.rvWifi.setAdapter(adapter); | ||
| 59 | + } | ||
| 60 | + adapter.setOnItemClickListener(new WifiRecycleAdapter.onItemClickListener() { | ||
| 61 | + @Override | ||
| 62 | + public void onItemClick(int position, ScanResult scanResult) { | ||
| 63 | + String encryptionType = scanResult.capabilities; | ||
| 64 | + SSID = scanResult.SSID; | ||
| 65 | + BSSID = scanResult.BSSID; | ||
| 66 | + if (TextUtils.isEmpty(currentUser.getUserId()) || TextUtils.isEmpty(currentUser.getId())) { | ||
| 67 | + AlertUtil.showDeftToast(getContext(), "参数异常,请稍后重试!"); | ||
| 68 | + return; | ||
| 69 | + } | ||
| 70 | + //判断是否需要输入密码 | ||
| 71 | + if (!encryptionType.contains("WEP") && !encryptionType.contains("PSK") && !encryptionType.contains("EAP")) { | ||
| 72 | + Log.e(TAG, "onItemClick: 不需要密码"); | ||
| 73 | + if (!TextUtils.isEmpty(scanResult.SSID) && !TextUtils.isEmpty(scanResult.BSSID)) { | ||
| 74 | + changeWifi(sn, scanResult.SSID, "", scanResult.BSSID); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + } else { | ||
| 78 | + //需要密码 | ||
| 79 | + if (!wifiPwdDialog.isShowing()) { | ||
| 80 | + wifiPwdDialog.setMsgTip(scanResult.SSID); | ||
| 81 | + wifiPwdDialog.show(); | ||
| 82 | + } | ||
| 83 | + } | ||
| 84 | + } | ||
| 85 | + }); | ||
| 86 | + wifiUtils.startScanWifi(); | ||
| 87 | + } | ||
| 88 | + | ||
| 89 | + private void initErrorDialog() { | ||
| 90 | + errorDialog = new TipDialog(getContext(), "", "关闭", R.color.btn_green, new TipDialog.DialogInterface() { | ||
| 91 | + @Override | ||
| 92 | + public void onClick(TipDialog dialog) { | ||
| 93 | + dialog.dismiss(); | ||
| 94 | + } | ||
| 95 | + }); | ||
| 96 | + errorDialog.setTipTextStyle(Typeface.DEFAULT); | ||
| 97 | + errorDialog.setTipTextSize(16); | ||
| 98 | + errorDialog.setCancelable(false); | ||
| 99 | + errorDialog.setCanceledOnTouchOutside(false); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + private void initRefreshLayout() { | ||
| 103 | +// fragment.binding.refreshLayout.setEnableLoadMore(false); | ||
| 104 | +// fragment.binding.refreshLayout.setOnRefreshListener(new OnRefreshListener() { | ||
| 105 | +// @Override | ||
| 106 | +// public void onRefresh(@NonNull RefreshLayout refreshLayout) { | ||
| 107 | +// showLoading(); | ||
| 108 | +// wifiUtils.startScanWifi(); | ||
| 109 | +// } | ||
| 110 | +// }); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + public void changeWifi(String sn, String wifiName, String wifiPwd, String wifiMac) { | ||
| 114 | + if (null == getContext()) { | ||
| 115 | + return; | ||
| 116 | + } | ||
| 117 | + fragment.getPresenter().changeWifi(getContext(), sn, wifiName, wifiPwd, wifiMac, new ChangeWifiFragmentPresenter.OnResponseListener() { | ||
| 118 | + @Override | ||
| 119 | + public void onSuccess() { | ||
| 120 | + | ||
| 121 | + } | ||
| 122 | + }); | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + private void initWifiPwdDialog() { | ||
| 126 | + wifiPwdDialog = new WifiPwdDialog(getContext(), "", "取消", new WifiPwdDialog.DialogInterface() { | ||
| 127 | + @Override | ||
| 128 | + public void onClick(WifiPwdDialog dialog) { | ||
| 129 | + dialog.dismiss(); | ||
| 130 | + } | ||
| 131 | + }, "确定", new WifiPwdDialog.ConnDialogInterface() { | ||
| 132 | + @Override | ||
| 133 | + public void onClick(WifiPwdDialog dialog, String pwd) { | ||
| 134 | + if (!TextUtils.isEmpty(pwd) && !TextUtils.isEmpty(SSID)) { | ||
| 135 | + dialog.dismiss(); | ||
| 136 | + if (!TextUtils.isEmpty(SSID) && !TextUtils.isEmpty(BSSID)) { | ||
| 137 | + changeWifi(sn, SSID, pwd, BSSID); | ||
| 138 | + } | ||
| 139 | + } else { | ||
| 140 | + AlertUtil.showDeftToast(getContext(), "密码不能为空"); | ||
| 141 | + } | ||
| 142 | + } | ||
| 143 | + }); | ||
| 144 | + wifiPwdDialog.setLeftBtnColor(R.color.color_999999); | ||
| 145 | + wifiPwdDialog.setRightBtnColor(R.color.btn_green); | ||
| 146 | + wifiPwdDialog.setCancelable(false); | ||
| 147 | + wifiPwdDialog.setCanceledOnTouchOutside(false); | ||
| 148 | + } | ||
| 149 | + | ||
| 150 | + public void updateWifiList() { | ||
| 151 | + hideLoading(); | ||
| 152 | + List<ScanResult> scanResults = wifiUtils.getScanResults(); | ||
| 153 | + if (null != scanResults && null != results) { | ||
| 154 | + results.clear(); | ||
| 155 | + results.addAll(scanResults); | ||
| 156 | + if (null != adapter) { | ||
| 157 | + adapter.notifyDataSetChanged(); | ||
| 158 | + } | ||
| 159 | + } | ||
| 160 | + } | ||
| 161 | + | ||
| 162 | + public void showLoading() { | ||
| 163 | + if (null == getContext()) { | ||
| 164 | + return; | ||
| 165 | + } | ||
| 166 | + fragment.binding.avLoading.show(); | ||
| 167 | + fragment.binding.llLoading.setVisibility(View.VISIBLE); | ||
| 168 | + //设置按钮不可点击 | ||
| 169 | + fragment.binding.btnNext.setClickable(false); | ||
| 170 | + fragment.binding.btnNext.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_xiaojia_btn_press)); | ||
| 171 | + | ||
| 172 | + } | ||
| 173 | + | ||
| 174 | + public void hideLoading() { | ||
| 175 | + if (null == getContext()) { | ||
| 176 | + return; | ||
| 177 | + } | ||
| 178 | +// fragment.binding.refreshLayout.finishRefresh(); | ||
| 179 | + fragment.binding.avLoading.hide(); | ||
| 180 | + fragment.binding.llLoading.setVisibility(View.GONE); | ||
| 181 | + //设置按钮可点击 | ||
| 182 | + fragment.binding.btnNext.setClickable(true); | ||
| 183 | + fragment.binding.btnNext.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.selector_xiaojia_btn_green)); | ||
| 184 | + } | ||
| 185 | + | ||
| 186 | + | ||
| 187 | +// private void queryDeviceConfigNet(Activity activity, String fromId) { | ||
| 188 | +// ConfigDeviceNetParam param = new ConfigDeviceNetParam(); | ||
| 189 | +// param.setAction("mc/getWifiResult"); | ||
| 190 | +// ConfigDeviceNetParam.DataBean dataBean = new ConfigDeviceNetParam.DataBean(); | ||
| 191 | +// dataBean.setFrom("he:28850150e8bd4c830314819939361b77"); | ||
| 192 | +// dataBean.setMyid("he:28850150e8bd4c830314819939361b77"); | ||
| 193 | +// dataBean.setToken("6fdff0f39ec659c94dd12cdc32937e9d"); | ||
| 194 | +// param.setData(dataBean); | ||
| 195 | +// fragment.getPresenter().queryConfigDeviceNetResult(activity, param); | ||
| 196 | +// } | ||
| 197 | +} | ||
| 198 | + |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/DeviceDetailView.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.view; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.text.TextUtils; | ||
| 5 | +import android.view.View; | ||
| 6 | + | ||
| 7 | +import com.cnlive.core.libs.base.frame.view.BaseView; | ||
| 8 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.FamilyListBean; | ||
| 9 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.DeviceInstructionActivity; | ||
| 10 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.DeviceManagerActivity; | ||
| 11 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.UserManagerActivity; | ||
| 12 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.DeviceDetailFragment; | ||
| 13 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 14 | + | ||
| 15 | +public class DeviceDetailView extends BaseView { | ||
| 16 | + private DeviceDetailFragment fragment; | ||
| 17 | + private FamilyListBean.UsersBeanX.DeviceListBean allDeviceInfo; | ||
| 18 | + private FamilyListBean.UsersBeanX currentUser; | ||
| 19 | + | ||
| 20 | + public DeviceDetailView(DeviceDetailFragment fragment) { | ||
| 21 | + this.fragment = fragment; | ||
| 22 | + } | ||
| 23 | + | ||
| 24 | + public Activity getContext() { | ||
| 25 | + return fragment == null ? null : fragment.getActivity(); | ||
| 26 | + } | ||
| 27 | + | ||
| 28 | + public void initView(FamilyListBean.UsersBeanX.DeviceListBean allDeviceInfo, FamilyListBean.UsersBeanX currentUser) { | ||
| 29 | + this.currentUser = currentUser; | ||
| 30 | + this.allDeviceInfo = allDeviceInfo; | ||
| 31 | + //使用者管理 | ||
| 32 | + fragment.binding.rlUserManager.setOnClickListener(new View.OnClickListener() { | ||
| 33 | + @Override | ||
| 34 | + public void onClick(View view) { | ||
| 35 | + if (null!=currentUser&&!TextUtils.isEmpty(currentUser.getId())) { | ||
| 36 | + UserManagerActivity.StartActivity(getContext(), currentUser.getId()); | ||
| 37 | + } | ||
| 38 | + } | ||
| 39 | + }); | ||
| 40 | + //设备管理 | ||
| 41 | + fragment.binding.rlDeviceManager.setOnClickListener(new View.OnClickListener() { | ||
| 42 | + @Override | ||
| 43 | + public void onClick(View view) { | ||
| 44 | + DeviceManagerActivity.startActivity(getContext(), currentUser,allDeviceInfo); | ||
| 45 | + } | ||
| 46 | + }); | ||
| 47 | + //设备说明 | ||
| 48 | + fragment.binding.rlDeviceDeclare.setOnClickListener(new View.OnClickListener() { | ||
| 49 | + @Override | ||
| 50 | + public void onClick(View view) { | ||
| 51 | + DeviceInstructionActivity.startActivity(getContext()); | ||
| 52 | + } | ||
| 53 | + }); | ||
| 54 | + } | ||
| 55 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/DeviceManagerFragmentView.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.view; | ||
| 2 | + | ||
| 3 | +import android.Manifest; | ||
| 4 | +import android.app.Activity; | ||
| 5 | +import android.content.Intent; | ||
| 6 | +import android.content.pm.PackageManager; | ||
| 7 | +import android.graphics.Typeface; | ||
| 8 | +import android.net.Uri; | ||
| 9 | +import android.provider.Settings; | ||
| 10 | +import android.text.TextUtils; | ||
| 11 | +import android.util.Log; | ||
| 12 | +import android.view.View; | ||
| 13 | + | ||
| 14 | +import androidx.annotation.NonNull; | ||
| 15 | +import androidx.core.app.ActivityCompat; | ||
| 16 | + | ||
| 17 | +import com.cnlive.core.libs.base.frame.view.BaseView; | ||
| 18 | +import com.cnlive.core.libs.base.util.AlertUtil; | ||
| 19 | +import com.cnlive.strike.xiaojiaspeaker.R; | ||
| 20 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.DeviceDetail; | ||
| 21 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.FamilyListBean; | ||
| 22 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.BlueToothStep2Activity; | ||
| 23 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.ChangeDeviceNameActivity; | ||
| 24 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.ChangeWifiActivity; | ||
| 25 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.DeviceInfoActivity; | ||
| 26 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.FirmwareUpdateActivity; | ||
| 27 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.DeviceManagerFragment; | ||
| 28 | +import com.cnlive.strike.xiaojiaspeaker.ui.widget.SelectDialog; | ||
| 29 | +import com.cnlive.strike.xiaojiaspeaker.util.lib_permisshelper.PermissionsListener; | ||
| 30 | +import com.cnlive.strike.xiaojiaspeaker.util.lib_permisshelper.PermissionsUtils; | ||
| 31 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 32 | + | ||
| 33 | +public class DeviceManagerFragmentView extends BaseView { | ||
| 34 | + private DeviceManagerFragment fragment; | ||
| 35 | + // private DeviceManagerMenuAdapter adapter; | ||
| 36 | +// private List<DeviceManagerMenu> deviceManagerMenuList; | ||
| 37 | + private DeviceDetail deviceDetail; | ||
| 38 | + private FamilyListBean.UsersBeanX.DeviceListBean currentDeviceInfo; | ||
| 39 | + private FamilyListBean.UsersBeanX currentUser; | ||
| 40 | + private PermissionsUtils mPermissionsUtils = new PermissionsUtils();//权限申请 | ||
| 41 | + private int permissionRequestCount = 0;//权限请求次数 | ||
| 42 | + private boolean isClickNextBtn = false; | ||
| 43 | + private SelectDialog selectDialog; | ||
| 44 | + private String TAG = "DeviceManagerFragmentView"; | ||
| 45 | + | ||
| 46 | + public DeviceManagerFragmentView(DeviceManagerFragment fragment) { | ||
| 47 | + this.fragment = fragment; | ||
| 48 | + initPermissionDefineTip(); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + public Activity getContext() { | ||
| 52 | + return fragment == null ? null : fragment.getActivity(); | ||
| 53 | + } | ||
| 54 | + | ||
| 55 | + public void initView(FamilyListBean.UsersBeanX currentUser, FamilyListBean.UsersBeanX.DeviceListBean currentDeviceInfo) { | ||
| 56 | + this.currentDeviceInfo = currentDeviceInfo; | ||
| 57 | + this.currentUser = currentUser; | ||
| 58 | +// deviceManagerMenuList = new ArrayList<>(); | ||
| 59 | +// deviceManagerMenuList.add(new DeviceManagerMenu("音箱名称", "as", DeviceManagerMenu.NO_RIGHT_ARROW)); | ||
| 60 | +// deviceManagerMenuList.add(new DeviceManagerMenu("WIFI设置", "asd", DeviceManagerMenu.NORMAL)); | ||
| 61 | +// deviceManagerMenuList.add(new DeviceManagerMenu("设备信息", "asd", DeviceManagerMenu.NO_MENU_DETAIL)); | ||
| 62 | +// deviceManagerMenuList.add(new DeviceManagerMenu("固件升级", "asd", DeviceManagerMenu.NORMAL)); | ||
| 63 | +// deviceManagerMenuList.add(new DeviceManagerMenu("远程控制", "手机可远程控制音箱播放的内容,但仅限听见中国", DeviceManagerMenu.SWITCH_NORMAL)); | ||
| 64 | +// deviceManagerMenuList.add(new DeviceManagerMenu("小家音箱播放", "音箱可作为蓝牙音箱,播放手机内所有声音", DeviceManagerMenu.SWITCH_NORMAL)); | ||
| 65 | +// | ||
| 66 | +// adapter=new DeviceManagerMenuAdapter(getContext(),deviceManagerMenuList); | ||
| 67 | +// fragment.binding.rvMenu.setLayoutManager(new LinearLayoutManager(getContext())); | ||
| 68 | +// fragment.binding.rvMenu.setAdapter(adapter); | ||
| 69 | +// ((DefaultItemAnimator) fragment.binding.rvMenu.getItemAnimator()).setSupportsChangeAnimations(false); | ||
| 70 | + | ||
| 71 | + if (currentUser.getIsMaster() == FamilyListBean.THE_HOST) { | ||
| 72 | + //显示删除 | ||
| 73 | + fragment.binding.llDeleteView.setVisibility(View.VISIBLE); | ||
| 74 | + } else { | ||
| 75 | + //隐藏删除 | ||
| 76 | + fragment.binding.llDeleteView.setVisibility(View.GONE); | ||
| 77 | + } | ||
| 78 | + | ||
| 79 | + //音箱名称 | ||
| 80 | + fragment.binding.llDeviceName.setOnClickListener(new View.OnClickListener() { | ||
| 81 | + @Override | ||
| 82 | + public void onClick(View view) { | ||
| 83 | + if (currentUser.getIsMaster() == FamilyListBean.THE_HOST) { | ||
| 84 | + ChangeDeviceNameActivity.startActivity(getContext(), deviceDetail.getSN(),deviceDetail.getDeviceName()); | ||
| 85 | + } else { | ||
| 86 | + AlertUtil.showDeftToast(getContext(), getContext().getResources().getString(R.string.change_device_no_pression_tip)); | ||
| 87 | + } | ||
| 88 | + } | ||
| 89 | + }); | ||
| 90 | + //wifi设置 | ||
| 91 | + fragment.binding.llWifiSetting.setOnClickListener(new View.OnClickListener() { | ||
| 92 | + @Override | ||
| 93 | + public void onClick(View view) { | ||
| 94 | + if (currentUser.getIsMaster() == FamilyListBean.THE_HOST) { | ||
| 95 | + BlueToothStep2Activity.startActivity(getContext()); | ||
| 96 | + } else { | ||
| 97 | + AlertUtil.showDeftToast(getContext(), getContext().getResources().getString(R.string.change_device_no_pression_tip)); | ||
| 98 | + } | ||
| 99 | + | ||
| 100 | + | ||
| 101 | + } | ||
| 102 | + }); | ||
| 103 | + //设备信息 | ||
| 104 | + fragment.binding.llDeviceInfo.setOnClickListener(new View.OnClickListener() { | ||
| 105 | + @Override | ||
| 106 | + public void onClick(View view) { | ||
| 107 | + DeviceInfoActivity.startActivity(getContext(), deviceDetail); | ||
| 108 | + } | ||
| 109 | + }); | ||
| 110 | + //固件升级 | ||
| 111 | + fragment.binding.llDeviceUpdate.setOnClickListener(new View.OnClickListener() { | ||
| 112 | + @Override | ||
| 113 | + public void onClick(View view) { | ||
| 114 | + if (currentUser.getIsMaster() == FamilyListBean.THE_HOST) { | ||
| 115 | + FirmwareUpdateActivity.startActivity(getContext(), deviceDetail); | ||
| 116 | + } else { | ||
| 117 | + AlertUtil.showDeftToast(getContext(), getContext().getResources().getString(R.string.change_device_no_pression_tip)); | ||
| 118 | + } | ||
| 119 | + } | ||
| 120 | + }); | ||
| 121 | + //删除设备 | ||
| 122 | + fragment.binding.tvDeleteDevice.setOnClickListener(new View.OnClickListener() { | ||
| 123 | + @Override | ||
| 124 | + public void onClick(View view) { | ||
| 125 | + SelectDialog selectDialog = new SelectDialog(getContext(), "删除设备后音箱将不可用\n确定删除吗?", "取消", new SelectDialog.DialogInterface() { | ||
| 126 | + @Override | ||
| 127 | + public void onClick(SelectDialog dialog) { | ||
| 128 | + dialog.dismiss(); | ||
| 129 | + } | ||
| 130 | + }, "删除", new SelectDialog.DialogInterface() { | ||
| 131 | + @Override | ||
| 132 | + public void onClick(SelectDialog dialog) { | ||
| 133 | + dialog.dismiss(); | ||
| 134 | + if (null != deviceDetail) { | ||
| 135 | + if (!TextUtils.isEmpty(deviceDetail.getSN())) { | ||
| 136 | + fragment.getPresenter().deleteDevice(getContext(), deviceDetail.getSN(),deviceDetail.getDeviceName()); | ||
| 137 | + } | ||
| 138 | + } else { | ||
| 139 | + AlertUtil.showDeftToast(getContext(), "删除失败"); | ||
| 140 | + } | ||
| 141 | + } | ||
| 142 | + }); | ||
| 143 | + selectDialog.setCancelable(false); | ||
| 144 | + selectDialog.setCanceledOnTouchOutside(false); | ||
| 145 | + selectDialog.setTipTextStyle(Typeface.DEFAULT); | ||
| 146 | + selectDialog.setRightBtnColor(R.color.btn_green); | ||
| 147 | + if (!selectDialog.isShowing()) { | ||
| 148 | + selectDialog.show(); | ||
| 149 | + } | ||
| 150 | + } | ||
| 151 | + }); | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + public void initData(DeviceDetail deviceDetail) { | ||
| 155 | + this.deviceDetail = deviceDetail; | ||
| 156 | + //设置音箱名称 | ||
| 157 | + fragment.binding.tvDeviceName.setText(deviceDetail.getDeviceName()); | ||
| 158 | + //设置wifi | ||
| 159 | + fragment.binding.tvWifiName.setText(deviceDetail.getWifiName()); | ||
| 160 | + if (!TextUtils.isEmpty(deviceDetail.getVer())) { | ||
| 161 | + String flag = "XiaoJiaSmartSpeaker_"; | ||
| 162 | + if (deviceDetail.getVer().indexOf("") != -1) { | ||
| 163 | + //设置固件版本号 | ||
| 164 | + fragment.binding.tvCurrentVersion.setText(deviceDetail.getVer().substring(flag.length(), deviceDetail.getVer().length())); | ||
| 165 | + } else { | ||
| 166 | + fragment.binding.tvCurrentVersion.setText(deviceDetail.getVer()); | ||
| 167 | + } | ||
| 168 | + } | ||
| 169 | + | ||
| 170 | + } | ||
| 171 | + | ||
| 172 | + /** | ||
| 173 | + * 显示loading | ||
| 174 | + */ | ||
| 175 | + public void showLoadingView() { | ||
| 176 | + if (fragment.binding.emptyLayout == null) { | ||
| 177 | + return; | ||
| 178 | + } | ||
| 179 | + fragment.binding.emptyLayout.show(true); | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + /** | ||
| 183 | + * 隐藏loading | ||
| 184 | + */ | ||
| 185 | + public void hideLoadingView() { | ||
| 186 | + if (fragment.binding.emptyLayout == null) { | ||
| 187 | + return; | ||
| 188 | + } | ||
| 189 | + fragment.binding.emptyLayout.hide(); | ||
| 190 | + } | ||
| 191 | + | ||
| 192 | + /** | ||
| 193 | + * 显示重试页面 | ||
| 194 | + * | ||
| 195 | + * @param errorCode | ||
| 196 | + * @param listener | ||
| 197 | + */ | ||
| 198 | + public void showRetryView(int errorCode, View.OnClickListener listener) { | ||
| 199 | + //显示空视图 | ||
| 200 | + fragment.binding.emptyLayout.setVisibility(View.VISIBLE); | ||
| 201 | + | ||
| 202 | + if (fragment.binding.emptyLayout == null) return; | ||
| 203 | + String titleText = ""; | ||
| 204 | + String detailText = ""; | ||
| 205 | + if (errorCode == -3) { | ||
| 206 | + titleText = getContext().getString(R.string.msg_failed_network_title); | ||
| 207 | + detailText = getContext().getString(R.string.msg_failed_network_detail); | ||
| 208 | + } else { | ||
| 209 | + titleText = getContext().getString(R.string.msg_failed_other_title); | ||
| 210 | + detailText = getContext().getString(R.string.msg_failed_other_detail); | ||
| 211 | + } | ||
| 212 | + fragment.binding.emptyLayout.show(false, titleText, detailText, getContext().getString(R.string.retry), R.drawable.wufalianjie, listener); | ||
| 213 | + } | ||
| 214 | + | ||
| 215 | + | ||
| 216 | + /** | ||
| 217 | + * 一次申请一组权限(使用拒绝弹框)点击事件 | ||
| 218 | + */ | ||
| 219 | + public void getPermissionsWithTip() { | ||
| 220 | + if (1 == permissionRequestCount) { | ||
| 221 | + return; | ||
| 222 | + } | ||
| 223 | + mPermissionsUtils | ||
| 224 | + .setPermissionsListener(new PermissionsListener() { | ||
| 225 | + @Override | ||
| 226 | + public void onDenied(String[] deniedPermissions) { | ||
| 227 | +// getPermissionsWithTip(); | ||
| 228 | + } | ||
| 229 | + | ||
| 230 | + @Override | ||
| 231 | + public void onGranted() { | ||
| 232 | + isClickNextBtn = true; | ||
| 233 | + ChangeWifiActivity.StartActivity(getContext(), deviceDetail.getSN(), currentUser); | ||
| 234 | + | ||
| 235 | + } | ||
| 236 | + }) | ||
| 237 | + .withActivity(getContext()) | ||
| 238 | + .getPermissions(getContext() | ||
| 239 | + , 100 | ||
| 240 | + , Manifest.permission.INTERNET | ||
| 241 | + , Manifest.permission.ACCESS_FINE_LOCATION | ||
| 242 | + , Manifest.permission.ACCESS_COARSE_LOCATION | ||
| 243 | + ); | ||
| 244 | +// .getPermissionsWithTips(MainActivity.this | ||
| 245 | +// ,100 | ||
| 246 | +// , new String[]{"人家要录音","我们需要读取你的信息,磨磨唧唧的","我要上网","我要读内存卡","我要看日历","我要定位"} | ||
| 247 | +// , Manifest.permission.RECORD_AUDIO | ||
| 248 | +// , Manifest.permission.READ_SMS | ||
| 249 | +// , Manifest.permission.INTERNET | ||
| 250 | +// , Manifest.permission.READ_EXTERNAL_STORAGE | ||
| 251 | +// , Manifest.permission.READ_CALENDAR | ||
| 252 | +// , Manifest.permission.ACCESS_FINE_LOCATION); | ||
| 253 | + } | ||
| 254 | + | ||
| 255 | + | ||
| 256 | + private void initPermissionDefineTip() { | ||
| 257 | + selectDialog = new SelectDialog(getContext(), "您尚未授予程序运行所需权限\n是否设置?", | ||
| 258 | + "取消", new SelectDialog.DialogInterface() { | ||
| 259 | + @Override | ||
| 260 | + public void onClick(SelectDialog dialog) { | ||
| 261 | + dialog.dismiss(); | ||
| 262 | + permissionRequestCount = 0; | ||
| 263 | + } | ||
| 264 | + }, "设置", new SelectDialog.DialogInterface() { | ||
| 265 | + @Override | ||
| 266 | + public void onClick(SelectDialog dialog) { | ||
| 267 | + dialog.dismiss(); | ||
| 268 | + Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS); | ||
| 269 | + Uri uri = Uri.fromParts("package", getContext().getPackageName(), null); | ||
| 270 | + intent.setData(uri); | ||
| 271 | + getContext().startActivityForResult(intent, 0); | ||
| 272 | + permissionRequestCount = 0; | ||
| 273 | + } | ||
| 274 | + }); | ||
| 275 | + selectDialog.setRightBtnColor(R.color.green); | ||
| 276 | + | ||
| 277 | + } | ||
| 278 | + | ||
| 279 | + /** | ||
| 280 | + * 权限回调 | ||
| 281 | + * | ||
| 282 | + * @param requestCode | ||
| 283 | + * @param permissions | ||
| 284 | + * @param grantResults | ||
| 285 | + */ | ||
| 286 | + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, | ||
| 287 | + @NonNull int[] grantResults) { | ||
| 288 | + Log.e(TAG, "onRequestPermissionsResult: "); | ||
| 289 | + if (1 == permissionRequestCount) { | ||
| 290 | + return; | ||
| 291 | + } | ||
| 292 | + boolean isShowPermissionTip = true; | ||
| 293 | + for (int i = 0; i < grantResults.length; i++) {//判断权限的结果,如果有被拒绝,就return | ||
| 294 | + if (grantResults[i] == PackageManager.PERMISSION_DENIED) { | ||
| 295 | + if (!ActivityCompat.shouldShowRequestPermissionRationale(getContext(), permissions[i])) { | ||
| 296 | + isShowPermissionTip = false; | ||
| 297 | + break; | ||
| 298 | + } | ||
| 299 | + } | ||
| 300 | + } | ||
| 301 | + if (isShowPermissionTip) { | ||
| 302 | + mPermissionsUtils.dealResult(requestCode, permissions, grantResults); | ||
| 303 | + } else { | ||
| 304 | + if (0 == permissionRequestCount) { | ||
| 305 | + selectDialog.setCancelable(false); | ||
| 306 | + selectDialog.setCanceledOnTouchOutside(false); | ||
| 307 | + if (!selectDialog.isShowing()) { | ||
| 308 | + selectDialog.show(); | ||
| 309 | + permissionRequestCount = 1; | ||
| 310 | + } | ||
| 311 | + } else { | ||
| 312 | + return; | ||
| 313 | + } | ||
| 314 | + } | ||
| 315 | + } | ||
| 316 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/FirmwareUpdateFragmentView.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.view; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.view.View; | ||
| 5 | + | ||
| 6 | +import com.cnlive.core.libs.base.frame.view.BaseView; | ||
| 7 | +import com.cnlive.core.libs.base.util.AlertUtil; | ||
| 8 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.DeviceDetail; | ||
| 9 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.FirmwareUpdateFragment; | ||
| 10 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 11 | + | ||
| 12 | +public class FirmwareUpdateFragmentView extends BaseView { | ||
| 13 | + private FirmwareUpdateFragment fragment; | ||
| 14 | + | ||
| 15 | + public FirmwareUpdateFragmentView(FirmwareUpdateFragment fragment) { | ||
| 16 | + this.fragment = fragment; | ||
| 17 | + } | ||
| 18 | + | ||
| 19 | + public Activity getContext() { | ||
| 20 | + return fragment == null ? null : fragment.getActivity(); | ||
| 21 | + } | ||
| 22 | + | ||
| 23 | + public void initView(DeviceDetail deviceDetail) { | ||
| 24 | + if (deviceDetail.getVer().indexOf("") != -1) { | ||
| 25 | + String flag = "XiaoJiaSmartSpeaker_"; | ||
| 26 | + //设置固件版本号 | ||
| 27 | + fragment.binding.tvCurrentVersion.setText(deviceDetail.getVer().substring(flag.length(),deviceDetail.getVer().length())); | ||
| 28 | + fragment.binding.tvNewVersion.setText(deviceDetail.getVer().substring(flag.length(),deviceDetail.getVer().length())); | ||
| 29 | + } else { | ||
| 30 | + fragment.binding.tvCurrentVersion.setText(deviceDetail.getVer()); | ||
| 31 | + fragment.binding.tvNewVersion.setText(deviceDetail.getVer()); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | + fragment.binding.btnCheckUpdate.setOnClickListener(new View.OnClickListener() { | ||
| 35 | + @Override | ||
| 36 | + public void onClick(View view) { | ||
| 37 | + AlertUtil.showDeftToast(getContext(),"当前为最新版本"); | ||
| 38 | + } | ||
| 39 | + }); | ||
| 40 | + } | ||
| 41 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/InvitFriendView.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.view; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.graphics.Bitmap; | ||
| 5 | +import android.graphics.BitmapFactory; | ||
| 6 | +import android.text.TextUtils; | ||
| 7 | +import android.view.View; | ||
| 8 | + | ||
| 9 | +import androidx.core.content.ContextCompat; | ||
| 10 | +import androidx.recyclerview.widget.LinearLayoutManager; | ||
| 11 | + | ||
| 12 | +import com.alibaba.android.arouter.launcher.ARouter; | ||
| 13 | +import com.cnlive.core.libs.base.application.AppConfig; | ||
| 14 | +import com.cnlive.core.libs.base.application.GlideApp; | ||
| 15 | +import com.cnlive.core.libs.base.arouter.QrService; | ||
| 16 | +import com.cnlive.core.libs.base.frame.view.BaseView; | ||
| 17 | +import com.cnlive.core.libs.base.util.AlertUtil; | ||
| 18 | +import com.cnlive.core.libs.base.util.SimpleDES; | ||
| 19 | +import com.cnlive.strike.xiaojiaspeaker.R; | ||
| 20 | +import com.cnlive.strike.xiaojiaspeaker.commonInfo.XiaoJIaCommInfo; | ||
| 21 | +import com.cnlive.strike.xiaojiaspeaker.constants.XiaoJiaConst; | ||
| 22 | +import com.cnlive.strike.xiaojiaspeaker.model.RoleInfo; | ||
| 23 | +import com.cnlive.strike.xiaojiaspeaker.model.XiaoJiaQrcode; | ||
| 24 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.RoleNetBean; | ||
| 25 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.ShareFriendActivity; | ||
| 26 | +import com.cnlive.strike.xiaojiaspeaker.ui.adapter.SetRoleAdapter; | ||
| 27 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.InvitFriendFragment; | ||
| 28 | +import com.cnlive.strike.xiaojiaspeaker.util.CommonUtils; | ||
| 29 | +import com.cnlive.strike.xiaojiaspeaker.util.DensityUtil; | ||
| 30 | +import com.cnlive.strike.xiaojiaspeaker.util.GsonUtil; | ||
| 31 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 32 | + | ||
| 33 | +import org.json.JSONException; | ||
| 34 | +import org.json.JSONObject; | ||
| 35 | + | ||
| 36 | +import java.util.ArrayList; | ||
| 37 | +import java.util.List; | ||
| 38 | + | ||
| 39 | +public class InvitFriendView extends BaseView { | ||
| 40 | + private InvitFriendFragment fragment; | ||
| 41 | + private List<RoleInfo> roleInfoList; | ||
| 42 | + private SetRoleAdapter setRoleAdapter; | ||
| 43 | + private String encryptionContent; | ||
| 44 | + private String currentSelectFamilyId; | ||
| 45 | + | ||
| 46 | + public void setCurrentSelectFamilyId(String currentSelectFamilyId) { | ||
| 47 | + this.currentSelectFamilyId = currentSelectFamilyId; | ||
| 48 | + } | ||
| 49 | + | ||
| 50 | + public InvitFriendView(InvitFriendFragment fragment) { | ||
| 51 | + this.fragment = fragment; | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + public Activity getContext() { | ||
| 55 | + return fragment == null ? null : fragment.getActivity(); | ||
| 56 | + } | ||
| 57 | + | ||
| 58 | + public void initView() { | ||
| 59 | + setShareCantClick(); | ||
| 60 | + this.currentSelectFamilyId = currentSelectFamilyId; | ||
| 61 | + fragment.binding.btnShare.setOnClickListener(v -> { | ||
| 62 | + if ("0".equals(fragment.binding.btnShare.getTag().toString())) { | ||
| 63 | + AlertUtil.showDeftToast(getContext(), "请选择角色"); | ||
| 64 | + return; | ||
| 65 | + } | ||
| 66 | + if (!TextUtils.isEmpty(encryptionContent)) { | ||
| 67 | + ShareFriendActivity.startActivity(fragment.getActivity(), XiaoJIaCommInfo.getUserIcon(getContext()), XiaoJIaCommInfo.getUserNickName(getContext()), encryptionContent); | ||
| 68 | + } else { | ||
| 69 | + //提示跳转失败原因 | ||
| 70 | + AlertUtil.showDeftToast(getContext(), "参数异常"); | ||
| 71 | + } | ||
| 72 | + }); | ||
| 73 | + } | ||
| 74 | + | ||
| 75 | + public void setData(RoleNetBean roleNetBean) { | ||
| 76 | + roleInfoList = new ArrayList<>(); | ||
| 77 | + //整理数据 | ||
| 78 | + //获取选中的联系人 | ||
| 79 | + if (null != roleNetBean.getRoleUserList()) { | ||
| 80 | + RoleInfo roleInfo = null; | ||
| 81 | + for (int i = 0; i < roleNetBean.getRoleUserList().size(); i++) { | ||
| 82 | + roleInfo = new RoleInfo(); | ||
| 83 | + roleInfo.setUid(roleNetBean.getRoleUserList().get(i).getSid()); | ||
| 84 | + roleInfo.setUserName(roleNetBean.getRoleUserList().get(i).getNick()); | ||
| 85 | + roleInfo.setUserIcon(roleNetBean.getRoleUserList().get(i).getFace()); | ||
| 86 | + List<RoleNetBean.RoleListBean> roleList = new ArrayList<>(); | ||
| 87 | + for (int j = 0; j < roleNetBean.getRoleList().size(); j++) { | ||
| 88 | + RoleNetBean.RoleListBean bean = new RoleNetBean.RoleListBean(); | ||
| 89 | + bean.setAllowUse(roleNetBean.getRoleList().get(j).isAllowUse()); | ||
| 90 | + bean.setId(roleNetBean.getRoleList().get(j).getId()); | ||
| 91 | + bean.setRoleName(roleNetBean.getRoleList().get(j).getRoleName()); | ||
| 92 | + bean.setParentPosition(i); | ||
| 93 | + roleList.add(bean); | ||
| 94 | + } | ||
| 95 | + roleInfo.setRoleList(roleList); | ||
| 96 | + roleInfoList.add(roleInfo); | ||
| 97 | + } | ||
| 98 | + } | ||
| 99 | + setRoleAdapter = new SetRoleAdapter(getContext(), roleInfoList); | ||
| 100 | +// setRoleAdapter.setGridCount(4); | ||
| 101 | + setRoleAdapter.setIsShowItemUserInfo(View.GONE); | ||
| 102 | + fragment.binding.rvRole.setLayoutManager(new LinearLayoutManager(getContext())); | ||
| 103 | + fragment.binding.rvRole.setAdapter(setRoleAdapter); | ||
| 104 | + //设置角色选中事件 | ||
| 105 | + setRoleAdapter.setOnSelectListener(new SetRoleAdapter.OnSelectListener() { | ||
| 106 | + @Override | ||
| 107 | + public void onSelect(int roleId) { | ||
| 108 | + fragment.binding.llNoQrcode.setVisibility(View.GONE); | ||
| 109 | + createQrcode(roleId); | ||
| 110 | + setShareClick(); | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + @Override | ||
| 114 | + public void onCancel() { | ||
| 115 | + fragment.binding.llNoQrcode.setVisibility(View.VISIBLE); | ||
| 116 | + setShareCantClick(); | ||
| 117 | + } | ||
| 118 | + }); | ||
| 119 | + } | ||
| 120 | + | ||
| 121 | + public void createQrcode(int roleId) { | ||
| 122 | + JSONObject jsonObject = new JSONObject(); | ||
| 123 | + try { | ||
| 124 | + XiaoJiaQrcode xiaoJiaQrcode = new XiaoJiaQrcode(); | ||
| 125 | + xiaoJiaQrcode.setFamilyId(XiaoJIaCommInfo.getFamilyId(getContext())); | ||
| 126 | + xiaoJiaQrcode.setRoleId(roleId); | ||
| 127 | + xiaoJiaQrcode.setUuid(CommonUtils.getUUID()); | ||
| 128 | + | ||
| 129 | + jsonObject.put("xiajiaContent", GsonUtil.GsonString(xiaoJiaQrcode)); | ||
| 130 | + jsonObject.put("time", System.currentTimeMillis()); | ||
| 131 | + jsonObject.put("type", XiaoJiaConst.QRCODE_TYPE); | ||
| 132 | + | ||
| 133 | + String qrContent = jsonObject.toString(); | ||
| 134 | + encryptionContent = SimpleDES.ebotongEncrypto(qrContent, "cnliveIm"); | ||
| 135 | + encryptionContent = encryptionContent.replaceAll("\\\n", ""); | ||
| 136 | + encryptionContent = AppConfig.getShareDownload() + "isWjjQr=" + encryptionContent + "&wjjQrSkipType=wjjQrXiaojiaBoxType"; | ||
| 137 | + QrService service = (QrService) ARouter.getInstance().navigation(QrService.class); | ||
| 138 | + if (null == service) { | ||
| 139 | + return; | ||
| 140 | + } | ||
| 141 | + Bitmap logo = BitmapFactory.decodeResource(getContext().getResources(), R.mipmap.ic_launcher); | ||
| 142 | + if (null == logo) { | ||
| 143 | + return; | ||
| 144 | + } | ||
| 145 | + Bitmap bitmap = service.createQrIconBitMap(encryptionContent, DensityUtil.dp2px(getContext(), 245), logo, 10); | ||
| 146 | +// binding.ivQr.setBackgroundDrawable(bitmap); | ||
| 147 | + if (getContext() == null) { | ||
| 148 | + return; | ||
| 149 | + } | ||
| 150 | + if (null != bitmap) { | ||
| 151 | + GlideApp.with(getContext()).load(bitmap).into(fragment.binding.ivQrcode); | ||
| 152 | + } | ||
| 153 | + | ||
| 154 | + } catch (JSONException e) { | ||
| 155 | + e.printStackTrace(); | ||
| 156 | + } | ||
| 157 | + } | ||
| 158 | + | ||
| 159 | + /** | ||
| 160 | + * 显示loading | ||
| 161 | + */ | ||
| 162 | + public void showLoadingView() { | ||
| 163 | + if (fragment.binding.emptyLayout == null) { | ||
| 164 | + return; | ||
| 165 | + } | ||
| 166 | + fragment.binding.emptyLayout.show(true); | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + /** | ||
| 170 | + * 隐藏loading | ||
| 171 | + */ | ||
| 172 | + public void hideLoadingView() { | ||
| 173 | + if (fragment.binding.emptyLayout == null) { | ||
| 174 | + return; | ||
| 175 | + } | ||
| 176 | + fragment.binding.emptyLayout.hide(); | ||
| 177 | + } | ||
| 178 | + | ||
| 179 | + /** | ||
| 180 | + * 显示重试页面 | ||
| 181 | + * | ||
| 182 | + * @param errorCode | ||
| 183 | + * @param listener | ||
| 184 | + */ | ||
| 185 | + public void showRetryView(int errorCode, View.OnClickListener listener) { | ||
| 186 | + //显示空视图 | ||
| 187 | + fragment.binding.emptyLayout.setVisibility(View.VISIBLE); | ||
| 188 | + | ||
| 189 | + if (fragment.binding.emptyLayout == null) return; | ||
| 190 | + String titleText = ""; | ||
| 191 | + String detailText = ""; | ||
| 192 | + if (errorCode == -3) { | ||
| 193 | + titleText = getContext().getString(R.string.msg_failed_network_title); | ||
| 194 | + detailText = getContext().getString(R.string.msg_failed_network_detail); | ||
| 195 | + } else { | ||
| 196 | + titleText = getContext().getString(R.string.msg_failed_other_title); | ||
| 197 | + detailText = getContext().getString(R.string.msg_failed_other_detail); | ||
| 198 | + } | ||
| 199 | + fragment.binding.emptyLayout.show(false, titleText, detailText, getContext().getString(R.string.retry), R.drawable.wufalianjie, listener); | ||
| 200 | + } | ||
| 201 | + | ||
| 202 | + /** | ||
| 203 | + * 设置绑定按钮不可点击 | ||
| 204 | + */ | ||
| 205 | + private void setShareCantClick() { | ||
| 206 | + if (null == getContext()) { | ||
| 207 | + return; | ||
| 208 | + } | ||
| 209 | + fragment.binding.btnShare.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_xiaojia_btn_press)); | ||
| 210 | + fragment.binding.btnShare.setTag("0"); | ||
| 211 | + | ||
| 212 | + } | ||
| 213 | + | ||
| 214 | + /** | ||
| 215 | + * 设置绑定按钮可点击 | ||
| 216 | + */ | ||
| 217 | + private void setShareClick() { | ||
| 218 | + if (null == getContext()) { | ||
| 219 | + return; | ||
| 220 | + } | ||
| 221 | + fragment.binding.btnShare.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.selector_xiaojia_btn_green)); | ||
| 222 | + fragment.binding.btnShare.setTag("1"); | ||
| 223 | + } | ||
| 224 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/SearchDevicefragmentView.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.view; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.bluetooth.BluetoothAdapter; | ||
| 5 | +import android.content.Intent; | ||
| 6 | +import android.text.TextUtils; | ||
| 7 | +import android.view.View; | ||
| 8 | + | ||
| 9 | +import androidx.core.content.ContextCompat; | ||
| 10 | +import androidx.recyclerview.widget.DefaultItemAnimator; | ||
| 11 | +import androidx.recyclerview.widget.LinearLayoutManager; | ||
| 12 | + | ||
| 13 | +import com.clj.fastble.BleManager; | ||
| 14 | +import com.clj.fastble.callback.BleScanCallback; | ||
| 15 | +import com.clj.fastble.data.BleDevice; | ||
| 16 | +import com.cnlive.core.libs.base.frame.view.BaseView; | ||
| 17 | +import com.cnlive.strike.xiaojiaspeaker.R; | ||
| 18 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.BlueToothHelpActivity; | ||
| 19 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.SelectWifiActivity; | ||
| 20 | +import com.cnlive.strike.xiaojiaspeaker.ui.adapter.BluetoothDeviceAdapter; | ||
| 21 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.SearchDevicefragment; | ||
| 22 | +import com.cnlive.strike.xiaojiaspeaker.ui.widget.SelectDialog; | ||
| 23 | +import com.cnlive.strike.xiaojiaspeaker.util.WifiUtils; | ||
| 24 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 25 | + | ||
| 26 | +import java.util.ArrayList; | ||
| 27 | +import java.util.List; | ||
| 28 | + | ||
| 29 | +public class SearchDevicefragmentView extends BaseView { | ||
| 30 | + private SearchDevicefragment fragment; | ||
| 31 | + private BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); | ||
| 32 | + private List<BleDevice> bleDevices = new ArrayList<>(); | ||
| 33 | + private BluetoothDeviceAdapter adapter; | ||
| 34 | + private WifiUtils wifiUtils; | ||
| 35 | + private SelectDialog wifiDialog; | ||
| 36 | + | ||
| 37 | + public SearchDevicefragmentView(SearchDevicefragment fragment) { | ||
| 38 | + this.fragment = fragment; | ||
| 39 | + } | ||
| 40 | + | ||
| 41 | + public Activity getContext() { | ||
| 42 | + return null == fragment ? null : fragment.getActivity(); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + public void initView() { | ||
| 46 | + if (null == getContext()) { | ||
| 47 | + return; | ||
| 48 | + } | ||
| 49 | + //设置配对按钮不可点击 | ||
| 50 | + setBondDeviceCantClick(); | ||
| 51 | + //隐藏重试 | ||
| 52 | + hideView(fragment.binding.llRetry); | ||
| 53 | + //显示loading | ||
| 54 | + showView(fragment.binding.llLoading); | ||
| 55 | + initWifiDialog(); | ||
| 56 | + wifiUtils = new WifiUtils(getContext()); | ||
| 57 | + //重试按钮点击事件 | ||
| 58 | + fragment.binding.btnRetry.setOnClickListener(new View.OnClickListener() { | ||
| 59 | + @Override | ||
| 60 | + public void onClick(View view) { | ||
| 61 | + scanBlueToothDevice(); | ||
| 62 | + } | ||
| 63 | + }); | ||
| 64 | + //未发现设备帮助点击 | ||
| 65 | + fragment.binding.tvNotFoundDevice.setOnClickListener(new View.OnClickListener() { | ||
| 66 | + @Override | ||
| 67 | + public void onClick(View view) { | ||
| 68 | + BlueToothHelpActivity.startActivity(getContext()); | ||
| 69 | + } | ||
| 70 | + }); | ||
| 71 | + //上一步按钮 | ||
| 72 | + fragment.binding.tvPreviousStep.setOnClickListener(new View.OnClickListener() { | ||
| 73 | + @Override | ||
| 74 | + public void onClick(View view) { | ||
| 75 | +// BlueToothStep2Activity.startActivity(getContext()); | ||
| 76 | + fragment.getActivity().finish(); | ||
| 77 | + } | ||
| 78 | + }); | ||
| 79 | + //配对按钮点击 | ||
| 80 | + fragment.binding.btnBondDevice.setOnClickListener(new View.OnClickListener() { | ||
| 81 | + @Override | ||
| 82 | + public void onClick(View view) { | ||
| 83 | + //判断wifi是否打开 | ||
| 84 | + if (!wifiUtils.isOpenWifi()) { | ||
| 85 | + if (!wifiDialog.isShowing()) { | ||
| 86 | + wifiDialog.show(); | ||
| 87 | + } | ||
| 88 | + } else { | ||
| 89 | +// 获取当前选中设备 | ||
| 90 | + if (null != adapter) { | ||
| 91 | + BleDevice bleDevice = adapter.getSelectDevice(); | ||
| 92 | + if (null != bleDevice) { | ||
| 93 | + SelectWifiActivity.StartActivity(getContext(), bleDevice); | ||
| 94 | + } | ||
| 95 | + } | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + } | ||
| 99 | + }); | ||
| 100 | + } | ||
| 101 | + | ||
| 102 | + private void initWifiDialog() { | ||
| 103 | + wifiDialog = new SelectDialog(getContext(), "小家音箱需开启WIFI,是否允许?", "取消", new SelectDialog.DialogInterface() { | ||
| 104 | + @Override | ||
| 105 | + public void onClick(SelectDialog dialog) { | ||
| 106 | + dialog.dismiss(); | ||
| 107 | + } | ||
| 108 | + }, "设置", new SelectDialog.DialogInterface() { | ||
| 109 | + @Override | ||
| 110 | + public void onClick(SelectDialog dialog) { | ||
| 111 | + getContext().startActivity(new Intent(android.provider.Settings.ACTION_WIFI_SETTINGS)); | ||
| 112 | + dialog.dismiss(); | ||
| 113 | + } | ||
| 114 | + }); | ||
| 115 | + wifiDialog.setRightBtnColor(R.color.btn_green); | ||
| 116 | + wifiDialog.setCancelable(false); | ||
| 117 | + wifiDialog.setCanceledOnTouchOutside(false); | ||
| 118 | + } | ||
| 119 | + | ||
| 120 | + public void initListAdapter() { | ||
| 121 | + if (null == getContext()) { | ||
| 122 | + return; | ||
| 123 | + } | ||
| 124 | + adapter = new BluetoothDeviceAdapter(getContext(), bleDevices); | ||
| 125 | + adapter.setHasStableIds(true); | ||
| 126 | + fragment.binding.rvBlueTooth.setLayoutManager(new LinearLayoutManager(getContext())); | ||
| 127 | + fragment.binding.rvBlueTooth.setAdapter(adapter); | ||
| 128 | + ((DefaultItemAnimator) fragment.binding.rvBlueTooth.getItemAnimator()).setSupportsChangeAnimations(false); | ||
| 129 | + | ||
| 130 | + adapter.setOnItemClickListener(new BluetoothDeviceAdapter.OnItemClickListener() { | ||
| 131 | + @Override | ||
| 132 | + public void onItemClick(int position, BleDevice bleDevice) { | ||
| 133 | + //设置配对按钮可以点击 | ||
| 134 | + setBondDeviceClick(); | ||
| 135 | + | ||
| 136 | +// // | ||
| 137 | + } | ||
| 138 | + }); | ||
| 139 | + //开始扫描蓝牙 | ||
| 140 | + scanBlueToothDevice(); | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + | ||
| 144 | + /** | ||
| 145 | + * 开始扫描蓝牙设备 | ||
| 146 | + */ | ||
| 147 | + public void scanBlueToothDevice() { | ||
| 148 | + if (null == getContext()) { | ||
| 149 | + return; | ||
| 150 | + } | ||
| 151 | + //隐藏loading视图 | ||
| 152 | + hideView(fragment.binding.llRetry); | ||
| 153 | + if (null != adapter) { | ||
| 154 | + adapter.clearData(); | ||
| 155 | + } | ||
| 156 | + BleManager.getInstance().scan(new BleScanCallback() { | ||
| 157 | + // 扫描结束,列出所有扫描到的符合扫描规则的BLE设备(主线程) | ||
| 158 | + @Override | ||
| 159 | + public void onScanFinished(List<BleDevice> scanResultList) { | ||
| 160 | + if (null == getContext()) { | ||
| 161 | + return; | ||
| 162 | + } | ||
| 163 | + //判断结果是否为空 | ||
| 164 | + if (null == bleDevices || bleDevices.size() < 1) { | ||
| 165 | + //隐藏loading视图 | ||
| 166 | + hideView(fragment.binding.llLoading); | ||
| 167 | + //显示重试视图 | ||
| 168 | + showView(fragment.binding.llRetry); | ||
| 169 | + } | ||
| 170 | + | ||
| 171 | + } | ||
| 172 | + | ||
| 173 | + // 开始扫描(主线程) | ||
| 174 | + @Override | ||
| 175 | + public void onScanStarted(boolean success) { | ||
| 176 | + //隐藏重试 | ||
| 177 | + hideView(fragment.binding.llRetry); | ||
| 178 | + //显示loading | ||
| 179 | + showView(fragment.binding.llLoading); | ||
| 180 | + } | ||
| 181 | + | ||
| 182 | + // 扫描到一个符合扫描规则的BLE设备(主线程) | ||
| 183 | + @Override | ||
| 184 | + public void onScanning(BleDevice bleDevice) { | ||
| 185 | + if (TextUtils.isEmpty(bleDevice.getName()) || bleDevice.getName().indexOf("XIAOJIA-") == -1) { | ||
| 186 | + return; | ||
| 187 | + } | ||
| 188 | + | ||
| 189 | + if (null != adapter) { | ||
| 190 | + adapter.addListData(bleDevice); | ||
| 191 | + //隐藏loading | ||
| 192 | + hideView(fragment.binding.llLoading); | ||
| 193 | + //隐藏重试 | ||
| 194 | + hideView(fragment.binding.llRetry); | ||
| 195 | + | ||
| 196 | + } | ||
| 197 | + } | ||
| 198 | + }); | ||
| 199 | + } | ||
| 200 | + | ||
| 201 | + /** | ||
| 202 | + * 隐藏视图 | ||
| 203 | + * | ||
| 204 | + * @param view | ||
| 205 | + */ | ||
| 206 | + private void hideView(View view) { | ||
| 207 | + if (view.getVisibility() == View.VISIBLE) { | ||
| 208 | + view.setVisibility(View.GONE); | ||
| 209 | + } | ||
| 210 | + } | ||
| 211 | + | ||
| 212 | + /** | ||
| 213 | + * 显示视图 | ||
| 214 | + * | ||
| 215 | + * @param view | ||
| 216 | + */ | ||
| 217 | + private void showView(View view) { | ||
| 218 | + if (view.getVisibility() != View.VISIBLE) { | ||
| 219 | + view.setVisibility(View.VISIBLE); | ||
| 220 | + } | ||
| 221 | + } | ||
| 222 | + | ||
| 223 | + /** | ||
| 224 | + * 设置绑定按钮不可点击 | ||
| 225 | + */ | ||
| 226 | + private void setBondDeviceCantClick() { | ||
| 227 | + if (null == getContext()) { | ||
| 228 | + return; | ||
| 229 | + } | ||
| 230 | + fragment.binding.btnBondDevice.setClickable(false); | ||
| 231 | + fragment.binding.btnBondDevice.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_xiaojia_btn_press)); | ||
| 232 | + } | ||
| 233 | + | ||
| 234 | + /** | ||
| 235 | + * 设置绑定按钮可点击 | ||
| 236 | + */ | ||
| 237 | + private void setBondDeviceClick() { | ||
| 238 | + if (null == getContext()) { | ||
| 239 | + return; | ||
| 240 | + } | ||
| 241 | + fragment.binding.btnBondDevice.setClickable(true); | ||
| 242 | + fragment.binding.btnBondDevice.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.selector_xiaojia_btn_green)); | ||
| 243 | + } | ||
| 244 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/SelectIMFriendView.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.view; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.content.Context; | ||
| 5 | +import android.text.Editable; | ||
| 6 | +import android.text.TextUtils; | ||
| 7 | +import android.text.TextWatcher; | ||
| 8 | +import android.util.Log; | ||
| 9 | +import android.view.View; | ||
| 10 | +import android.view.WindowManager; | ||
| 11 | +import android.view.inputmethod.InputMethodManager; | ||
| 12 | + | ||
| 13 | +import androidx.core.content.ContextCompat; | ||
| 14 | +import androidx.recyclerview.widget.LinearLayoutManager; | ||
| 15 | + | ||
| 16 | +import com.alibaba.android.arouter.launcher.ARouter; | ||
| 17 | +import com.cnlive.core.libs.base.arouter.im.FriendListData; | ||
| 18 | +import com.cnlive.core.libs.base.arouter.im.ImOpenService; | ||
| 19 | +import com.cnlive.core.libs.base.frame.view.BaseView; | ||
| 20 | +import com.cnlive.core.libs.base.ui.widget.LetterBarView; | ||
| 21 | +import com.cnlive.strike.xiaojiaspeaker.R; | ||
| 22 | +import com.cnlive.strike.xiaojiaspeaker.model.IMFriendHasLetterInfo; | ||
| 23 | +import com.cnlive.strike.xiaojiaspeaker.model.IMFriendNoLetterInfo; | ||
| 24 | +import com.cnlive.strike.xiaojiaspeaker.model.LetterComparator; | ||
| 25 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.XiaoJiaContactInfo; | ||
| 26 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.SetFriendsRoleActivity; | ||
| 27 | +import com.cnlive.strike.xiaojiaspeaker.ui.adapter.SelectIMFriendAdapter; | ||
| 28 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.SelectIMFriendFragment; | ||
| 29 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 30 | + | ||
| 31 | +import java.util.ArrayList; | ||
| 32 | +import java.util.Collections; | ||
| 33 | +import java.util.List; | ||
| 34 | + | ||
| 35 | +public class SelectIMFriendView extends BaseView implements LetterBarView.OnLetterSelectListener { | ||
| 36 | + private SelectIMFriendFragment fragment; | ||
| 37 | + private SelectIMFriendAdapter adapter; | ||
| 38 | + private List<IMFriendNoLetterInfo> noLetterInfoList; | ||
| 39 | + private List<IMFriendHasLetterInfo> imFriendInfoList; | ||
| 40 | + private LinearLayoutManager linearLayoutManager; | ||
| 41 | + private String currentSelectFamilyId; | ||
| 42 | + private boolean isFirst = true; | ||
| 43 | + | ||
| 44 | + public void setCurrentSelectFamilyId(String currentSelectFamilyId) { | ||
| 45 | + this.currentSelectFamilyId = currentSelectFamilyId; | ||
| 46 | + } | ||
| 47 | + | ||
| 48 | + public SelectIMFriendView(SelectIMFriendFragment fragment) { | ||
| 49 | + this.fragment = fragment; | ||
| 50 | + } | ||
| 51 | + | ||
| 52 | + public Activity getContext() { | ||
| 53 | + return fragment == null ? null : fragment.getActivity(); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + public void getIMData(XiaoJiaContactInfo xiaoJiaContactInfo) { | ||
| 57 | + ImOpenService service = (ImOpenService) ARouter.getInstance().build("/im/cnIMService").navigation(getContext()); | ||
| 58 | + if (null == service) { | ||
| 59 | + return; | ||
| 60 | + } | ||
| 61 | + service.getFriendList(new ImOpenService.CNValueCallBack<List<FriendListData>>() { | ||
| 62 | + @Override | ||
| 63 | + public void onError(int var1, String var2) { | ||
| 64 | + hideLoadingView(); | ||
| 65 | + showRetryView(-1, new View.OnClickListener() { | ||
| 66 | + @Override | ||
| 67 | + public void onClick(View view) { | ||
| 68 | + fragment.getPresenter().getFamilyMember(getContext(), currentSelectFamilyId); | ||
| 69 | + } | ||
| 70 | + }); | ||
| 71 | + } | ||
| 72 | + | ||
| 73 | + @Override | ||
| 74 | + public void onSuccess(List<FriendListData> var1) { | ||
| 75 | + | ||
| 76 | + List<String> hasSelectList = xiaoJiaContactInfo.getSids(); | ||
| 77 | + noLetterInfoList = new ArrayList<>(); | ||
| 78 | + if (null == var1) { | ||
| 79 | + return; | ||
| 80 | + } | ||
| 81 | + for (int i = 0; i < var1.size(); i++) { | ||
| 82 | + IMFriendNoLetterInfo noLetterInfo = new IMFriendNoLetterInfo(); | ||
| 83 | + //可选中 | ||
| 84 | + noLetterInfo.setCantSelect(false); | ||
| 85 | + for (int j = 0; j < hasSelectList.size(); j++) { | ||
| 86 | + //不可选中 | ||
| 87 | + if (hasSelectList.get(j).equals(var1.get(i).getFriendId())) { | ||
| 88 | + noLetterInfo.setCantSelect(true); | ||
| 89 | + break; | ||
| 90 | + } | ||
| 91 | + } | ||
| 92 | + noLetterInfo.setUserName(var1.get(i).getFriendNickName()); | ||
| 93 | + noLetterInfo.setId(var1.get(i).getFriendId()); | ||
| 94 | + noLetterInfo.setUserIcon(var1.get(i).getFriendFaceUrl()); | ||
| 95 | + noLetterInfoList.add(noLetterInfo); | ||
| 96 | + | ||
| 97 | + } | ||
| 98 | + int hasSelectCount = 0; | ||
| 99 | + if (null != hasSelectList) { | ||
| 100 | + hasSelectCount = hasSelectList.size(); | ||
| 101 | + } | ||
| 102 | + //设置 | ||
| 103 | + initView(noLetterInfoList, hasSelectCount); | ||
| 104 | + | ||
| 105 | + } | ||
| 106 | + }); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + public void initView(List<IMFriendNoLetterInfo> list, int hasSelectCount) { | ||
| 110 | + //设置按钮不可点击 | ||
| 111 | + nextBtnCanNotClick(); | ||
| 112 | + //假设这个是原有数据 | ||
| 113 | +// this.noLetterInfoList = noLetterInfoList; | ||
| 114 | + | ||
| 115 | + /*this.noLetterInfoList=new ArrayList<>(); | ||
| 116 | + IMFriendNoLetterInfo noLetterInfo = new IMFriendNoLetterInfo(); | ||
| 117 | + noLetterInfo.setUserName("韩亚云"); | ||
| 118 | + noLetterInfo.setCantSelect(true); | ||
| 119 | + noLetterInfo.setId("352660"); | ||
| 120 | + noLetterInfoList.add(noLetterInfo); | ||
| 121 | + | ||
| 122 | + noLetterInfo = new IMFriendNoLetterInfo(); | ||
| 123 | + noLetterInfo.setUserName("杨帅"); | ||
| 124 | + noLetterInfo.setId("352668"); | ||
| 125 | + noLetterInfoList.add(noLetterInfo); | ||
| 126 | + | ||
| 127 | + noLetterInfo = new IMFriendNoLetterInfo(); | ||
| 128 | + noLetterInfo.setUserName("杨杨"); | ||
| 129 | + noLetterInfo.setId("352700"); | ||
| 130 | + noLetterInfoList.add(noLetterInfo); | ||
| 131 | + | ||
| 132 | + noLetterInfo = new IMFriendNoLetterInfo(); | ||
| 133 | + noLetterInfo.setUserName("杨天"); | ||
| 134 | + noLetterInfo.setId("352782"); | ||
| 135 | + noLetterInfoList.add(noLetterInfo); | ||
| 136 | + | ||
| 137 | + noLetterInfo = new IMFriendNoLetterInfo(); | ||
| 138 | + noLetterInfo.setUserName("郭瑞鹏"); | ||
| 139 | + noLetterInfo.setId("352898"); | ||
| 140 | + noLetterInfoList.add(noLetterInfo); | ||
| 141 | + | ||
| 142 | + noLetterInfo = new IMFriendNoLetterInfo(); | ||
| 143 | + noLetterInfo.setUserName("殷巧娟"); | ||
| 144 | + noLetterInfo.setId("353001"); | ||
| 145 | + noLetterInfoList.add(noLetterInfo); | ||
| 146 | + | ||
| 147 | + noLetterInfo = new IMFriendNoLetterInfo(); | ||
| 148 | + noLetterInfo.setUserName("张晓文"); | ||
| 149 | + noLetterInfo.setId("353036"); | ||
| 150 | + noLetterInfoList.add(noLetterInfo); | ||
| 151 | + | ||
| 152 | + | ||
| 153 | + noLetterInfo = new IMFriendNoLetterInfo(); | ||
| 154 | + noLetterInfo.setUserName("小明"); | ||
| 155 | + noLetterInfo.setId("353360"); | ||
| 156 | + noLetterInfoList.add(noLetterInfo); | ||
| 157 | + | ||
| 158 | + noLetterInfo = new IMFriendNoLetterInfo(); | ||
| 159 | + noLetterInfo.setUserName("小红"); | ||
| 160 | + noLetterInfo.setId("353417"); | ||
| 161 | + noLetterInfoList.add(noLetterInfo); | ||
| 162 | + | ||
| 163 | + noLetterInfo = new IMFriendNoLetterInfo(); | ||
| 164 | + noLetterInfo.setUserName("小绿"); | ||
| 165 | + noLetterInfo.setId("353557"); | ||
| 166 | + noLetterInfoList.add(noLetterInfo); | ||
| 167 | + | ||
| 168 | + noLetterInfo = new IMFriendNoLetterInfo(); | ||
| 169 | + noLetterInfo.setUserName("小黄"); | ||
| 170 | + noLetterInfo.setId("353651"); | ||
| 171 | + noLetterInfoList.add(noLetterInfo); | ||
| 172 | + | ||
| 173 | + noLetterInfo = new IMFriendNoLetterInfo(); | ||
| 174 | + noLetterInfo.setUserName("张三"); | ||
| 175 | + noLetterInfo.setId("353728"); | ||
| 176 | + noLetterInfoList.add(noLetterInfo); | ||
| 177 | + | ||
| 178 | + noLetterInfo = new IMFriendNoLetterInfo(); | ||
| 179 | + noLetterInfo.setUserName("李四"); | ||
| 180 | + noLetterInfo.setId("353777"); | ||
| 181 | + noLetterInfoList.add(noLetterInfo); | ||
| 182 | + | ||
| 183 | + noLetterInfo = new IMFriendNoLetterInfo(); | ||
| 184 | + noLetterInfo.setUserName("王五"); | ||
| 185 | + noLetterInfo.setId("353789"); | ||
| 186 | + noLetterInfoList.add(noLetterInfo);*/ | ||
| 187 | + | ||
| 188 | + | ||
| 189 | + //对数据进行排序 | ||
| 190 | + Collections.sort(noLetterInfoList, new LetterComparator()); | ||
| 191 | + | ||
| 192 | + //开始循环遍历索引 | ||
| 193 | + String lastIndexStr = ""; | ||
| 194 | + //设置新的的带有索引的数据 | ||
| 195 | + imFriendInfoList = new ArrayList<>(); | ||
| 196 | + for (int i = 0; i < noLetterInfoList.size(); i++) { | ||
| 197 | + IMFriendHasLetterInfo hasLetterInfo = null; | ||
| 198 | + if (!lastIndexStr.equals(noLetterInfoList.get(i).getLetter())) { | ||
| 199 | + //添加索引 | ||
| 200 | + lastIndexStr = noLetterInfoList.get(i).getLetter(); | ||
| 201 | + //设置索引数据 | ||
| 202 | + hasLetterInfo = new IMFriendHasLetterInfo(); | ||
| 203 | + hasLetterInfo.setLetter(noLetterInfoList.get(i).getLetter()); | ||
| 204 | + //设置item类型 | ||
| 205 | + hasLetterInfo.setType(IMFriendHasLetterInfo.LETTER_INDEX); | ||
| 206 | + //添加数据 | ||
| 207 | + imFriendInfoList.add(hasLetterInfo); | ||
| 208 | + } | ||
| 209 | + //添加普通数据 | ||
| 210 | + hasLetterInfo = new IMFriendHasLetterInfo(); | ||
| 211 | + hasLetterInfo.setId(noLetterInfoList.get(i).getId()); | ||
| 212 | + hasLetterInfo.setType(IMFriendHasLetterInfo.USER_INFO); | ||
| 213 | + hasLetterInfo.setCantSelect(noLetterInfoList.get(i).isCantSelect()); | ||
| 214 | + hasLetterInfo.setUserIcon(noLetterInfoList.get(i).getUserIcon()); | ||
| 215 | + hasLetterInfo.setUserName(noLetterInfoList.get(i).getUserName()); | ||
| 216 | + imFriendInfoList.add(hasLetterInfo); | ||
| 217 | + } | ||
| 218 | + | ||
| 219 | + for (int i = 0; i < imFriendInfoList.size(); i++) { | ||
| 220 | + if (!lastIndexStr.equals(imFriendInfoList.get(i).getLetter())) { | ||
| 221 | + lastIndexStr = imFriendInfoList.get(i).getLetter(); | ||
| 222 | + //添加索引 | ||
| 223 | +// imFriendInfo = new IMFriendHasLetterInfo(); | ||
| 224 | + } | ||
| 225 | + } | ||
| 226 | + adapter = new SelectIMFriendAdapter(getContext(), imFriendInfoList); | ||
| 227 | + adapter.setCantSelectCount(hasSelectCount); | ||
| 228 | + linearLayoutManager = new LinearLayoutManager(getContext()); | ||
| 229 | + fragment.binding.rvFriends.setLayoutManager(linearLayoutManager); | ||
| 230 | + fragment.binding.rvFriends.setAdapter(adapter); | ||
| 231 | + hideLoadingView(); | ||
| 232 | + //设置选中状态监听 | ||
| 233 | + adapter.setOnItemCheckBoxListener(new SelectIMFriendAdapter.OnItemCheckBoxListener() { | ||
| 234 | + @Override | ||
| 235 | + public void itemCheckCount(int count) { | ||
| 236 | + if (count != 0) { | ||
| 237 | + fragment.binding.btnNext.setText("下一步(" + count + ")"); | ||
| 238 | + nextBtnCanClick(); | ||
| 239 | + } else { | ||
| 240 | + fragment.binding.btnNext.setText("下一步"); | ||
| 241 | + nextBtnCanNotClick(); | ||
| 242 | + } | ||
| 243 | + } | ||
| 244 | + }); | ||
| 245 | + //设置索引滑动监听 | ||
| 246 | + fragment.binding.letterBarView.setOnLetterSelectListener(this); | ||
| 247 | + //搜索框点击事件 | ||
| 248 | + fragment.binding.etQuery.setOnClickListener(new View.OnClickListener() { | ||
| 249 | + @Override | ||
| 250 | + public void onClick(View view) { | ||
| 251 | + fragment.binding.etQuery.setFocusable(true);//设置获取焦点可以编辑 | ||
| 252 | + fragment.binding.etQuery.setFocusableInTouchMode(true); | ||
| 253 | + fragment.binding.etQuery.requestFocus();//重新请求焦点 | ||
| 254 | + if (isFirst) { | ||
| 255 | + //强制调用键盘 | ||
| 256 | + InputMethodManager inputMethodManager = | ||
| 257 | + (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE); | ||
| 258 | + if (getContext().getWindow().getAttributes().softInputMode == WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED) { | ||
| 259 | + inputMethodManager.toggleSoftInput(0, InputMethodManager.SHOW_FORCED); | ||
| 260 | + } | ||
| 261 | + isFirst = false; | ||
| 262 | + } | ||
| 263 | + } | ||
| 264 | + }); | ||
| 265 | + fragment.binding.etQuery.addTextChangedListener(new TextWatcher() { | ||
| 266 | + @Override | ||
| 267 | + public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) { | ||
| 268 | + | ||
| 269 | + } | ||
| 270 | + | ||
| 271 | + @Override | ||
| 272 | + public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) { | ||
| 273 | + if (null != adapter) { | ||
| 274 | + if (charSequence.toString().trim().length() > 0) { | ||
| 275 | + fragment.binding.ivDelete.setVisibility(View.VISIBLE); | ||
| 276 | + List<IMFriendHasLetterInfo> list = new ArrayList<>(); | ||
| 277 | + for (int t = 0; t < imFriendInfoList.size(); t++) { | ||
| 278 | + if (imFriendInfoList.get(t).getType() != IMFriendHasLetterInfo.LETTER_INDEX) { | ||
| 279 | + if (imFriendInfoList.get(t).getUserName().indexOf(charSequence.toString()) != -1) { | ||
| 280 | + Log.e(TAG, "onTextChanged: " + imFriendInfoList.get(t).getUserName()); | ||
| 281 | + list.add(imFriendInfoList.get(t)); | ||
| 282 | + } | ||
| 283 | + } | ||
| 284 | + } | ||
| 285 | + adapter.searchItems(list); | ||
| 286 | + } else { | ||
| 287 | + fragment.binding.ivDelete.setVisibility(View.GONE); | ||
| 288 | + adapter.resetItems(); | ||
| 289 | + } | ||
| 290 | + } | ||
| 291 | + } | ||
| 292 | + | ||
| 293 | + @Override | ||
| 294 | + public void afterTextChanged(Editable editable) { | ||
| 295 | + | ||
| 296 | + } | ||
| 297 | + }); | ||
| 298 | + | ||
| 299 | + //删除 | ||
| 300 | + fragment.binding.ivDelete.setOnClickListener(new View.OnClickListener() { | ||
| 301 | + @Override | ||
| 302 | + public void onClick(View view) { | ||
| 303 | + fragment.binding.etQuery.setText(""); | ||
| 304 | + if (null != adapter) { | ||
| 305 | + adapter.resetItems(); | ||
| 306 | + } | ||
| 307 | + } | ||
| 308 | + }); | ||
| 309 | + //下一步按钮 | ||
| 310 | + fragment.binding.btnNext.setOnClickListener(new View.OnClickListener() { | ||
| 311 | + @Override | ||
| 312 | + public void onClick(View view) { | ||
| 313 | + //获取选择的uid | ||
| 314 | + if (null != adapter) { | ||
| 315 | + String selectUids = adapter.getSelectUid(); | ||
| 316 | + SetFriendsRoleActivity.startActivity(getContext(), selectUids, currentSelectFamilyId); | ||
| 317 | + | ||
| 318 | + } | ||
| 319 | + } | ||
| 320 | + }); | ||
| 321 | + } | ||
| 322 | + | ||
| 323 | + /** | ||
| 324 | + * 下一步按钮可以点击 | ||
| 325 | + */ | ||
| 326 | + public void nextBtnCanClick() { | ||
| 327 | + fragment.binding.btnNext.setEnabled(true); | ||
| 328 | + fragment.binding.btnNext.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.selector_xiaojia_btn_green)); | ||
| 329 | + | ||
| 330 | + } | ||
| 331 | + | ||
| 332 | + /** | ||
| 333 | + * 下一步按钮可以点击 | ||
| 334 | + */ | ||
| 335 | + public void nextBtnCanNotClick() { | ||
| 336 | + fragment.binding.btnNext.setEnabled(false); | ||
| 337 | + fragment.binding.btnNext.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_xiaojia_btn_press)); | ||
| 338 | + } | ||
| 339 | + | ||
| 340 | + /** | ||
| 341 | + * 点击索引 | ||
| 342 | + * | ||
| 343 | + * @param s | ||
| 344 | + */ | ||
| 345 | + @Override | ||
| 346 | + public void onLetterSelect(String s) { | ||
| 347 | + //滑动列表 | ||
| 348 | + if (null != adapter && null != imFriendInfoList && !TextUtils.isEmpty(s) && null != linearLayoutManager) { | ||
| 349 | + //获取指定列表 | ||
| 350 | + if (null != adapter.getContactLetterGuideMap()) { | ||
| 351 | + if (null != adapter.getContactLetterGuideMap().get(s)) { | ||
| 352 | + linearLayoutManager.scrollToPositionWithOffset(adapter.getContactLetterGuideMap().get(s), 0); | ||
| 353 | + } | ||
| 354 | + | ||
| 355 | + } | ||
| 356 | + } | ||
| 357 | + } | ||
| 358 | + | ||
| 359 | + /** | ||
| 360 | + * 显示loading | ||
| 361 | + */ | ||
| 362 | + public void showLoadingView() { | ||
| 363 | + if (fragment.binding.emptyLayout == null) { | ||
| 364 | + return; | ||
| 365 | + } | ||
| 366 | + fragment.binding.emptyLayout.show(true); | ||
| 367 | + } | ||
| 368 | + | ||
| 369 | + /** | ||
| 370 | + * 隐藏loading | ||
| 371 | + */ | ||
| 372 | + public void hideLoadingView() { | ||
| 373 | + if (fragment.binding.emptyLayout == null) { | ||
| 374 | + return; | ||
| 375 | + } | ||
| 376 | + fragment.binding.emptyLayout.hide(); | ||
| 377 | + } | ||
| 378 | + | ||
| 379 | + /** | ||
| 380 | + * 显示重试页面 | ||
| 381 | + * | ||
| 382 | + * @param errorCode | ||
| 383 | + * @param listener | ||
| 384 | + */ | ||
| 385 | + public void showRetryView(int errorCode, View.OnClickListener listener) { | ||
| 386 | + //显示空视图 | ||
| 387 | + fragment.binding.emptyLayout.setVisibility(View.VISIBLE); | ||
| 388 | + | ||
| 389 | + if (fragment.binding.emptyLayout == null) return; | ||
| 390 | + String titleText = ""; | ||
| 391 | + String detailText = ""; | ||
| 392 | + if (errorCode == -3) { | ||
| 393 | + titleText = getContext().getString(R.string.msg_failed_network_title); | ||
| 394 | + detailText = getContext().getString(R.string.msg_failed_network_detail); | ||
| 395 | + } else { | ||
| 396 | + titleText = getContext().getString(R.string.msg_failed_other_title); | ||
| 397 | + detailText = getContext().getString(R.string.msg_failed_other_detail); | ||
| 398 | + } | ||
| 399 | + fragment.binding.emptyLayout.show(false, titleText, detailText, getContext().getString(R.string.retry), R.drawable.wufalianjie, listener); | ||
| 400 | + } | ||
| 401 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/SelectWifiFragmentView.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.view; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.bluetooth.BluetoothGatt; | ||
| 5 | +import android.graphics.Typeface; | ||
| 6 | +import android.net.wifi.ScanResult; | ||
| 7 | +import android.os.Handler; | ||
| 8 | +import android.text.TextUtils; | ||
| 9 | +import android.util.Log; | ||
| 10 | +import android.view.View; | ||
| 11 | + | ||
| 12 | +import androidx.core.content.ContextCompat; | ||
| 13 | +import androidx.recyclerview.widget.LinearLayoutManager; | ||
| 14 | + | ||
| 15 | +import com.clj.fastble.BleManager; | ||
| 16 | +import com.clj.fastble.callback.BleGattCallback; | ||
| 17 | +import com.clj.fastble.callback.BleNotifyCallback; | ||
| 18 | +import com.clj.fastble.callback.BleWriteCallback; | ||
| 19 | +import com.clj.fastble.data.BleDevice; | ||
| 20 | +import com.clj.fastble.exception.BleException; | ||
| 21 | +import com.cnlive.core.libs.base.frame.view.BaseView; | ||
| 22 | +import com.cnlive.core.libs.base.util.AlertUtil; | ||
| 23 | +import com.cnlive.strike.xiaojiaspeaker.R; | ||
| 24 | +import com.cnlive.strike.xiaojiaspeaker.commonInfo.XiaoJIaCommInfo; | ||
| 25 | +import com.cnlive.strike.xiaojiaspeaker.constants.BlufiConstants; | ||
| 26 | +import com.cnlive.strike.xiaojiaspeaker.frame.presenter.SelectWifiFragmentPresenter; | ||
| 27 | +import com.cnlive.strike.xiaojiaspeaker.model.message.EventMsg; | ||
| 28 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.NetworkResultBean; | ||
| 29 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.ConnBluetoothSuccessActivity; | ||
| 30 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.ConnFailActivity; | ||
| 31 | +import com.cnlive.strike.xiaojiaspeaker.ui.adapter.WifiRecycleAdapter; | ||
| 32 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.SelectWifiFragment; | ||
| 33 | +import com.cnlive.strike.xiaojiaspeaker.ui.widget.TipDialog; | ||
| 34 | +import com.cnlive.strike.xiaojiaspeaker.ui.widget.WifiPwdDialog; | ||
| 35 | +import com.cnlive.strike.xiaojiaspeaker.util.BlueToothUtil; | ||
| 36 | +import com.cnlive.strike.xiaojiaspeaker.util.QMUITipDialogUtil; | ||
| 37 | +import com.cnlive.strike.xiaojiaspeaker.util.WifiUtils; | ||
| 38 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 39 | + | ||
| 40 | +import org.greenrobot.eventbus.EventBus; | ||
| 41 | + | ||
| 42 | +import java.io.UnsupportedEncodingException; | ||
| 43 | +import java.util.ArrayList; | ||
| 44 | +import java.util.List; | ||
| 45 | + | ||
| 46 | +public class SelectWifiFragmentView extends BaseView { | ||
| 47 | + private SelectWifiFragment fragment; | ||
| 48 | + private WifiRecycleAdapter adapter; | ||
| 49 | + private List<ScanResult> results = new ArrayList<>(); | ||
| 50 | + private WifiUtils wifiUtils; | ||
| 51 | + private String TAG = "SelectWifiView"; | ||
| 52 | + private WifiPwdDialog wifiPwdDialog; | ||
| 53 | + private TipDialog errorDialog; | ||
| 54 | + private String SSID; | ||
| 55 | + private BleDevice bleDevice; | ||
| 56 | + private Handler failHandler; | ||
| 57 | + private String familyId; | ||
| 58 | + private String cmccId;//移动id | ||
| 59 | + private final int DELAY_TIME = 5;//延时查询10秒 | ||
| 60 | + private Runnable failRunnable; | ||
| 61 | + private boolean isSetNetSuccess = false; | ||
| 62 | + private final int FAIL_DELAY_TIME = 40;//配网中等待时间40秒 | ||
| 63 | + | ||
| 64 | + public SelectWifiFragmentView(SelectWifiFragment fragment) { | ||
| 65 | + this.fragment = fragment; | ||
| 66 | + wifiUtils = new WifiUtils(fragment.getActivity()); | ||
| 67 | + failHandler = new Handler(); | ||
| 68 | + failRunnable = new Runnable() { | ||
| 69 | + @Override | ||
| 70 | + public void run() { | ||
| 71 | + if (!isSetNetSuccess) { | ||
| 72 | + if (null != getContext()) { | ||
| 73 | + QMUITipDialogUtil.dismessDialog(); | ||
| 74 | + AlertUtil.showDeftToast(getContext(), "配网超时"); | ||
| 75 | + } | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + }; | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + public Activity getContext() { | ||
| 82 | + return fragment == null ? null : fragment.getActivity(); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + public void initWifiList(final BleDevice bleDevice) { | ||
| 86 | + this.familyId = XiaoJIaCommInfo.getFamilyId(getContext()); | ||
| 87 | + this.cmccId = XiaoJIaCommInfo.getCMCCId(getContext()); | ||
| 88 | + this.bleDevice = bleDevice; | ||
| 89 | + showLoading(); | ||
| 90 | + initWifiPwdDialog(); | ||
| 91 | + initErrorDialog(); | ||
| 92 | + if (null == adapter) { | ||
| 93 | + adapter = new WifiRecycleAdapter(getContext(), results); | ||
| 94 | + fragment.binding.rvWifi.setLayoutManager(new LinearLayoutManager(getContext())); | ||
| 95 | + fragment.binding.rvWifi.setAdapter(adapter); | ||
| 96 | + } | ||
| 97 | + adapter.setOnItemClickListener(new WifiRecycleAdapter.onItemClickListener() { | ||
| 98 | + @Override | ||
| 99 | + public void onItemClick(int position, ScanResult scanResult) { | ||
| 100 | + String encryptionType = scanResult.capabilities; | ||
| 101 | + SSID = scanResult.SSID; | ||
| 102 | + if (TextUtils.isEmpty(cmccId) || TextUtils.isEmpty(familyId)) { | ||
| 103 | + AlertUtil.showDeftToast(getContext(), "参数异常,请稍后重试!"); | ||
| 104 | + return; | ||
| 105 | + } | ||
| 106 | + //判断是否需要输入密码 | ||
| 107 | + if (!encryptionType.contains("WEP") && !encryptionType.contains("PSK") && !encryptionType.contains("EAP")) { | ||
| 108 | + Log.e(TAG, "onItemClick: 不需要密码"); | ||
| 109 | + connectDevice(bleDevice, SSID, ""); | ||
| 110 | + } else { | ||
| 111 | + //需要密码 | ||
| 112 | + if (!wifiPwdDialog.isShowing()) { | ||
| 113 | + wifiPwdDialog.setMsgTip(scanResult.SSID); | ||
| 114 | + wifiPwdDialog.show(); | ||
| 115 | + } | ||
| 116 | + } | ||
| 117 | + } | ||
| 118 | + }); | ||
| 119 | + wifiUtils.startScanWifi(); | ||
| 120 | + } | ||
| 121 | + | ||
| 122 | + private void initErrorDialog() { | ||
| 123 | + errorDialog = new TipDialog(getContext(), "", "关闭", R.color.btn_green, new TipDialog.DialogInterface() { | ||
| 124 | + @Override | ||
| 125 | + public void onClick(TipDialog dialog) { | ||
| 126 | + dialog.dismiss(); | ||
| 127 | + } | ||
| 128 | + }); | ||
| 129 | + errorDialog.setTipTextStyle(Typeface.DEFAULT); | ||
| 130 | + errorDialog.setTipTextSize(16); | ||
| 131 | + errorDialog.setCancelable(false); | ||
| 132 | + errorDialog.setCanceledOnTouchOutside(false); | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + private void initRefreshLayout() { | ||
| 136 | +// fragment.binding.refreshLayout.setEnableLoadMore(false); | ||
| 137 | +// fragment.binding.refreshLayout.setOnRefreshListener(new OnRefreshListener() { | ||
| 138 | +// @Override | ||
| 139 | +// public void onRefresh(@NonNull RefreshLayout refreshLayout) { | ||
| 140 | +// showLoading(); | ||
| 141 | +// wifiUtils.startScanWifi(); | ||
| 142 | +// } | ||
| 143 | +// }); | ||
| 144 | + } | ||
| 145 | + | ||
| 146 | + private void initWifiPwdDialog() { | ||
| 147 | + wifiPwdDialog = new WifiPwdDialog(getContext(), "", "取消", new WifiPwdDialog.DialogInterface() { | ||
| 148 | + @Override | ||
| 149 | + public void onClick(WifiPwdDialog dialog) { | ||
| 150 | + dialog.dismiss(); | ||
| 151 | + } | ||
| 152 | + }, "确定", new WifiPwdDialog.ConnDialogInterface() { | ||
| 153 | + @Override | ||
| 154 | + public void onClick(WifiPwdDialog dialog, String pwd) { | ||
| 155 | + if (!TextUtils.isEmpty(pwd) && !TextUtils.isEmpty(SSID)) { | ||
| 156 | + dialog.dismiss(); | ||
| 157 | + connectDevice(bleDevice, SSID, pwd); | ||
| 158 | + } else { | ||
| 159 | + AlertUtil.showDeftToast(getContext(), "密码不能为空"); | ||
| 160 | + } | ||
| 161 | + } | ||
| 162 | + }); | ||
| 163 | + wifiPwdDialog.setLeftBtnColor(R.color.color_999999); | ||
| 164 | + wifiPwdDialog.setRightBtnColor(R.color.btn_green); | ||
| 165 | + wifiPwdDialog.setCancelable(false); | ||
| 166 | + wifiPwdDialog.setCanceledOnTouchOutside(false); | ||
| 167 | + } | ||
| 168 | + | ||
| 169 | + public void updateWifiList() { | ||
| 170 | + hideLoading(); | ||
| 171 | + List<ScanResult> scanResults = wifiUtils.getScanResults(); | ||
| 172 | + if (null != scanResults && null != results) { | ||
| 173 | + results.clear(); | ||
| 174 | + results.addAll(scanResults); | ||
| 175 | + if (null != adapter) { | ||
| 176 | + adapter.notifyDataSetChanged(); | ||
| 177 | + } | ||
| 178 | + } | ||
| 179 | + } | ||
| 180 | + | ||
| 181 | + public void showLoading() { | ||
| 182 | + if (null == getContext()) { | ||
| 183 | + return; | ||
| 184 | + } | ||
| 185 | + fragment.binding.avLoading.show(); | ||
| 186 | + fragment.binding.llLoading.setVisibility(View.VISIBLE); | ||
| 187 | + //设置按钮不可点击 | ||
| 188 | + fragment.binding.btnNext.setClickable(false); | ||
| 189 | + fragment.binding.btnNext.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_xiaojia_btn_press)); | ||
| 190 | + | ||
| 191 | + } | ||
| 192 | + | ||
| 193 | + public void hideLoading() { | ||
| 194 | + if (null == getContext()) { | ||
| 195 | + return; | ||
| 196 | + } | ||
| 197 | +// fragment.binding.refreshLayout.finishRefresh(); | ||
| 198 | + fragment.binding.avLoading.hide(); | ||
| 199 | + fragment.binding.llLoading.setVisibility(View.GONE); | ||
| 200 | + //设置按钮可点击 | ||
| 201 | + fragment.binding.btnNext.setClickable(true); | ||
| 202 | + fragment.binding.btnNext.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.selector_xiaojia_btn_green)); | ||
| 203 | + } | ||
| 204 | + | ||
| 205 | + private void connectDevice(BleDevice bleDevice, final String wifiSSID, final String wifiPwd) { | ||
| 206 | + BleManager.getInstance().disconnect(bleDevice); | ||
| 207 | + BleManager.getInstance().connect(bleDevice, new BleGattCallback() { | ||
| 208 | + // 开始连接 | ||
| 209 | + @Override | ||
| 210 | + public void onStartConnect() { | ||
| 211 | + if (null == getContext()) { | ||
| 212 | + return; | ||
| 213 | + } | ||
| 214 | + QMUITipDialogUtil.loadingDialog(getContext(), "配网中,请稍后...", false); | ||
| 215 | + | ||
| 216 | + } | ||
| 217 | + | ||
| 218 | + // 连接失败 | ||
| 219 | + @Override | ||
| 220 | + public void onConnectFail(BleDevice bleDevice, BleException exception) { | ||
| 221 | + QMUITipDialogUtil.dismessDialog(); | ||
| 222 | + AlertUtil.showDeftToast(getContext(), "连接无响应,请稍后重试"); | ||
| 223 | + EventBus.getDefault().post(new EventMsg(EventMsg.DEVICE_NOT_RESPONSE, "")); | ||
| 224 | + } | ||
| 225 | + | ||
| 226 | + // 连接成功,BleDevice即为所连接的BLE设备 | ||
| 227 | + @Override | ||
| 228 | + public void onConnectSuccess(final BleDevice bleDevice, BluetoothGatt gatt, int status) { | ||
| 229 | + isSetNetSuccess = false; | ||
| 230 | + if (null != failHandler && null != failRunnable) { | ||
| 231 | + failHandler.removeCallbacks(failRunnable); | ||
| 232 | + failHandler.postDelayed(failRunnable, FAIL_DELAY_TIME * 1000); | ||
| 233 | + } | ||
| 234 | + BleManager.getInstance().notify( | ||
| 235 | + bleDevice, | ||
| 236 | + BlufiConstants.UUID_WIFI_SERVICE.toString(), | ||
| 237 | + BlufiConstants.UUID_NOTIFY_CHARACTERISTIC.toString(), | ||
| 238 | + new BleNotifyCallback() { | ||
| 239 | + @Override | ||
| 240 | + public void onNotifySuccess() { | ||
| 241 | + // 打开通知操作成功 | ||
| 242 | + BleManager.getInstance().write( | ||
| 243 | + bleDevice, | ||
| 244 | + BlufiConstants.UUID_WIFI_SERVICE.toString(), | ||
| 245 | + BlufiConstants.UUID_WRITE_CHARACTERISTIC.toString(), | ||
| 246 | + (BlueToothUtil.getSSIDAndPwd(wifiSSID, wifiPwd, cmccId)).getBytes(), | ||
| 247 | + new BleWriteCallback() { | ||
| 248 | + @Override | ||
| 249 | + public void onWriteSuccess(int current, int total, byte[] justWrite) { | ||
| 250 | +// Log.e(TAG, "onWriteSuccess: " + current + "," + total); | ||
| 251 | + // 发送数据到设备成功(分包发送的情况下,可以通过方法中返回的参数可以查看发送进度) | ||
| 252 | + } | ||
| 253 | + | ||
| 254 | + @Override | ||
| 255 | + public void onWriteFailure(BleException exception) { | ||
| 256 | + Log.e(TAG, "onWriteFailure: "); | ||
| 257 | + AlertUtil.showDeftToast(getContext(), "连接无响应,请稍后重试"); | ||
| 258 | + | ||
| 259 | + } | ||
| 260 | + }); | ||
| 261 | + // | ||
| 262 | + } | ||
| 263 | + | ||
| 264 | + @Override | ||
| 265 | + public void onNotifyFailure(BleException exception) { | ||
| 266 | + QMUITipDialogUtil.dismessDialog(); | ||
| 267 | + AlertUtil.showDeftToast(getContext(), "连接无响应,请稍后重试"); | ||
| 268 | + } | ||
| 269 | + | ||
| 270 | + @Override | ||
| 271 | + public void onCharacteristicChanged(byte[] data) { | ||
| 272 | + if (null == getContext()) { | ||
| 273 | + return; | ||
| 274 | + } | ||
| 275 | + try { | ||
| 276 | + String result = new String(data, "UTF-8"); | ||
| 277 | + Log.e(TAG, "onCharacteristicChanged: " + result); | ||
| 278 | + if (result.indexOf(BlufiConstants.BIND_SUCCESS) != -1 || result.indexOf(BlufiConstants.BIND_FAIL) != -1) { | ||
| 279 | + isSetNetSuccess = true; | ||
| 280 | + BleManager.getInstance().stopNotify(bleDevice, BlufiConstants.UUID_WIFI_SERVICE.toString(), BlufiConstants.UUID_NOTIFY_CHARACTERISTIC.toString()); | ||
| 281 | + BleManager.getInstance().disconnect(bleDevice); | ||
| 282 | + //查询配网是否成功 | ||
| 283 | + if (null == getContext()) { | ||
| 284 | + return; | ||
| 285 | + } | ||
| 286 | + //查询配网结果(延时查询) | ||
| 287 | + new Handler().postDelayed(new Runnable() { | ||
| 288 | + @Override | ||
| 289 | + public void run() { | ||
| 290 | + fragment.getPresenter().queryConfigDeviceNetResult(getContext(), familyId, new SelectWifiFragmentPresenter.OnResponseListener() { | ||
| 291 | + @Override | ||
| 292 | + public void onSuccess(NetworkResultBean networkResultBean) { | ||
| 293 | + if (null == getContext()) { | ||
| 294 | + return; | ||
| 295 | + } | ||
| 296 | + //判断是否绑定 | ||
| 297 | + if (networkResultBean.isIsBinded()) { | ||
| 298 | + EventBus.getDefault().post(new EventMsg(EventMsg.CLOSE_BLUETOOTH_ACTIVITY, null)); | ||
| 299 | + ConnBluetoothSuccessActivity.startActivity(getContext(), networkResultBean); | ||
| 300 | + } else { | ||
| 301 | + if (!TextUtils.isEmpty(networkResultBean.getPhone())) { | ||
| 302 | + ConnFailActivity.startActivity(getContext(), networkResultBean.getPhone()); | ||
| 303 | + }else { | ||
| 304 | + ConnFailActivity.startActivity(getContext(), networkResultBean.getBindtel()); | ||
| 305 | + } | ||
| 306 | + } | ||
| 307 | + } | ||
| 308 | + }); | ||
| 309 | + } | ||
| 310 | + }, DELAY_TIME * 1000); | ||
| 311 | + } else if (result.indexOf(BlufiConstants.WIFI_LINK_FAIL) != -1) { | ||
| 312 | + if (null != failHandler && null != failRunnable) { | ||
| 313 | + failHandler.removeCallbacks(failRunnable); | ||
| 314 | + } | ||
| 315 | + QMUITipDialogUtil.dismessDialog(); | ||
| 316 | + BleManager.getInstance().stopNotify(bleDevice, BlufiConstants.UUID_WIFI_SERVICE.toString(), BlufiConstants.UUID_NOTIFY_CHARACTERISTIC.toString()); | ||
| 317 | + BleManager.getInstance().disconnect(bleDevice); | ||
| 318 | + if (null != errorDialog) { | ||
| 319 | + if (!TextUtils.isEmpty(SSID)) { | ||
| 320 | + errorDialog.setTipMsg(SSID + "\n配网失败"); | ||
| 321 | + if (!errorDialog.isShowing()) { | ||
| 322 | + errorDialog.show(); | ||
| 323 | + } | ||
| 324 | + } | ||
| 325 | + } | ||
| 326 | + | ||
| 327 | + } | ||
| 328 | + } catch (UnsupportedEncodingException e) { | ||
| 329 | + e.printStackTrace(); | ||
| 330 | + } | ||
| 331 | + } | ||
| 332 | + } | ||
| 333 | + ); | ||
| 334 | + | ||
| 335 | + | ||
| 336 | + } | ||
| 337 | + | ||
| 338 | + // 连接中断,isActiveDisConnected表示是否是主动调用了断开连接方法 | ||
| 339 | + @Override | ||
| 340 | + public void onDisConnected(boolean isActiveDisConnected, BleDevice device, BluetoothGatt gatt, int status) { | ||
| 341 | + | ||
| 342 | + } | ||
| 343 | + }); | ||
| 344 | + } | ||
| 345 | + | ||
| 346 | + | ||
| 347 | +// private void queryDeviceConfigNet(Activity activity, String fromId) { | ||
| 348 | +// ConfigDeviceNetParam param = new ConfigDeviceNetParam(); | ||
| 349 | +// param.setAction("mc/getWifiResult"); | ||
| 350 | +// ConfigDeviceNetParam.DataBean dataBean = new ConfigDeviceNetParam.DataBean(); | ||
| 351 | +// dataBean.setFrom("he:28850150e8bd4c830314819939361b77"); | ||
| 352 | +// dataBean.setMyid("he:28850150e8bd4c830314819939361b77"); | ||
| 353 | +// dataBean.setToken("6fdff0f39ec659c94dd12cdc32937e9d"); | ||
| 354 | +// param.setData(dataBean); | ||
| 355 | +// fragment.getPresenter().queryConfigDeviceNetResult(activity, param); | ||
| 356 | +// } | ||
| 357 | +} | ||
| 358 | + |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/SetFriendsRoleView.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.view; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.text.TextUtils; | ||
| 5 | +import android.view.View; | ||
| 6 | + | ||
| 7 | +import androidx.core.content.ContextCompat; | ||
| 8 | +import androidx.recyclerview.widget.LinearLayoutManager; | ||
| 9 | + | ||
| 10 | +import com.cnlive.core.libs.base.frame.view.BaseView; | ||
| 11 | +import com.cnlive.core.libs.base.util.AlertUtil; | ||
| 12 | +import com.cnlive.strike.xiaojiaspeaker.R; | ||
| 13 | +import com.cnlive.strike.xiaojiaspeaker.model.RoleInfo; | ||
| 14 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.RoleNetBean; | ||
| 15 | +import com.cnlive.strike.xiaojiaspeaker.ui.adapter.SetRoleAdapter; | ||
| 16 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.SetFriendsRoleFragment; | ||
| 17 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 18 | + | ||
| 19 | +import java.util.ArrayList; | ||
| 20 | +import java.util.List; | ||
| 21 | + | ||
| 22 | +public class SetFriendsRoleView extends BaseView { | ||
| 23 | + private SetFriendsRoleFragment fragment; | ||
| 24 | + private List<RoleInfo> roleInfoList; | ||
| 25 | + private SetRoleAdapter adapter; | ||
| 26 | + private String currentSelFamilyId; | ||
| 27 | + | ||
| 28 | + public void setCurrentSelFamilyId(String currentSelFamilyId) { | ||
| 29 | + this.currentSelFamilyId = currentSelFamilyId; | ||
| 30 | + } | ||
| 31 | + | ||
| 32 | + public SetFriendsRoleView(SetFriendsRoleFragment fragment) { | ||
| 33 | + this.fragment = fragment; | ||
| 34 | + } | ||
| 35 | + | ||
| 36 | + public Activity getContext() { | ||
| 37 | + return fragment == null ? null : fragment.getActivity(); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + public void initView(RoleNetBean roleNetBean) { | ||
| 41 | + nextBtnCanNotClick(); | ||
| 42 | + roleInfoList = new ArrayList<>(); | ||
| 43 | + //整理数据 | ||
| 44 | + //获取选中的联系人 | ||
| 45 | + if (null != roleNetBean.getRoleUserList()) { | ||
| 46 | + RoleInfo roleInfo = null; | ||
| 47 | + for (int i = 0; i < roleNetBean.getRoleUserList().size(); i++) { | ||
| 48 | + roleInfo = new RoleInfo(); | ||
| 49 | + roleInfo.setUid(roleNetBean.getRoleUserList().get(i).getSid()); | ||
| 50 | + roleInfo.setUserName(roleNetBean.getRoleUserList().get(i).getNick()); | ||
| 51 | + roleInfo.setUserIcon(roleNetBean.getRoleUserList().get(i).getFace()); | ||
| 52 | + List<RoleNetBean.RoleListBean> roleList = new ArrayList<>(); | ||
| 53 | + for (int j = 0; j < roleNetBean.getRoleList().size(); j++) { | ||
| 54 | + RoleNetBean.RoleListBean bean = new RoleNetBean.RoleListBean(); | ||
| 55 | + bean.setAllowUse(roleNetBean.getRoleList().get(j).isAllowUse()); | ||
| 56 | + bean.setId(roleNetBean.getRoleList().get(j).getId()); | ||
| 57 | + bean.setRoleName(roleNetBean.getRoleList().get(j).getRoleName()); | ||
| 58 | + bean.setParentPosition(i); | ||
| 59 | + roleList.add(bean); | ||
| 60 | + } | ||
| 61 | + roleInfo.setRoleList(roleList); | ||
| 62 | + roleInfoList.add(roleInfo); | ||
| 63 | + } | ||
| 64 | + } | ||
| 65 | + //设置适配器 | ||
| 66 | + adapter = new SetRoleAdapter(getContext(), roleInfoList, currentSelFamilyId); | ||
| 67 | + fragment.binding.rvFriendsRole.setLayoutManager(new LinearLayoutManager(getContext())); | ||
| 68 | + fragment.binding.rvFriendsRole.setAdapter(adapter); | ||
| 69 | + //设置点击 | ||
| 70 | + adapter.setOnSelectListener(new SetRoleAdapter.OnSelectListener() { | ||
| 71 | + @Override | ||
| 72 | + public void onSelect(int roleId) { | ||
| 73 | + //判断用户角色是都全部设置 | ||
| 74 | + if (adapter.isPeopleAllSetRole()) { | ||
| 75 | + nextBtnCanClick(); | ||
| 76 | + } else { | ||
| 77 | + nextBtnCanNotClick(); | ||
| 78 | + } | ||
| 79 | + } | ||
| 80 | + | ||
| 81 | + @Override | ||
| 82 | + public void onCancel() { | ||
| 83 | + //判断用户角色是都全部设置 | ||
| 84 | + if (adapter.isPeopleAllSetRole()) { | ||
| 85 | + nextBtnCanClick(); | ||
| 86 | + } else { | ||
| 87 | + nextBtnCanNotClick(); | ||
| 88 | + } | ||
| 89 | + } | ||
| 90 | + }); | ||
| 91 | + //关闭提示 | ||
| 92 | + fragment.binding.llCloseTip.setOnClickListener(new View.OnClickListener() { | ||
| 93 | + @Override | ||
| 94 | + public void onClick(View v) { | ||
| 95 | + fragment.binding.flTipView.setVisibility(View.GONE); | ||
| 96 | + } | ||
| 97 | + }); | ||
| 98 | + //一键邀请 | ||
| 99 | + fragment.binding.btnNext.setOnClickListener(new View.OnClickListener() { | ||
| 100 | + @Override | ||
| 101 | + public void onClick(View v) { | ||
| 102 | + if (null != adapter) { | ||
| 103 | + String result = adapter.getRoleSetResult(); | ||
| 104 | + if (!TextUtils.isEmpty(result)) { | ||
| 105 | + fragment.getPresenter().invitFamilyMember(getContext(), result); | ||
| 106 | + } else { | ||
| 107 | + AlertUtil.showDeftToast(getContext(), "发送参数异常"); | ||
| 108 | + } | ||
| 109 | + } | ||
| 110 | + } | ||
| 111 | + }); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + | ||
| 115 | + /** | ||
| 116 | + * 显示loading | ||
| 117 | + */ | ||
| 118 | + public void showLoadingView() { | ||
| 119 | + if (fragment.binding.emptyLayout == null) { | ||
| 120 | + return; | ||
| 121 | + } | ||
| 122 | + fragment.binding.emptyLayout.show(true); | ||
| 123 | + } | ||
| 124 | + | ||
| 125 | + /** | ||
| 126 | + * 隐藏loading | ||
| 127 | + */ | ||
| 128 | + public void hideLoadingView() { | ||
| 129 | + if (fragment.binding.emptyLayout == null) { | ||
| 130 | + return; | ||
| 131 | + } | ||
| 132 | + fragment.binding.emptyLayout.hide(); | ||
| 133 | + } | ||
| 134 | + | ||
| 135 | + /** | ||
| 136 | + * 显示重试页面 | ||
| 137 | + * | ||
| 138 | + * @param errorCode | ||
| 139 | + * @param listener | ||
| 140 | + */ | ||
| 141 | + public void showRetryView(int errorCode, View.OnClickListener listener) { | ||
| 142 | + //显示空视图 | ||
| 143 | + fragment.binding.emptyLayout.setVisibility(View.VISIBLE); | ||
| 144 | + | ||
| 145 | + if (fragment.binding.emptyLayout == null) return; | ||
| 146 | + String titleText = ""; | ||
| 147 | + String detailText = ""; | ||
| 148 | + if (errorCode == -3) { | ||
| 149 | + titleText = getContext().getString(R.string.msg_failed_network_title); | ||
| 150 | + detailText = getContext().getString(R.string.msg_failed_network_detail); | ||
| 151 | + } else { | ||
| 152 | + titleText = getContext().getString(R.string.msg_failed_other_title); | ||
| 153 | + detailText = getContext().getString(R.string.msg_failed_other_detail); | ||
| 154 | + } | ||
| 155 | + fragment.binding.emptyLayout.show(false, titleText, detailText, getContext().getString(R.string.retry), R.drawable.wufalianjie, listener); | ||
| 156 | + } | ||
| 157 | + | ||
| 158 | + /** | ||
| 159 | + * 下一步按钮可以点击 | ||
| 160 | + */ | ||
| 161 | + public void nextBtnCanClick() { | ||
| 162 | + fragment.binding.btnNext.setEnabled(true); | ||
| 163 | + fragment.binding.btnNext.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.selector_xiaojia_btn_green)); | ||
| 164 | + | ||
| 165 | + } | ||
| 166 | + | ||
| 167 | + /** | ||
| 168 | + * 下一步按钮可以点击 | ||
| 169 | + */ | ||
| 170 | + public void nextBtnCanNotClick() { | ||
| 171 | + fragment.binding.btnNext.setEnabled(false); | ||
| 172 | + fragment.binding.btnNext.setBackground(ContextCompat.getDrawable(getContext(), R.drawable.shape_xiaojia_btn_press)); | ||
| 173 | + } | ||
| 174 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/frame/view/UserManagerView.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.frame.view; | ||
| 2 | + | ||
| 3 | +import android.app.Activity; | ||
| 4 | +import android.graphics.Color; | ||
| 5 | +import android.graphics.Typeface; | ||
| 6 | +import android.text.TextUtils; | ||
| 7 | +import android.view.View; | ||
| 8 | +import android.widget.Button; | ||
| 9 | + | ||
| 10 | +import androidx.core.content.ContextCompat; | ||
| 11 | +import androidx.recyclerview.widget.LinearLayoutManager; | ||
| 12 | + | ||
| 13 | +import com.cnlive.core.libs.base.frame.view.BaseView; | ||
| 14 | +import com.cnlive.core.libs.base.util.AlertUtil; | ||
| 15 | +import com.cnlive.strike.xiaojiaspeaker.R; | ||
| 16 | +import com.cnlive.strike.xiaojiaspeaker.commonInfo.XiaoJIaCommInfo; | ||
| 17 | +import com.cnlive.strike.xiaojiaspeaker.frame.presenter.UserManagerPresenter; | ||
| 18 | +import com.cnlive.strike.xiaojiaspeaker.model.RoleInfo; | ||
| 19 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.FamilyRoleBean; | ||
| 20 | +import com.cnlive.strike.xiaojiaspeaker.netWork.bean.RoleNetBean; | ||
| 21 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.InvitFriendActivity; | ||
| 22 | +import com.cnlive.strike.xiaojiaspeaker.ui.activity.SelectIMFriendActivity; | ||
| 23 | +import com.cnlive.strike.xiaojiaspeaker.ui.adapter.UserManagerAdapter; | ||
| 24 | +import com.cnlive.strike.xiaojiaspeaker.ui.fragment.UserManagerFragment; | ||
| 25 | +import com.cnlive.strike.xiaojiaspeaker.ui.widget.EditRoleDialog; | ||
| 26 | +import com.cnlive.strike.xiaojiaspeaker.ui.widget.SelectDialog; | ||
| 27 | +import com.cnlive.strike.xiaojiaspeaker.ui.widget.popmenu.PopMenu; | ||
| 28 | +import com.cnlive.strike.xiaojiaspeaker.ui.widget.popmenu.PopMenuInfo; | ||
| 29 | +import com.hannesdorfmann.mosby3.mvp.MvpView; | ||
| 30 | + | ||
| 31 | +import java.util.ArrayList; | ||
| 32 | +import java.util.List; | ||
| 33 | + | ||
| 34 | +public class UserManagerView extends BaseView { | ||
| 35 | + private UserManagerFragment fragment; | ||
| 36 | + private List<FamilyRoleBean.FamilyRoleListBean> familyRoleList; | ||
| 37 | + private UserManagerAdapter adapter; | ||
| 38 | + private List<PopMenuInfo> popMenuInfoList = null; | ||
| 39 | + private PopMenu mPopMenu; | ||
| 40 | + private List<RoleInfo> roleInfoList; | ||
| 41 | + private EditRoleDialog editRoleDialog; | ||
| 42 | + private SelectDialog deleteDialog; | ||
| 43 | + private Button btn_invit; | ||
| 44 | + private String currentSelectFamilyId; | ||
| 45 | + private String test = "{\n" + | ||
| 46 | + "\t\"familyRoleList\": [{\n" + | ||
| 47 | + "\t\t\t\"family_id\": \"fb8f160efc61431f96e8111e0cbfd349\",\n" + | ||
| 48 | + "\t\t\t\"roleName\": \"爷爷\",\n" + | ||
| 49 | + "\t\t\t\"id\": 3,\n" + | ||
| 50 | + "\t\t\t\"userMsg\": {\n" + | ||
| 51 | + "\t\t\t\t\"image\": \"\",\n" + | ||
| 52 | + "\t\t\t\t\"nickName\": \"demotest6\",\n" + | ||
| 53 | + "\t\t\t\t\"userId\": \"123456\"\n" + | ||
| 54 | + "\t\t\t},\n" + | ||
| 55 | + "\t\t\t\"sid\": 123456\n" + | ||
| 56 | + "\t\t},\n" + | ||
| 57 | + "\t\t{\n" + | ||
| 58 | + "\t\t\t\"family_id\": \"fb8f160efc61431f96e8111e0cbfd349\",\n" + | ||
| 59 | + "\t\t\t\"roleName\": \"管理员\",\n" + | ||
| 60 | + "\t\t\t\"id\": 11,\n" + | ||
| 61 | + "\t\t\t\"userMsg\": {\n" + | ||
| 62 | + "\t\t\t\t\"image\": \"http://yweb0.cnliveimg.com/images/headImg/2019/0903/1567494184454_small.jpg\",\n" + | ||
| 63 | + "\t\t\t\t\"nickName\": \"泡泡龙1\",\n" + | ||
| 64 | + "\t\t\t\t\"userId\": \"10505015\"\n" + | ||
| 65 | + "\t\t\t},\n" + | ||
| 66 | + "\t\t\t\"sid\": 10505015\n" + | ||
| 67 | + "\t\t},\n" + | ||
| 68 | + "\t\t{\n" + | ||
| 69 | + "\t\t\t\"family_id\": \"fb8f160efc61431f96e8111e0cbfd349\",\n" + | ||
| 70 | + "\t\t\t\"roleName\": \"妈妈\",\n" + | ||
| 71 | + "\t\t\t\"id\": 2,\n" + | ||
| 72 | + "\t\t\t\"userMsg\": {\n" + | ||
| 73 | + "\t\t\t\t\"image\": \"http://yweb0.cnliveimg.com/images/headImg/2019/0927/1569568821902_small.jpg\",\n" + | ||
| 74 | + "\t\t\t\t\"nickName\": \"徐近程\",\n" + | ||
| 75 | + "\t\t\t\t\"userId\": \"10510277\"\n" + | ||
| 76 | + "\t\t\t},\n" + | ||
| 77 | + "\t\t\t\"sid\": 10510277\n" + | ||
| 78 | + "\t\t}\n" + | ||
| 79 | + "\t],\n" + | ||
| 80 | + "\t\"isMaster\": 0\n" + | ||
| 81 | + "}"; | ||
| 82 | + | ||
| 83 | + public UserManagerView(UserManagerFragment fragment) { | ||
| 84 | + this.fragment = fragment; | ||
| 85 | + } | ||
| 86 | + | ||
| 87 | + public Activity getContext() { | ||
| 88 | + return fragment == null ? null : fragment.getActivity(); | ||
| 89 | + } | ||
| 90 | + | ||
| 91 | + public void setCurrentSelectFamily(String selectFamily) { | ||
| 92 | + currentSelectFamilyId = selectFamily; | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + public void initView(FamilyRoleBean familyRoleBean) { | ||
| 96 | + this.familyRoleList = familyRoleBean.getFamilyRoleList(); | ||
| 97 | +// FamilyRoleBean bean1 = GsonUtil.GsonToBean(test, FamilyRoleBean.class); | ||
| 98 | + if (null != familyRoleList) { | ||
| 99 | + for (FamilyRoleBean.FamilyRoleListBean bean : familyRoleList) { | ||
| 100 | + //判断是否是管理员 | ||
| 101 | + if (11 == bean.getId()) { | ||
| 102 | + bean.setType(FamilyRoleBean.FamilyRoleListBean.HOST); | ||
| 103 | + } else { | ||
| 104 | + bean.setType(FamilyRoleBean.FamilyRoleListBean.MEMBER); | ||
| 105 | + } | ||
| 106 | + } | ||
| 107 | + } | ||
| 108 | + for (int i = 0; i < familyRoleList.size(); i++) { | ||
| 109 | + //筛选出管理员 | ||
| 110 | + if (11 == familyRoleList.get(i).getId()) { | ||
| 111 | + FamilyRoleBean.FamilyRoleListBean bean = familyRoleList.get(i); | ||
| 112 | + familyRoleList.remove(i); | ||
| 113 | + familyRoleList.add(0, bean); | ||
| 114 | + } | ||
| 115 | + } | ||
| 116 | + //判断是否是管理者 | ||
| 117 | + if (FamilyRoleBean.HOST == familyRoleBean.getIsMaster()) { | ||
| 118 | + //是否显示按钮 | ||
| 119 | + if (null != familyRoleList && familyRoleList.size() > 1) { | ||
| 120 | + fragment.binding.llBtn.setVisibility(View.GONE); | ||
| 121 | + } else { | ||
| 122 | + fragment.binding.llBtn.setVisibility(View.VISIBLE); | ||
| 123 | + } | ||
| 124 | + adapter = new UserManagerAdapter(getContext(), familyRoleList, true); | ||
| 125 | + //是否显示使用者按钮 | ||
| 126 | + addAdminBtn(); | ||
| 127 | + } else { | ||
| 128 | + adapter = new UserManagerAdapter(getContext(), familyRoleList, false); | ||
| 129 | + | ||
| 130 | + } | ||
| 131 | + fragment.binding.rvUserManagerList.setLayoutManager(new LinearLayoutManager(getContext())); | ||
| 132 | + fragment.binding.rvUserManagerList.setAdapter(adapter); | ||
| 133 | + //编辑按钮点击事件 | ||
| 134 | + adapter.setOnEditClickListener(new UserManagerAdapter.OnEditClickListener() { | ||
| 135 | + @Override | ||
| 136 | + public void editClick(int position, FamilyRoleBean.FamilyRoleListBean bean) { | ||
| 137 | + fragment.getPresenter().getSetRoleList(getContext(), bean.getSid() + "", XiaoJIaCommInfo.getFamilyId(getContext()), bean); | ||
| 138 | + } | ||
| 139 | + }); | ||
| 140 | + //删除按钮点击 | ||
| 141 | + adapter.setOnDeleteClickListener(new UserManagerAdapter.OnDeleteClickListener() { | ||
| 142 | + @Override | ||
| 143 | + public void deleteClick(int position, FamilyRoleBean.FamilyRoleListBean bean) { | ||
| 144 | + deleteDialog = new SelectDialog(getContext(), "移除后,该用户将不再具备管理\n音箱的权限,确定移除吗?", "取消", new SelectDialog.DialogInterface() { | ||
| 145 | + @Override | ||
| 146 | + public void onClick(SelectDialog dialog) { | ||
| 147 | + dialog.dismiss(); | ||
| 148 | + } | ||
| 149 | + }, "确定", new SelectDialog.DialogInterface() { | ||
| 150 | + @Override | ||
| 151 | + public void onClick(SelectDialog dialog) { | ||
| 152 | + dialog.dismiss(); | ||
| 153 | + fragment.getPresenter().changeMemberRole(getContext(), bean.getSid() + "", bean.getFamily_id(), null, new UserManagerPresenter.OnResposeListener() { | ||
| 154 | + @Override | ||
| 155 | + public void onSuccess() { | ||
| 156 | + familyRoleList.remove(position); | ||
| 157 | + if (null != adapter) { | ||
| 158 | + adapter.notifyDataSetChanged(); | ||
| 159 | + } | ||
| 160 | + AlertUtil.showDeftToast(getContext(), "移除成功"); | ||
| 161 | + | ||
| 162 | + } | ||
| 163 | + }); | ||
| 164 | + } | ||
| 165 | + }); | ||
| 166 | + deleteDialog.setRightBtnColor(R.color.btn_green); | ||
| 167 | + deleteDialog.setTipTextStyle(Typeface.DEFAULT); | ||
| 168 | + if (!deleteDialog.isShowing()) { | ||
| 169 | + deleteDialog.show(); | ||
| 170 | + } | ||
| 171 | + } | ||
| 172 | + }); | ||
| 173 | + //邀请网家家好友点击事件 | ||
| 174 | + fragment.binding.btnInvitFriend.setOnClickListener(new View.OnClickListener() { | ||
| 175 | + @Override | ||
| 176 | + public void onClick(View view) { | ||
| 177 | + SelectIMFriendActivity.startActivity(getContext(), currentSelectFamilyId); | ||
| 178 | + } | ||
| 179 | + }); | ||
| 180 | + //二维码点击 | ||
| 181 | + fragment.binding.btnQrcode.setOnClickListener(new View.OnClickListener() { | ||
| 182 | + @Override | ||
| 183 | + public void onClick(View view) { | ||
| 184 | + InvitFriendActivity.startActivity(getContext(), currentSelectFamilyId); | ||
| 185 | + } | ||
| 186 | + }); | ||
| 187 | + //关闭提示按钮 | ||
| 188 | + fragment.binding.llCloseTip.setOnClickListener(new View.OnClickListener() { | ||
| 189 | + @Override | ||
| 190 | + public void onClick(View view) { | ||
| 191 | + fragment.binding.flCloseView.setVisibility(View.GONE); | ||
| 192 | + } | ||
| 193 | + }); | ||
| 194 | + } | ||
| 195 | + | ||
| 196 | + public void addAdminBtn() { | ||
| 197 | + fragment.binding.topbar.removeAllRightViews(); //添加邀请者按钮 | ||
| 198 | + btn_invit = fragment.binding.topbar.addRightTextButton("邀请使用者", R.id.rightBtn); | ||
| 199 | + btn_invit.setTextSize(15); | ||
| 200 | + btn_invit.setTextColor(ContextCompat.getColor(getContext(), R.color.color_282828)); | ||
| 201 | + btn_invit.setOnClickListener(new View.OnClickListener() { | ||
| 202 | + @Override | ||
| 203 | + public void onClick(View view) { | ||
| 204 | + if (null != getContext()) { | ||
| 205 | + showPop(btn_invit); | ||
| 206 | + } | ||
| 207 | + } | ||
| 208 | + }); | ||
| 209 | + } | ||
| 210 | + | ||
| 211 | + public void initRoleDialog(RoleNetBean roleNetBean, FamilyRoleBean.FamilyRoleListBean familyRoleListBean) { | ||
| 212 | + roleInfoList = new ArrayList<>(); | ||
| 213 | + //整理数据 | ||
| 214 | + //获取选中的联系人 | ||
| 215 | + if (null != roleNetBean.getRoleUserList()) { | ||
| 216 | + RoleInfo roleInfo = null; | ||
| 217 | + for (int i = 0; i < roleNetBean.getRoleUserList().size(); i++) { | ||
| 218 | + roleInfo = new RoleInfo(); | ||
| 219 | + roleInfo.setUid(roleNetBean.getRoleUserList().get(i).getSid()); | ||
| 220 | + roleInfo.setUserName(roleNetBean.getRoleUserList().get(i).getNick()); | ||
| 221 | + roleInfo.setUserIcon(roleNetBean.getRoleUserList().get(i).getFace()); | ||
| 222 | + List<RoleNetBean.RoleListBean> roleList = new ArrayList<>(); | ||
| 223 | + for (int j = 0; j < roleNetBean.getRoleList().size(); j++) { | ||
| 224 | + RoleNetBean.RoleListBean bean = new RoleNetBean.RoleListBean(); | ||
| 225 | + bean.setAllowUse(roleNetBean.getRoleList().get(j).isAllowUse()); | ||
| 226 | + bean.setId(roleNetBean.getRoleList().get(j).getId()); | ||
| 227 | + bean.setRoleName(roleNetBean.getRoleList().get(j).getRoleName()); | ||
| 228 | + bean.setParentPosition(i); | ||
| 229 | + roleList.add(bean); | ||
| 230 | + } | ||
| 231 | + roleInfo.setRoleList(roleList); | ||
| 232 | + roleInfoList.add(roleInfo); | ||
| 233 | + } | ||
| 234 | + } | ||
| 235 | + //设置适配器 | ||
| 236 | + if (null == editRoleDialog) { | ||
| 237 | + editRoleDialog = new EditRoleDialog(getContext()); | ||
| 238 | + } | ||
| 239 | + editRoleDialog.setData(roleInfoList, familyRoleListBean); | ||
| 240 | + editRoleDialog.setCancelable(false); | ||
| 241 | + editRoleDialog.setCanceledOnTouchOutside(false); | ||
| 242 | + if (!editRoleDialog.isShowing()) { | ||
| 243 | + editRoleDialog.show(); | ||
| 244 | + } | ||
| 245 | + editRoleDialog.setOnClickListener(new EditRoleDialog.OnClickListener() { | ||
| 246 | + @Override | ||
| 247 | + public void onCancelClick(EditRoleDialog dialog) { | ||
| 248 | + dialog.dismiss(); | ||
| 249 | + } | ||
| 250 | + | ||
| 251 | + @Override | ||
| 252 | + public void onSaveClick(EditRoleDialog dialog, String selectSid, String selectRole, String selectRoleName) { | ||
| 253 | + if (!TextUtils.isEmpty(selectSid) && !TextUtils.isEmpty(selectRole) && !TextUtils.isEmpty(currentSelectFamilyId)) { | ||
| 254 | + fragment.getPresenter().changeMemberRole(getContext(), selectSid, familyRoleListBean.getFamily_id(), selectRole, new UserManagerPresenter.OnResposeListener() { | ||
| 255 | + @Override | ||
| 256 | + public void onSuccess() { | ||
| 257 | + dialog.dismiss(); | ||
| 258 | + if (!TextUtils.isEmpty(selectRole) && !TextUtils.isEmpty(selectRoleName)) { | ||
| 259 | + familyRoleListBean.setId(Integer.parseInt(selectRole)); | ||
| 260 | + familyRoleListBean.setRoleName(selectRoleName); | ||
| 261 | + if (null != adapter) { | ||
| 262 | + adapter.notifyDataSetChanged(); | ||
| 263 | + } | ||
| 264 | + AlertUtil.showDeftToast(getContext(), "保存成功"); | ||
| 265 | + } | ||
| 266 | + } | ||
| 267 | + }); | ||
| 268 | + } else { | ||
| 269 | + AlertUtil.showDeftToast(getContext(), "保存失败,请移除成员再试"); | ||
| 270 | + dialog.dismiss(); | ||
| 271 | + } | ||
| 272 | + } | ||
| 273 | + }); | ||
| 274 | + } | ||
| 275 | + | ||
| 276 | + /** | ||
| 277 | + * 显示loading | ||
| 278 | + */ | ||
| 279 | + public void showLoadingView() { | ||
| 280 | + if (fragment.binding.emptyLayout == null) { | ||
| 281 | + return; | ||
| 282 | + } | ||
| 283 | + fragment.binding.emptyLayout.show(true); | ||
| 284 | + } | ||
| 285 | + | ||
| 286 | + /** | ||
| 287 | + * 隐藏loading | ||
| 288 | + */ | ||
| 289 | + public void hideLoadingView() { | ||
| 290 | + if (fragment.binding.emptyLayout == null) { | ||
| 291 | + return; | ||
| 292 | + } | ||
| 293 | + fragment.binding.emptyLayout.hide(); | ||
| 294 | + } | ||
| 295 | + | ||
| 296 | + /** | ||
| 297 | + * 显示重试页面 | ||
| 298 | + * | ||
| 299 | + * @param errorCode | ||
| 300 | + * @param listener | ||
| 301 | + */ | ||
| 302 | + public void showRetryView(int errorCode, View.OnClickListener listener) { | ||
| 303 | + //显示空视图 | ||
| 304 | + fragment.binding.emptyLayout.setVisibility(View.VISIBLE); | ||
| 305 | + | ||
| 306 | + if (fragment.binding.emptyLayout == null) return; | ||
| 307 | + String titleText = ""; | ||
| 308 | + String detailText = ""; | ||
| 309 | + if (errorCode == -3) { | ||
| 310 | + titleText = getContext().getString(R.string.msg_failed_network_title); | ||
| 311 | + detailText = getContext().getString(R.string.msg_failed_network_detail); | ||
| 312 | + } else { | ||
| 313 | + titleText = getContext().getString(R.string.msg_failed_other_title); | ||
| 314 | + detailText = getContext().getString(R.string.msg_failed_other_detail); | ||
| 315 | + } | ||
| 316 | + fragment.binding.emptyLayout.show(false, titleText, detailText, getContext().getString(R.string.retry), R.drawable.wufalianjie, listener); | ||
| 317 | + } | ||
| 318 | + | ||
| 319 | + public void initPopView() { | ||
| 320 | +// View contentView = LayoutInflater.from(getContext()) | ||
| 321 | +// .inflate(R.layout.activity_all_device, null); | ||
| 322 | +// BottomSheetDialog dialog = new BottomSheetDialog(getContext()); | ||
| 323 | +// dialog.setContentView(contentView); | ||
| 324 | +// dialog.setCancelable(false); | ||
| 325 | +// BottomSheetBehavior sheetBehavior = BottomSheetBehavior.from((View) contentView.getParent()); | ||
| 326 | +// sheetBehavior.setPeekHeight(200); | ||
| 327 | + //给布局设置透明背景色,让图片突出来 | ||
| 328 | +// bottomSheetDialog.getDelegate().findViewById(android.support.design.R.id.design_bottom_sheet) | ||
| 329 | +// .setBackgroundColor(getResources().getColor(android.R.color.transparent)); | ||
| 330 | +// dialog.show(); | ||
| 331 | + | ||
| 332 | + popMenuInfoList = new ArrayList<>(); | ||
| 333 | + PopMenuInfo popMenuInfo = new PopMenuInfo(); | ||
| 334 | + popMenuInfo.setTitle("邀请网家家好友"); | ||
| 335 | + popMenuInfo.setImgDrawable(R.drawable.icon_xiaojia_friend); | ||
| 336 | + popMenuInfoList.add(popMenuInfo); | ||
| 337 | + popMenuInfo = new PopMenuInfo(); | ||
| 338 | + popMenuInfo.setTitle("生成二维码邀请"); | ||
| 339 | + popMenuInfo.setImgDrawable(R.drawable.icon_xiaojia_qrcode); | ||
| 340 | + popMenuInfoList.add(popMenuInfo); | ||
| 341 | + | ||
| 342 | + if (null == mPopMenu) { | ||
| 343 | + mPopMenu = new PopMenu.Builder(fragment.getActivity()) | ||
| 344 | + .addData(popMenuInfoList) | ||
| 345 | + .setBackgroundColorArray(new int[]{Color.parseColor("#363636"), Color.parseColor("#BF000000"), Color.parseColor("#BF000000")}) | ||
| 346 | + .setLeftAndRightMargin(20) | ||
| 347 | + .setTopMargin(20) | ||
| 348 | + .setLineColor(R.color.white_50) | ||
| 349 | + .setTextColor(R.color.white) | ||
| 350 | + .setLineVisible(View.GONE) | ||
| 351 | +// .setArrowHeight(30f) | ||
| 352 | +// .setArrowHeight(30f) | ||
| 353 | + .setCancelable(false) | ||
| 354 | + .setCornerRadius(20f) | ||
| 355 | + .build(); | ||
| 356 | + } | ||
| 357 | + | ||
| 358 | + mPopMenu.setmItemClickListener(new PopMenu.OnItemClickListener() { | ||
| 359 | + @Override | ||
| 360 | + public void onClick(int position, PopMenuInfo popMenuInfo) { | ||
| 361 | + if (position == 0) { | ||
| 362 | + SelectIMFriendActivity.startActivity(getContext(), currentSelectFamilyId); | ||
| 363 | + } else if (position == 1) { | ||
| 364 | + InvitFriendActivity.startActivity(getContext(), currentSelectFamilyId); | ||
| 365 | + } | ||
| 366 | + } | ||
| 367 | + }); | ||
| 368 | + } | ||
| 369 | + | ||
| 370 | + public void showPop(View view) { | ||
| 371 | + if (null != getContext() && null != mPopMenu) { | ||
| 372 | + mPopMenu.show(view); | ||
| 373 | + } | ||
| 374 | + } | ||
| 375 | + | ||
| 376 | +} |
module/xiaojiasoundbox/src/main/java/com/cnlive/strike/xiaojiaspeaker/listener/WifiChangeListener.java
0 → 100644
| 1 | +package com.cnlive.strike.xiaojiaspeaker.listener; | ||
| 2 | + | ||
| 3 | +import android.net.NetworkInfo; | ||
| 4 | + | ||
| 5 | +public interface WifiChangeListener { | ||
| 6 | + void onScanResultAvailable(); | ||
| 7 | + | ||
| 8 | + void onWiFiStateChanged(int wifiState); | ||
| 9 | + | ||
| 10 | + void onNetWorkStateChanged(NetworkInfo.DetailedState state, String SSID); | ||
| 11 | + | ||
| 12 | + void onWifiPasswordFault(); | ||
| 13 | +} |