Commit 10656f4db11b35ec1c72abaea2fc39137fafe37b

Authored by YangShuai
1 parent 890ed474

完成用户登录模块修改

Showing 62 changed files with 4612 additions and 33 deletions

Too many changes to show.

To preserve performance only 62 of 250 files are displayed.

app/strike/build.gradle
... ... @@ -157,6 +157,7 @@ dependencies {
157 157 // implementation project(path: ':core:database')
158 158 implementation project(path: ':core:network')
159 159 implementation project(path: ':core:base')
  160 + implementation project(path: ':cloud:user')
160 161  
161 162 // implementation project(path: ':core:util')
162 163 // implementation project(path: ':core:encipher')
... ...
app/strike/src/main/java/com/cnlive/strike/MainActivity.java
... ... @@ -4,33 +4,33 @@ package com.cnlive.strike;
4 4 import android.content.Intent;
5 5 import android.view.View;
6 6  
7   -import com.cnlive.core.libs.base.network.manager.SubscriptionManager;
8 7 import com.cnlive.core.libs.base.frame.activity.BaseActivity;
  8 +import com.cnlive.strike.user.ui.activity.LoginActivity;
9 9  
10 10 public class MainActivity extends BaseActivity {
11 11  
12   -
13 12 @Override
14   - protected int initLayout() {
  13 + protected int getLayoutId() {
15 14 return R.layout.activity_main;
16 15 }
17 16  
18 17 @Override
19 18 protected void initView() {
20   -// findViewById(R.id.go_to).setOnClickListener(view -> startActivity(new Intent(this, MyActivity.class)));
  19 + super.initView();
21 20 findViewById(R.id.go_to).setOnClickListener(new View.OnClickListener() {
22 21 @Override
23 22 public void onClick(View v) {
24   - startActivity(new Intent(MainActivity.this,MyActivity.class));
  23 + startActivity(new Intent(MainActivity.this, LoginActivity.class));
  24 +// LoginActivity.start(MainActivity.this);
25 25  
26 26 }
27 27 });
28 28 }
29 29  
  30 +
30 31 @Override
31 32 protected void onPause() {
32 33 super.onPause();
33   - SubscriptionManager.getInstance().cancelAll();
34 34 }
35 35  
36 36 @Override
... ...
app/strike/src/main/java/com/cnlive/strike/MyActivity.java
... ... @@ -6,8 +6,9 @@ import com.cnlive.core.libs.base.frame.activity.BaseActivity;
6 6  
7 7 public class MyActivity extends BaseActivity {
8 8  
  9 +
9 10 @Override
10   - protected int initLayout() {
  11 + protected int getLayoutId() {
11 12 return R.layout.activity_my;
12 13 }
13 14  
... ...
app/strike/src/main/java/com/cnlive/strike/MyActivityTest1.java
... ... @@ -6,8 +6,9 @@ import com.cnlive.core.libs.base.frame.activity.BaseActivity;
6 6 public class MyActivityTest1 extends BaseActivity {
7 7  
8 8 @Override
9   - protected int initLayout() {
  9 + protected int getLayoutId() {
10 10 return R.layout.activity_my1;
  11 +
11 12 }
12 13  
13 14 @Override
... ...
app/strike/src/main/java/com/cnlive/strike/MyApp.java
... ... @@ -2,6 +2,7 @@ package com.cnlive.strike;
2 2  
3 3 import android.app.Application;
4 4  
  5 +import com.alibaba.android.arouter.launcher.ARouter;
5 6 import com.cnlive.core.libs.base.application.AppConfig;
6 7  
7 8 public class MyApp extends Application {
... ... @@ -15,5 +16,19 @@ public class MyApp extends Application {
15 16 "", "", "",
16 17 "", "", "",
17 18 BuildConfig.BAIDU_MAP_APP_KEY, "");
  19 + initARouter();
  20 + }
  21 +
  22 +
  23 + /**
  24 + * 初始化阿里的路由
  25 + */
  26 + private void initARouter() {
  27 + if (BuildConfig.DEBUG) { // 这两行必须写在init之前,否则这些配置在init过程中将无效
  28 + ARouter.openLog(); // 打印日志
  29 + ARouter.openDebug(); // 开启调试模式(如果在InstantRun模式下运行,必须开启调试模式!线上版本需要关闭,否则有安全风险)
  30 + ARouter.printStackTrace(); // 打印日志的时候打印线程堆栈
  31 + }
  32 + ARouter.init(this); // 尽可能早,推荐在Application中初始化
18 33 }
19 34 }
... ...
app/strike/src/main/java/com/cnlive/strike/MyFragment.java
... ... @@ -9,11 +9,10 @@ import android.view.ViewGroup;
9 9 import android.widget.TextView;
10 10  
11 11 import com.cnlive.core.libs.base.frame.fragment.BaseFragment;
12   -import com.cnlive.core.libs.base.network.BaseResult;
13   -import com.cnlive.core.libs.base.network.HttpConn;
14   -import com.cnlive.core.libs.base.network.NetCallBack;
  12 +import com.cnlive.core.network.BaseResult;
  13 +import com.cnlive.core.network.HttpConn;
  14 +import com.cnlive.core.network.NetCallBack;
15 15 import com.cnlive.core.libs.base.util.StatusBarConfig;
16   -import com.cnlive.core.network.interceptor.BasicParamsInterceptor;
17 16 import com.cnlive.strike.network.BaseRequest;
18 17 import com.cnlive.strike.network.api.ApiService;
19 18 import com.cnlive.strike.network.bean.LetHimNoSeeBean;
... ... @@ -43,6 +42,7 @@ public class MyFragment extends BaseFragment<MyFragmentView, MyPresenter> {
43 42  
44 43 @Override
45 44 protected void initView() {
  45 + super.initView();
46 46 setStatusBarColor(R.color.green, 0);
47 47 setStatusBarTextColor(StatusBarConfig.BLACK);
48 48 view.findViewById(R.id.btn_test).setOnClickListener(new View.OnClickListener() {
... ... @@ -81,7 +81,7 @@ public class MyFragment extends BaseFragment<MyFragmentView, MyPresenter> {
81 81 .setUrl("http://gank.io/api/data/")
82 82 .service(ApiService.class)
83 83 .getTest()
84   - .flatMap(new Function<TestBean, Observable<BaseResult<LetHimNoSeeBean>>>() {
  84 + .concatMap(new Function<TestBean, Observable<BaseResult<LetHimNoSeeBean>>>() {
85 85 @Override
86 86 public Observable<BaseResult<LetHimNoSeeBean>> apply(TestBean testBean) throws Exception {
87 87 Log.e(TAG, "apply: " + testBean.getResults().size());
... ... @@ -107,13 +107,7 @@ public class MyFragment extends BaseFragment&lt;MyFragmentView, MyPresenter&gt; {
107 107  
108 108 }
109 109 });
110   - }
111   -
112   - @Override
113   - protected void initData() {
114 110 getPresenter().setData("hha");
115 111 getMvpView().setData("test");
116 112 }
117   -
118   -
119 113 }
... ...
app/strike/src/main/java/com/cnlive/strike/MyFragment1.java
... ... @@ -25,15 +25,8 @@ public class MyFragment1 extends BaseFragment {
25 25  
26 26 @Override
27 27 protected void initView() {
  28 + super.initView();
28 29 setStatusBarColor(R.color.qmui_config_color_red, 0);
29 30 setStatusBarTextColor(StatusBarConfig.BLACK);
30   -
31   - }
32   -
33   - @Override
34   - protected void initData() {
35   -// getPresenter().setData1("dd");
36 31 }
37   -
38   -
39 32 }
... ...
app/strike/src/main/java/com/cnlive/strike/network/BaseRequest.java
... ... @@ -4,17 +4,16 @@ package com.cnlive.strike.network;
4 4 import android.text.TextUtils;
5 5  
6 6 import com.cnlive.core.libs.base.application.AppConfig;
7   -import com.cnlive.core.network.request.NetBuilder;
  7 +import com.cnlive.core.network.NetBuilder;
8 8  
9 9 import java.util.ArrayList;
10   -import java.util.HashMap;
11 10 import java.util.List;
12   -import java.util.Map;
13 11  
14 12 import okhttp3.Interceptor;
15 13  
16 14 /**
17   - * ys
  15 + * 基本请求
  16 + * ys
18 17 */
19 18 public class BaseRequest {
20 19 private String userSetUrl;
... ...
app/strike/src/main/java/com/cnlive/strike/network/api/ApiService.java
1 1 package com.cnlive.strike.network.api;
2 2  
3   -import com.cnlive.core.libs.base.network.BaseResult;
  3 +import com.cnlive.core.network.BaseResult;
4 4 import com.cnlive.strike.network.bean.LetHimNoSeeBean;
5 5 import com.cnlive.strike.network.bean.TestBean;
6 6  
... ...
app/strike/src/main/res/values/styles.xml
1 1 <resources>
2 2  
3 3 <!-- Base application theme. -->
4   - <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
  4 + <style name="AppTheme" parent="QMUI.Compat.NoActionBar">
5 5 <!-- Customize your theme here. -->
6 6 <item name="colorPrimary">@color/colorPrimary</item>
7 7 <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
... ...
cloud/user/.gitignore 0 → 100644
  1 +/build
... ...
cloud/user/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 21
  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 + debug {
  20 + resValue("string", "ACCOUNT_LABEL", "网家家 内测")
  21 + resValue("string", "ACCOUNT_TYPE", "com.cnlive.strike.debug.AccountType")
  22 + resValue("string", "ACCOUNT_PROVIDE", "com.cnlive.strike.debug.AccountProvide")
  23 + zipAlignEnabled true
  24 + }
  25 + release {
  26 + resValue("string", "ACCOUNT_LABEL", "网家家")
  27 + resValue("string", "ACCOUNT_TYPE", "com.cnlive.strike.AccountType")
  28 + resValue("string", "ACCOUNT_PROVIDE", "com.cnlive.strike.AccountProvide")
  29 + minifyEnabled false
  30 + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  31 + zipAlignEnabled true
  32 + }
  33 + }
  34 + dataBinding {
  35 + enabled true
  36 + }
  37 +
  38 +}
  39 +
  40 +dependencies {
  41 + implementation fileTree(dir: 'libs', include: ['*.jar'])
  42 +
  43 + implementation 'androidx.appcompat:appcompat:1.1.0'
  44 + testImplementation 'junit:junit:4.12'
  45 + androidTestImplementation 'androidx.test.ext:junit:1.1.1'
  46 + androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
  47 +
  48 + implementation project(path: ':core:network')
  49 +// implementation project(path: ':core:base')
  50 +
  51 + implementation 'com.cnlive.libs:emoj:2.0.9'
  52 +}
... ...
cloud/user/consumer-rules.pro 0 → 100644
cloud/user/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
... ...
cloud/user/src/androidTest/java/com/cnlive/strike/user/ExampleInstrumentedTest.java 0 → 100644
  1 +package com.cnlive.strike.user;
  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.user.test", appContext.getPackageName());
  26 + }
  27 +}
... ...
cloud/user/src/debug/res/mipmap-hdpi/icon_account.png 0 → 100644

4.41 KB

cloud/user/src/debug/res/mipmap-ldpi/icon_account.png 0 → 100644

2.17 KB

cloud/user/src/debug/res/mipmap-xhdpi/icon_account.png 0 → 100644

5.93 KB

cloud/user/src/debug/res/mipmap-xxhdpi/icon_account.png 0 → 100644

9.25 KB

cloud/user/src/debug/res/mipmap-xxxhdpi/icon_account.png 0 → 100644

13.2 KB

cloud/user/src/main/AndroidManifest.xml 0 → 100644
  1 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  2 + xmlns:tools="http://schemas.android.com/tools"
  3 + package="com.cnlive.strike.user">
  4 +
  5 + <uses-permission android:name="android.permission.INTERNET" />
  6 +
  7 + <!-- for mta statistics, not necessary-->
  8 + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  9 + <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  10 + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  11 + <uses-permission
  12 + android:name="android.permission.AUTHENTICATE_ACCOUNTS"
  13 + android:maxSdkVersion="22" />
  14 + <uses-permission
  15 + android:name="android.permission.GET_ACCOUNTS"
  16 + android:maxSdkVersion="22" />
  17 + <uses-permission
  18 + android:name="android.permission.MANAGE_ACCOUNTS"
  19 + android:maxSdkVersion="22" />
  20 + <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" /> <!-- 账户自动更新 App保活相关 -->
  21 + <uses-permission android:name="android.permission.WRITE_SYNC_SETTINGS" />
  22 + <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
  23 + <uses-permission android:name="android.permission.REQUEST_IGNORE_BATTERY_OPTIMIZATIONS" />
  24 + <uses-permission android:name="android.permission.ACTION_LIGHT_DEVICE_IDLE_MODE_CHANGED" />
  25 + <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" /> <!-- 账户权限相关 -->
  26 + <uses-permission
  27 + android:name="android.permission.INTERACT_ACROSS_USERS_FULL"
  28 + tools:ignore="ProtectedPermissions" />
  29 + <uses-permission
  30 + android:name="android.permission.ACCOUNT_MANAGER"
  31 + tools:ignore="ProtectedPermissions" />
  32 + <uses-permission android:name="android.permission.INTERNET" />
  33 +
  34 + <application android:largeHeap="true">
  35 + <meta-data
  36 + android:name="WEIBO_APPKEY"
  37 + android:value="3884700821" />
  38 + <meta-data
  39 + android:name="WEIBO_CHANNEL"
  40 + android:value="weibo" />
  41 +
  42 + <activity android:name="com.cnlive.strike.moudle.user.ui.activity.MainTestActivity" />
  43 + <activity
  44 + android:name=".ui.activity.LoginActivity"
  45 + android:configChanges="keyboardHidden|screenSize|orientation|smallestScreenSize|screenLayout"
  46 + android:launchMode="singleTop"
  47 + android:screenOrientation="portrait"
  48 + android:windowSoftInputMode="stateHidden|adjustPan">
  49 + <intent-filter>
  50 + <action android:name="android.accounts.AccountAuthenticator" />
  51 + </intent-filter>
  52 + </activity>
  53 +
  54 + <activity
  55 + android:name="com.cnlive.strike.moudle.user.ui.activity.BindPhoneNumberActivity"
  56 + android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation"
  57 + android:launchMode="singleTop"
  58 + android:screenOrientation="portrait" />
  59 + <activity
  60 + android:name="com.cnlive.strike.moudle.user.ui.activity.FirstLoginActivity"
  61 + android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation"
  62 + android:launchMode="singleTop"
  63 + android:screenOrientation="portrait" />
  64 + <activity
  65 + android:name=".ui.activity.SelectCountryActivity"
  66 + android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation"
  67 + android:launchMode="singleTask"
  68 + android:screenOrientation="portrait"
  69 + android:windowSoftInputMode="adjustResize" />
  70 + <!-- 个人资料页-->
  71 + <activity
  72 + android:name="com.cnlive.strike.moudle.user.ui.activity.PersonalDataActivity"
  73 + android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation"
  74 + android:launchMode="singleTop"
  75 + android:screenOrientation="portrait" />
  76 + <!--预览头像-->
  77 + <activity
  78 + android:name="com.cnlive.strike.moudle.user.ui.activity.PersonalImageActivity"
  79 + android:configChanges="screenSize|smallestScreenSize|screenLayout|orientation"
  80 + android:launchMode="singleTop"
  81 + android:screenOrientation="portrait" />
  82 + <!-- 个人资料姓名-->
  83 + <activity
  84 + android:name="com.cnlive.strike.moudle.user.ui.activity.UpdateContentActivity"
  85 + android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation"
  86 + android:launchMode="singleTop"
  87 + android:screenOrientation="portrait"
  88 + android:windowSoftInputMode="stateVisible|adjustPan" />
  89 + <!-- 个人签名-->
  90 + <activity
  91 + android:name="com.cnlive.strike.moudle.user.ui.activity.SignatureActivity"
  92 + android:configChanges="keyboardHidden|screenSize|smallestScreenSize|screenLayout|orientation"
  93 + android:launchMode="singleTop"
  94 + android:screenOrientation="portrait"
  95 + android:windowSoftInputMode="stateVisible|adjustPan" />
  96 +
  97 +
  98 + <service
  99 + android:name="com.cnlive.strike.user.auth.UserAccountService"
  100 + tools:ignore="ExportedService">
  101 + <intent-filter>
  102 + <action android:name="android.accounts.AccountAuthenticator" />
  103 + </intent-filter>
  104 +
  105 + <meta-data
  106 + android:name="android.accounts.AccountAuthenticator"
  107 + android:resource="@xml/authenticator" />
  108 + </service>
  109 +
  110 + <service
  111 + android:name="com.cnlive.strike.user.auth.UserSyncService"
  112 + android:exported="true">
  113 + <intent-filter>
  114 + <action android:name="android.content.SyncAdapter" />
  115 + </intent-filter>
  116 +
  117 + <meta-data
  118 + android:name="android.content.SyncAdapter"
  119 + android:resource="@xml/account_sync_adapter" />
  120 + </service>
  121 +
  122 + <provider
  123 + android:name="com.cnlive.strike.user.auth.UserAccountProvider"
  124 + android:authorities="@string/ACCOUNT_PROVIDE"
  125 + android:exported="false"
  126 + android:syncable="true" />
  127 + </application>
  128 +</manifest>
... ...
cloud/user/src/main/java/com/cnlive/strike/user/UserUtilAction.java 0 → 100644
  1 +package com.cnlive.strike.user;
  2 +
  3 +import android.content.Context;
  4 +import android.os.Environment;
  5 +
  6 +import com.cnlive.core.libs.base.application.AppConfig;
  7 +import com.cnlive.core.network.BaseResult;
  8 +import com.cnlive.strike.user.network.api.ApiBaseServiceOpen;
  9 +import com.cnlive.strike.user.network.api.BaseRequest;
  10 +import com.cnlive.strike.user.network.model.TokenData;
  11 +import com.cnlive.strike.user.network.model.UserData;
  12 +
  13 +import java.io.File;
  14 +import java.util.HashMap;
  15 +import java.util.Map;
  16 +
  17 +import io.reactivex.Observable;
  18 +import okhttp3.MediaType;
  19 +import okhttp3.RequestBody;
  20 +
  21 +
  22 +
  23 +/**
  24 + * Created by Lynn on 2018/10/15.
  25 + */
  26 +
  27 +public class UserUtilAction {
  28 + public static int TOKEN_ERROR_CODE = -900001;
  29 + public static String TOKEN_ERROR_MSG = "用户token为空";
  30 +
  31 + /**
  32 + * 快捷登录前发送手机验证码
  33 + *
  34 + * @param context
  35 + * @param mobile 手机号
  36 + * @return
  37 + */
  38 + public static Observable<BaseResult> sendMsgBefQuickLoginAction(final Context context, final String mobile, String countryCode) {
  39 + Map<String, String> requestMap = new HashMap<>();
  40 + requestMap.put("appId", AppConfig.getAppId());
  41 + requestMap.put("mobile", mobile);
  42 + requestMap.put("countryCode", countryCode);
  43 + requestMap.put("clientPlat", "a");
  44 + return BaseRequest.init().service(ApiBaseServiceOpen.class).sendVerifyCodeBefQuickLogin(requestMap);
  45 + }
  46 +
  47 +
  48 + /**
  49 + * 快捷登录
  50 + *
  51 + * @param context
  52 + * @param userPhone 手机号
  53 + * @param userCode 验证码
  54 + * @return
  55 + */
  56 + public static Observable<BaseResult<UserData>> quickLoginAction(Context context, String userPhone, String userCode, String countryCode) {
  57 + Map<String, String> requestMap = new HashMap<>();
  58 + requestMap.put("appId", AppConfig.getAppId());
  59 + requestMap.put("userName", userPhone);
  60 + requestMap.put("verificationCode", userCode);
  61 + requestMap.put("uuid", AppConfig.getAppUUID());
  62 + requestMap.put("frmId", AppConfig.getAppChannel());
  63 + requestMap.put("countryCode", countryCode);
  64 + requestMap.put("clientPlat", "a");
  65 + return BaseRequest.init().service(ApiBaseServiceOpen.class).quickLogin(requestMap);
  66 +
  67 + }
  68 +
  69 + /**
  70 + * 登录
  71 + *
  72 + * @param context
  73 + * @param userName 用户名
  74 + * @param pwd 密码
  75 + * @return
  76 + */
  77 + public static Observable<BaseResult<UserData>> loginAction(Context context, String userName, String pwd) {
  78 + Map<String, String> map = new HashMap<>();
  79 + map.put("appId", AppConfig.getAppId());
  80 + map.put("userName", userName);
  81 + map.put("pwd", pwd);
  82 + map.put("uuid", AppConfig.getAppUUID());
  83 + map.put("frmId", "");
  84 + map.put("clientPlat", "a");
  85 + return BaseRequest.init().service(ApiBaseServiceOpen.class).login(map);
  86 +
  87 + }
  88 +
  89 +
  90 + /**
  91 + * 查询用户信息
  92 + *
  93 + * @param context
  94 + * @param userId 用户ID
  95 + * @param srcUid 被查询用户ID
  96 + * @param token 查询者平台TOKEN
  97 + * @return
  98 + */
  99 + public static Observable<BaseResult<UserData>> queryUserInfo(Context context, String userId, String srcUid, String token) {
  100 + Map<String, String> map = new HashMap<>();
  101 + map.put("appId", AppConfig.getAppId());
  102 + map.put("uid", userId);
  103 + map.put("srcUid", srcUid);
  104 + map.put("clientPlat", "a");
  105 + map.put("token", token);
  106 +// if (TextUtils.isEmpty(token)) {
  107 +// callback.callback(TOKEN_ERROR_CODE, TOKEN_ERROR_MSG, null);
  108 +// }
  109 + return BaseRequest.init().service(ApiBaseServiceOpen.class).queryUserInfo(map);
  110 +
  111 + }
  112 +
  113 + /**
  114 + * 修改用户附加信息
  115 + *
  116 + * @param context
  117 + * @param userId 用户id
  118 + * @param extInfo 扩展信息
  119 + * @param token 平台token
  120 + * @return
  121 + */
  122 + public static Observable<BaseResult> updateUserExtInfo(Context context, String userId, String extInfo, String token) {
  123 + Map<String, String> map = new HashMap<>();
  124 + map.put("appId", AppConfig.getAppId());
  125 + map.put("uid", userId);
  126 + map.put("extInfo", extInfo);
  127 + map.put("token", token);
  128 + map.put("clientPlat", "a");
  129 +// if (TextUtils.isEmpty(token)) {
  130 +// callback.callback(TOKEN_ERROR_CODE, TOKEN_ERROR_MSG, null);
  131 +// }
  132 + return BaseRequest.init().service(ApiBaseServiceOpen.class).updateUserExtInfo(map);
  133 +
  134 + }
  135 +
  136 + ;
  137 +
  138 + /**
  139 + * 修改用户单项信息
  140 + *
  141 + * @param context
  142 + * @param uid 用户Id
  143 + * @param type nickName-昵称,gender-性别,email-邮箱, location-联系方式
  144 + * @param value 对应的信息,性别,m:男、f:女、n:未知
  145 + * @param token 平台TOKEN
  146 + * @return
  147 + */
  148 + public static Observable<BaseResult> modifyUserInfo(Context context, String uid, String type, String value, String token) {
  149 + Map<String, String> map = new HashMap<>();
  150 + map.put("appId", AppConfig.getAppId());
  151 + map.put("uid", uid);
  152 + map.put("type", type);
  153 + map.put("value", value);
  154 + map.put("clientPlat", "a");
  155 + map.put("token", token);
  156 +// if (TextUtils.isEmpty(token)) {
  157 +// callback.callback(TOKEN_ERROR_CODE, TOKEN_ERROR_MSG, null);
  158 +// }
  159 + return BaseRequest.init().service(ApiBaseServiceOpen.class).modifyUserInfo(map);
  160 +
  161 + }
  162 +
  163 + /**
  164 + * 注册或修改手机号前发手机验证码
  165 + *
  166 + * @param context
  167 + * @param mobile 手机号
  168 + * @return
  169 + */
  170 + public static Observable<BaseResult> sendVerifyCodeForUnRegistered(Context context, String mobile, String countryCode) {
  171 + Map<String, String> map = new HashMap<>();
  172 + map.put("appId", AppConfig.getAppId());
  173 + map.put("mobile", mobile);
  174 + map.put("clientPlat", "a");
  175 + map.put("countryCode", countryCode);
  176 + return BaseRequest.init().service(ApiBaseServiceOpen.class).sendVerifyCodeForUnRegistered(map);
  177 + }
  178 +
  179 + /**
  180 + * 更新手机号
  181 + *
  182 + * @param context
  183 + * @param uid 用户ID
  184 + * @param mobile 手机号
  185 + * @param verificationCode 手机验证码
  186 + * @param token 平台TOKEN
  187 + * @return
  188 + */
  189 + public static Observable<BaseResult> updateMobile(Context context, String uid, String mobile, String verificationCode, String token, String countryCode) {
  190 + Map<String, String> map = new HashMap<>();
  191 + map.put("appId", AppConfig.getAppId());
  192 + map.put("uid", uid);
  193 + map.put("mobile", mobile);
  194 + map.put("verificationCode", verificationCode);
  195 + map.put("clientPlat", "a");
  196 + map.put("countryCode", countryCode);
  197 + map.put("token", token);
  198 +// if (TextUtils.isEmpty(token)) {
  199 +// callback.callback(TOKEN_ERROR_CODE, TOKEN_ERROR_MSG, null);
  200 +// }
  201 + return BaseRequest.init().service(ApiBaseServiceOpen.class).updateMobile(map);
  202 +
  203 + }
  204 +
  205 + /**
  206 + * 注册
  207 + *
  208 + * @param context
  209 + * @param userName 邮箱或手机
  210 + * @param pwd 密码
  211 + * @param verificationCode 手机验证码(手机号注册时必填)
  212 + * @return
  213 + */
  214 + public static Observable<BaseResult<UserData>> register(Context context, String userName, String pwd, String verificationCode) {
  215 + Map<String, String> map = new HashMap<>();
  216 + map.put("appId", AppConfig.getAppId());
  217 + map.put("userName", userName);
  218 + map.put("pwd", pwd);
  219 + map.put("verificationCode", verificationCode);
  220 + map.put("invitationCode", "");
  221 + map.put("uuid", AppConfig.getAppUUID());
  222 + map.put("frmId", "");
  223 + map.put("clientPlat", "a");
  224 + return BaseRequest.init().service(ApiBaseServiceOpen.class).register(map);
  225 + }
  226 +
  227 +
  228 + /**
  229 + * 获取access_token
  230 + *
  231 + * @param context
  232 + * @return
  233 + */
  234 + public static Observable<BaseResult<TokenData>> accessToken(Context context) {
  235 + Map<String, String> map = new HashMap<>();
  236 + map.put("appId", AppConfig.getAppId());
  237 + map.put("secret", AppConfig.getAppSceret());
  238 + return BaseRequest.init().service(ApiBaseServiceOpen.class).accessToken(map);
  239 + }
  240 +
  241 +// /**
  242 +// * 上传头像
  243 +// *
  244 +// * @param context
  245 +// * @param uid 用户ID
  246 +// * @param face 头像文件
  247 +// * @param token 平台TOKEN
  248 +// * @param access_token
  249 +// * @return
  250 +// */
  251 +// public static Disposable updateUserFace(Context context, String uid, File face, String token, String access_token, DataCallback<BaseInfo<FaceData>> callback) {
  252 +// Map<String, RequestBody> params = new HashMap<>();
  253 +//
  254 +// if (TextUtils.isEmpty(token)) {
  255 +// callback.callback(TOKEN_ERROR_CODE, TOKEN_ERROR_MSG, null);
  256 +// }
  257 +//
  258 +// params.put("uid", getRequestString(uid));
  259 +// params.put("clientPlat", getRequestString("a"));
  260 +// params.put("token", getRequestString(token));
  261 +// params.put("access_token", getRequestString(access_token));
  262 +//
  263 +// RequestBody requestFace = RequestBody.create(MediaType.parse("multipart/form-data"), face);
  264 +// MultipartBody.Part faceBody = MultipartBody.Part.createFormData("face", face.getName(), requestFace);
  265 +//
  266 +// List<MultipartBody.Part> parts = new ArrayList<>();
  267 +// parts.add(faceBody);
  268 +//
  269 +//
  270 +// Subscriber<BaseInfo<FaceData>> subscriber = new Subscriber<BaseInfo<FaceData>>(context, ApiBaseSubscriber.subscriberBuild) {
  271 +// @Override
  272 +// public void onCompleted(String s, String s1, BaseInfo<FaceData> faceDataBaseInfo) {
  273 +// if (callback == null) return;
  274 +// callback.callback(SUCCESS, "", faceDataBaseInfo);
  275 +// }
  276 +//
  277 +// @Override
  278 +// public void onError(String s, String s1) {
  279 +// if (callback == null) return;
  280 +// int errorCode = -1;
  281 +// try {
  282 +// errorCode = Integer.valueOf(s);
  283 +// } catch (Exception ignored) {
  284 +// } finally {
  285 +// callback.callback(errorCode, s1, null);
  286 +// }
  287 +// }
  288 +// };
  289 +//
  290 +// return ApiBaseRequest.subscribe(ApiBaseRequest.service(ApiBaseServiceOpen.class).updateUserFace(params, parts), subscriber);
  291 +//// return ApiBaseRequest.service(ApiBaseServiceOpen.class, service -> service.updateUserFace(params, parts)).subscribe(context, callback);
  292 +// }
  293 +
  294 + private static RequestBody getRequestString(String value) {
  295 + RequestBody requestString = RequestBody.create(MediaType.parse("text/plain"), value);
  296 + return requestString;
  297 + }
  298 +
  299 +// public static Disposable zipFiles(Context context, List<String> imageFiles, DataCallback<List<String>> callback) {
  300 +// if (imageFiles == null || imageFiles.size() == 0) {
  301 +// callback.callback(0, "", imageFiles);
  302 +// } else {
  303 +// return Flowable.just(imageFiles)
  304 +// .observeOn(Schedulers.io())
  305 +// .map(list -> Luban.with(context)
  306 +// .ignoreBy(500)
  307 +// .setTargetDir(getPath())
  308 +// .load(list)
  309 +// .get())
  310 +// .observeOn(AndroidSchedulers.mainThread())
  311 +// .doOnError(throwable -> callback.callback(0, "", imageFiles))
  312 +// .onErrorResumeNext(Flowable.empty())
  313 +// .subscribe(
  314 +// list -> {
  315 +// List<String> files = new ArrayList<>();
  316 +// for (File file : list) files.add(file.getPath());
  317 +// callback.callback(0, "", files);
  318 +// });
  319 +// }
  320 +// return null;
  321 +// }
  322 +
  323 + private static String getPath() {
  324 + String path = Environment.getExternalStorageDirectory() + "/strike/image/";
  325 + File file = new File(path);
  326 + if (file.mkdirs()) {
  327 + return path;
  328 + }
  329 + return path;
  330 + }
  331 +
  332 +
  333 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/auth/AccountAuthenticatorActivity.java 0 → 100644
  1 +/*
  2 + * Copyright (C) 2009 The Android Open Source Project
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +
  17 +package com.cnlive.strike.user.auth;
  18 +
  19 +import android.accounts.AccountAuthenticatorResponse;
  20 +import android.accounts.AccountManager;
  21 +import android.os.Bundle;
  22 +
  23 +import androidx.appcompat.app.AppCompatActivity;
  24 +
  25 +/**
  26 + * Base class for implementing an Activity that is used to help implement an
  27 + * AbstractAccountAuthenticator. If the AbstractAccountAuthenticator needs to use an activity
  28 + * to handle the request then it can have the activity extend AccountAuthenticatorActivity.
  29 + * The AbstractAccountAuthenticator passes in the response to the intent using the following:
  30 + * <pre>
  31 + * intent.putExtra({@link AccountManager#KEY_ACCOUNT_AUTHENTICATOR_RESPONSE}, response);
  32 + * </pre>
  33 + * The activity then sets the result that is to be handed to the response via
  34 + * {@link #setAccountAuthenticatorResult(Bundle)}.
  35 + * This result will be sent as the result of the request when the activity finishes. If this
  36 + * is never set or if it is set to null then error {@link AccountManager#ERROR_CODE_CANCELED}
  37 + * will be called on the response.
  38 + */
  39 +public class AccountAuthenticatorActivity extends AppCompatActivity {
  40 + private AccountAuthenticatorResponse mAccountAuthenticatorResponse = null;
  41 + private Bundle mResultBundle = null;
  42 +
  43 + /**
  44 + * Set the result that is to be sent as the result of the request that caused this
  45 + * Activity to be launched. If result is null or this method is never called then
  46 + * the request will be canceled.
  47 + *
  48 + * @param result this is returned as the result of the AbstractAccountAuthenticator request
  49 + */
  50 + public final void setAccountAuthenticatorResult(Bundle result) {
  51 + mResultBundle = result;
  52 + }
  53 +
  54 + /**
  55 + * Retreives the AccountAuthenticatorResponse from either the intent of the icicle, if the
  56 + * icicle is non-zero.
  57 + *
  58 + * @param icicle the save instance data of this Activity, may be null
  59 + */
  60 + protected void onCreate(Bundle icicle) {
  61 + super.onCreate(icicle);
  62 +
  63 + mAccountAuthenticatorResponse =
  64 + getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
  65 +
  66 + if (mAccountAuthenticatorResponse != null) {
  67 + mAccountAuthenticatorResponse.onRequestContinued();
  68 + }
  69 + }
  70 +
  71 + /**
  72 + * Sends the result or a Constants.ERROR_CODE_CANCELED error if a result isn't present.
  73 + */
  74 + public void finish() {
  75 + if (mAccountAuthenticatorResponse != null) {
  76 + // send the result bundle back if set, otherwise send an error.
  77 + if (mResultBundle != null) {
  78 + mAccountAuthenticatorResponse.onResult(mResultBundle);
  79 + } else {
  80 + mAccountAuthenticatorResponse.onError(AccountManager.ERROR_CODE_CANCELED,
  81 + "canceled");
  82 + }
  83 + mAccountAuthenticatorResponse = null;
  84 + }
  85 + super.finish();
  86 + }
  87 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/auth/UserAccountAuthenticator.java 0 → 100644
  1 +package com.cnlive.strike.user.auth;
  2 +
  3 +import android.accounts.AbstractAccountAuthenticator;
  4 +import android.accounts.Account;
  5 +import android.accounts.AccountAuthenticatorResponse;
  6 +import android.accounts.AccountManager;
  7 +import android.accounts.NetworkErrorException;
  8 +import android.content.Context;
  9 +import android.content.Intent;
  10 +import android.os.Bundle;
  11 +
  12 +import com.cnlive.core.libs.base.util.LogUtil;
  13 +
  14 +
  15 +public class UserAccountAuthenticator extends AbstractAccountAuthenticator {
  16 + private String _tag = "UserAccountAuthenticator";
  17 + private Context _context;
  18 +
  19 + public UserAccountAuthenticator(Context context) {
  20 + super(context);
  21 + _context = context;
  22 + }
  23 +
  24 + public Bundle addAccount(AccountAuthenticatorResponse response, String accountType, String authTokenType, String[] requiredFeatures, Bundle options) {
  25 + LogUtil.d(_tag, accountType + " - " + authTokenType);
  26 + Bundle ret = new Bundle();
  27 + try {
  28 + Class<?> clazz = Class.forName("com.cnlive.strike.moudle.user.ui.activity.LoginActivity");
  29 + Intent intent = new Intent(_context, clazz);
  30 + intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE, response);
  31 + ret.putParcelable(AccountManager.KEY_INTENT, intent);
  32 + } catch (ClassNotFoundException e) {
  33 + e.printStackTrace();
  34 + }
  35 + return ret;
  36 + }
  37 +
  38 +
  39 + @Override
  40 + public Bundle confirmCredentials(AccountAuthenticatorResponse response, Account account, Bundle options) {
  41 + LogUtil.d(_tag, ".confirmCredentials");
  42 + return null;
  43 + }
  44 +
  45 +
  46 + @Override
  47 + public Bundle editProperties(AccountAuthenticatorResponse response, String accountType) {
  48 + LogUtil.d(_tag, ".editProperties");
  49 + return null;
  50 + }
  51 +
  52 +
  53 + @Override
  54 + public Bundle getAuthToken(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle loginOptions) throws NetworkErrorException {
  55 + LogUtil.d(_tag, ".getAuthToken");
  56 + return null;
  57 + }
  58 +
  59 +
  60 + @Override
  61 + public String getAuthTokenLabel(String authTokenType) {
  62 + LogUtil.d(_tag, ".getAuthTokenLabel");
  63 + return null;
  64 + }
  65 +
  66 +
  67 + @Override
  68 + public Bundle hasFeatures(AccountAuthenticatorResponse response, Account account, String[] features) throws NetworkErrorException {
  69 + LogUtil.d(_tag, ".hasFeatures");
  70 + return null;
  71 + }
  72 +
  73 +
  74 + @Override
  75 + public Bundle updateCredentials(AccountAuthenticatorResponse response, Account account, String authTokenType, Bundle loginOptions) {
  76 + LogUtil.d(_tag, ".updateCredentials");
  77 + return null;
  78 + }
  79 +
  80 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/auth/UserAccountProvider.java 0 → 100644
  1 +package com.cnlive.strike.user.auth;
  2 +
  3 +import android.content.ContentProvider;
  4 +import android.content.ContentValues;
  5 +import android.database.Cursor;
  6 +import android.net.Uri;
  7 +
  8 +import androidx.annotation.Nullable;
  9 +
  10 +public class UserAccountProvider extends ContentProvider {
  11 +
  12 + @Override
  13 + public boolean onCreate() {
  14 + return false;
  15 + }
  16 +
  17 + @Nullable
  18 + @Override
  19 + public Cursor query(Uri uri, String[] projection, String selection, String[] selectionArgs, String sortOrder) {
  20 + return null;
  21 + }
  22 +
  23 + @Nullable
  24 + @Override
  25 + public String getType(Uri uri) {
  26 + return null;
  27 + }
  28 +
  29 + @Nullable
  30 + @Override
  31 + public Uri insert(Uri uri, ContentValues values) {
  32 + return null;
  33 + }
  34 +
  35 + @Override
  36 + public int delete(Uri uri, String selection, String[] selectionArgs) {
  37 + return 0;
  38 + }
  39 +
  40 + @Override
  41 + public int update(Uri uri, ContentValues values, String selection, String[] selectionArgs) {
  42 + return 0;
  43 + }
  44 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/auth/UserAccountService.java 0 → 100644
  1 +package com.cnlive.strike.user.auth;
  2 +
  3 +import android.app.Service;
  4 +import android.content.Intent;
  5 +import android.os.IBinder;
  6 +
  7 +public class UserAccountService extends Service {
  8 + private UserAccountAuthenticator _saa;
  9 +
  10 + @Override
  11 + public IBinder onBind(Intent intent) {
  12 + IBinder ret = null;
  13 + if (intent.getAction().equals(android.accounts.AccountManager.ACTION_AUTHENTICATOR_INTENT))
  14 + ret = getMovieAuthenticator().getIBinder();
  15 + return ret;
  16 + }
  17 +
  18 + private UserAccountAuthenticator getMovieAuthenticator() {
  19 + if (_saa == null)
  20 + _saa = new UserAccountAuthenticator(this);
  21 + return _saa;
  22 + }
  23 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/auth/UserService.java 0 → 100644
  1 +package com.cnlive.strike.user.auth;
  2 +
  3 +import android.accounts.Account;
  4 +import android.accounts.AccountManager;
  5 +import android.accounts.AccountManagerCallback;
  6 +import android.content.ContentResolver;
  7 +import android.content.Context;
  8 +import android.os.Bundle;
  9 +import android.text.TextUtils;
  10 +
  11 +import com.cnlive.core.libs.base.application.AppConfig;
  12 +import com.cnlive.core.libs.base.util.SharedPreferencesHelper;
  13 +import com.cnlive.strike.user.R;
  14 +import com.cnlive.strike.user.model.CNLiveUserInfo;
  15 +import com.cnlive.strike.user.model.CNLiveUserInfoExt;
  16 +import com.cnlive.strike.user.network.model.UserData;
  17 +import com.google.gson.Gson;
  18 +
  19 +import java.util.HashMap;
  20 +import java.util.Map;
  21 +
  22 +/**
  23 + * 用户管理类
  24 + */
  25 +public class UserService {
  26 + private final String defaultFaceUrl = "http://wjj.ys1.cnliveimg.com/admin/test/head.png";
  27 +
  28 + private final String baseFaceUrl = "/mobile/images/mobilehead/default/";
  29 +
  30 + private boolean checkDefaultUrl(String url) {
  31 + if (!TextUtils.isEmpty(url) && url.contains(baseFaceUrl)) return true;
  32 + return false;
  33 + }
  34 +
  35 + private final String KEY_DEFAULT_ACCOUNT = "defaultaccount";//用户默认账户
  36 + private final String KEY_USER_DATA_USER_ID = "uid"; //用户uid
  37 + private final String KEY_USER_DATA_NICKNAME = "nickname"; //用户昵称
  38 + private final String KEY_USER_DATA_BIGFACEURL = "bigfaceurl"; //用户头像
  39 + private final String KEY_USER_DATA_FACEURL = "faceurl"; //用户头像
  40 + private final String KEY_USER_DATA_GENDER = "gender"; //用户性别
  41 + private final String KEY_USER_DATA_MOBILE = "mobile"; //用户手机号
  42 + private final String KEY_USER_COUNTRY_CODE = "countryCode";//手机号国家码
  43 + private final String KEY_USER_DATA_EMAIL = "email"; //用户邮箱
  44 + private final String KEY_USER_DATA_LOCATION = "location"; //用户地址
  45 + private final String KEY_USER_TOKEN = "token"; //用户token
  46 + private final String KEY_USER_FIRST_LOGIN = "firstLogin"; //用户token
  47 + private final String KEY_USER_SIGN = "sign"; //用户签名
  48 + private final String KEY_USER_UID_QQ = "qq"; //qquid
  49 + private final String KEY_USER_UID_WECHAT = "wechat"; //微信uid
  50 + private final String KEY_USER_UID_WEIBO = "weibo"; //微信签名
  51 +
  52 + private static UserService mInstance;
  53 + private Account activeAccount;
  54 + private CNLiveUserInfo activeUserInfo;
  55 + private SharedPreferencesHelper sharedPrefs;
  56 + private AccountManager mAccountManager;
  57 + private String mAccountType, mAccountProvide;
  58 +
  59 + private Map<String, Account> mAccountMap = new HashMap<>();
  60 +
  61 + /**
  62 + * 获取用户管理服务实例
  63 + *
  64 + * @param context 上下文
  65 + * @return 管理对象实例
  66 + */
  67 + public static synchronized UserService getInstance(Context context) {
  68 + if (mInstance == null && context != null)
  69 + mInstance = new UserService(context.getApplicationContext());
  70 + return mInstance;
  71 + }
  72 +
  73 + /**
  74 + * 默认构造函数(单例)
  75 + *
  76 + * @param context
  77 + */
  78 + private UserService(Context context) {
  79 + sharedPrefs = SharedPreferencesHelper.getInstance(context);
  80 + mAccountManager = AccountManager.get(context);
  81 + mAccountType = context.getString(R.string.ACCOUNT_TYPE);
  82 + mAccountProvide = context.getString(R.string.ACCOUNT_PROVIDE);
  83 + //初始化用户列表
  84 + initSystemAccounts();
  85 + //初始化登录用户
  86 + initAppAccount();
  87 + }
  88 +
  89 + /**
  90 + * 初始化系统用户列表
  91 + */
  92 + private void initSystemAccounts() {
  93 + mAccountMap.clear();
  94 + Account[] accounts = mAccountManager.getAccountsByType(mAccountType);
  95 + for (Account account : accounts) {
  96 + mAccountMap.put(account.name, account);
  97 + }
  98 + }
  99 +
  100 + /**
  101 + * 初始化默认系统账号
  102 + */
  103 + private void initAppAccount() {
  104 + String accountName = sharedPrefs.getValue(KEY_DEFAULT_ACCOUNT);
  105 +
  106 + if (mAccountMap.containsKey(accountName)) {
  107 + activeAccount = mAccountMap.get(accountName);
  108 + activeUserInfo = getAccountInfo(activeAccount);
  109 + } else {
  110 + activeAccount = null;
  111 + activeUserInfo = null;
  112 + }
  113 + }
  114 +
  115 + /**
  116 + * 判断App用户登录
  117 + *
  118 + * @return 如果登录返回 true
  119 + */
  120 + public boolean hasAppAccount() {
  121 + String accountName = sharedPrefs.getValue(KEY_DEFAULT_ACCOUNT);
  122 + return mAccountMap.containsKey(accountName) && activeUserInfo != null;
  123 + }
  124 +
  125 + /**
  126 + * 登录App用户 ,录入系统账号信息
  127 + *
  128 + * @param username 用户名
  129 + * @param password 密码
  130 + * @param userProfile 用户数据
  131 + */
  132 + public void loginAppAccount(String username, String password, UserData userProfile) {
  133 + if (mAccountMap.containsKey(username)) {
  134 + activeAccount = mAccountMap.get(username);
  135 + mAccountManager.setPassword(activeAccount, password);
  136 + } else {
  137 + activeAccount = new Account(username, mAccountType);
  138 + mAccountManager.addAccountExplicitly(activeAccount, password, null);
  139 + }
  140 +
  141 + // 自动同步
  142 + ContentResolver.setIsSyncable(activeAccount, mAccountProvide, 1);
  143 + ContentResolver.setSyncAutomatically(activeAccount, mAccountProvide, true);
  144 + // 间隔时间为30秒
  145 + ContentResolver.addPeriodicSync(activeAccount, mAccountProvide, new Bundle(), 1);
  146 +
  147 + setSystemAccountInfo(activeAccount, userProfile);
  148 +
  149 + mAccountMap.put(username, activeAccount);
  150 +
  151 + activeUserInfo = getAccountInfo(activeAccount);
  152 +
  153 + sharedPrefs.setValue(KEY_DEFAULT_ACCOUNT, username);
  154 + }
  155 +
  156 + /**
  157 + * 登出App用户
  158 + */
  159 + public void logoutAppAccount() {
  160 + AppConfig.setSid("");
  161 + if (sharedPrefs != null) {
  162 + sharedPrefs.remove(KEY_DEFAULT_ACCOUNT);
  163 + }
  164 + if (mAccountMap != null && activeAccount != null) mAccountMap.remove(activeAccount.name);
  165 + activeAccount = null;
  166 + activeUserInfo = null;
  167 + mInstance = null;
  168 + }
  169 +
  170 + /**
  171 + * 获取已经登陆用户信息
  172 + *
  173 + * @return 用户信息
  174 + */
  175 + public CNLiveUserInfo getAppAccount() {
  176 + return activeUserInfo;
  177 + }
  178 +
  179 + public static String getUid(Context context) {
  180 + CNLiveUserInfo activeUserInfo = getInstance(context).getAppAccount();
  181 + return activeUserInfo == null ? "" : activeUserInfo.getUid();
  182 + }
  183 +
  184 + public Account getSystemAccount() {
  185 + return activeAccount;
  186 + }
  187 +
  188 + public String getPassword(Account account) {
  189 + return mAccountManager.getPassword(account);
  190 + }
  191 +
  192 + /**
  193 + * 删除系统账号信息
  194 + *
  195 + * @param username 用户名
  196 + */
  197 + public void removeUser(String username, AccountManagerCallback<Boolean> callback) {
  198 + Account account = mAccountMap.remove(username);
  199 + if (account != null) mAccountManager.removeAccount(account, callback, null);
  200 + }
  201 +
  202 + /**
  203 + * 删除系统账号信息
  204 + *
  205 + * @param account 系统账号
  206 + */
  207 + public void removeUser(Account account, AccountManagerCallback<Boolean> callback) {
  208 + if (account != null) {
  209 + mAccountManager.removeAccount(account, callback, null);
  210 + }
  211 + }
  212 +
  213 +
  214 + /**
  215 + * 更新系统账号信息
  216 + *
  217 + * @param account 系统账号数据
  218 + * @param userProfile 用户账号数据
  219 + */
  220 + private void setSystemAccountInfo(Account account, UserData userProfile) {
  221 + if (account == null) return;
  222 + if (checkDefaultUrl(userProfile.getFaceUrl())) {
  223 + userProfile.setFaceUrl(defaultFaceUrl);
  224 + userProfile.setBigFaceUrl(defaultFaceUrl);
  225 + }
  226 + mAccountManager.setUserData(account, KEY_USER_DATA_USER_ID, userProfile.getUid());
  227 + mAccountManager.setUserData(account, KEY_USER_DATA_NICKNAME, userProfile.getNickName());
  228 + mAccountManager.setUserData(account, KEY_USER_DATA_FACEURL, userProfile.getFaceUrl());
  229 + mAccountManager.setUserData(account, KEY_USER_DATA_BIGFACEURL, userProfile.getBigFaceUrl());
  230 + mAccountManager.setUserData(account, KEY_USER_DATA_GENDER, userProfile.getGender());
  231 + mAccountManager.setUserData(account, KEY_USER_DATA_MOBILE, userProfile.getMobile());
  232 + mAccountManager.setUserData(account, KEY_USER_COUNTRY_CODE, userProfile.getCountryCode());
  233 + mAccountManager.setUserData(account, KEY_USER_DATA_EMAIL, userProfile.getEmail());
  234 + mAccountManager.setUserData(account, KEY_USER_FIRST_LOGIN, userProfile.isNewUser() ? "0" : "1");
  235 + mAccountManager.setUserData(account, KEY_USER_DATA_LOCATION, userProfile.getLocation());
  236 + mAccountManager.setUserData(account, KEY_USER_TOKEN, userProfile.getToken());
  237 +
  238 + mAccountManager.setUserData(account, KEY_USER_UID_QQ, userProfile.getQqUid());
  239 + mAccountManager.setUserData(account, KEY_USER_UID_WEIBO, userProfile.getSinaUid());
  240 + mAccountManager.setUserData(account, KEY_USER_UID_WECHAT, userProfile.getWxUid());
  241 + setUserExt(userProfile.getExtInfo());
  242 + }
  243 +
  244 + public void setUserExt(String ext) {
  245 + try {
  246 + CNLiveUserInfoExt extData = new Gson().fromJson(ext, CNLiveUserInfoExt.class);
  247 +
  248 + mAccountManager.setUserData(activeAccount, KEY_USER_SIGN, extData.getUserSign());
  249 + } catch (Exception e) {
  250 + }
  251 + }
  252 +
  253 + public void setUserInfo(UserData userProfile) {
  254 + if (mAccountMap.containsKey(sharedPrefs.getValue(KEY_DEFAULT_ACCOUNT))) {
  255 + mAccountManager.setUserData(activeAccount, KEY_USER_DATA_USER_ID, userProfile.getUid());
  256 + mAccountManager.setUserData(activeAccount, KEY_USER_DATA_NICKNAME, userProfile.getNickName());
  257 + mAccountManager.setUserData(activeAccount, KEY_USER_DATA_FACEURL, userProfile.getFaceUrl());
  258 + mAccountManager.setUserData(activeAccount, KEY_USER_DATA_BIGFACEURL, userProfile.getBigFaceUrl());
  259 + mAccountManager.setUserData(activeAccount, KEY_USER_DATA_GENDER, userProfile.getGender());
  260 + mAccountManager.setUserData(activeAccount, KEY_USER_DATA_MOBILE, userProfile.getMobile());
  261 + mAccountManager.setUserData(activeAccount, KEY_USER_COUNTRY_CODE, userProfile.getCountryCode());
  262 + mAccountManager.setUserData(activeAccount, KEY_USER_DATA_EMAIL, userProfile.getEmail());
  263 +
  264 + mAccountManager.setUserData(activeAccount, KEY_USER_FIRST_LOGIN, "1");
  265 +
  266 + mAccountManager.setUserData(activeAccount, KEY_USER_UID_QQ, userProfile.getQqUid());
  267 + mAccountManager.setUserData(activeAccount, KEY_USER_UID_WEIBO, userProfile.getSinaUid());
  268 + mAccountManager.setUserData(activeAccount, KEY_USER_UID_WECHAT, userProfile.getWxUid());
  269 + setUserExt(userProfile.getExtInfo());
  270 +
  271 + activeUserInfo = getAccountInfo(activeAccount);
  272 + }
  273 + }
  274 +
  275 + public void setUserSign(String userSign) {
  276 + if (mAccountMap.containsKey(sharedPrefs.getValue(KEY_DEFAULT_ACCOUNT))) {
  277 + activeUserInfo.setUserSign(userSign);
  278 + mAccountManager.setUserData(activeAccount, KEY_USER_SIGN, userSign);
  279 + }
  280 + }
  281 +
  282 + public void setUserFaceUrl(String faceUrl, String bigFaceUrl) {
  283 + if (mAccountMap.containsKey(sharedPrefs.getValue(KEY_DEFAULT_ACCOUNT))) {
  284 + activeUserInfo.setFaceUrl(faceUrl);
  285 + activeUserInfo.setBigFaceUrl(bigFaceUrl);
  286 + mAccountManager.setUserData(activeAccount, KEY_USER_DATA_FACEURL, faceUrl);
  287 + mAccountManager.setUserData(activeAccount, KEY_USER_DATA_BIGFACEURL, bigFaceUrl);
  288 + }
  289 + }
  290 +
  291 + public void setUserNickName(String nickName) {
  292 + if (mAccountMap.containsKey(sharedPrefs.getValue(KEY_DEFAULT_ACCOUNT))) {
  293 + activeUserInfo.setNickName(nickName);
  294 + mAccountManager.setUserData(activeAccount, KEY_USER_DATA_NICKNAME, nickName);
  295 + }
  296 + }
  297 +
  298 + public void setPhoneNumber(String phoneNumber, String countryCode) {
  299 + if (mAccountMap.containsKey(sharedPrefs.getValue(KEY_DEFAULT_ACCOUNT))) {
  300 + activeUserInfo.setMobile(phoneNumber);
  301 + mAccountManager.setUserData(activeAccount, KEY_USER_DATA_MOBILE, phoneNumber);
  302 + mAccountManager.setUserData(activeAccount, KEY_USER_COUNTRY_CODE, countryCode);
  303 + }
  304 + }
  305 +
  306 + /**
  307 + * 更新用户性别
  308 + *
  309 + * @param sex
  310 + */
  311 + public void setUserSex(String sex) {
  312 + if (mAccountMap.containsKey(sharedPrefs.getValue(KEY_DEFAULT_ACCOUNT))) {
  313 + activeUserInfo.setGender(sex);
  314 + mAccountManager.setUserData(activeAccount, KEY_USER_DATA_GENDER, sex);
  315 + }
  316 + }
  317 +
  318 + /**
  319 + * 更新 用户信息的地址
  320 + *
  321 + * @param location
  322 + */
  323 + public void setUserLocation(String location) {
  324 + if (mAccountMap.containsKey(sharedPrefs.getValue(KEY_DEFAULT_ACCOUNT))) {
  325 + activeUserInfo.setLocation(location);
  326 + mAccountManager.setUserData(activeAccount, KEY_USER_DATA_LOCATION, location);
  327 + }
  328 + }
  329 +
  330 + /**
  331 + * 通过系统账号获取用户账号信息
  332 + *
  333 + * @param account 系统账号数据
  334 + * @return 用户账号信息
  335 + */
  336 + public CNLiveUserInfo getAccountInfo(Account account) {
  337 + if (account == null) return null;
  338 +
  339 + CNLiveUserInfo user = new CNLiveUserInfo();
  340 + user.setUid(mAccountManager.getUserData(account, KEY_USER_DATA_USER_ID));
  341 + user.setNickName(mAccountManager.getUserData(account, KEY_USER_DATA_NICKNAME));
  342 + user.setFaceUrl(mAccountManager.getUserData(account, KEY_USER_DATA_FACEURL));
  343 + user.setBigFaceUrl(mAccountManager.getUserData(account, KEY_USER_DATA_BIGFACEURL));
  344 + user.setGender(mAccountManager.getUserData(account, KEY_USER_DATA_GENDER));
  345 + user.setMobile(mAccountManager.getUserData(account, KEY_USER_DATA_MOBILE));
  346 + user.setCountryCode(mAccountManager.getUserData(account, KEY_USER_COUNTRY_CODE));
  347 + user.setEmail(mAccountManager.getUserData(account, KEY_USER_DATA_EMAIL));
  348 + user.setNewUser("0".equals(mAccountManager.getUserData(account, KEY_USER_FIRST_LOGIN)));
  349 + user.setLocation(mAccountManager.getUserData(account, KEY_USER_DATA_LOCATION));
  350 + user.setToken(mAccountManager.getUserData(account, KEY_USER_TOKEN));
  351 + user.setUserSign(mAccountManager.getUserData(account, KEY_USER_SIGN));
  352 +
  353 + user.setQqUid(mAccountManager.getUserData(account, KEY_USER_UID_QQ));
  354 + user.setWxUid(mAccountManager.getUserData(account, KEY_USER_UID_WECHAT));
  355 + user.setSinaUid(mAccountManager.getUserData(account, KEY_USER_UID_WEIBO));
  356 +
  357 + AppConfig.setSid(user.getUid());
  358 +
  359 + return user;
  360 + }
  361 +
  362 + /**
  363 + * 获取系统账号列表
  364 + *
  365 + * @return 用户列表
  366 + */
  367 + public Account[] getUserList() {
  368 + return mAccountManager.getAccountsByType(mAccountType);
  369 + }
  370 +
  371 +
  372 + public static boolean hasAppAccount(Context context) {
  373 + return UserService.getInstance(context).getAppAccount() != null;
  374 + }
  375 +
  376 + /**
  377 + * 更新 qqId
  378 + *
  379 + * @param qqID
  380 + */
  381 + public void setUserQQUID(String qqID) {
  382 + if (mAccountMap.containsKey(sharedPrefs.getValue(KEY_DEFAULT_ACCOUNT))) {
  383 + activeUserInfo.setQqUid(qqID);
  384 + mAccountManager.setUserData(activeAccount, KEY_USER_UID_QQ, qqID);
  385 + }
  386 + }
  387 +
  388 + /**
  389 + * 更新 weixinUID
  390 + *
  391 + * @param wxuid
  392 + */
  393 + public void setUserWXUID(String wxuid) {
  394 + if (mAccountMap.containsKey(sharedPrefs.getValue(KEY_DEFAULT_ACCOUNT))) {
  395 + activeUserInfo.setWxUid(wxuid);
  396 + mAccountManager.setUserData(activeAccount, KEY_USER_UID_WECHAT, wxuid);
  397 + }
  398 + }
  399 +
  400 + /**
  401 + * 更新 微博Uid
  402 + *
  403 + * @param wbuid
  404 + */
  405 + public void setUserWBUID(String wbuid) {
  406 + if (mAccountMap.containsKey(sharedPrefs.getValue(KEY_DEFAULT_ACCOUNT))) {
  407 + activeUserInfo.setSinaUid(wbuid);
  408 + mAccountManager.setUserData(activeAccount, KEY_USER_UID_WEIBO, wbuid);
  409 + }
  410 + }
  411 +
  412 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/auth/UserSyncService.java 0 → 100644
  1 +package com.cnlive.strike.user.auth;
  2 +
  3 +import android.accounts.Account;
  4 +import android.app.Service;
  5 +import android.content.AbstractThreadedSyncAdapter;
  6 +import android.content.ContentProviderClient;
  7 +import android.content.Context;
  8 +import android.content.Intent;
  9 +import android.content.SyncResult;
  10 +import android.os.Bundle;
  11 +import android.os.IBinder;
  12 +
  13 +public class UserSyncService extends Service {
  14 +
  15 + private static final Object syncLock = new Object();
  16 + private static SyncAdapter syncAdapter = null;
  17 +
  18 + @Override
  19 + public IBinder onBind(Intent intent) {
  20 + return syncAdapter.getSyncAdapterBinder();
  21 + }
  22 +
  23 + @Override
  24 + public void onCreate() {
  25 + super.onCreate();
  26 + synchronized (syncLock) {
  27 + if (syncAdapter == null) {
  28 + syncAdapter = new SyncAdapter(getApplicationContext(), true);
  29 + }
  30 + }
  31 + }
  32 +
  33 +
  34 + class SyncAdapter extends AbstractThreadedSyncAdapter {
  35 +
  36 + public SyncAdapter(Context context, boolean autoInitialize) {
  37 + super(context, autoInitialize);
  38 + }
  39 +
  40 + @Override
  41 + public void onPerformSync(Account account, Bundle extras, String authority, ContentProviderClient provider, SyncResult syncResult) {
  42 + }
  43 +
  44 + }
  45 +}
0 46 \ No newline at end of file
... ...
cloud/user/src/main/java/com/cnlive/strike/user/frame/data/FirstLoginData.java 0 → 100644
  1 +package com.cnlive.strike.user.frame.data;
  2 +
  3 +import androidx.databinding.BaseObservable;
  4 +import androidx.databinding.Bindable;
  5 +import com.cnlive.strike.user.BR;
  6 +/**
  7 + * Created by xiansong on 2018/1/19.
  8 + */
  9 +
  10 +public class FirstLoginData extends BaseObservable {
  11 +
  12 + private String name;
  13 + private String image;
  14 +
  15 + @Bindable
  16 + public String getImage() {
  17 + return image;
  18 + }
  19 +
  20 + public void setImage(String image) {
  21 + this.image = image;
  22 + super.notifyPropertyChanged(BR.image);
  23 + }
  24 +
  25 + @Bindable
  26 + public String getName() {
  27 + return name;
  28 + }
  29 +
  30 + public void setName(String name) {
  31 + this.name = name;
  32 + super.notifyPropertyChanged(BR.name);
  33 + }
  34 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/frame/data/LoginData.java 0 → 100644
  1 +package com.cnlive.strike.user.frame.data;
  2 +
  3 +import androidx.databinding.BaseObservable;
  4 +import androidx.databinding.Bindable;
  5 +
  6 +import com.cnlive.core.network.HttpConn;
  7 +import com.cnlive.core.network.NetCallBack;
  8 +import com.cnlive.strike.user.BR;
  9 +
  10 +import static android.view.View.GONE;
  11 +import static android.view.View.VISIBLE;
  12 +
  13 +/**
  14 + * Created by xiansong on 2018/1/2.
  15 + */
  16 +@Deprecated
  17 +public class LoginData extends BaseObservable implements NetCallBack {
  18 + private String name = "";
  19 + private String password = "";
  20 + private int loadVisibility = GONE;
  21 +
  22 + @Bindable
  23 + public String getName() {
  24 + return name;
  25 + }
  26 +
  27 + public void setName(String name) {
  28 + this.name = name;
  29 + notifyPropertyChanged(BR.name);
  30 + }
  31 +
  32 + @Bindable
  33 + public String getPassword() {
  34 + return password;
  35 + }
  36 +
  37 + public void setPassword(String password) {
  38 + this.password = password;
  39 + notifyPropertyChanged(BR.password);
  40 + }
  41 +
  42 + @Bindable
  43 + public int getLoadVisibility() {
  44 + return loadVisibility;
  45 + }
  46 +
  47 + public void setLoadVisibility(int loadVisibility) {
  48 + this.loadVisibility = loadVisibility;
  49 + notifyPropertyChanged(BR.loadVisibility);
  50 + }
  51 +
  52 +// @Override
  53 +// public void onState(int state) {
  54 +// loadVisibility = state == Config.STATE_LOAD ? VISIBLE : GONE;
  55 +// }
  56 +
  57 + @Override
  58 + public void onRequestState(int state) {
  59 + loadVisibility = state == HttpConn.ON_START ? VISIBLE : GONE;
  60 + }
  61 +
  62 + @Override
  63 + public void onSuccess(Object data) {
  64 +
  65 + }
  66 +
  67 + @Override
  68 + public void onFailure(String errCode, String errMsg) {
  69 +
  70 + }
  71 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/frame/data/OtherUserInfo.java 0 → 100644
  1 +package com.cnlive.strike.user.frame.data;
  2 +
  3 +import java.io.Serializable;
  4 +
  5 +/**
  6 + * 作者: 吴奎庆
  7 + * <p>
  8 + * 时间: 2019/9/10
  9 + * <p>
  10 + * 简介: 三方登陆的用户信息
  11 + */
  12 +public class OtherUserInfo implements Serializable {
  13 + // 用户昵称
  14 + String nickName;
  15 + //性别,m:男、f:女、n:未知
  16 + String gender;
  17 + //用户所在地
  18 + String location;
  19 + //头像,约100*100
  20 + String faceUrl;
  21 +
  22 + //第三方用户ID
  23 + //[qq: 建议使用openid, wx: 建议使用unionid, sina: 建议使用idstr];
  24 + //注意:同一用户在登录Sp下不同app时,thirdPartyId必须相同
  25 + String thirdPartyId;
  26 + //三方登陆的类型 微信: weixin 微博 :sina qq :qq
  27 + String loginType;
  28 +
  29 + public String getLoginType() {
  30 + return loginType;
  31 + }
  32 +
  33 + public void setLoginType(String loginType) {
  34 + this.loginType = loginType;
  35 + }
  36 +
  37 + public String getNickName() {
  38 + return nickName;
  39 + }
  40 +
  41 + public void setNickName(String nickName) {
  42 + this.nickName = nickName;
  43 + }
  44 +
  45 + public String getGender() {
  46 + return gender;
  47 + }
  48 +
  49 + public void setGender(String gender) {
  50 + this.gender = gender;
  51 + }
  52 +
  53 + public String getLocation() {
  54 + return location;
  55 + }
  56 +
  57 + public void setLocation(String location) {
  58 + this.location = location;
  59 + }
  60 +
  61 + public String getFaceUrl() {
  62 + return faceUrl;
  63 + }
  64 +
  65 + public void setFaceUrl(String faceUrl) {
  66 + this.faceUrl = faceUrl;
  67 + }
  68 +
  69 + public String getThirdPartyId() {
  70 + return thirdPartyId;
  71 + }
  72 +
  73 + public void setThirdPartyId(String thirdPartyId) {
  74 + this.thirdPartyId = thirdPartyId;
  75 + }
  76 +
  77 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/frame/data/QuickLoginData.java 0 → 100644
  1 +package com.cnlive.strike.user.frame.data;
  2 +
  3 +
  4 +import androidx.databinding.BaseObservable;
  5 +import androidx.databinding.Bindable;
  6 +
  7 +import com.cnlive.core.network.HttpConn;
  8 +import com.cnlive.core.network.NetCallBack;
  9 +import com.cnlive.strike.user.BR;
  10 +
  11 +import static android.view.View.GONE;
  12 +import static android.view.View.VISIBLE;
  13 +
  14 +/**
  15 + * Created by xiansong on 2018/1/11.
  16 + */
  17 +//implements StateCallback
  18 +public class QuickLoginData extends BaseObservable implements NetCallBack {
  19 + private static final String send = "获取验证码";
  20 + private static final String time_format = "%s秒后重发";
  21 +
  22 + private String phone = "";
  23 + private String code = "";
  24 + private String sendBtnText = send;
  25 + private int time;
  26 + private boolean sendEnabled = true;
  27 + private int loadVisibility = GONE;
  28 +
  29 + @Bindable
  30 + public String getPhone() {
  31 + return phone;
  32 + }
  33 +
  34 + public void setPhone(String phone) {
  35 + this.phone = phone;
  36 + notifyPropertyChanged(BR.phone);
  37 + }
  38 +
  39 + @Bindable
  40 + public String getCode() {
  41 + return code;
  42 + }
  43 +
  44 + public void setCode(String code) {
  45 + this.code = code;
  46 + notifyPropertyChanged(BR.code);
  47 + }
  48 +
  49 + @Bindable
  50 + public int getTime() {
  51 + return time;
  52 + }
  53 +
  54 + public void setTime(int time) {
  55 + this.time = time;
  56 + setSendBtnText(time <= 0 ? send : String.format(time_format, time));
  57 + setSendEnabled(time <= 0);
  58 + notifyPropertyChanged(BR.time);
  59 + }
  60 +
  61 + @Bindable
  62 + public String getSendBtnText() {
  63 + return sendBtnText;
  64 + }
  65 +
  66 + public void setSendBtnText(String sendBtnText) {
  67 + this.sendBtnText = sendBtnText;
  68 + notifyPropertyChanged(BR.sendBtnText);
  69 + }
  70 +
  71 + @Bindable
  72 + public boolean getSendEnabled() {
  73 + return sendEnabled;
  74 + }
  75 +
  76 + public void setSendEnabled(boolean sendEnabled) {
  77 + this.sendEnabled = sendEnabled;
  78 + notifyPropertyChanged(BR.sendEnabled);
  79 + }
  80 +
  81 + @Bindable
  82 + public int getLoadVisibility() {
  83 + return loadVisibility;
  84 + }
  85 +
  86 + public void setLoadVisibility(int loadVisibility) {
  87 + this.loadVisibility = loadVisibility;
  88 + notifyPropertyChanged(BR.loadVisibility);
  89 + }
  90 +
  91 + @Override
  92 + public void onRequestState(int state) {
  93 + loadVisibility = state == HttpConn.ON_START ? VISIBLE : GONE;
  94 + }
  95 +
  96 + @Override
  97 + public void onSuccess(Object data) {
  98 +
  99 + }
  100 +
  101 + @Override
  102 + public void onFailure(String errCode, String errMsg) {
  103 +
  104 + }
  105 +
  106 +// @Override
  107 +// public void onState(int state) {
  108 +// }
  109 +}
0 110 \ No newline at end of file
... ...
cloud/user/src/main/java/com/cnlive/strike/user/frame/presenter/QuickLoginPresenter.java 0 → 100644
  1 +package com.cnlive.strike.user.frame.presenter;
  2 +
  3 +import android.accounts.Account;
  4 +import android.content.Context;
  5 +import android.text.TextUtils;
  6 +import android.util.Log;
  7 +
  8 +import com.cnlive.core.libs.base.application.AppConfig;
  9 +import com.cnlive.core.libs.base.frame.presenter.BasePresenter;
  10 +import com.cnlive.core.network.BaseResult;
  11 +import com.cnlive.core.network.HttpConn;
  12 +import com.cnlive.core.network.NetCallBack;
  13 +import com.cnlive.core.libs.base.util.TimerUtil;
  14 +import com.cnlive.strike.user.R;
  15 +import com.cnlive.strike.user.UserUtilAction;
  16 +import com.cnlive.strike.user.auth.UserService;
  17 +import com.cnlive.strike.user.frame.data.OtherUserInfo;
  18 +import com.cnlive.strike.user.frame.data.QuickLoginData;
  19 +import com.cnlive.strike.user.frame.view.QuickLoginView;
  20 +import com.cnlive.strike.user.model.CNLiveUserInfo;
  21 +import com.cnlive.strike.user.router.user.UserAction;
  22 +import com.cnlive.strike.user.ui.fragment.QuickLoginFragment;
  23 +import com.cnlive.strike.user.util.RegexUtils;
  24 +import com.cnlive.strike.user.util.TimeEvent;
  25 +import com.hannesdorfmann.mosby3.mvp.MvpActivity;
  26 +
  27 +import java.util.Arrays;
  28 +import java.util.Collections;
  29 +
  30 +import io.reactivex.disposables.Disposable;
  31 +
  32 +
  33 +/**
  34 + * @author Lynn
  35 + * @date 2017/12/22
  36 + */
  37 +
  38 +public class QuickLoginPresenter extends BasePresenter<QuickLoginView> {
  39 + private TimerUtil timerUtil; //计时工具类
  40 +
  41 + // private Event<CNLiveUserInfo> event;
  42 + private Disposable sendMsgBefQuickLogin;
  43 +// private Event otherEvent;
  44 +
  45 + public void deleteUserInfo(Context context, String userName) {
  46 + UserService.getInstance(context).removeUser(userName, future -> {
  47 + if (getView() == null) return;
  48 + //获取已登录用户列表
  49 + Account[] accounts = UserService.getInstance(context).getUserList();
  50 + //倒序输出最近登录用户
  51 +
  52 + Collections.reverse(Arrays.asList(accounts));
  53 + getView().uploadListData(accounts);
  54 + });
  55 + }
  56 +
  57 + public void init(Context context) {
  58 + if (getView() == null) return;
  59 + UserService us = UserService.getInstance(context);
  60 + //获取已登录用户列表
  61 + Account[] accounts = us.getUserList();
  62 + //倒序输出最近登录用户
  63 + Collections.reverse(Arrays.asList(accounts));
  64 + //获取最近登录用户数据
  65 + Account account = accounts.length > 0 ? accounts[0] : null;
  66 + String name = account == null ? "" : account.name;
  67 + //页面填充数据
  68 + if (!TextUtils.isEmpty(name)) {
  69 + getView().uploadInputData(name);
  70 + }
  71 + if (null != accounts) {
  72 + getView().uploadListData(accounts);
  73 + }
  74 + }
  75 +
  76 + private void startTimer() {
  77 + if (timerUtil != null) timerUtil.cancel();
  78 +
  79 + timerUtil = new TimerUtil();
  80 + timerUtil.setTotalTime(60_000);//设置毫秒数
  81 + timerUtil.setIntervalTime(500);//设置间隔数
  82 + timerUtil.start();
  83 + timerUtil.setTimerLiener(new TimerUtil.TimeListener() {
  84 + @Override
  85 + public void onFinish() {
  86 + if (getView() != null) getView().onTimerFinish();
  87 + }
  88 +
  89 + @Override
  90 + public void onInterval(long remainTime) {
  91 + if (getView() != null) getView().onTimerInterval(remainTime / 1000);
  92 + }
  93 + });
  94 + }
  95 +
  96 + public void sendCode(Context context, String phone, String countryCode) {
  97 + if (getView() == null) return;
  98 + if (TimeEvent.debounce(2_000)) return;
  99 + if (TextUtils.isEmpty(phone)) {
  100 + getView().showToast(context.getString(R.string.user_toast_quick_login_empty_phone));
  101 + return;
  102 + }
  103 + if ("86".equals(countryCode) && !RegexUtils.isMobileSimple(phone)) {
  104 + getView().showToast(context.getString(R.string.user_toast_quick_login_error_phone));
  105 + return;
  106 + }
  107 + if (sendMsgBefQuickLogin != null && !sendMsgBefQuickLogin.isDisposed()) {
  108 + getView().showToast("处理中请稍后...");
  109 + } else {
  110 + sendMsgBefQuickLogin = HttpConn.action(UserUtilAction.sendMsgBefQuickLoginAction(context, phone, countryCode), new NetCallBack<BaseResult>() {
  111 + @Override
  112 + public void onRequestState(int state) {
  113 +
  114 + }
  115 +
  116 + @Override
  117 + public void onSuccess(BaseResult data) {
  118 + startTimer();
  119 + ifViewAttached(view -> view.showToast("验证码已发送"));
  120 + }
  121 +
  122 + @Override
  123 + public void onFailure(String errCode, String errMsg) {
  124 + ifViewAttached(view -> view.showToast(errMsg));
  125 +
  126 + }
  127 + });
  128 + }
  129 + }
  130 +
  131 + public void login(QuickLoginFragment context, QuickLoginData data, String countryCode) {
  132 + if (TextUtils.isEmpty(data.getPhone())) {
  133 + ifViewAttached(view -> view.showToast(context.getString(R.string.user_toast_quick_login_empty_phone)));
  134 + } else if (TextUtils.isEmpty(data.getCode())) {
  135 + ifViewAttached(view -> view.showToast(context.getString(R.string.user_toast_quick_login_empty_code)));
  136 + } else {
  137 + context.isLogin = true;
  138 +// UserAction.mobileLogin(context.getActivity(), data.getPhone(), data.getCode(), countryCode, initLoginEvent(context, true));
  139 + UserAction.mobileLogin(context.getActivity(), data.getPhone(), data.getCode(), countryCode, new UserAction.CallBack() {
  140 + @Override
  141 + public void callback(int state, String msg, Object object) {
  142 + initLoginEvent(context, state, msg, true, null);
  143 + }
  144 + });
  145 +
  146 + }
  147 + }
  148 +
  149 + private void initLoginEvent(QuickLoginFragment context, int state, String msg, Boolean retry, OtherUserInfo otherUserInfo) {
  150 + switch (state) {
  151 + //请求成功
  152 + case 0:
  153 + CNLiveUserInfo user = UserService.getInstance(context.getActivity()).getAppAccount();
  154 + if (user == null || (user != null && TextUtils.isEmpty(user.getToken()))) {
  155 + ifViewAttached(view -> view.showToast("用户登陆失败,再试一次吧."));
  156 + } else if (user.isNewUser()) {
  157 + //是新用户
  158 + //TODO 必须设置用户头像
  159 + //OpenInstall用户注册统计
  160 +// OpenInstall.reportRegister();
  161 + //友盟账号登录统计,暂时只有平台登录,后续对接三方登录
  162 +// MobclickAgent.onProfileSignIn("CNLive", user.getUid());
  163 + //三方登陆不需要重新设置头像 otherUserInfo不为空表示三方登陆
  164 + if (otherUserInfo != null) {
  165 + ifViewAttached(view -> view.showMainView(true, true));
  166 + } else {
  167 + ifViewAttached(view -> view.showEditView(false));
  168 + }
  169 + } else {
  170 + //友盟账号登录统计,暂时只有平台登录,后续对接三方登录
  171 +// MobclickAgent.onProfileSignIn("CNLive", user.getUid());
  172 + ifViewAttached(view -> view.showMainView(false, false));
  173 + }
  174 + AppConfig.setCountryCode("");
  175 + AppConfig.setVerificationCode("");
  176 + AppConfig.setUserPhone("");
  177 + context.hasLogin = true;
  178 + if (context != null) {
  179 + context.isLogin = false;
  180 + }
  181 + break;
  182 + case HttpConn.ON_START:
  183 + ifViewAttached(view -> view.showProgress());
  184 + break;
  185 + case HttpConn.ON_END:
  186 + ifViewAttached(view -> view.hideProgress());
  187 + break;
  188 + case 41010: //手机号无效
  189 + ifViewAttached(view -> view.showToast(msg));
  190 + break;
  191 + case 41002: //验证码为6位数字
  192 + ifViewAttached(view -> view.showToast(msg));
  193 + break;
  194 + case 41009: //验证码错误
  195 + ifViewAttached(view -> view.showToast(msg));
  196 + break;
  197 + case 41006: //手机号已存在
  198 + ifViewAttached(view -> view.showToast(msg));
  199 + break;
  200 + case 42013: //此帐号未注册,请先注册
  201 + ifViewAttached(view -> view.bindPhone(otherUserInfo));
  202 + break;
  203 + case 6208: //当前用户在其他地点登陆
  204 + if (retry) {
  205 + if (otherUserInfo == null) {
  206 + UserAction.mobileLogin(context.getActivity(), context.data.getPhone(), context.data.getCode(), "", new UserAction.CallBack() {
  207 + @Override
  208 + public void callback(int state, String msg, Object object) {
  209 + initLoginEvent(context, state, msg, false, null);
  210 + }
  211 + });
  212 + }
  213 + return;
  214 + } else {
  215 + ifViewAttached(view -> view.showToast("用户登录失败,再试一次吧."));
  216 + }
  217 + break;
  218 + default: //其他错误
  219 + ifViewAttached(view -> view.showToast(msg));
  220 + break;
  221 + }
  222 + }
  223 +
  224 +// private void initLoginEvent(QuickLoginFragment context, Boolean retry) {
  225 +// return initLoginEvent(context, retry, null);
  226 +// }
  227 +
  228 +
  229 +//
  230 +// private Event<CNLiveUserInfo> initLoginEvent(QuickLoginFragment context, Boolean retry, OtherUserInfo otherUserInfo) {
  231 +// return event = new Event<CNLiveUserInfo>()
  232 +// .setStateCallback(state -> {
  233 +// if (state == Config.STATE_LOAD) getView().showProgress();
  234 +// else getView().hideProgress();
  235 +// }).setFailureCallback((state, message) -> {
  236 +// if (context == null) return;
  237 +// if (getView() == null) return;
  238 +// switch (state) {
  239 +// case 41010: //手机号无效
  240 +// getView().showToast(message);
  241 +// break;
  242 +// case 41002: //验证码为6位数字
  243 +// getView().showToast(message);
  244 +// break;
  245 +// case 41009: //验证码错误
  246 +// getView().showToast(message);
  247 +// break;
  248 +// case 41006: //手机号已存在
  249 +// getView().showToast(message);
  250 +// break;
  251 +// case 42013: //此帐号未注册,请先注册
  252 +// getView().bindPhone(otherUserInfo);
  253 +// break;
  254 +// case 6208: //当前用户在其他地点登陆
  255 +// if (retry) {
  256 +// if (otherUserInfo == null) {
  257 +// UserAction.mobileLogin(context.getActivity(), context.data.getPhone(), context.data.getCode(), "", initLoginEvent(context, false));
  258 +// }
  259 +// return;
  260 +// } else getView().showToast("用户登录失败,再试一次吧.");
  261 +// break;
  262 +// default: //其他错误
  263 +// getView().showToast(message);
  264 +// break;
  265 +// }
  266 +// context.hasLogin = false;
  267 +// if (context != null) context.isLogin = false;
  268 +// }).setSuccessCallback((info) -> {
  269 +// if (context == null) return;
  270 +// if (getView() == null) return;
  271 +// CNLiveUserInfo user = UserService.getInstance(context.getActivity()).getAppAccount();
  272 +// if (user == null || (user != null && TextUtils.isEmpty(user.getToken()))) {
  273 +// getView().showToast("用户登陆失败,再试一次吧.");
  274 +// } else if (user.isNewUser()) {
  275 +// //是新用户
  276 +// //TODO 必须设置用户头像
  277 +// //OpenInstall用户注册统计
  278 +//// OpenInstall.reportRegister();
  279 +// //友盟账号登录统计,暂时只有平台登录,后续对接三方登录
  280 +//// MobclickAgent.onProfileSignIn("CNLive", user.getUid());
  281 +// //三方登陆不需要重新设置头像 otherUserInfo不为空表示三方登陆
  282 +// if (otherUserInfo != null) {
  283 +// getView().showMainView(true, true);
  284 +// } else {
  285 +// getView().showEditView(false);
  286 +// }
  287 +//
  288 +// } else {
  289 +// //友盟账号登录统计,暂时只有平台登录,后续对接三方登录
  290 +//// MobclickAgent.onProfileSignIn("CNLive", user.getUid());
  291 +// getView().showMainView(false, false);
  292 +// }
  293 +// AppConfig.setCountryCode("");
  294 +// AppConfig.setVerificationCode("");
  295 +// AppConfig.setUserPhone("");
  296 +// context.hasLogin = true;
  297 +// if (context != null) context.isLogin = false;
  298 +// }).setCancelCallback(() -> {
  299 +// //取消操作可能被触发多次 ,根据页面逻辑选择使用
  300 +// context.hasLogin = false;
  301 +// if (context != null) context.isLogin = false;
  302 +// });
  303 +// }
  304 +
  305 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/frame/presenter/SelectCountryPresenter.java 0 → 100644
  1 +package com.cnlive.strike.user.frame.presenter;
  2 +
  3 +import com.cnlive.core.libs.base.frame.activity.BaseActivity;
  4 +import com.cnlive.core.libs.base.frame.presenter.BasePresenter;
  5 +import com.cnlive.strike.user.frame.view.SelectCountryView;
  6 +import com.cnlive.strike.user.model.CountryData;
  7 +import com.cnlive.strike.user.ui.activity.SelectCountryActivity;
  8 +import com.google.gson.Gson;
  9 +import com.google.gson.reflect.TypeToken;
  10 +import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter;
  11 +
  12 +import java.lang.reflect.Type;
  13 +import java.util.ArrayList;
  14 +import java.util.List;
  15 +
  16 +import io.reactivex.Observable;
  17 +import io.reactivex.ObservableEmitter;
  18 +import io.reactivex.ObservableOnSubscribe;
  19 +import io.reactivex.Observer;
  20 +import io.reactivex.android.schedulers.AndroidSchedulers;
  21 +import io.reactivex.disposables.Disposable;
  22 +import io.reactivex.schedulers.Schedulers;
  23 +
  24 +/**
  25 + * 作者: 吴奎庆
  26 + * <p>
  27 + * 时间: 2018/11/17
  28 + * <p>
  29 + * 简介:
  30 + */
  31 +public class SelectCountryPresenter extends BasePresenter<SelectCountryView> {
  32 + public void processData(SelectCountryActivity countryActivity, String countryCode) {
  33 +
  34 +
  35 + Observable.create(new ObservableOnSubscribe<List<CountryData>>() {
  36 + @Override
  37 + public void subscribe(ObservableEmitter<List<CountryData>> emitter) throws Exception {
  38 + String country = "[{\"contryName\":\"阿尔巴尼亚\",\"contryCode\":\"355\"},{\"contryName\":\"阿尔及利亚\",\"contryCode\":\"213\"},{\"contryName\":\"阿富汗\",\"contryCode\":\"93\"},{\"contryName\":\"阿根廷\",\"contryCode\":\"54\"},{\"contryName\":\"阿拉伯联合酋长国\",\"contryCode\":\"971\"},{\"contryName\":\"阿鲁巴\",\"contryCode\":\"297\"},{\"contryName\":\"阿曼\",\"contryCode\":\"968\"},{\"contryName\":\"阿塞拜疆\",\"contryCode\":\"994\"},{\"contryName\":\"埃及\",\"contryCode\":\"20\"},{\"contryName\":\"埃塞俄比亚\",\"contryCode\":\"251\"},{\"contryName\":\"爱尔兰\",\"contryCode\":\"353\"},{\"contryName\":\"爱沙尼亚\",\"contryCode\":\"372\"},{\"contryName\":\"安道尔\",\"contryCode\":\"376\"},{\"contryName\":\"安哥拉\",\"contryCode\":\"244\"},{\"contryName\":\"安圭拉\",\"contryCode\":\"1264\"},{\"contryName\":\"安提瓜和巴布达\",\"contryCode\":\"1268\"},{\"contryName\":\"奥地利\",\"contryCode\":\"43\"},{\"contryName\":\"澳大利亚\",\"contryCode\":\"61\"},{\"contryName\":\"巴巴多斯\",\"contryCode\":\"1246\"},{\"contryName\":\"巴布亚新几内亚\",\"contryCode\":\"675\"},{\"contryName\":\"巴哈马\",\"contryCode\":\"1242\"},{\"contryName\":\"巴基斯坦\",\"contryCode\":\"92\"},{\"contryName\":\"巴拉圭\",\"contryCode\":\"595\"},{\"contryName\":\"巴林\",\"contryCode\":\"973\"},{\"contryName\":\"巴拿马\",\"contryCode\":\"507\"},{\"contryName\":\"巴西\",\"contryCode\":\"55\"},{\"contryName\":\"白俄罗斯\",\"contryCode\":\"375\"},{\"contryName\":\"百慕大群岛\",\"contryCode\":\"1441\"},{\"contryName\":\"保加利亚\",\"contryCode\":\"359\"},{\"contryName\":\"贝宁\",\"contryCode\":\"229\"},{\"contryName\":\"比利时\",\"contryCode\":\"32\"},{\"contryName\":\"冰岛\",\"contryCode\":\"354\"},{\"contryName\":\"波多黎各\",\"contryCode\":\"1787\"},{\"contryName\":\"波兰\",\"contryCode\":\"48\"},{\"contryName\":\"波斯尼亚和黑塞哥维那\",\"contryCode\":\"387\"},{\"contryName\":\"玻利维亚\",\"contryCode\":\"591\"},{\"contryName\":\"伯利兹\",\"contryCode\":\"501\"},{\"contryName\":\"博茨瓦纳\",\"contryCode\":\"267\"},{\"contryName\":\"不丹\",\"contryCode\":\"975\"},{\"contryName\":\"布基纳法索\",\"contryCode\":\"226\"},{\"contryName\":\"布隆迪\",\"contryCode\":\"257\"},{\"contryName\":\"朝鲜\",\"contryCode\":\"850\"},{\"contryName\":\"赤道几内亚\",\"contryCode\":\"240\"},{\"contryName\":\"丹麦\",\"contryCode\":\"45\"},{\"contryName\":\"德国\",\"contryCode\":\"49\"},{\"contryName\":\"东帝汶\",\"contryCode\":\"670\"},{\"contryName\":\"多哥\",\"contryCode\":\"228\"},{\"contryName\":\"多米尼加\",\"contryCode\":\"1767\"},{\"contryName\":\"多米尼加共和国\",\"contryCode\":\"1809\"},{\"contryName\":\"俄罗斯\",\"contryCode\":\"7\"},{\"contryName\":\"厄瓜多尔\",\"contryCode\":\"593\"},{\"contryName\":\"厄立特里亚\",\"contryCode\":\"291\"},{\"contryName\":\"法国\",\"contryCode\":\"33\"},{\"contryName\":\"法罗群岛\",\"contryCode\":\"298\"},{\"contryName\":\"法属波利尼西亚\",\"contryCode\":\"689\"},{\"contryName\":\"法属圭亚那\",\"contryCode\":\"594\"},{\"contryName\":\"菲律宾\",\"contryCode\":\"63\"},{\"contryName\":\"斐济\",\"contryCode\":\"679\"},{\"contryName\":\"芬兰\",\"contryCode\":\"358\"},{\"contryName\":\"冈比亚\",\"contryCode\":\"220\"},{\"contryName\":\"刚果共和国\",\"contryCode\":\"242\"},{\"contryName\":\"刚果民主共和国\",\"contryCode\":\"243\"},{\"contryName\":\"哥伦比亚\",\"contryCode\":\"57\"},{\"contryName\":\"哥斯达黎加\",\"contryCode\":\"506\"},{\"contryName\":\"格林纳达\",\"contryCode\":\"1473\"},{\"contryName\":\"格陵兰岛\",\"contryCode\":\"299\"},{\"contryName\":\"格鲁吉亚\",\"contryCode\":\"995\"},{\"contryName\":\"古巴\",\"contryCode\":\"53\"},{\"contryName\":\"瓜德罗普岛\",\"contryCode\":\"590\"},{\"contryName\":\"瓜地马拉\",\"contryCode\":\"502\"},{\"contryName\":\"关岛\",\"contryCode\":\"1671\"},{\"contryName\":\"圭亚那\",\"contryCode\":\"592\"},{\"contryName\":\"哈萨克斯坦\",\"contryCode\":\"7\"},{\"contryName\":\"海地\",\"contryCode\":\"509\"},{\"contryName\":\"韩国\",\"contryCode\":\"82\"},{\"contryName\":\"荷兰\",\"contryCode\":\"31\"},{\"contryName\":\"荷兰加勒比\",\"contryCode\":\"599\"},{\"contryName\":\"黑山\",\"contryCode\":\"382\"},{\"contryName\":\"洪都拉斯\",\"contryCode\":\"504\"},{\"contryName\":\"基里巴斯\",\"contryCode\":\"686\"},{\"contryName\":\"吉布提\",\"contryCode\":\"253\"},{\"contryName\":\"吉尔吉斯斯坦\",\"contryCode\":\"996\"},{\"contryName\":\"几内亚\",\"contryCode\":\"224\"},{\"contryName\":\"几内亚比绍共和国\",\"contryCode\":\"245\"},{\"contryName\":\"加拿大\",\"contryCode\":\"1\"},{\"contryName\":\"加纳\",\"contryCode\":\"233\"},{\"contryName\":\"加蓬\",\"contryCode\":\"241\"},{\"contryName\":\"柬埔寨\",\"contryCode\":\"855\"},{\"contryName\":\"捷克\",\"contryCode\":\"420\"},{\"contryName\":\"津巴布韦\",\"contryCode\":\"263\"},{\"contryName\":\"喀麦隆\",\"contryCode\":\"237\"},{\"contryName\":\"卡塔尔\",\"contryCode\":\"974\"},{\"contryName\":\"开曼群岛\",\"contryCode\":\"1345\"},{\"contryName\":\"开普\",\"contryCode\":\"238\"},{\"contryName\":\"科摩罗\",\"contryCode\":\"269\"},{\"contryName\":\"科威特\",\"contryCode\":\"965\"},{\"contryName\":\"克罗地亚\",\"contryCode\":\"385\"},{\"contryName\":\"肯尼亚\",\"contryCode\":\"254\"},{\"contryName\":\"库克群岛\",\"contryCode\":\"682\"},{\"contryName\":\"库拉索\",\"contryCode\":\"599\"},{\"contryName\":\"拉脱维亚\",\"contryCode\":\"371\"},{\"contryName\":\"莱索托\",\"contryCode\":\"266\"},{\"contryName\":\"老挝\",\"contryCode\":\"856\"},{\"contryName\":\"黎巴嫩\",\"contryCode\":\"961\"},{\"contryName\":\"立陶宛\",\"contryCode\":\"370\"},{\"contryName\":\"利比里亚\",\"contryCode\":\"231\"},{\"contryName\":\"利比亚\",\"contryCode\":\"218\"},{\"contryName\":\"列支敦士登\",\"contryCode\":\"423\"},{\"contryName\":\"留尼汪\",\"contryCode\":\"262\"},{\"contryName\":\"卢森堡\",\"contryCode\":\"352\"},{\"contryName\":\"卢旺达\",\"contryCode\":\"250\"},{\"contryName\":\"罗马尼亚\",\"contryCode\":\"40\"},{\"contryName\":\"马达加斯加\",\"contryCode\":\"261\"},{\"contryName\":\"马尔代夫\",\"contryCode\":\"960\"},{\"contryName\":\"马耳他\",\"contryCode\":\"356\"},{\"contryName\":\"马拉维\",\"contryCode\":\"265\"},{\"contryName\":\"马来西亚\",\"contryCode\":\"60\"},{\"contryName\":\"马里\",\"contryCode\":\"223\"},{\"contryName\":\"马其顿\",\"contryCode\":\"389\"},{\"contryName\":\"马绍尔群岛\",\"contryCode\":\"692\"},{\"contryName\":\"马约特\",\"contryCode\":\"269\"},{\"contryName\":\"毛里求斯\",\"contryCode\":\"230\"},{\"contryName\":\"毛里塔尼亚\",\"contryCode\":\"222\"},{\"contryName\":\"美国\",\"contryCode\":\"1\"},{\"contryName\":\"美属萨摩亚\",\"contryCode\":\"1684\"},{\"contryName\":\"蒙古\",\"contryCode\":\"976\"},{\"contryName\":\"蒙特塞拉特岛\",\"contryCode\":\"1664\"},{\"contryName\":\"孟加拉国\",\"contryCode\":\"880\"},{\"contryName\":\"秘鲁\",\"contryCode\":\"51\"},{\"contryName\":\"密克罗尼西亚\",\"contryCode\":\"691\"},{\"contryName\":\"缅甸\",\"contryCode\":\"95\"},{\"contryName\":\"摩尔多瓦\",\"contryCode\":\"373\"},{\"contryName\":\"摩洛哥\",\"contryCode\":\"212\"},{\"contryName\":\"摩纳哥\",\"contryCode\":\"377\"},{\"contryName\":\"莫桑比克\",\"contryCode\":\"258\"},{\"contryName\":\"墨西哥\",\"contryCode\":\"52\"},{\"contryName\":\"拿鲁岛\",\"contryCode\":\"674\"},{\"contryName\":\"纳米比亚\",\"contryCode\":\"264\"},{\"contryName\":\"南非\",\"contryCode\":\"27\"},{\"contryName\":\"尼泊尔\",\"contryCode\":\"977\"},{\"contryName\":\"尼加拉瓜\",\"contryCode\":\"505\"},{\"contryName\":\"尼日尔\",\"contryCode\":\"227\"},{\"contryName\":\"尼日利亚\",\"contryCode\":\"234\"},{\"contryName\":\"挪威\",\"contryCode\":\"47\"},{\"contryName\":\"帕劳\",\"contryCode\":\"680\"},{\"contryName\":\"葡萄牙\",\"contryCode\":\"351\"},{\"contryName\":\"日本\",\"contryCode\":\"81\"},{\"contryName\":\"瑞典\",\"contryCode\":\"46\"},{\"contryName\":\"瑞士\",\"contryCode\":\"41\"},{\"contryName\":\"萨尔瓦多\",\"contryCode\":\"503\"},{\"contryName\":\"萨摩亚\",\"contryCode\":\"685\"},{\"contryName\":\"塞尔维亚\",\"contryCode\":\"381\"},{\"contryName\":\"塞拉利昂\",\"contryCode\":\"232\"},{\"contryName\":\"塞内加尔\",\"contryCode\":\"221\"},{\"contryName\":\"塞浦路斯\",\"contryCode\":\"357\"},{\"contryName\":\"塞舌尔\",\"contryCode\":\"248\"},{\"contryName\":\"沙特阿拉伯\",\"contryCode\":\"966\"},{\"contryName\":\"圣彼埃尔和密克隆岛\",\"contryCode\":\"508\"},{\"contryName\":\"圣多美和普林西比\",\"contryCode\":\"239\"},{\"contryName\":\"圣基茨和尼维斯\",\"contryCode\":\"1869\"},{\"contryName\":\"圣露西亚\",\"contryCode\":\"1758\"},{\"contryName\":\"圣马力诺\",\"contryCode\":\"378\"},{\"contryName\":\"圣文森特和格林纳丁斯\",\"contryCode\":\"1784\"},{\"contryName\":\"斯里兰卡\",\"contryCode\":\"94\"},{\"contryName\":\"斯洛伐克\",\"contryCode\":\"421\"},{\"contryName\":\"斯洛文尼亚\",\"contryCode\":\"386\"},{\"contryName\":\"斯威士兰\",\"contryCode\":\"268\"},{\"contryName\":\"苏丹\",\"contryCode\":\"249\"},{\"contryName\":\"苏里南\",\"contryCode\":\"597\"},{\"contryName\":\"所罗门群岛\",\"contryCode\":\"677\"},{\"contryName\":\"索马里\",\"contryCode\":\"252\"},{\"contryName\":\"塔吉克斯坦\",\"contryCode\":\"992\"},{\"contryName\":\"泰国\",\"contryCode\":\"66\"},{\"contryName\":\"坦桑尼亚\",\"contryCode\":\"255\"},{\"contryName\":\"汤加\",\"contryCode\":\"676\"},{\"contryName\":\"特克斯和凯科斯群岛\",\"contryCode\":\"1649\"},{\"contryName\":\"特立尼达和多巴哥\",\"contryCode\":\"1868\"},{\"contryName\":\"突尼斯\",\"contryCode\":\"216\"},{\"contryName\":\"土耳其\",\"contryCode\":\"90\"},{\"contryName\":\"土库曼斯坦\",\"contryCode\":\"993\"},{\"contryName\":\"瓦努阿图\",\"contryCode\":\"678\"},{\"contryName\":\"委内瑞拉\",\"contryCode\":\"58\"},{\"contryName\":\"文莱\",\"contryCode\":\"673\"},{\"contryName\":\"乌干达\",\"contryCode\":\"256\"},{\"contryName\":\"乌克兰\",\"contryCode\":\"380\"},{\"contryName\":\"乌拉圭\",\"contryCode\":\"598\"},{\"contryName\":\"乌兹别克斯坦\",\"contryCode\":\"998\"},{\"contryName\":\"西班牙\",\"contryCode\":\"34\"},{\"contryName\":\"希腊\",\"contryCode\":\"30\"},{\"contryName\":\"象牙海岸\",\"contryCode\":\"225\"},{\"contryName\":\"新加坡\",\"contryCode\":\"65\"},{\"contryName\":\"新喀里多尼亚\",\"contryCode\":\"687\"},{\"contryName\":\"新西兰\",\"contryCode\":\"64\"},{\"contryName\":\"匈牙利\",\"contryCode\":\"36\"},{\"contryName\":\"叙利亚\",\"contryCode\":\"963\"},{\"contryName\":\"牙买加\",\"contryCode\":\"1876\"},{\"contryName\":\"亚美尼亚\",\"contryCode\":\"374\"},{\"contryName\":\"也门\",\"contryCode\":\"967\"},{\"contryName\":\"伊拉克\",\"contryCode\":\"964\"},{\"contryName\":\"伊朗\",\"contryCode\":\"98\"},{\"contryName\":\"以色列\",\"contryCode\":\"972\"},{\"contryName\":\"意大利\",\"contryCode\":\"39\"},{\"contryName\":\"印度\",\"contryCode\":\"91\"},{\"contryName\":\"印度尼西亚\",\"contryCode\":\"62\"},{\"contryName\":\"英国\",\"contryCode\":\"44\"},{\"contryName\":\"英属处女群岛\",\"contryCode\":\"1284\"},{\"contryName\":\"约旦\",\"contryCode\":\"962\"},{\"contryName\":\"越南\",\"contryCode\":\"84\"},{\"contryName\":\"赞比亚\",\"contryCode\":\"260\"},{\"contryName\":\"乍得\",\"contryCode\":\"235\"},{\"contryName\":\"直布罗陀\",\"contryCode\":\"350\"},{\"contryName\":\"智利\",\"contryCode\":\"56\"},{\"contryName\":\"中非共和国\",\"contryCode\":\"236\"},{\"contryName\":\"中国(澳门)\",\"contryCode\":\"853\"},{\"contryName\":\"中国(台湾)\",\"contryCode\":\"886\"},{\"contryName\":\"中国(香港)\",\"contryCode\":\"852\"},{\"contryName\":\"中国\",\"contryCode\":\"86\"}]";
  39 +
  40 + Gson gson = new Gson();
  41 + Type type = new TypeToken<List<CountryData>>() {
  42 + }.getType();
  43 + List<CountryData> countryDataList = gson.fromJson(country, type);
  44 + countryDataList.size();
  45 + //处理数据 设置Letter
  46 + for (CountryData countryData : countryDataList) {
  47 + countryData.setLetterContent(countryData.getContryName());
  48 + }
  49 + //处理数据
  50 + String letter = "";
  51 + List<CountryData> newList = new ArrayList<>();
  52 + for (CountryData data : countryDataList) {
  53 + if (!letter.equals(data.getLetter().substring(0, 1))) {
  54 + letter = data.getLetter().substring(0, 1);
  55 + CountryData newBean = new CountryData();
  56 + newBean.setLetter(letter);
  57 + newBean.setType(CountryData.TYPE_CATGORY);
  58 + newList.add(newBean);
  59 + countryActivity.contactLetterGuideMap.put(letter, newList.size());
  60 + }
  61 +
  62 + data.setType(CountryData.TYPE_COUNTRY);
  63 + newList.add(data);
  64 + if (countryCode.equals(data.getContryCode())) {
  65 + data.setSelect(true);
  66 + countryActivity.fistPosition = newList.indexOf(data);
  67 + } else {
  68 + data.setSelect(false);
  69 + }
  70 + }
  71 + if (emitter != null && newList != null) {
  72 + emitter.onNext(newList);
  73 + }
  74 + }
  75 + }).subscribeOn(Schedulers.io())
  76 + .observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<List<CountryData>>() {
  77 + @Override
  78 + public void onSubscribe(Disposable d) {
  79 +
  80 + }
  81 +
  82 + @Override
  83 + public void onNext(List<CountryData> countryData) {
  84 + ifViewAttached(view -> view.showView(countryData));
  85 + }
  86 +
  87 + @Override
  88 + public void onError(Throwable e) {
  89 +
  90 + }
  91 +
  92 + @Override
  93 + public void onComplete() {
  94 +
  95 + }
  96 + });
  97 + }
  98 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/frame/view/QuickLoginView.java 0 → 100644
  1 +package com.cnlive.strike.user.frame.view;
  2 +
  3 +import android.accounts.Account;
  4 +import android.app.Activity;
  5 +import android.content.Context;
  6 +import android.text.Editable;
  7 +import android.text.Spannable;
  8 +import android.text.SpannableStringBuilder;
  9 +import android.text.TextPaint;
  10 +import android.text.TextUtils;
  11 +import android.text.TextWatcher;
  12 +import android.text.method.LinkMovementMethod;
  13 +import android.text.style.ClickableSpan;
  14 +import android.text.style.ForegroundColorSpan;
  15 +import android.view.View;
  16 +
  17 +import com.alibaba.android.arouter.launcher.ARouter;
  18 +import com.cnlive.core.libs.base.application.AppConfig;
  19 +import com.cnlive.core.libs.base.frame.view.BaseView;
  20 +import com.cnlive.core.libs.base.util.AlertUtil;
  21 +import com.cnlive.core.libs.base.util.DoublePressed;
  22 +import com.cnlive.strike.user.R;
  23 +import com.cnlive.strike.user.frame.data.OtherUserInfo;
  24 +import com.cnlive.strike.user.model.LoginSuccessInfo;
  25 +import com.cnlive.strike.user.sms.OnSmsCatchListener;
  26 +import com.cnlive.strike.user.sms.SmsVerifyCatcher;
  27 +import com.cnlive.strike.user.ui.fragment.QuickLoginFragment;
  28 +
  29 +import java.util.regex.Matcher;
  30 +import java.util.regex.Pattern;
  31 +
  32 +/**
  33 + * @author Lynn
  34 + * @date 2017/12/22
  35 + */
  36 +
  37 +public class QuickLoginView extends BaseView {
  38 +
  39 + private QuickLoginFragment fragment;
  40 +
  41 + public QuickLoginView(QuickLoginFragment fragment) {
  42 + this.fragment = fragment;
  43 + }
  44 +
  45 + public Activity getContext() {
  46 + return fragment.getActivity();
  47 + }
  48 +
  49 + /**
  50 + * 更新用户信息点击事件
  51 + */
  52 + public void onUploadLoginUser(String name) {
  53 + uploadInputData(name);
  54 + }
  55 +
  56 +
  57 + /**
  58 + * 删除用户记录
  59 + */
  60 + public void onDeleteLoginUser(String name) {
  61 + fragment.getPresenter().deleteUserInfo(getContext(), name);
  62 + }
  63 +
  64 + //更新输入信息
  65 + public void uploadInputData(String phone) {
  66 + fragment.data.setPhone(phone);
  67 + if (!TextUtils.isEmpty(phone)) {
  68 + fragment.binding.ivDelete.setVisibility(View.VISIBLE);
  69 + }
  70 + fragment.data.setCode("");
  71 + //通过DataBinding更新文字后无法立即设置光标位置
  72 + if (!TextUtils.isEmpty(phone)) {
  73 + fragment.binding.userName.setText(phone);
  74 + fragment.binding.userName.setSelection(phone.length());
  75 + }
  76 + String contryCode = AppConfig.getCountryCode();
  77 + //设置区号
  78 +// CNLiveUserInfo userInfo = UserService.getInstance(fragment.getActivity()).getAppAccount();
  79 + if (!TextUtils.isEmpty(contryCode)) {
  80 + fragment.binding.tvCountry.setText("+ " + contryCode);
  81 + } else {
  82 + fragment.binding.tvCountry.setText("+ " + "86");
  83 + }
  84 + String contryName = AppConfig.getCountryName();
  85 + if (TextUtils.isEmpty(contryName)) {
  86 + fragment.binding.tvCountryName.setText("中国");
  87 + } else {
  88 + fragment.binding.tvCountryName.setText(contryName);
  89 + }
  90 +
  91 +
  92 + }
  93 +
  94 + public void uploadInputData(String phone, String countryCode, String verficatinCode) {
  95 + fragment.data.setPhone(phone);
  96 + if (!TextUtils.isEmpty(phone)) {
  97 + fragment.binding.ivDelete.setVisibility(View.VISIBLE);
  98 + }
  99 +// fragment.data.setCode(TextUtils.isEmpty(verficatinCode) ? "" : verficatinCode);
  100 + //通过DataBinding更新文字后无法立即设置光标位置
  101 + if (!TextUtils.isEmpty(phone)) {
  102 + fragment.binding.userName.setText(phone);
  103 + fragment.binding.userName.setSelection(phone.length());
  104 + }
  105 +
  106 + //设置区号
  107 +// CNLiveUserInfo userInfo = UserService.getInstance(fragment.getActivity()).getAppAccount();
  108 +// if (userInfo != null && !TextUtils.isEmpty(userInfo.getCountryCode())) {
  109 +// fragment.rootBinding.tvCountry.setText("+ " + userInfo.getCountryCode());
  110 +// } else {
  111 +// fragment.rootBinding.tvCountry.setText("+ " + "86");
  112 +// }
  113 + fragment.binding.tvCountry.setText("+ ".concat(TextUtils.isEmpty(countryCode) ? "86" : countryCode));
  114 +
  115 + }
  116 +
  117 + public void initView() {
  118 + if (fragment == null) return;
  119 + fragment.smsVerifyCatcher = new SmsVerifyCatcher(fragment.getActivity(), new OnSmsCatchListener<String>() {
  120 + @Override
  121 + public void onSmsCatch(String message) {
  122 + String code = parseCode(message);
  123 + fragment.binding.etSms.setText(code);
  124 + }
  125 + });
  126 + fragment.binding.userName.addTextChangedListener(new TextWatcher() {
  127 + @Override
  128 + public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  129 + }
  130 +
  131 + @Override
  132 + public void onTextChanged(CharSequence s, int start, int before, int count) {
  133 + }
  134 +
  135 + @Override
  136 + public void afterTextChanged(Editable s) {
  137 + if (s.length() > 0) {
  138 + fragment.binding.ivDelete.setVisibility(View.VISIBLE);
  139 + } else {
  140 + fragment.binding.ivDelete.setVisibility(View.GONE);
  141 + }
  142 + }
  143 + });
  144 +
  145 + fragment.binding.etSms.addTextChangedListener(new TextWatcher() {
  146 + @Override
  147 + public void beforeTextChanged(CharSequence s, int start, int count, int after) {
  148 + }
  149 +
  150 + @Override
  151 + public void onTextChanged(CharSequence s, int start, int before, int count) {
  152 + }
  153 +
  154 + @Override
  155 + public void afterTextChanged(Editable s) {
  156 + if (s.length() > 0) {
  157 + fragment.binding.ivDeleteYzm.setVisibility(View.VISIBLE);
  158 + } else {
  159 + fragment.binding.ivDeleteYzm.setVisibility(View.GONE);
  160 + }
  161 + }
  162 + });
  163 +
  164 +
  165 + }
  166 +
  167 + //更新用户列表
  168 + public void uploadListData(Account[] list) {
  169 + fragment.adapter.clear();
  170 + if (list.length > 0) fragment.adapter.addAll(list);
  171 + }
  172 +
  173 + public void showToast(String msg) {
  174 + if (getContext() == null) return;
  175 + Context context = getContext();
  176 + AlertUtil.showDeftToast(context, msg);
  177 + }
  178 +
  179 +
  180 + public void showEditView(boolean isHasOtherUserInfo) {
  181 + if (getContext() == null) return;
  182 + //设置跳转信息
  183 + LoginSuccessInfo successInfo = new LoginSuccessInfo();
  184 + successInfo.setTagMsg(TextUtils.isEmpty(fragment.tagMsg) ? "" : fragment.tagMsg);
  185 + successInfo.setClickAd(fragment.clickAd);
  186 +// HelperUtil.isNewUser(fragment.getActivity(), successInfo, isHasOtherUserInfo);
  187 +
  188 +// Intent intent = new Intent(getContext(), FirstLoginActivity.class);
  189 +// intent.putExtra(LoginActivity.TAG_MSG, TextUtils.isEmpty(fragment.tagMsg) ? "" : fragment.tagMsg);
  190 +// intent.putExtra(LoginActivity.TAG_CLICK_AD, fragment.clickAd);
  191 +// getContext().startActivity(intent);
  192 +// getContext().finish();
  193 + }
  194 +
  195 + public void showMainView(boolean isNewUser, boolean isHasOtherUserInfo) {
  196 + if (getContext() == null) return;
  197 + //判断如果是因为token为空跳转到的登录页面则不需要跳转到MainActivity,直接关闭登录页面即可
  198 + if (fragment.fromTokenError) {
  199 + fragment.getActivity().finish();
  200 + return;
  201 + }
  202 + //设置跳转信息
  203 + LoginSuccessInfo successInfo = new LoginSuccessInfo();
  204 + successInfo.setType("login");
  205 + successInfo.setUri(fragment.uri);
  206 + successInfo.setClickAd(fragment.clickAd);
  207 + successInfo.setTagShare(fragment.tagShare);
  208 + successInfo.setTagMsg(fragment.tagMsg);
  209 + if (isNewUser) {
  210 +// HelperUtil.isNewUser(fragment.getActivity(), successInfo, isHasOtherUserInfo);
  211 + } else {
  212 +// HelperUtil.isNotNewUser(fragment.getActivity(), successInfo);
  213 + }
  214 +// EventBus.getDefault().post(new UserEventMsg(UserEventMsg.LOGIN_SUCCESS, successInfo));
  215 +// Intent intent = new Intent(getContext(), MainTestActivity.class);
  216 +// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
  217 +// intent.putExtra("type", "login");
  218 +// intent.putExtra("uri", fragment.uri);
  219 +// intent.putExtra(LoginActivity.TAG_CLICK_AD, fragment.clickAd);
  220 +// intent.putExtra("sharetype", fragment.tagShare);
  221 +// if (!TextUtils.isEmpty(fragment.tagMsg))
  222 +// intent.putExtra("classifyTagMsg", fragment.tagMsg);
  223 +// getContext().startActivity(intent);
  224 + }
  225 +
  226 + public void showProgress() {
  227 + if (!fragment.mProgressDialog.isShowing()) fragment.mProgressDialog.show();
  228 + }
  229 +
  230 + public void hideProgress() {
  231 + if (fragment.mProgressDialog.isShowing()) {
  232 + fragment.isLogin = false;
  233 + fragment.mProgressDialog.dismiss();
  234 + }
  235 + }
  236 +
  237 + public void onTimerFinish() {
  238 + fragment.data.setTime(0);
  239 + fragment.binding.codeRequest.setTextColor(fragment.getActivity().getResources().getColor(R.color.white));
  240 + }
  241 +
  242 + public void onTimerInterval(long l) {
  243 + fragment.data.setTime((int) l);
  244 + fragment.binding.codeRequest.setTextColor(fragment.getActivity().getResources().getColor(R.color.color_f2f2f2));
  245 + }
  246 +
  247 + public void setAgreementText() {
  248 + String textContent = "登录即代表阅读并同意《用户协议》 及 《隐私政策》";
  249 + SpannableStringBuilder ssb = new SpannableStringBuilder(textContent);
  250 + ssb.setSpan(new ClickableSpan() {
  251 + @Override
  252 + public void onClick(View widget) {
  253 + if (!fragment.isLogin) {
  254 + startWebView("yhxy");
  255 + }
  256 + }
  257 +
  258 + @Override
  259 + public void updateDrawState(TextPaint ds) {
  260 + ds.setUnderlineText(false);
  261 + }
  262 + }, 11, 15, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
  263 +
  264 + ssb.setSpan(new ClickableSpan() {
  265 + @Override
  266 + public void onClick(View widget) {
  267 + if (!fragment.isLogin) {
  268 + startWebView("yszc");
  269 + }
  270 + }
  271 +
  272 + @Override
  273 + public void updateDrawState(TextPaint ds) {
  274 + ds.setUnderlineText(false);
  275 + }
  276 + }, 20, 24, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
  277 +
  278 + ssb.setSpan(new ForegroundColorSpan(fragment.getResources().getColor(R.color.color_23d41e)), 11, 15, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
  279 + ssb.setSpan(new ForegroundColorSpan(fragment.getResources().getColor(R.color.color_23d41e)), 20, 24, Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
  280 + fragment.binding.tvAgreement.setMovementMethod(LinkMovementMethod.getInstance());
  281 + fragment.binding.tvAgreement.setText(ssb);
  282 + }
  283 +
  284 + private void startWebView(String type) {
  285 +// WWebView wWebView = new WWebView.Builder()
  286 +// .urlType(type)
  287 +// .isOther(true)
  288 +// .enableJump(true)
  289 +// .enableRefresh(false)
  290 +// .enableImageLongClick(false)
  291 +// .builder();
  292 +// wWebView.startWebViewActivity(fragment.getActivity());
  293 +
  294 +
  295 + ARouter.getInstance().build("/web/WebViewActivity")
  296 + .withString("rUrlType", type)
  297 + .withBoolean("rIsOther", true)
  298 + .withBoolean("rEnableJump", true)
  299 + .withBoolean("rEnableRefresh", false)
  300 + .withBoolean("rEnableImageLongClick", false)
  301 + .navigation(fragment.getActivity());
  302 + }
  303 +
  304 + public void startWeb() {
  305 + if (fragment == null) return;
  306 + //浏览入口
  307 + if (DoublePressed.onDoublePressed()) return;
  308 +// WWebView wWebView = new WWebView.Builder()
  309 +// // TODO: 2018/12/28 浏览页面h5地址
  310 +// .url(AppConfig.isDebug() ? "http://wjjh5test.cnlive.com/cnLogoutPreview.html" : "http://wjjh5.cnlive.com/cnLogoutPreview.html")
  311 +// .enableTitleLayout(false)
  312 +// .enableTitle(false)
  313 +// .enableJump(true)
  314 +// .enableImageLongClick(false)
  315 +// .enableClose(false)
  316 +// .enableRefresh(false)
  317 +// .from(WWebViewOptions.FROM_PRE_BROWSE)
  318 +// .builder();
  319 +// wWebView.startWebViewActivity(fragment.getActivity());
  320 +
  321 +
  322 + ARouter.getInstance().build("/web/WebViewActivity")
  323 +// .withString("rSid", uid == null ? "" : uid)
  324 + .withString("rUrl", AppConfig.isDebug() ? "http://wjjh5test.cnlive.com/cnLogoutPreview.html" : "http://wjjh5.cnlive.com/cnLogoutPreview.html")
  325 + .withBoolean("rEnableTitle", false)
  326 + .withBoolean("enableMore", false)
  327 + .withBoolean("rEnableJump", true)
  328 + .withBoolean("rNeedSign", false)
  329 + .withBoolean("rEnableRefresh", false)
  330 + .withBoolean("rEnableClose", false)
  331 + .withBoolean("rEnableTitleLayout", false)
  332 + .navigation(fragment.getActivity());
  333 +
  334 +
  335 + }
  336 +
  337 +
  338 + private String parseCode(String message) {
  339 + Pattern p = Pattern.compile("\\b\\d{6}\\b");
  340 + Matcher m = p.matcher(message);
  341 + String code = "";
  342 + while (m.find()) {
  343 + code = m.group(0);
  344 + }
  345 + return code;
  346 + }
  347 +
  348 + public void bindPhone(OtherUserInfo otherUserInfo) {
  349 + if (fragment == null) return;
  350 +// BindPhoneNumberActivity.startActivity(fragment.getActivity(),
  351 +// otherUserInfo, fragment.fromTokenError, fragment.tagMsg, fragment.tagShare, fragment.clickAd);
  352 + }
  353 +
  354 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/frame/view/SelectCountryView.java 0 → 100644
  1 +package com.cnlive.strike.user.frame.view;
  2 +
  3 +import android.content.Intent;
  4 +import android.view.Gravity;
  5 +import android.view.View;
  6 +import android.widget.RelativeLayout;
  7 +import android.widget.TextView;
  8 +
  9 +import androidx.recyclerview.widget.LinearLayoutManager;
  10 +
  11 +import com.cnlive.core.libs.base.frame.view.BaseView;
  12 +import com.cnlive.core.libs.base.ui.widget.LetterBarView;
  13 +import com.cnlive.core.libs.base.util.AlertUtil;
  14 +import com.cnlive.core.libs.base.util.DensityUtils;
  15 +import com.cnlive.strike.user.R;
  16 +import com.cnlive.strike.user.model.CountryData;
  17 +import com.cnlive.strike.user.ui.activity.SelectCountryActivity;
  18 +import com.cnlive.strike.user.ui.adapter.SelectCountryAdapter;
  19 +import com.qmuiteam.qmui.widget.QMUITopBar;
  20 +
  21 +import java.util.List;
  22 +
  23 +/**
  24 + * 作者: 吴奎庆
  25 + * <p>
  26 + * 时间: 2018/11/17
  27 + * <p>
  28 + * 简介:
  29 + */
  30 +public class SelectCountryView extends BaseView implements SelectCountryAdapter.OnItemClickLIstener {
  31 + private SelectCountryActivity mContext;
  32 + private TextView rightBtn;
  33 + public SelectCountryAdapter mAdapter;
  34 + private QMUITopBar toolbar;
  35 +
  36 + public SelectCountryView(SelectCountryActivity countryActivity) {
  37 + mContext = countryActivity;
  38 + }
  39 +
  40 + public void initView() {
  41 + initTooBar();
  42 + LinearLayoutManager linearLayoutManager = new LinearLayoutManager(mContext);
  43 + mContext.binding.rvCountry.setLayoutManager(linearLayoutManager);
  44 + if (mAdapter == null) mAdapter = new SelectCountryAdapter(mContext);
  45 + mContext.binding.rvCountry.setAdapter(mAdapter);
  46 + mContext.binding.letterBarView.setOnLetterSelectListener(new LetterBarView.OnLetterSelectListener() {
  47 + @Override
  48 + public void onLetterSelect(String s) {
  49 + if (mContext.contactLetterGuideMap != null && mContext.contactLetterGuideMap.containsKey(s)) {
  50 + linearLayoutManager.scrollToPositionWithOffset(mContext.contactLetterGuideMap.get(s), 0);
  51 + }
  52 + }
  53 + });
  54 + mAdapter.setOnItemClickListener(this);
  55 + }
  56 +
  57 + private void initTooBar() {
  58 + if (mContext == null) return;
  59 + toolbar = (QMUITopBar) mContext.binding.includeToolbar;
  60 + toolbar.setTitle("选择国家");
  61 + toolbar.addLeftImageButton(R.drawable.xzq_fh, R.id.qmui_topbar_item_left_back).setOnClickListener(new View.OnClickListener() {
  62 + @Override
  63 + public void onClick(View v) {
  64 + mContext.finish();
  65 + }
  66 + });
  67 + }
  68 +
  69 + public void showMessage(String message) {
  70 + if (mContext == null) return;
  71 + AlertUtil.showDeftToast(mContext, message);
  72 + }
  73 +
  74 + public TextView addRightTextButtonWrapContent(QMUITopBar toolbar, int bgId) {
  75 + int dp_10 = DensityUtils.dp2px(mContext, 10);
  76 + TextView textView = new TextView(mContext);
  77 + textView.setBackgroundResource(bgId > 0 ? bgId : android.R.color.transparent);
  78 + textView.setGravity(Gravity.CENTER);
  79 + textView.setTextSize(15f);
  80 + textView.setPadding(dp_10, 0, dp_10, 0);
  81 + textView.setText(mContext.getResources().getString(R.string.select_contact_finish));
  82 + textView.setTextColor(mContext.getResources().getColor(R.color.color_656565));
  83 + RelativeLayout.LayoutParams rl = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
  84 + rl.addRule(RelativeLayout.CENTER_IN_PARENT);
  85 + toolbar.addRightView(textView, R.id.rightBtn, rl);
  86 + return textView;
  87 + }
  88 +
  89 +
  90 + CountryData currentData;
  91 +
  92 + @Override
  93 + public void onItemClick(CountryData data, int position) {
  94 +
  95 + if (position == mContext.fistPosition) {
  96 + if (data.isSelect()) {
  97 + mAdapter.getItem(position).setSelect(false);
  98 + } else {
  99 + mAdapter.getItem(position).setSelect(true);
  100 + }
  101 + mAdapter.notifyItemChanged(position);
  102 + } else {
  103 + if (data.isSelect()) {
  104 + mAdapter.getItem(position).setSelect(false);
  105 + } else {
  106 + mAdapter.getItem(position).setSelect(true);
  107 + }
  108 + if (mContext.fistPosition != -1) {
  109 + if (mAdapter.getItem(mContext.fistPosition).isSelect()) {
  110 + mAdapter.getItem(mContext.fistPosition).setSelect(false);
  111 + }
  112 + }
  113 + mAdapter.notifyItemChanged(position);
  114 + mAdapter.notifyItemChanged(mContext.fistPosition);
  115 + }
  116 + if (data.isSelect()){
  117 + if (rightBtn != null){
  118 + rightBtn.setVisibility(View.VISIBLE);
  119 + rightBtn.setTextColor(mContext.getResources().getColor(R.color.color_ffa300));
  120 + }
  121 +
  122 + }else {
  123 + if (rightBtn != null){
  124 + rightBtn.setVisibility(View.GONE);
  125 + rightBtn.setTextColor(mContext.getResources().getColor(R.color.color_656565));
  126 + }
  127 +
  128 + }
  129 + currentData = data;
  130 + mContext.fistPosition = position;
  131 + }
  132 +
  133 + public void showView(List<CountryData> countryData) {
  134 + if (mAdapter != null)
  135 + mAdapter.addItems(countryData);
  136 + mContext.binding.emptyView.setVisibility(View.GONE);
  137 +
  138 + rightBtn = addRightTextButtonWrapContent(toolbar, -1);
  139 + rightBtn.setVisibility(View.GONE);
  140 + rightBtn.setOnClickListener(v -> {
  141 + Intent intent = new Intent();
  142 + if (currentData != null && currentData.isSelect()) {
  143 + intent.putExtra("country", currentData.getContryName());
  144 + intent.putExtra("countryCode", currentData.getContryCode());
  145 + }
  146 +
  147 + mContext.setResult(mContext.ACTIVITY_RESULT_CODE, intent);
  148 + mContext.finish();
  149 + });
  150 +
  151 + }
  152 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/model/BankCardInfo.java 0 → 100644
  1 +package com.cnlive.strike.user.model;
  2 +
  3 +/**
  4 + * 银行卡信息
  5 + * Created by xiansong on 2017/12/27.
  6 + * TODO 数据库加密
  7 + */
  8 +
  9 +public class BankCardInfo {
  10 + //银行名称
  11 + private String bankName;
  12 + //银行卡卡号
  13 + private String bankCardNumber;
  14 + //银行卡类型
  15 + private String bankCardType;
  16 + //持卡人姓名
  17 + private String holderName;
  18 + //持卡人预留手机号
  19 + private String holderPhoneNumber;
  20 +
  21 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/model/BindPhoneNumberInfo.java 0 → 100644
  1 +package com.cnlive.strike.user.model;
  2 +
  3 +import android.graphics.drawable.Drawable;
  4 +
  5 +
  6 +import androidx.databinding.BaseObservable;
  7 +import androidx.databinding.Bindable;
  8 +
  9 +import java.io.Serializable;
  10 +import com.cnlive.strike.user.BR;
  11 +/**
  12 + * 作者: 吴奎庆
  13 + * <p>
  14 + * 时间: 2019/9/9
  15 + * <p>
  16 + * 简介: 用户绑定的信息
  17 + */
  18 +public class BindPhoneNumberInfo extends BaseObservable implements Serializable {
  19 + public static final int TYPE_TITLE= 199149;
  20 + public static final int TYPE_LOGIN= 199150;
  21 + //条目类型
  22 + public int itemType ;
  23 + // 类型名
  24 + private String itemName;
  25 + // 类型名
  26 + private String typeName;
  27 + //类型图标
  28 + private Drawable typeIcon;
  29 + //用户名
  30 + private String userName;
  31 + //是否绑定
  32 + private boolean isBind;
  33 + //类型 0手机号 3 微信 2 qq 1 微博
  34 + public int type ;
  35 +
  36 + public int getType() {
  37 + return type;
  38 + }
  39 +
  40 + public void setType(int type) {
  41 + this.type = type;
  42 + }
  43 +
  44 +
  45 + public int getItemType() {
  46 + return itemType;
  47 + }
  48 +
  49 + public void setItemType(int itemType) {
  50 + this.itemType = itemType;
  51 + }
  52 +
  53 + public String getItemName() {
  54 + return itemName;
  55 + }
  56 +
  57 + public void setItemName(String itemName) {
  58 + this.itemName = itemName;
  59 + }
  60 +
  61 + public String getTypeName() {
  62 + return typeName;
  63 + }
  64 +
  65 + public void setTypeName(String typeName) {
  66 + this.typeName = typeName;
  67 + }
  68 +
  69 + public Drawable getTypeIcon() {
  70 + return typeIcon;
  71 + }
  72 +
  73 + public void setTypeIcon(Drawable typeIcon) {
  74 + this.typeIcon = typeIcon;
  75 + }
  76 +
  77 + public String getUserName() {
  78 + return userName;
  79 + }
  80 +
  81 + public void setUserName(String userName) {
  82 + this.userName = userName;
  83 + }
  84 + @Bindable
  85 + public boolean isBind() {
  86 + return isBind;
  87 + }
  88 +
  89 + public void setBind(boolean bind) {
  90 + isBind = bind;
  91 + notifyPropertyChanged(BR.bind);
  92 + }
  93 +
  94 +
  95 +
  96 +
  97 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/model/CNLiveUserInfo.java 0 → 100644
  1 +package com.cnlive.strike.user.model;
  2 +
  3 +import android.text.TextUtils;
  4 +
  5 +import java.io.Serializable;
  6 +
  7 +/**
  8 + * 开放平台-用户信息
  9 + *
  10 + * @author Lynn
  11 + * @date 2017/12/22
  12 + */
  13 +
  14 +public class CNLiveUserInfo implements Serializable {
  15 + //用户id
  16 + private String uid;
  17 + //昵称
  18 + private String nickName;
  19 + //性别
  20 + private String gender;
  21 + //地址
  22 + private String location;
  23 + //头像
  24 + private String faceUrl;
  25 + //手机号
  26 + private String mobile;
  27 + //邮箱
  28 + private String email;
  29 + //平台TOKEN
  30 + private String token;
  31 + //新用户
  32 + private boolean isNewUser;
  33 + //个性签名
  34 + private String userSign;
  35 + //用户头像大图
  36 + private String bigFaceUrl;
  37 + //手机号国家码
  38 + private String countryCode;
  39 + //qqid
  40 + private String qqUid;
  41 + //微信id
  42 + private String wxUid;
  43 + //微博id
  44 + private String sinaUid;
  45 +
  46 +
  47 + public String getUid() {
  48 + return uid == null ? "" : uid;
  49 + }
  50 +
  51 + public void setUid(String uid) {
  52 + this.uid = uid;
  53 + }
  54 +
  55 + public String getNickName() {
  56 + return nickName;
  57 + }
  58 +
  59 + public void setNickName(String nickName) {
  60 + this.nickName = nickName;
  61 + }
  62 +
  63 + public String getGender() {
  64 + return gender;
  65 + }
  66 +
  67 + public void setGender(String gender) {
  68 + this.gender = gender;
  69 + }
  70 +
  71 + public String getLocation() {
  72 + return location;
  73 + }
  74 +
  75 + public void setLocation(String location) {
  76 + this.location = location;
  77 + }
  78 +
  79 + public String getFaceUrl() {
  80 + return faceUrl;
  81 + }
  82 +
  83 + public void setFaceUrl(String faceUrl) {
  84 + this.faceUrl = faceUrl;
  85 + }
  86 +
  87 + public String getBigFaceUrl() {
  88 + if (TextUtils.isEmpty(bigFaceUrl)) return faceUrl;
  89 + return bigFaceUrl;
  90 + }
  91 +
  92 + public void setBigFaceUrl(String bigFaceUrl) {
  93 + this.bigFaceUrl = bigFaceUrl;
  94 + }
  95 +
  96 + public String getMobile() {
  97 + return mobile;
  98 + }
  99 +
  100 + public void setMobile(String mobile) {
  101 + this.mobile = mobile;
  102 + }
  103 +
  104 + public String getEmail() {
  105 + return email;
  106 + }
  107 +
  108 + public void setEmail(String email) {
  109 + this.email = email;
  110 + }
  111 +
  112 + public String getToken() {
  113 + return token;
  114 + }
  115 +
  116 + public void setToken(String token) {
  117 + this.token = token;
  118 + }
  119 +
  120 + public boolean isNewUser() {
  121 + return isNewUser;
  122 + }
  123 +
  124 + public void setNewUser(boolean newUser) {
  125 + isNewUser = newUser;
  126 + }
  127 +
  128 + public String getQqUid() {
  129 + return qqUid;
  130 + }
  131 +
  132 + public void setQqUid(String qqUid) {
  133 + this.qqUid = qqUid;
  134 + }
  135 +
  136 + public String getWxUid() {
  137 + return wxUid;
  138 + }
  139 +
  140 + public void setWxUid(String wxUid) {
  141 + this.wxUid = wxUid;
  142 + }
  143 +
  144 + public String getSinaUid() {
  145 + return sinaUid;
  146 + }
  147 +
  148 + public void setSinaUid(String sinaUid) {
  149 + this.sinaUid = sinaUid;
  150 + }
  151 +
  152 + public String getUserSign() {
  153 + return userSign;
  154 + }
  155 +
  156 + public void setUserSign(String userSign) {
  157 + this.userSign = userSign;
  158 + }
  159 +
  160 + public String getCountryCode() {
  161 + return countryCode;
  162 + }
  163 +
  164 + public void setCountryCode(String countryCode) {
  165 + this.countryCode = countryCode;
  166 + }
  167 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/model/CNLiveUserInfoExt.java 0 → 100644
  1 +package com.cnlive.strike.user.model;
  2 +
  3 +/**
  4 + * Created by xiansong on 2018/4/3.
  5 + */
  6 +
  7 +public class CNLiveUserInfoExt {
  8 +
  9 +
  10 + @Override
  11 + public String toString() {
  12 + return "CNLiveUserInfoExt{" +
  13 + "userSign='" + userSign + '\'' +
  14 + '}';
  15 + }
  16 +
  17 + private String userSign ;
  18 +
  19 + public String getUserSign() {
  20 + return userSign;
  21 + }
  22 +
  23 + public void setUserSign(String userSign) {
  24 + this.userSign = userSign;
  25 + }
  26 +
  27 +
  28 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/model/CertificationInfo.java 0 → 100644
  1 +package com.cnlive.strike.user.model;
  2 +
  3 +/**
  4 + * 实名认证信息
  5 + * Created by xiansong on 2017/12/27.
  6 + */
  7 +
  8 +public class CertificationInfo {
  9 + //姓名
  10 + private String name;
  11 + //手机号
  12 + private String phoneNumber;
  13 + //身份证编号
  14 + private String idNumber;
  15 +
  16 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/model/CountryData.java 0 → 100644
  1 +package com.cnlive.strike.user.model;
  2 +
  3 +import android.text.TextUtils;
  4 +
  5 +import androidx.databinding.BaseObservable;
  6 +import androidx.databinding.Bindable;
  7 +
  8 +import com.cnlive.strike.user.util.PinyinUtil;
  9 +import com.cnlive.strike.user.util.search.SearchUtil;
  10 +
  11 +import java.io.Serializable;
  12 +import java.util.Locale;
  13 +import com.cnlive.strike.user.BR;
  14 +/**
  15 + * 作者: 吴奎庆
  16 + * <p>
  17 + * 时间: 2018/11/17
  18 + * <p>
  19 + * 简介:
  20 + */
  21 +public class CountryData extends BaseObservable implements Serializable {
  22 +
  23 + public static final int TYPE_CATGORY= 199149;
  24 + public static final int TYPE_COUNTRY= 199150;
  25 + public int getType() {
  26 + return type;
  27 + }
  28 +
  29 + public void setType(int type) {
  30 + this.type = type;
  31 + }
  32 +
  33 + public int type ;
  34 +
  35 + public String getLetter() {
  36 + return letter;
  37 + }
  38 +
  39 + public void setLetter(String letter) {
  40 + this.letter = letter;
  41 + }
  42 +
  43 + /**
  44 + * contryName : 阿尔巴尼亚
  45 + * contryCode : 355
  46 + */
  47 + private String letter = "";
  48 +
  49 + private String contryName;
  50 + private String contryCode;
  51 +
  52 + private boolean isSelect;
  53 + @Bindable
  54 + public boolean isSelect() {
  55 + return isSelect;
  56 + }
  57 +
  58 + public void setSelect(boolean isSelect) {
  59 + this.isSelect = isSelect;
  60 + notifyPropertyChanged(BR.select);
  61 + }
  62 +
  63 +
  64 + public String getContryName() {
  65 + return contryName;
  66 + }
  67 +
  68 + public void setContryName(String contryName) {
  69 +
  70 + this.contryName = contryName;
  71 + }
  72 +
  73 + public String getContryCode() {
  74 + return contryCode;
  75 + }
  76 +
  77 + public void setContryCode(String contryCode) {
  78 + this.contryCode = contryCode;
  79 + }
  80 +
  81 +
  82 + public void setLetterContent(String nickName) {
  83 + if (TextUtils.isEmpty(nickName)) {
  84 + letter = "#";
  85 + } else {
  86 + String pinYin = PinyinUtil.getPinyin(nickName).toUpperCase(Locale.getDefault());
  87 + if (TextUtils.isEmpty(pinYin)) {
  88 + letter = "#";
  89 + } else {
  90 + letter = SearchUtil.isAllEnglish(pinYin.substring(0, 1)) ? pinYin : "#";
  91 + }
  92 + }
  93 + }
  94 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/model/LoginSuccessInfo.java 0 → 100644
  1 +package com.cnlive.strike.user.model;
  2 +
  3 +import android.net.Uri;
  4 +
  5 +import java.io.Serializable;
  6 +
  7 +/**
  8 + * 登录成功后携带的跳转信息
  9 + */
  10 +public class LoginSuccessInfo implements Serializable {
  11 + private String type;
  12 + private Uri uri;
  13 + public Boolean clickAd;
  14 + public String tagShare;
  15 + public String tagMsg;
  16 +
  17 + public String getType() {
  18 + return type;
  19 + }
  20 +
  21 + public void setType(String type) {
  22 + this.type = type;
  23 + }
  24 +
  25 + public Uri getUri() {
  26 + return uri;
  27 + }
  28 +
  29 + public void setUri(Uri uri) {
  30 + this.uri = uri;
  31 + }
  32 +
  33 + public Boolean getClickAd() {
  34 + return clickAd;
  35 + }
  36 +
  37 + public void setClickAd(Boolean clickAd) {
  38 + this.clickAd = clickAd;
  39 + }
  40 +
  41 + public String getTagShare() {
  42 + return tagShare;
  43 + }
  44 +
  45 + public void setTagShare(String tagShare) {
  46 + this.tagShare = tagShare;
  47 + }
  48 +
  49 + public String getTagMsg() {
  50 + return tagMsg;
  51 + }
  52 +
  53 + public void setTagMsg(String tagMsg) {
  54 + this.tagMsg = tagMsg;
  55 + }
  56 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/model/UserConst.java 0 → 100644
  1 +package com.cnlive.strike.user.model;
  2 +
  3 +public class UserConst {
  4 + public static final int IS_NEW_USER = 1000;//是新用户
  5 + public static final int IS_NOT_NEW_USER = 1001;//不是新用户
  6 + public static final int MODIFY_USER_IMAGE = 1002;//修改用户头像
  7 + public static final int USER_INVALID = 1003;//用户失效
  8 + public static final int MODIFY_USER_NAME = 1004;//修改用户昵称
  9 + public static final int COIN_RAIN_ACTION = 1005;//下金币
  10 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/model/UserData.java 0 → 100644
  1 +package com.cnlive.strike.user.model;
  2 +
  3 +/**
  4 + * Created by Lynn on 2018/10/15.
  5 + */
  6 +
  7 +public class UserData {
  8 + private String uid;
  9 + private String nickName;
  10 + private String gender;
  11 + private String location;
  12 + private String faceUrl;
  13 + private String mobile;
  14 + private String email;
  15 + private String extInfo;
  16 + private String qqUid;
  17 + private String wxUid;
  18 + private String sinaUid;
  19 + private String renrenUid;
  20 + private String hUid;
  21 + private String platformId;
  22 + private String token;
  23 + private String callbackAcitvityStatushttpPostUrl;
  24 + private boolean isNewUser;
  25 + private String bigFaceUrl;
  26 + private String countryCode = "86";//手机号国家码
  27 +
  28 + public String getUid() {
  29 + return uid;
  30 + }
  31 +
  32 + public void setUid(String uid) {
  33 + this.uid = uid;
  34 + }
  35 +
  36 + public String getNickName() {
  37 + return nickName;
  38 + }
  39 +
  40 + public void setNickName(String nickName) {
  41 + this.nickName = nickName;
  42 + }
  43 +
  44 + public String getLocation() {
  45 + return location;
  46 + }
  47 +
  48 + public void setLocation(String location) {
  49 + this.location = location;
  50 + }
  51 +
  52 + public String getGender() {
  53 + return gender;
  54 + }
  55 +
  56 + public void setGender(String gender) {
  57 + this.gender = gender;
  58 + }
  59 +
  60 + public String getFaceUrl() {
  61 + return faceUrl;
  62 + }
  63 +
  64 + public void setFaceUrl(String faceUrl) {
  65 + this.faceUrl = faceUrl;
  66 + }
  67 +
  68 + public String getToken() {
  69 + return token;
  70 + }
  71 +
  72 + public void setToken(String token) {
  73 + this.token = token;
  74 + }
  75 +
  76 + public String getExtInfo() {
  77 + return extInfo;
  78 + }
  79 +
  80 + public void setExtInfo(String extInfo) {
  81 + this.extInfo = extInfo;
  82 + }
  83 +
  84 + public String getMobile() {
  85 + return mobile;
  86 + }
  87 +
  88 + public void setMobile(String mobile) {
  89 + this.mobile = mobile;
  90 + }
  91 +
  92 + public String getEmail() {
  93 + return email;
  94 + }
  95 +
  96 + public void setEmail(String email) {
  97 + this.email = email;
  98 + }
  99 +
  100 + public String getQqUid() {
  101 + return qqUid;
  102 + }
  103 +
  104 + public void setQqUid(String qqUid) {
  105 + this.qqUid = qqUid;
  106 + }
  107 +
  108 + public String getWxUid() {
  109 + return wxUid;
  110 + }
  111 +
  112 + public void setWxUid(String wxUid) {
  113 + this.wxUid = wxUid;
  114 + }
  115 +
  116 + public String getSinaUid() {
  117 + return sinaUid;
  118 + }
  119 +
  120 + public void setSinaUid(String sinaUid) {
  121 + this.sinaUid = sinaUid;
  122 + }
  123 +
  124 + public String getRenrenUid() {
  125 + return renrenUid;
  126 + }
  127 +
  128 + public void setRenrenUid(String renrenUid) {
  129 + this.renrenUid = renrenUid;
  130 + }
  131 +
  132 + public String gethUid() {
  133 + return hUid;
  134 + }
  135 +
  136 + public void sethUid(String hUid) {
  137 + this.hUid = hUid;
  138 + }
  139 +
  140 + public String getPlatformId() {
  141 + return platformId;
  142 + }
  143 +
  144 + public void setPlatformId(String platformId) {
  145 + this.platformId = platformId;
  146 + }
  147 +
  148 + public boolean isNewUser() {
  149 + return isNewUser;
  150 + }
  151 +
  152 + public void setNewUser(boolean newUser) {
  153 + isNewUser = newUser;
  154 + }
  155 +
  156 + public String getBigFaceUrl() {
  157 + return bigFaceUrl;
  158 + }
  159 +
  160 + public void setBigFaceUrl(String bigFaceUrl) {
  161 + this.bigFaceUrl = bigFaceUrl;
  162 + }
  163 +
  164 + public String getCountryCode() {
  165 + return countryCode;
  166 + }
  167 +
  168 + public void setCountryCode(String countryCode) {
  169 + this.countryCode = countryCode;
  170 + }
  171 +
  172 + public String getCallbackAcitvityStatushttpPostUrl() {
  173 + return callbackAcitvityStatushttpPostUrl;
  174 + }
  175 +
  176 + public void setCallbackAcitvityStatushttpPostUrl(String callbackAcitvityStatushttpPostUrl) {
  177 + this.callbackAcitvityStatushttpPostUrl = callbackAcitvityStatushttpPostUrl;
  178 + }
  179 +
  180 + @Override
  181 + public String toString() {
  182 + return "UserData{" +
  183 + "uid='" + uid + '\'' +
  184 + ", nickName='" + nickName + '\'' +
  185 + ", gender='" + gender + '\'' +
  186 + ", location='" + location + '\'' +
  187 + ", faceUrl='" + faceUrl + '\'' +
  188 + ", mobile='" + mobile + '\'' +
  189 + ", email='" + email + '\'' +
  190 + ", extInfo='" + extInfo + '\'' +
  191 + ", qqUid='" + qqUid + '\'' +
  192 + ", wxUid='" + wxUid + '\'' +
  193 + ", sinaUid='" + sinaUid + '\'' +
  194 + ", renrenUid='" + renrenUid + '\'' +
  195 + ", hUid='" + hUid + '\'' +
  196 + ", platformId='" + platformId + '\'' +
  197 + ", token='" + token + '\'' +
  198 + ", callbackAcitvityStatushttpPostUrl='" + callbackAcitvityStatushttpPostUrl + '\'' +
  199 + ", isNewUser=" + isNewUser +
  200 + ", bigFaceUrl='" + bigFaceUrl + '\'' +
  201 + ", countryCode='" + countryCode + '\'' +
  202 + '}';
  203 + }
  204 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/model/UserFaithInfo.java 0 → 100644
  1 +package com.cnlive.strike.user.model;
  2 +
  3 +/**
  4 + * 用户信用信息
  5 + * Created by xiansong on 2017/12/27.
  6 + */
  7 +
  8 +public class UserFaithInfo {
  9 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/model/WalletInfo.java 0 → 100644
  1 +package com.cnlive.strike.user.model;
  2 +
  3 +/**
  4 + * 我的钱包 / 资产管理
  5 + * Created by xiansong on 2017/12/27.
  6 + */
  7 +
  8 +public class WalletInfo {
  9 +
  10 + //钱包余额
  11 + private String residual;
  12 +
  13 + //积分
  14 + private String integral;
  15 +
  16 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/model/msg/UserEventMsg.java 0 → 100644
  1 +package com.cnlive.strike.user.model.msg;
  2 +
  3 +public class UserEventMsg {
  4 + public static final int LOGIN_SUCCESS = 0;//登陆成功
  5 + public static final int LOGIN_FAIL = 1;//登录失败
  6 + public static final int LOGIN_OUT = 2;//退出登录
  7 + public static final int IS_NEW_USER = 3;//是新用户
  8 + public static final int MODIFY_USER_IMAGE = 4;//修改用户头像
  9 + public static final int COIN_RAIN_ACTION = 5;//掉金币
  10 +
  11 + private int type;
  12 + private Object Data;
  13 +
  14 + public UserEventMsg(int type, Object data) {
  15 + this.type = type;
  16 + Data = data;
  17 + }
  18 +
  19 + public int getType() {
  20 + return type;
  21 + }
  22 +
  23 + public void setType(int type) {
  24 + this.type = type;
  25 + }
  26 +
  27 + public Object getData() {
  28 + return Data;
  29 + }
  30 +
  31 + public void setData(Object data) {
  32 + Data = data;
  33 + }
  34 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/network/api/ApiBaseServiceOpen.java 0 → 100644
  1 +package com.cnlive.strike.user.network.api;
  2 +
  3 +
  4 +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;
  8 +
  9 +import java.util.List;
  10 +import java.util.Map;
  11 +
  12 +import io.reactivex.Observable;
  13 +import okhttp3.MultipartBody;
  14 +import okhttp3.RequestBody;
  15 +import retrofit2.http.Multipart;
  16 +import retrofit2.http.POST;
  17 +import retrofit2.http.Part;
  18 +import retrofit2.http.PartMap;
  19 +import retrofit2.http.QueryMap;
  20 +
  21 +/**
  22 + * Created by xiansong on 2018/3/22.
  23 + */
  24 +
  25 +public interface ApiBaseServiceOpen {
  26 +
  27 +
  28 + /**
  29 + * 顶踩一条节目 0:踩 1:顶
  30 + *
  31 + * @param map
  32 + * @return
  33 + */
  34 + @POST("open/api2/ctServices/supportForHd/support")
  35 + Observable<BaseResult> support(@QueryMap Map<String, String> map);
  36 +
  37 +
  38 + /**
  39 + * 快捷登录前发送验证码
  40 + *
  41 + * @param map
  42 + * @return
  43 + */
  44 + @POST("open/api2/user/sendVerifyCode")
  45 + Observable<BaseResult> sendVerifyCodeBefQuickLogin(@QueryMap Map<String, String> map);
  46 +
  47 + /**
  48 + * 快捷登录
  49 + *
  50 + * @param map
  51 + * @return
  52 + */
  53 + @POST("open/api2/user/loginInQuickly")
  54 + Observable<BaseResult<UserData>> quickLogin(@QueryMap Map<String, String> map);
  55 +
  56 + /**
  57 + * 登录
  58 + *
  59 + * @param map
  60 + * @return
  61 + */
  62 + @POST("open/api2/user/loginIn")
  63 + Observable<BaseResult<UserData>> login(@QueryMap Map<String, String> map);
  64 +
  65 + /**
  66 + * 查询用户信息
  67 + *
  68 + * @param map
  69 + * @return
  70 + */
  71 + @POST("open/api2/user/readUserById")
  72 + Observable<BaseResult<UserData>> queryUserInfo(@QueryMap Map<String, String> map);
  73 +
  74 + /**
  75 + * 更新用户附加信息
  76 + *
  77 + * @param map
  78 + * @return
  79 + */
  80 + @POST("open/api2/user/updateUserExtInfo")
  81 + Observable<BaseResult> updateUserExtInfo(@QueryMap Map<String, String> map);
  82 +
  83 + /**
  84 + * 修改用户单项信息
  85 + *
  86 + * @param map
  87 + * @return
  88 + */
  89 + @POST("open/api2/user/updateUserById")
  90 + Observable<BaseResult> modifyUserInfo(@QueryMap Map<String, String> map);
  91 +
  92 +
  93 + /**
  94 + * 注册或修改手机号前发手机验证码
  95 + *
  96 + * @param map
  97 + * @return
  98 + */
  99 + @POST("open/api2/user/sendVerifyCodeForUnRegistered")
  100 + Observable<BaseResult> sendVerifyCodeForUnRegistered(@QueryMap Map<String, String> map);
  101 +
  102 + /**
  103 + * 更新手机号
  104 + *
  105 + * @param map
  106 + * @return
  107 + */
  108 + @POST("open/api2/user/updateMobileById")
  109 + Observable<BaseResult> updateMobile(@QueryMap Map<String, String> map);
  110 +
  111 + /**
  112 + * 注册
  113 + *
  114 + * @param map
  115 + * @return
  116 + */
  117 + @POST("open/api2/user/register")
  118 + Observable<BaseResult<UserData>> register(@QueryMap Map<String, String> map);
  119 +
  120 +
  121 + /**
  122 + * 获取access_token
  123 + *
  124 + * @param map
  125 + * @return
  126 + */
  127 + @POST("open/api2/token")
  128 + Observable<BaseResult<TokenData>> accessToken(@QueryMap Map<String, String> map);
  129 +
  130 + /**
  131 + * 上传头像
  132 + *
  133 + * @param map
  134 + * @param params
  135 + * @return
  136 + */
  137 + @Multipart
  138 + @POST("open/api2/user/updateUserFaceById")
  139 + Observable<BaseResult<FaceData>> updateUserFace(@PartMap Map<String, RequestBody> map,
  140 + @Part List<MultipartBody.Part> params);
  141 +
  142 +
  143 +
  144 + /**
  145 + * 音频播放鉴权接口
  146 + * @param map
  147 + * @return
  148 + */
  149 + @POST("open/api2/user/loginIn3rdForWJJ")
  150 + Observable<BaseResult<UserData>> loginIn3rdForWJJ(@QueryMap Map<String, String> map);
  151 + /**
  152 + * 登陆
  153 + * @param map
  154 + * @return
  155 + */
  156 + @POST("open/api2/user/loginIn3rdAndMobileForWJJ")
  157 + Observable<BaseResult<UserData>> loginIn3rdAndMobileForWJJ(@QueryMap Map<String, String> map);
  158 +
  159 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/network/api/BaseRequest.java 0 → 100644
  1 +package com.cnlive.strike.user.network.api;
  2 +
  3 +
  4 +import android.text.TextUtils;
  5 +
  6 +import com.cnlive.core.libs.base.application.AppConfig;
  7 +import com.cnlive.core.network.BaseResult;
  8 +import com.cnlive.core.network.NetBuilder;
  9 +import com.cnlive.core.network.ServerException;
  10 +
  11 +import java.util.ArrayList;
  12 +import java.util.List;
  13 +
  14 +import io.reactivex.Observable;
  15 +import okhttp3.Interceptor;
  16 +
  17 +/**
  18 + * 基本请求
  19 + * ys
  20 + */
  21 +public class BaseRequest {
  22 + private String userSetUrl;
  23 + private static BaseRequest request;
  24 + private long connectTimeout;//连接超时
  25 + private long readTimeout;//读取超时
  26 + private long writeTimeout;//写入超时
  27 + private List<Interceptor> interceptorList;//拦截器
  28 + private String baseUrl = "http://gank.io/api/data/";
  29 + private final String SP_CMS_URL_DEBUT = "http://cmstest.cnlive.com:8768/";
  30 + private final String SP_CMS_URL = "http://cms.cnlive.com:8768/";
  31 + //网++ 接口域名
  32 + public final String SP_BASE_URL = "https://apiwjj.cnlive.com/";
  33 + //网++ 测试环境 接口域名
  34 + public final String SP_DEBUG_URL = "http://apiwjjtest.cnlive.com/";
  35 + //OPEN API 接口域名
  36 + private final String OPEN_URL = "https://api.cnlive.com/";
  37 +
  38 + /**
  39 + * 构造函数初始化
  40 + */
  41 + public BaseRequest() {
  42 + interceptorList = new ArrayList<>();
  43 + }
  44 +
  45 +
  46 + /**
  47 + * 设置连接超时
  48 + *
  49 + * @param connectTimeout
  50 + * @return
  51 + */
  52 + public BaseRequest setConnectTimeout(long connectTimeout) {
  53 + init();
  54 + connectTimeout = connectTimeout;
  55 + return request;
  56 + }
  57 +
  58 + /**
  59 + * 设置读取超时
  60 + *
  61 + * @param readTimeout
  62 + * @return
  63 + */
  64 + public BaseRequest setReadTimeout(long readTimeout) {
  65 + init();
  66 + readTimeout = readTimeout;
  67 + return request;
  68 + }
  69 +
  70 + /**
  71 + * 设置写入超时
  72 + *
  73 + * @param writeTimeout
  74 + * @return
  75 + */
  76 + public BaseRequest setWriteTimeout(long writeTimeout) {
  77 + init();
  78 + writeTimeout = writeTimeout;
  79 + return request;
  80 + }
  81 +
  82 +
  83 + /**
  84 + * 初始化接口地址
  85 + */
  86 + private String initBaseUrl(Class clazz) {
  87 + if (AppConfig.isDebug()) {
  88 + baseUrl = SP_DEBUG_URL;//还原初始地址
  89 + if (clazz == ApiBaseServiceOpen.class) {
  90 + return OPEN_URL;
  91 + }
  92 + }
  93 + return baseUrl;
  94 + }
  95 +
  96 + /**
  97 + * 设置连接地址
  98 + *
  99 + * @param url
  100 + * @return
  101 + */
  102 + public BaseRequest setUrl(String url) {
  103 + init();
  104 + userSetUrl = url;
  105 + return request;
  106 + }
  107 +
  108 + /**
  109 + * 添加拦截器
  110 + *
  111 + * @param interceptor
  112 + * @return
  113 + */
  114 + public BaseRequest addInterceptor(Interceptor interceptor) {
  115 + if (null != interceptor) {
  116 + interceptorList.add(interceptor);
  117 + }
  118 + return request;
  119 + }
  120 +
  121 + /**
  122 + * @return
  123 + */
  124 + public static synchronized BaseRequest init() {
  125 + if (null == request) {
  126 + request = new BaseRequest();
  127 + }
  128 + return request;
  129 + }
  130 +
  131 + public <NetService> NetService service(Class<NetService> clz) {
  132 + NetService service = null;
  133 + NetBuilder builder = new NetBuilder(clz);
  134 + if (connectTimeout > 0) {
  135 + builder.setConnectTimeout(connectTimeout);
  136 + }
  137 + if (readTimeout > 0) {
  138 + builder.setReadTimeout(readTimeout);
  139 + }
  140 + if (writeTimeout > 0) {
  141 + builder.setWriteTimeout(writeTimeout);
  142 + }
  143 + if (null != interceptorList && interceptorList.size() > 0) {
  144 + builder.addInterceptors(interceptorList);
  145 + }
  146 + //设置接口请求头地址
  147 + if (!TextUtils.isEmpty(userSetUrl)) {
  148 + builder.setBaseUrl(userSetUrl);
  149 + userSetUrl = "";
  150 + } else {
  151 + builder.setBaseUrl(initBaseUrl(clz));
  152 + }
  153 + service = (NetService) builder.getService();
  154 + builder = null;
  155 + //重置属性
  156 + resetData();
  157 + return service;
  158 +
  159 + }
  160 +
  161 + private void resetData() {
  162 + interceptorList.clear();
  163 +
  164 + connectTimeout = 0;
  165 + readTimeout = 0;
  166 + writeTimeout = 0;
  167 + }
  168 +
  169 +
  170 +
  171 +
  172 +}
0 173 \ No newline at end of file
... ...
cloud/user/src/main/java/com/cnlive/strike/user/network/model/FaceData.java 0 → 100644
  1 +package com.cnlive.strike.user.network.model;
  2 +
  3 +/**
  4 + * Created by Lynn on 2018/10/15.
  5 + */
  6 +
  7 +public class FaceData {
  8 + private String faceUrl;
  9 + private String bigFaceUrl;
  10 +
  11 + public String getFaceUrl() {
  12 + return faceUrl;
  13 + }
  14 +
  15 + public void setFaceUrl(String faceUrl) {
  16 + this.faceUrl = faceUrl;
  17 + }
  18 +
  19 + public String getBigFaceUrl() {
  20 + return bigFaceUrl;
  21 + }
  22 +
  23 + public void setBigFaceUrl(String bigFaceUrl) {
  24 + this.bigFaceUrl = bigFaceUrl;
  25 + }
  26 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/network/model/StorageInfoData.java 0 → 100644
  1 +package com.cnlive.strike.user.network.model;
  2 +
  3 +/**
  4 + * Created by cnlive201803 on 2018/5/31.
  5 + */
  6 +
  7 +public class StorageInfoData {
  8 + private int storageId;
  9 + private String storageName;
  10 + private int storageType;
  11 + private int state;
  12 + private int contentType;
  13 + private int profile;
  14 + private String domain;
  15 +
  16 +
  17 + public int getStorageId() {
  18 + return storageId;
  19 + }
  20 +
  21 + public void setStorageId(int storageId) {
  22 + this.storageId = storageId;
  23 + }
  24 +
  25 + public String getStorageName() {
  26 + return storageName;
  27 + }
  28 +
  29 + public void setStorageName(String storageName) {
  30 + this.storageName = storageName;
  31 + }
  32 +
  33 + public int getStorageType() {
  34 + return storageType;
  35 + }
  36 +
  37 + public void setStorageType(int storageType) {
  38 + this.storageType = storageType;
  39 + }
  40 +
  41 + public int getState() {
  42 + return state;
  43 + }
  44 +
  45 + public void setState(int state) {
  46 + this.state = state;
  47 + }
  48 +
  49 + public int getContentType() {
  50 + return contentType;
  51 + }
  52 +
  53 + public void setContentType(int contentType) {
  54 + this.contentType = contentType;
  55 + }
  56 +
  57 + public int getProfile() {
  58 + return profile;
  59 + }
  60 +
  61 + public void setProfile(int profile) {
  62 + this.profile = profile;
  63 + }
  64 +
  65 + public String getDomain() {
  66 + return domain;
  67 + }
  68 +
  69 + public void setDomain(String domain) {
  70 + this.domain = domain;
  71 + }
  72 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/network/model/TimeStampInfo.java 0 → 100644
  1 +package com.cnlive.strike.user.network.model;
  2 +
  3 +/**
  4 + * 作者: 吴奎庆
  5 + * <p>
  6 + * 时间: 2019/8/27
  7 + * <p>
  8 + * 简介:
  9 + */
  10 +public class TimeStampInfo {
  11 + long timestamp;
  12 +
  13 + public long getTimestamp() {
  14 + return timestamp;
  15 + }
  16 +
  17 + public void setTimestamp(long timestamp) {
  18 + this.timestamp = timestamp;
  19 + }
  20 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/network/model/TokenData.java 0 → 100644
  1 +package com.cnlive.strike.user.network.model;
  2 +
  3 +/**
  4 + * Created by Lynn on 2018/10/15.
  5 + */
  6 +
  7 +public class TokenData {
  8 +
  9 + private String access_token;
  10 + private int expires_in;
  11 +
  12 + public String getAccess_token() {
  13 + return access_token;
  14 + }
  15 +
  16 + public void setAccess_token(String access_token) {
  17 + this.access_token = access_token;
  18 + }
  19 +
  20 + public int getExpires_in() {
  21 + return expires_in;
  22 + }
  23 +
  24 + public void setExpires_in(int expires_in) {
  25 + this.expires_in = expires_in;
  26 + }
  27 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/network/model/UserData.java 0 → 100644
  1 +package com.cnlive.strike.user.network.model;
  2 +
  3 +/**
  4 + * Created by Lynn on 2018/10/15.
  5 + */
  6 +
  7 +public class UserData {
  8 + private String uid;
  9 + private String nickName;
  10 + private String gender;
  11 + private String location;
  12 + private String faceUrl;
  13 + private String mobile;
  14 + private String email;
  15 + private String extInfo;
  16 + private String qqUid;
  17 + private String wxUid;
  18 + private String sinaUid;
  19 + private String renrenUid;
  20 + private String hUid;
  21 + private String platformId;
  22 + private String token;
  23 + private String callbackAcitvityStatushttpPostUrl;
  24 + private boolean isNewUser;
  25 + private String bigFaceUrl;
  26 + private String countryCode = "86";//手机号国家码
  27 +
  28 + public String getUid() {
  29 + return uid;
  30 + }
  31 +
  32 + public void setUid(String uid) {
  33 + this.uid = uid;
  34 + }
  35 +
  36 + public String getNickName() {
  37 + return nickName;
  38 + }
  39 +
  40 + public void setNickName(String nickName) {
  41 + this.nickName = nickName;
  42 + }
  43 +
  44 + public String getLocation() {
  45 + return location;
  46 + }
  47 +
  48 + public void setLocation(String location) {
  49 + this.location = location;
  50 + }
  51 +
  52 + public String getGender() {
  53 + return gender;
  54 + }
  55 +
  56 + public void setGender(String gender) {
  57 + this.gender = gender;
  58 + }
  59 +
  60 + public String getFaceUrl() {
  61 + return faceUrl;
  62 + }
  63 +
  64 + public void setFaceUrl(String faceUrl) {
  65 + this.faceUrl = faceUrl;
  66 + }
  67 +
  68 + public String getToken() {
  69 + return token;
  70 + }
  71 +
  72 + public void setToken(String token) {
  73 + this.token = token;
  74 + }
  75 +
  76 + public String getExtInfo() {
  77 + return extInfo;
  78 + }
  79 +
  80 + public void setExtInfo(String extInfo) {
  81 + this.extInfo = extInfo;
  82 + }
  83 +
  84 + public String getMobile() {
  85 + return mobile;
  86 + }
  87 +
  88 + public void setMobile(String mobile) {
  89 + this.mobile = mobile;
  90 + }
  91 +
  92 + public String getEmail() {
  93 + return email;
  94 + }
  95 +
  96 + public void setEmail(String email) {
  97 + this.email = email;
  98 + }
  99 +
  100 + public String getQqUid() {
  101 + return qqUid;
  102 + }
  103 +
  104 + public void setQqUid(String qqUid) {
  105 + this.qqUid = qqUid;
  106 + }
  107 +
  108 + public String getWxUid() {
  109 + return wxUid;
  110 + }
  111 +
  112 + public void setWxUid(String wxUid) {
  113 + this.wxUid = wxUid;
  114 + }
  115 +
  116 + public String getSinaUid() {
  117 + return sinaUid;
  118 + }
  119 +
  120 + public void setSinaUid(String sinaUid) {
  121 + this.sinaUid = sinaUid;
  122 + }
  123 +
  124 + public String getRenrenUid() {
  125 + return renrenUid;
  126 + }
  127 +
  128 + public void setRenrenUid(String renrenUid) {
  129 + this.renrenUid = renrenUid;
  130 + }
  131 +
  132 + public String gethUid() {
  133 + return hUid;
  134 + }
  135 +
  136 + public void sethUid(String hUid) {
  137 + this.hUid = hUid;
  138 + }
  139 +
  140 + public String getPlatformId() {
  141 + return platformId;
  142 + }
  143 +
  144 + public void setPlatformId(String platformId) {
  145 + this.platformId = platformId;
  146 + }
  147 +
  148 + public boolean isNewUser() {
  149 + return isNewUser;
  150 + }
  151 +
  152 + public void setNewUser(boolean newUser) {
  153 + isNewUser = newUser;
  154 + }
  155 +
  156 + public String getBigFaceUrl() {
  157 + return bigFaceUrl;
  158 + }
  159 +
  160 + public void setBigFaceUrl(String bigFaceUrl) {
  161 + this.bigFaceUrl = bigFaceUrl;
  162 + }
  163 +
  164 + public String getCountryCode() {
  165 + return countryCode;
  166 + }
  167 +
  168 + public void setCountryCode(String countryCode) {
  169 + this.countryCode = countryCode;
  170 + }
  171 +
  172 + public String getCallbackAcitvityStatushttpPostUrl() {
  173 + return callbackAcitvityStatushttpPostUrl;
  174 + }
  175 +
  176 + public void setCallbackAcitvityStatushttpPostUrl(String callbackAcitvityStatushttpPostUrl) {
  177 + this.callbackAcitvityStatushttpPostUrl = callbackAcitvityStatushttpPostUrl;
  178 + }
  179 +
  180 + @Override
  181 + public String toString() {
  182 + return "UserData{" +
  183 + "uid='" + uid + '\'' +
  184 + ", nickName='" + nickName + '\'' +
  185 + ", gender='" + gender + '\'' +
  186 + ", location='" + location + '\'' +
  187 + ", faceUrl='" + faceUrl + '\'' +
  188 + ", mobile='" + mobile + '\'' +
  189 + ", email='" + email + '\'' +
  190 + ", extInfo='" + extInfo + '\'' +
  191 + ", qqUid='" + qqUid + '\'' +
  192 + ", wxUid='" + wxUid + '\'' +
  193 + ", sinaUid='" + sinaUid + '\'' +
  194 + ", renrenUid='" + renrenUid + '\'' +
  195 + ", hUid='" + hUid + '\'' +
  196 + ", platformId='" + platformId + '\'' +
  197 + ", token='" + token + '\'' +
  198 + ", callbackAcitvityStatushttpPostUrl='" + callbackAcitvityStatushttpPostUrl + '\'' +
  199 + ", isNewUser=" + isNewUser +
  200 + ", bigFaceUrl='" + bigFaceUrl + '\'' +
  201 + ", countryCode='" + countryCode + '\'' +
  202 + '}';
  203 + }
  204 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/router/user/UserARouter.java 0 → 100644
  1 +package com.cnlive.strike.user.router.user;
  2 +
  3 +import android.content.Context;
  4 +
  5 +import com.alibaba.android.arouter.launcher.ARouter;
  6 +import com.cnlive.strike.user.R;
  7 +
  8 +/**
  9 + * 作者: 吴奎庆
  10 + * <p>
  11 + * 时间: 2019/4/25
  12 + * <p>
  13 + * 简介:
  14 + */
  15 +public class UserARouter {
  16 + /**
  17 + * 打开举报的h5页面
  18 + *
  19 + * @param context
  20 + * @param url
  21 + */
  22 + public static void startReportUser(Context context, String url) {
  23 + ARouter.getInstance().build("/web/WebViewActivity")
  24 + .withString("rUrl", url)
  25 + .navigation(context);
  26 + }
  27 +
  28 + /**
  29 + * 打开发现页面
  30 + * @param context
  31 + */
  32 + public static void startFind(Context context) {
  33 + ARouter.getInstance().build("/main/FindActivity")
  34 + .withTransition(R.anim.activity_in, R.anim.activity_out)
  35 + .navigation(context);
  36 + }
  37 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/router/user/UserAction.java 0 → 100644
  1 +package com.cnlive.strike.user.router.user;
  2 +
  3 +import android.accounts.Account;
  4 +import android.app.Activity;
  5 +import android.content.Context;
  6 +import android.net.Uri;
  7 +import android.text.TextUtils;
  8 +import android.util.Log;
  9 +
  10 +import com.cnlive.core.network.BaseResult;
  11 +import com.cnlive.core.network.HttpConn;
  12 +import com.cnlive.core.network.NetCallBack;
  13 +import com.cnlive.core.network.ServerException;
  14 +import com.cnlive.strike.user.UserUtilAction;
  15 +import com.cnlive.strike.user.auth.UserService;
  16 +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 +
  20 +import io.reactivex.Observable;
  21 +import io.reactivex.ObservableSource;
  22 +import io.reactivex.functions.Function;
  23 +
  24 +
  25 +public class UserAction {
  26 +
  27 + private static final int MAX_USER_COUNT = 1;
  28 +
  29 + private static String baseUrl = "/mobile/images/mobilehead/default/";
  30 + private static String iconUrl = "http://wjj.ys1.cnliveimg.com/admin/test/head.png";
  31 +
  32 + private static boolean checkDefaultUrl(String url) {
  33 + if (url.contains(baseUrl)) return true;
  34 + return false;
  35 + }
  36 +
  37 + public static Uri getUri(Context context) {
  38 + return context instanceof Activity && ((Activity) context).getIntent() != null ?
  39 + ((Activity) context).getIntent().getData() : null;
  40 + }
  41 +
  42 +
  43 +// @Deprecated
  44 +// public static void userLogin(Context context, String name, String password, Event<CNLiveUserInfo> event) {
  45 +// Logic.create()
  46 +// .action(UserUtilAction.loginAction(context, name, password))
  47 +// .action(loginAppAction(context, name, password))
  48 +//// .action(loginIMAction())
  49 +// .start(event);
  50 +// }
  51 +
  52 + public static void mobileLogin(Context context, String phone, String code, String countryCode, CallBack callBack) {
  53 +// Logic.create()
  54 +// .action(UserUtilAction.quickLoginAction(context, phone, code, countryCode))
  55 +// .action(loginAppAction(context, phone, code))
  56 +//// .action(loginIMAction())
  57 +// .start(event);
  58 + HttpConn.action(
  59 + UserUtilAction.quickLoginAction(context, phone, code, countryCode)
  60 + , new NetCallBack<BaseResult<UserData>>() {
  61 + @Override
  62 + public void onRequestState(int state) {
  63 + if (null != callBack) {
  64 + callBack.callback(state, "", null);
  65 + }
  66 + }
  67 +
  68 + @Override
  69 + public void onSuccess(BaseResult<UserData> data) {
  70 + loginAppAction(data, context, phone, code, false, callBack);
  71 + }
  72 +
  73 + @Override
  74 + public void onFailure(String errCode, String errMsg) {
  75 + if (null != callBack) {
  76 + callBack.callback(Integer.parseInt(errCode), errMsg, null);
  77 + }
  78 + }
  79 + });
  80 +
  81 + }
  82 +
  83 + private static Observable<CNLiveUserInfo> loginAppAction(BaseResult<UserData> data, Context context, String userName, String userPassword, boolean otherLogin, CallBack callBack) {
  84 + CNLiveUserInfo userinfo = null;
  85 + if (null == data || null == data.getData()) {
  86 + if (null != callBack) {
  87 + callBack.callback(-5, "获取账户信息失败 请重试.", null);
  88 + }
  89 + } else if (TextUtils.isEmpty(data.getData().getMobile())) {
  90 + callBack.callback(-5, "绑定手机号已失效..", null);
  91 + } else {
  92 + //更新登录用户信息
  93 + UserService userService = UserService.getInstance(context);
  94 + userService.loginAppAccount(
  95 + otherLogin ? data.getData().getMobile() : userName,
  96 + otherLogin ? data.getData().getMobile() : userPassword,
  97 + data.getData());
  98 + //保留近期登录用户
  99 + Account[] accounts = userService.getUserList();
  100 + userinfo = userService.getAppAccount();
  101 + if (accounts.length <= MAX_USER_COUNT) {
  102 + callBack.callback(0, "", userinfo);
  103 + } else {
  104 + CNLiveUserInfo finalUserinfo = userinfo;
  105 + userService.removeUser(accounts[0], future -> callBack.callback(0, "", finalUserinfo));
  106 + }
  107 + }
  108 + return Observable.just(userinfo);
  109 + }
  110 +
  111 + public interface CallBack {
  112 + void callback(int state, String msg, Object object);
  113 + }
  114 +
  115 +// private static Logic.Action<BaseInfo<UserData>, CNLiveUserInfo> loginAppAction(Context context, String userName, String userPassword) {
  116 +// return loginAppAction(context, userName, userPassword, false);
  117 +// }
  118 +//
  119 +// private static Logic.Action<BaseInfo<UserData>, CNLiveUserInfo> loginAppAction(Context context, String userName, String userPassword, boolean otherLogin) {
  120 +// return (userData, callback) -> {
  121 +// if (userData == null || userData.getData() == null) {
  122 +// callback.callback(-5, "获取账户信息失败 请重试.", null);
  123 +// } else if (TextUtils.isEmpty(userData.getData().getMobile())) {
  124 +// callback.callback(-5, "绑定手机号已失效..", null);
  125 +// } else {
  126 +// //更新登录用户信息
  127 +// UserService userService = UserService.getInstance(context);
  128 +// userService.loginAppAccount(
  129 +// otherLogin ? userData.getData().getMobile() : userName,
  130 +// otherLogin ? userData.getData().getMobile() : userPassword,
  131 +// userData.getData());
  132 +//// DaoHelper.updateInstance(context);
  133 +// //保留近期登录用户
  134 +// Account[] accounts = userService.getUserList();
  135 +// CNLiveUserInfo userinfo = userService.getAppAccount();
  136 +// if (accounts.length <= MAX_USER_COUNT) {
  137 +// callback.callback(0, "", userinfo);
  138 +// } else {
  139 +// userService.removeUser(accounts[0], future -> callback.callback(0, "", userinfo));
  140 +// }
  141 +// }
  142 +// return null;
  143 +// };
  144 +// }
  145 +
  146 +
  147 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/router/user/UserOfflineUtil.java 0 → 100644
  1 +package com.cnlive.strike.user.router.user;
  2 +
  3 +import android.content.Context;
  4 +
  5 +import com.cnlive.core.libs.base.util.AlertUtil;
  6 +import com.cnlive.strike.user.auth.UserService;
  7 +
  8 +import org.greenrobot.eventbus.EventBus;
  9 +
  10 +/**
  11 + * Created by xiansong on 2018/1/4.
  12 + */
  13 +
  14 +public class UserOfflineUtil {
  15 +
  16 + private static final String TAG = UserOfflineUtil.class.getSimpleName();
  17 +
  18 + public static void userOffline(Context context) {
  19 +// if (ActivityLifecycle.isActive()) {
  20 +// ForceOfflineDialogActivity.start(context, "用户在其他端登录.", "退出", R.color.color_dialog_btn, "重新登录", R.color.color_ffa300);
  21 +// } else {
  22 +// FinishAllActivity.finish(context);
  23 +// }
  24 + }
  25 +
  26 + public static void userOffline2(Context context) {
  27 +// if (ActivityLifecycle.isActive()) {
  28 +// OfflineDialogActivity.start(context, "网络连接不可用.", "退出", R.color.color_dialog_btn, "重试", R.color.color_ffa300);
  29 +// } else {
  30 +// FinishAllActivity.finish(context);
  31 +// }
  32 + }
  33 +
  34 + public static void userInvalid(Context context) {
  35 + AlertUtil.showDeftToast(context, "用户 已失效.");
  36 + appLogout(context);
  37 + }
  38 +
  39 + //todo BottomSheet
  40 + public static void logout(Context context) {
  41 +// new BottomSheet.BottomListSheetBuilder(context)
  42 +// .addItem("退出登录", "", true)
  43 +// .addItem("取消")
  44 +// .setOnSheetItemClickListener((dialog, itemView, position, tag) -> {
  45 +// switch (position) {
  46 +// case 0:
  47 +// appLogout(context);
  48 +// break;
  49 +// }
  50 +// dialog.dismiss(false);
  51 +// }).build().show();
  52 + }
  53 +
  54 + public static void appLogout(Context context) {
  55 + String uid = UserService.getUid(context);
  56 + UserService.getInstance(context).logoutAppAccount();
  57 + //退出登录
  58 +
  59 +// LoginManager.logout(uid, null, context);
  60 +// if (ActivityLifecycle.isActive()) {
  61 +// LoginActivity.start(context);
  62 +// } else {
  63 +// Log.e("FinishAllActivity", "FinishAllActivity-----logout");
  64 +// FinishAllActivity.finish(context);
  65 +// }
  66 +// AudioUtil.closeAudio(context);
  67 +// //友盟-用户退出
  68 +// MobclickAgent.onProfileSignOff();
  69 + }
  70 +
  71 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/sms/OnSmsCatchListener.java 0 → 100644
  1 +/*******************************************************************************
  2 + * Copyright 2016 Anton Bevza stfalcon.com
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + *******************************************************************************/
  16 +
  17 +package com.cnlive.strike.user.sms;
  18 +
  19 +public interface OnSmsCatchListener<T> {
  20 + void onSmsCatch(String message);
  21 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/sms/SmsReceiver.java 0 → 100644
  1 +/*******************************************************************************
  2 + * Copyright 2016 Anton Bevza stfalcon.com
  3 + * <p>
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + * <p>
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + * <p>
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + *******************************************************************************/
  16 +
  17 +package com.cnlive.strike.user.sms;
  18 +
  19 +import android.content.BroadcastReceiver;
  20 +import android.content.Context;
  21 +import android.content.Intent;
  22 +import android.os.Build;
  23 +import android.os.Bundle;
  24 +import android.telephony.SmsMessage;
  25 +import android.util.Log;
  26 +
  27 +class SmsReceiver extends BroadcastReceiver {
  28 + private OnSmsCatchListener<String> callback;
  29 + private String phoneNumberFilter;
  30 + private String filter;
  31 +
  32 + /**
  33 + * Set result callback
  34 + * @param callback OnSmsCatchListener
  35 + */
  36 + public void setCallback(OnSmsCatchListener<String> callback) {
  37 + this.callback = callback;
  38 + }
  39 +
  40 + @Override
  41 + public void onReceive(Context context, Intent intent) {
  42 + final Bundle bundle = intent.getExtras();
  43 + try {
  44 + if (bundle != null) {
  45 + final Object[] pdusObj = (Object[]) bundle.get("pdus");
  46 + for (int i = 0; i < pdusObj.length; i++) {
  47 + SmsMessage currentMessage = getIncomingMessage(pdusObj[i], bundle);
  48 + String message = null;
  49 + if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.DONUT) {
  50 + message = currentMessage.getDisplayMessageBody();
  51 + }
  52 + if (callback != null) {
  53 + callback.onSmsCatch(message);
  54 + }
  55 + }
  56 + }
  57 + } catch (Exception e) {
  58 + Log.e("SmsReceiver", "Exception smsReceiver" + e);
  59 + }
  60 + }
  61 +
  62 + private SmsMessage getIncomingMessage(Object aObject, Bundle bundle) {
  63 + SmsMessage currentSMS = null;
  64 +
  65 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
  66 + String format = bundle.getString("format");
  67 + currentSMS = SmsMessage.createFromPdu((byte[]) aObject, format);
  68 + } else {
  69 + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.DONUT) {
  70 + currentSMS = SmsMessage.createFromPdu((byte[]) aObject);
  71 + }
  72 + }
  73 + Log.e("手机验证码:",currentSMS+"--->");
  74 + return currentSMS;
  75 + }
  76 +
  77 + /**
  78 + * Set phone number filter
  79 + *
  80 + * @param phoneNumberFilter phone number
  81 + */
  82 + public void setPhoneNumberFilter(String phoneNumberFilter) {
  83 + this.phoneNumberFilter = phoneNumberFilter;
  84 + }
  85 +
  86 + /**
  87 + * set message filter with regexp
  88 + *
  89 + * @param regularExpression regexp
  90 + */
  91 + public void setFilter(String regularExpression) {
  92 + this.filter = regularExpression;
  93 + }
  94 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/sms/SmsVerifyCatcher.java 0 → 100644
  1 +/*******************************************************************************
  2 + * Copyright 2016 Anton Bevza stfalcon.com
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + *******************************************************************************/
  16 +
  17 +package com.cnlive.strike.user.sms;
  18 +
  19 +import android.Manifest;
  20 +import android.app.Activity;
  21 +import android.app.Dialog;
  22 +import android.content.IntentFilter;
  23 +import android.content.pm.PackageManager;
  24 +import android.os.Build;
  25 +
  26 +import androidx.core.app.ActivityCompat;
  27 +import androidx.core.content.ContextCompat;
  28 +import androidx.fragment.app.Fragment;
  29 +
  30 +/**
  31 + * Created by Anton Bevza on 8/15/16.
  32 + */
  33 +public class SmsVerifyCatcher {
  34 +
  35 + public static int PERMISSION_REQUEST_CODE = 12;
  36 +
  37 + private Activity activity;
  38 + private Fragment fragment;
  39 + private OnSmsCatchListener<String> onSmsCatchListener;
  40 + private SmsReceiver smsReceiver;
  41 + private String phoneNumber;
  42 + private String filter;
  43 + private Dialog dialog;
  44 +
  45 + public SmsVerifyCatcher(Activity activity, OnSmsCatchListener<String> onSmsCatchListener) {
  46 + this.activity = activity;
  47 + this.onSmsCatchListener = onSmsCatchListener;
  48 + smsReceiver = new SmsReceiver();
  49 + smsReceiver.setCallback(this.onSmsCatchListener);
  50 + }
  51 +
  52 + public SmsVerifyCatcher(Activity activity, Fragment fragment, OnSmsCatchListener<String> onSmsCatchListener) {
  53 + this(activity, onSmsCatchListener);
  54 + this.fragment = fragment;
  55 + }
  56 +
  57 + //For fragments
  58 + public static boolean isStoragePermissionGranted(Activity activity, Fragment fragment) {
  59 + if (Build.VERSION.SDK_INT >= 23) {
  60 + if (ContextCompat.checkSelfPermission(activity, Manifest.permission.RECEIVE_SMS)
  61 + == PackageManager.PERMISSION_GRANTED &&
  62 + ContextCompat.checkSelfPermission(activity, Manifest.permission.READ_SMS)
  63 + == PackageManager.PERMISSION_GRANTED) {
  64 + return true;
  65 + } else {
  66 + if (fragment == null) {
  67 + ActivityCompat.requestPermissions(activity,
  68 + new String[]{Manifest.permission.RECEIVE_SMS,
  69 + Manifest.permission.READ_SMS}, PERMISSION_REQUEST_CODE);
  70 + } else {
  71 + fragment.requestPermissions(
  72 + new String[]{Manifest.permission.RECEIVE_SMS,
  73 + Manifest.permission.READ_SMS}, PERMISSION_REQUEST_CODE);
  74 + }
  75 + return false;
  76 + }
  77 + } else {
  78 + return true;
  79 + }
  80 + }
  81 +//
  82 +// private boolean checkPermissions(Activity activity, String[] permissions, int requestCode) {
  83 +// //Android6.0以下默认有权限
  84 +// if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M)
  85 +// return true;
  86 +//
  87 +// List<String> needList = new ArrayList<>();
  88 +// boolean needShowRationale = false;
  89 +// int length = permissions.length;
  90 +//
  91 +// for (int i = 0; i < length; i++) {
  92 +// String permisson = permissions[i];
  93 +// if (TextUtils.isEmpty(permisson)) continue;
  94 +// if (ActivityCompat.checkSelfPermission(activity, permisson)
  95 +// != PackageManager.PERMISSION_GRANTED) {
  96 +// needList.add(permisson);
  97 +// if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permisson))
  98 +// needShowRationale = true;
  99 +// }
  100 +// }
  101 +//
  102 +// if (needList.size() != 0) {
  103 +// if (needShowRationale) {
  104 +// showPermission(needList, requestCode);
  105 +// return false;
  106 +// }
  107 +//
  108 +// ActivityCompat.requestPermissions(activity, needList.toArray(new String[needList.size()]), requestCode);
  109 +// return false;
  110 +// } else {
  111 +// return true;
  112 +// }
  113 +// }
  114 +
  115 +// public void showPermission(List<String> needList, int requestCode) {
  116 +// if (dialog != null) dialog.dismiss();
  117 +// //TODO 用户取消权限申请
  118 +// dialog = AlertDialogUtils.showTwoButtonDialog(
  119 +// activity,
  120 +// "取消",
  121 +// "我知道了",
  122 +// "应用程序需要获取短信的权限,否则无法自动填充短信验证码.",
  123 +// com.cnlive.media.picker.R.color.color_dialog_btn, com.cnlive.media.picker.R.color.color_ffa300, new AlertDialogUtils.DialogTwoListener() {
  124 +// @Override
  125 +// public void onClickLeft(Dialog dialog) {
  126 +// dialog.dismiss();
  127 +// //TODO 用户取消权限申请
  128 +//// activity.getPresenter().startLogin(activity);
  129 +// }
  130 +//
  131 +// @Override
  132 +// public void onClickRight(Dialog dialog) {
  133 +// dialog.dismiss();
  134 +// ActivityCompat.requestPermissions(activity, needList.toArray(new String[needList.size()]), requestCode);
  135 +// }
  136 +// });
  137 +// dialog.setCancelable(false);
  138 +// }
  139 +
  140 +
  141 +// public void onStart(String[] permissions, int requestCode) {
  142 +// if (checkPermissions(activity, permissions,requestCode)) {
  143 +// registerReceiver();
  144 +// }
  145 +// }
  146 +
  147 + public void onStartCurrent() {
  148 + if (isStoragePermissionGranted(activity,fragment)) {
  149 + registerReceiver();
  150 + }
  151 + }
  152 +
  153 + private void registerReceiver() {
  154 + smsReceiver = new SmsReceiver();
  155 + smsReceiver.setCallback(onSmsCatchListener);
  156 + smsReceiver.setPhoneNumberFilter(phoneNumber);
  157 + smsReceiver.setFilter(filter);
  158 + IntentFilter intentFilter = new IntentFilter();
  159 + intentFilter.addAction("android.provider.Telephony.SMS_RECEIVED");
  160 + activity.registerReceiver(smsReceiver, intentFilter);
  161 + }
  162 +
  163 + public void setPhoneNumberFilter(String phoneNumber) {
  164 + this.phoneNumber = phoneNumber;
  165 + }
  166 +
  167 + public void onStop() {
  168 + try {
  169 + if (dialog!=null)dialog.dismiss();
  170 + activity.unregisterReceiver(smsReceiver);
  171 + } catch (IllegalArgumentException ignore) {
  172 + //receiver not registered
  173 + }
  174 + }
  175 +
  176 + public void setFilter(String regexp) {
  177 + this.filter = regexp;
  178 + }
  179 +
  180 + public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
  181 + if (requestCode==PERMISSION_REQUEST_CODE){
  182 + if (grantResults.length > 1 &&
  183 + grantResults[0] == PackageManager.PERMISSION_GRANTED &&
  184 + grantResults[1] == PackageManager.PERMISSION_GRANTED) {
  185 + registerReceiver();
  186 + }
  187 + }
  188 + }
  189 +
  190 +}
... ...
cloud/user/src/main/java/com/cnlive/strike/user/ui/activity/LoginActivity.java 0 → 100644
  1 +package com.cnlive.strike.user.ui.activity;
  2 +
  3 +import android.app.Activity;
  4 +import android.content.Context;
  5 +import android.content.Intent;
  6 +import android.net.Uri;
  7 +
  8 +import androidx.annotation.NonNull;
  9 +import androidx.fragment.app.Fragment;
  10 +import androidx.fragment.app.FragmentManager;
  11 +
  12 +import com.alibaba.android.arouter.facade.annotation.Route;
  13 +import com.cnlive.core.libs.base.frame.activity.BaseActivity;
  14 +import com.cnlive.core.libs.base.util.FragmentUtil;
  15 +import com.cnlive.strike.user.R;
  16 +import com.cnlive.strike.user.ui.fragment.QuickLoginFragment;
  17 +
  18 +/**
  19 + * @author Lynn
  20 + * @date 2017/12/22
  21 + */
  22 +@Route(path = "/cnmain/LoginActivity")
  23 +public class LoginActivity extends BaseActivity {
  24 + public static String FROM_TOKEN_ERROR = "from_token_error";
  25 + public static String TAG_MSG = "tagMsg";
  26 + public static String TAG_SHARE = "tagValue";
  27 + public static String TAG_CLICK_AD= "clickAd";
  28 + private Fragment quickLoginFragment;
  29 + private boolean fromTokenError;
  30 + private String tagMsg;
  31 + private String shareType;
  32 + private boolean clickAd;
  33 +
  34 + // @Override
  35 +// public Resources getResources() {
  36 +// Resources res = super.getResources();
  37 +// Configuration config = new Configuration();
  38 +// config.setToDefaults();
  39 +// res.updateConfiguration(config, res.getDisplayMetrics());
  40 +// return res;
  41 +// }
  42 + public static void start(Context context) {
  43 + Intent intent = new Intent(context, LoginActivity.class);
  44 + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
  45 + context.startActivity(intent);
  46 + if (context instanceof Activity) ((Activity) context).finish();
  47 + }
  48 +
  49 + public static void start(Context context, Uri uri) {
  50 + Intent intent = new Intent(context, LoginActivity.class);
  51 + intent.setData(uri);
  52 + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
  53 + context.startActivity(intent);
  54 + if (context instanceof Activity) ((Activity) context).finish();
  55 + }
  56 +
  57 + public static void start(Context context, Uri uri, String type) {
  58 + Intent intent = new Intent(context, LoginActivity.class);
  59 + intent.setData(uri);
  60 + intent.putExtra(TAG_SHARE, type);
  61 + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
  62 + context.startActivity(intent);
  63 + if (context instanceof Activity) ((Activity) context).finish();
  64 + }
  65 +
  66 + public static void start(Context context, boolean fromTokenError) {
  67 + Intent intent = new Intent(context, LoginActivity.class);
  68 + intent.putExtra(FROM_TOKEN_ERROR, fromTokenError);
  69 + context.startActivity(intent);
  70 + }
  71 +
  72 + public static void start(Context context, String tag) {
  73 + Intent intent = new Intent(context, LoginActivity.class);
  74 + intent.putExtra(TAG_MSG, tag);
  75 + context.startActivity(intent);
  76 + }
  77 +
  78 + @Override
  79 + protected int getLayoutId() {
  80 + return R.layout.activity_login;
  81 + }
  82 +
  83 + @Override
  84 + protected void initView() {
  85 + fromTokenError = getIntent().getBooleanExtra(FROM_TOKEN_ERROR, false);
  86 + tagMsg = getIntent().getStringExtra(TAG_MSG) == null ? "" : getIntent().getStringExtra(TAG_MSG);
  87 + shareType = getIntent().getStringExtra(TAG_SHARE);
  88 + clickAd = getIntent().getBooleanExtra(TAG_CLICK_AD,false);
  89 + addFragment();
  90 + }
  91 +
  92 + @Override
  93 + protected void initData() {
  94 +
  95 + }
  96 +
  97 + @Override
  98 + public void onActivityResult(int requestCode, int resultCode, Intent data) {
  99 + super.onActivityResult(requestCode, resultCode, data);
  100 + if (quickLoginFragment != null)
  101 + quickLoginFragment.onActivityResult(requestCode, resultCode, data);
  102 + }
  103 +
  104 + @Override
  105 + protected void onNewIntent(Intent intent) {
  106 + super.onNewIntent(intent);
  107 + tagMsg = intent.getStringExtra(TAG_MSG) == null ? "" : intent.getStringExtra(TAG_MSG);
  108 + clickAd = getIntent().getBooleanExtra(TAG_CLICK_AD,false);
  109 + addFragment();
  110 + }
  111 +
  112 + private void addFragment() {
  113 + if ("shareIM".equals(shareType) || "shareMom".equals(shareType)) {
  114 + quickLoginFragment = QuickLoginFragment.newInstance(fromTokenError, tagMsg, shareType,clickAd);
  115 + } else {
  116 + quickLoginFragment = QuickLoginFragment.newInstance(fromTokenError, tagMsg,clickAd);
  117 + }
  118 +
  119 + FragmentManager fragmentManager = getSupportFragmentManager();
  120 + FragmentUtil fragmentUtil = new FragmentUtil(R.id.loginContent);
  121 + fragmentUtil.changeFragment(quickLoginFragment, fragmentManager);
  122 + }
  123 +
  124 + @Override
  125 + public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
  126 + super.onRequestPermissionsResult(requestCode, permissions, grantResults);
  127 + if (quickLoginFragment != null)
  128 + quickLoginFragment.onRequestPermissionsResult(requestCode, permissions, grantResults);
  129 + }
  130 +}
... ...