Commit aaf6167820ccea71866d4ee14497db871209c572
代码合并冲突解决
Showing
63 changed files
with
4492 additions
and
48 deletions
Too many changes to show.
To preserve performance only 63 of 490 files are displayed.
app/strike/build.gradle
| ... | ... | @@ -11,7 +11,7 @@ android { |
| 11 | 11 | |
| 12 | 12 | defaultConfig { |
| 13 | 13 | applicationId "com.cnlive.strike" |
| 14 | - minSdkVersion 16 | |
| 14 | + minSdkVersion 21 | |
| 15 | 15 | targetSdkVersion 29 |
| 16 | 16 | versionCode 1 |
| 17 | 17 | versionName "1.0" |
| ... | ... | @@ -157,6 +157,8 @@ 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') | |
| 161 | + | |
| 160 | 162 | implementation project(path: ':core:imageload') |
| 161 | 163 | // implementation project(path: ':core:util') |
| 162 | 164 | // implementation project(path: ':core:encipher') | ... | ... |
app/strike/src/main/AndroidManifest.xml
| ... | ... | @@ -4,12 +4,15 @@ |
| 4 | 4 | |
| 5 | 5 | <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> |
| 6 | 6 | <uses-permission android:name="android.permission.INTERNET" /> |
| 7 | + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/> | |
| 8 | + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/> | |
| 7 | 9 | |
| 8 | 10 | <application |
| 9 | 11 | android:name=".MyApp" |
| 10 | 12 | android:allowBackup="true" |
| 11 | 13 | android:icon="@mipmap/ic_launcher" |
| 12 | 14 | android:label="@string/app_name" |
| 15 | + android:networkSecurityConfig="@xml/network_security_config" | |
| 13 | 16 | android:roundIcon="@mipmap/ic_launcher_round" |
| 14 | 17 | android:supportsRtl="true" |
| 15 | 18 | android:theme="@style/AppTheme"> | ... | ... |
app/strike/src/main/java/com/cnlive/strike/MyActivity.java
| 1 | 1 | package com.cnlive.strike; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -import com.cnlive.libs.base.frame.activity.BaseActivity; | |
| 4 | +import com.cnlive.core.libs.base.frame.activity.BaseActivity; | |
| 5 | 5 | |
| 6 | 6 | |
| 7 | 7 | public class MyActivity extends BaseActivity { |
| 8 | 8 | |
| 9 | 9 | @Override |
| 10 | - protected int initLayout() { | |
| 10 | + protected int getViewLayoutId() { | |
| 11 | 11 | return R.layout.activity_my; |
| 12 | 12 | } |
| 13 | 13 | |
| 14 | 14 | @Override |
| 15 | 15 | protected void initView() { |
| 16 | + setOpenSwipBack(true); | |
| 16 | 17 | getSupportFragmentManager().beginTransaction().replace(R.id.fragment_container, new MyFragment()).commitAllowingStateLoss(); |
| 17 | 18 | } |
| 18 | 19 | ... | ... |
app/strike/src/main/java/com/cnlive/strike/MyActivityTest1.java
| 1 | 1 | package com.cnlive.strike; |
| 2 | 2 | |
| 3 | -import com.cnlive.libs.base.frame.activity.BaseActivity; | |
| 3 | +import com.cnlive.core.libs.base.frame.activity.BaseActivity; | |
| 4 | 4 | |
| 5 | 5 | |
| 6 | 6 | public class MyActivityTest1 extends BaseActivity { |
| 7 | 7 | |
| 8 | 8 | @Override |
| 9 | - protected int initLayout() { | |
| 9 | + protected int getViewLayoutId() { | |
| 10 | 10 | return R.layout.activity_my1; |
| 11 | 11 | } |
| 12 | 12 | ... | ... |
app/strike/src/main/java/com/cnlive/strike/MyApp.java
| ... | ... | @@ -2,9 +2,33 @@ package com.cnlive.strike; |
| 2 | 2 | |
| 3 | 3 | import android.app.Application; |
| 4 | 4 | |
| 5 | +import com.alibaba.android.arouter.launcher.ARouter; | |
| 6 | +import com.cnlive.core.libs.base.application.AppConfig; | |
| 7 | + | |
| 5 | 8 | public class MyApp extends Application { |
| 6 | 9 | @Override |
| 7 | 10 | public void onCreate() { |
| 8 | 11 | super.onCreate(); |
| 12 | + AppConfig.init(this, BuildConfig.APP_ID, BuildConfig.APP_KEY, | |
| 13 | + BuildConfig.APP_SCERET, BuildConfig.SPECIAL_GROUP_MEMBER_LIMIT, | |
| 14 | + BuildConfig.VERSION_AS_DEBUG, "", "", | |
| 15 | + "10514333", "", | |
| 16 | + "", "", "", | |
| 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中初始化 | |
| 9 | 33 | } |
| 10 | 34 | } | ... | ... |
app/strike/src/main/java/com/cnlive/strike/MyFragment.java
| 1 | 1 | package com.cnlive.strike; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -import android.content.Intent; | |
| 4 | +import android.Manifest; | |
| 5 | 5 | import android.os.Bundle; |
| 6 | +import android.util.Log; | |
| 6 | 7 | import android.view.LayoutInflater; |
| 7 | 8 | import android.view.View; |
| 8 | 9 | import android.view.ViewGroup; |
| 10 | +import android.widget.TextView; | |
| 9 | 11 | |
| 10 | -import com.cnlive.libs.base.frame.fragment.BaseFragment; | |
| 11 | -import com.cnlive.libs.base.util.StatusBarConfig; | |
| 12 | +import com.cnlive.core.libs.base.frame.fragment.BaseFragment; | |
| 13 | +import com.cnlive.core.libs.base.interfaces.OnPermissionResponseListener; | |
| 14 | +import com.cnlive.core.network.BaseResult; | |
| 15 | +import com.cnlive.core.network.HttpConn; | |
| 16 | +import com.cnlive.core.network.NetCallBack; | |
| 17 | +import com.cnlive.core.libs.base.util.StatusBarConfig; | |
| 18 | +import com.cnlive.strike.network.BaseRequest; | |
| 19 | +import com.cnlive.strike.network.api.ApiService; | |
| 20 | +import com.cnlive.strike.network.bean.LetHimNoSeeBean; | |
| 21 | +import com.cnlive.strike.network.bean.TestBean; | |
| 12 | 22 | |
| 13 | 23 | import androidx.annotation.NonNull; |
| 14 | 24 | import androidx.annotation.Nullable; |
| 15 | 25 | |
| 26 | +import java.util.HashMap; | |
| 27 | +import java.util.Map; | |
| 28 | + | |
| 29 | +import io.reactivex.Observable; | |
| 30 | +import io.reactivex.functions.Function; | |
| 31 | + | |
| 16 | 32 | |
| 17 | 33 | public class MyFragment extends BaseFragment<MyFragmentView, MyPresenter> { |
| 18 | 34 | private View view; |
| 35 | + public TextView textView; | |
| 19 | 36 | |
| 20 | 37 | @Nullable |
| 21 | 38 | @Override |
| 22 | 39 | public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| 23 | 40 | view = inflater.inflate(R.layout.activity_main1, container, false); |
| 41 | + textView = view.findViewById(R.id.tv1); | |
| 24 | 42 | return view; |
| 25 | 43 | } |
| 26 | 44 | |
| 27 | 45 | @Override |
| 28 | 46 | protected void initView() { |
| 47 | + super.initView(); | |
| 29 | 48 | setStatusBarColor(R.color.green, 0); |
| 30 | 49 | setStatusBarTextColor(StatusBarConfig.BLACK); |
| 31 | - view.findViewById(R.id.btn_test).setOnClickListener(new View.OnClickListener() { | |
| 50 | + view.findViewById(R.id.btn_test2).setOnClickListener(new View.OnClickListener() { | |
| 32 | 51 | @Override |
| 33 | 52 | public void onClick(View v) { |
| 34 | - getActivity().startActivity(new Intent(getActivity(), MyActivityTest1.class)); | |
| 53 | + requestPermission(010001, "测试", new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, new OnPermissionResponseListener() { | |
| 54 | + @Override | |
| 55 | + public void onSuccess(String[] permissions) { | |
| 56 | + Log.e(TAG, "onSuccess: "); | |
| 57 | + } | |
| 58 | + | |
| 59 | + @Override | |
| 60 | + public void onFail() { | |
| 61 | + Log.e(TAG, "onFail: "); | |
| 62 | + } | |
| 63 | + }); | |
| 35 | 64 | } |
| 36 | 65 | }); |
| 37 | - } | |
| 66 | + view.findViewById(R.id.btn_test1).setOnClickListener(new View.OnClickListener() { | |
| 67 | + @Override | |
| 68 | + public void onClick(View v) { | |
| 69 | + requestPermission(new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, new OnPermissionResponseListener() { | |
| 70 | + @Override | |
| 71 | + public void onSuccess(String[] permissions) { | |
| 72 | + Log.e(TAG, "onSuccess: "); | |
| 73 | + } | |
| 38 | 74 | |
| 39 | - @Override | |
| 40 | - protected void initData() { | |
| 75 | + @Override | |
| 76 | + public void onFail() { | |
| 77 | + Log.e(TAG, "onFail: "); | |
| 78 | + } | |
| 79 | + }); | |
| 80 | + } | |
| 81 | + }); | |
| 82 | + view.findViewById(R.id.btn_test).setOnClickListener(new View.OnClickListener() { | |
| 83 | + @Override | |
| 84 | + public void onClick(View v) { | |
| 85 | + //单个请求 | |
| 86 | + HttpConn.action( | |
| 87 | + BaseRequest | |
| 88 | + .init() | |
| 89 | + .setUrl("http://gank.io/api/data/") | |
| 90 | + .service(ApiService.class) | |
| 91 | + .getTest(), new NetCallBack<TestBean>() { | |
| 92 | + @Override | |
| 93 | + public void onRequestState(int state) { | |
| 94 | + | |
| 95 | + } | |
| 96 | + | |
| 97 | + @Override | |
| 98 | + public void onSuccess(TestBean data) { | |
| 99 | + Log.e(TAG, "onSuccess: " + data.getResults().size()); | |
| 100 | + } | |
| 101 | + | |
| 102 | + @Override | |
| 103 | + public void onFailure(String errCode, String errMsg) { | |
| 104 | + Log.e(TAG, "onFailure: " + errMsg); | |
| 105 | + } | |
| 106 | + } | |
| 107 | + ); | |
| 108 | + //多个请求 | |
| 109 | + Map<String, String> param = new HashMap<>(); | |
| 110 | + param.put("sid", "358916"); | |
| 111 | + HttpConn | |
| 112 | + .action( | |
| 113 | + BaseRequest | |
| 114 | + .init() | |
| 115 | + .setUrl("http://gank.io/api/data/") | |
| 116 | + .service(ApiService.class) | |
| 117 | + .getTest() | |
| 118 | + .concatMap(new Function<TestBean, Observable<BaseResult<LetHimNoSeeBean>>>() { | |
| 119 | + @Override | |
| 120 | + public Observable<BaseResult<LetHimNoSeeBean>> apply(TestBean testBean) throws Exception { | |
| 121 | + Log.e(TAG, "apply: " + testBean.getResults().size()); | |
| 122 | + return BaseRequest.init().service(ApiService.class).getLetHimNoSee(param); | |
| 123 | + } | |
| 124 | + }), new NetCallBack<BaseResult<LetHimNoSeeBean>>() { | |
| 125 | + @Override | |
| 126 | + public void onRequestState(int state) { | |
| 127 | + | |
| 128 | + } | |
| 129 | + | |
| 130 | + @Override | |
| 131 | + public void onSuccess(BaseResult<LetHimNoSeeBean> data) { | |
| 132 | + Log.e(TAG, "onSuccess: " + data.getData().getDoNotletFsids().size()); | |
| 133 | + } | |
| 134 | + | |
| 135 | + @Override | |
| 136 | + public void onFailure(String errCode, String errMsg) { | |
| 137 | + Log.e(TAG, "onFailure: " + errMsg); | |
| 138 | + } | |
| 139 | + }); | |
| 140 | + | |
| 141 | + | |
| 142 | + } | |
| 143 | + }); | |
| 41 | 144 | getPresenter().setData("hha"); |
| 42 | 145 | getMvpView().setData("test"); |
| 43 | 146 | } |
| 44 | - | |
| 45 | - | |
| 46 | 147 | } | ... | ... |
app/strike/src/main/java/com/cnlive/strike/MyFragment1.java
| 1 | 1 | package com.cnlive.strike; |
| 2 | 2 | |
| 3 | 3 | |
| 4 | -import android.content.Intent; | |
| 5 | 4 | import android.os.Bundle; |
| 6 | 5 | import android.view.LayoutInflater; |
| 7 | 6 | import android.view.View; |
| ... | ... | @@ -10,8 +9,8 @@ import android.view.ViewGroup; |
| 10 | 9 | import androidx.annotation.NonNull; |
| 11 | 10 | import androidx.annotation.Nullable; |
| 12 | 11 | |
| 13 | -import com.cnlive.libs.base.frame.fragment.BaseFragment; | |
| 14 | -import com.cnlive.libs.base.util.StatusBarConfig; | |
| 12 | +import com.cnlive.core.libs.base.frame.fragment.BaseFragment; | |
| 13 | +import com.cnlive.core.libs.base.util.StatusBarConfig; | |
| 15 | 14 | |
| 16 | 15 | |
| 17 | 16 | public class MyFragment1 extends BaseFragment { |
| ... | ... | @@ -26,15 +25,8 @@ public class MyFragment1 extends BaseFragment { |
| 26 | 25 | |
| 27 | 26 | @Override |
| 28 | 27 | protected void initView() { |
| 28 | + super.initView(); | |
| 29 | 29 | setStatusBarColor(R.color.qmui_config_color_red, 0); |
| 30 | 30 | setStatusBarTextColor(StatusBarConfig.BLACK); |
| 31 | - | |
| 32 | - } | |
| 33 | - | |
| 34 | - @Override | |
| 35 | - protected void initData() { | |
| 36 | -// getPresenter().setData1("dd"); | |
| 37 | 31 | } |
| 38 | - | |
| 39 | - | |
| 40 | 32 | } | ... | ... |
app/strike/src/main/java/com/cnlive/strike/MyFragment1View.java
app/strike/src/main/java/com/cnlive/strike/MyFragmentView.java
| 1 | 1 | package com.cnlive.strike; |
| 2 | 2 | |
| 3 | -import com.cnlive.libs.base.frame.view.BaseView; | |
| 3 | +import com.cnlive.core.libs.base.frame.view.BaseView; | |
| 4 | 4 | |
| 5 | 5 | public class MyFragmentView extends BaseView { |
| 6 | 6 | MyFragment fragment; |
| ... | ... | @@ -9,7 +9,7 @@ public class MyFragmentView extends BaseView { |
| 9 | 9 | this.fragment = fragment; |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | - public void setData(String msg){ | |
| 13 | -// fragment.tx.setText(msg); | |
| 12 | + public void setData(String msg) { | |
| 13 | + fragment.textView.setText(msg); | |
| 14 | 14 | } |
| 15 | 15 | } | ... | ... |
app/strike/src/main/java/com/cnlive/strike/MyPresenter.java
| 1 | 1 | package com.cnlive.strike; |
| 2 | 2 | |
| 3 | -import com.cnlive.libs.base.frame.presenter.BasePresenter; | |
| 4 | -import com.hannesdorfmann.mosby3.mvp.MvpBasePresenter; | |
| 3 | +import com.cnlive.core.libs.base.frame.presenter.BasePresenter; | |
| 5 | 4 | |
| 6 | 5 | public class MyPresenter extends BasePresenter<MyFragmentView> { |
| 7 | 6 | public void setData(String msg) { | ... | ... |
app/strike/src/main/java/com/cnlive/strike/MyPresenter1.java
app/strike/src/main/java/com/cnlive/strike/network/BaseRequest.java
0 → 100644
| 1 | +package com.cnlive.strike.network; | |
| 2 | + | |
| 3 | + | |
| 4 | +import android.text.TextUtils; | |
| 5 | + | |
| 6 | +import com.cnlive.core.libs.base.application.AppConfig; | |
| 7 | +import com.cnlive.core.network.NetBuilder; | |
| 8 | + | |
| 9 | +import java.util.ArrayList; | |
| 10 | +import java.util.List; | |
| 11 | + | |
| 12 | +import okhttp3.Interceptor; | |
| 13 | + | |
| 14 | +/** | |
| 15 | + * 基本请求 | |
| 16 | + * ys | |
| 17 | + */ | |
| 18 | +public class BaseRequest { | |
| 19 | + private String userSetUrl; | |
| 20 | + private static BaseRequest request; | |
| 21 | + private long connectTimeout;//连接超时 | |
| 22 | + private long readTimeout;//读取超时 | |
| 23 | + private long writeTimeout;//写入超时 | |
| 24 | + private List<Interceptor> interceptorList;//拦截器 | |
| 25 | + private String baseUrl = "http://gank.io/api/data/"; | |
| 26 | + private final String SP_CMS_URL_DEBUT = "http://cmstest.cnlive.com:8768/"; | |
| 27 | + private final String SP_CMS_URL = "http://cms.cnlive.com:8768/"; | |
| 28 | + //网++ 接口域名 | |
| 29 | + public final String SP_BASE_URL = "https://apiwjj.cnlive.com/"; | |
| 30 | + //网++ 测试环境 接口域名 | |
| 31 | + public final String SP_DEBUG_URL = "http://apiwjjtest.cnlive.com/"; | |
| 32 | + //OPEN API 接口域名 | |
| 33 | + private final String SP_OPEN_URL = "https://api.cnlive.com/"; | |
| 34 | + | |
| 35 | + /** | |
| 36 | + * 构造函数初始化 | |
| 37 | + */ | |
| 38 | + public BaseRequest() { | |
| 39 | + interceptorList = new ArrayList<>(); | |
| 40 | + } | |
| 41 | + | |
| 42 | + | |
| 43 | + /** | |
| 44 | + * 设置连接超时 | |
| 45 | + * | |
| 46 | + * @param connectTimeout | |
| 47 | + * @return | |
| 48 | + */ | |
| 49 | + public BaseRequest setConnectTimeout(long connectTimeout) { | |
| 50 | + init(); | |
| 51 | + connectTimeout = connectTimeout; | |
| 52 | + return request; | |
| 53 | + } | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * 设置读取超时 | |
| 57 | + * | |
| 58 | + * @param readTimeout | |
| 59 | + * @return | |
| 60 | + */ | |
| 61 | + public BaseRequest setReadTimeout(long readTimeout) { | |
| 62 | + init(); | |
| 63 | + readTimeout = readTimeout; | |
| 64 | + return request; | |
| 65 | + } | |
| 66 | + | |
| 67 | + /** | |
| 68 | + * 设置写入超时 | |
| 69 | + * | |
| 70 | + * @param writeTimeout | |
| 71 | + * @return | |
| 72 | + */ | |
| 73 | + public BaseRequest setWriteTimeout(long writeTimeout) { | |
| 74 | + init(); | |
| 75 | + writeTimeout = writeTimeout; | |
| 76 | + return request; | |
| 77 | + } | |
| 78 | + | |
| 79 | + | |
| 80 | + /** | |
| 81 | + * 初始化接口地址 | |
| 82 | + */ | |
| 83 | + private String initBaseUrl(Class clzz) { | |
| 84 | + if (AppConfig.isDebug()) { | |
| 85 | + baseUrl = SP_DEBUG_URL;//还原初始地址 | |
| 86 | + } | |
| 87 | + return baseUrl; | |
| 88 | + } | |
| 89 | + | |
| 90 | + /** | |
| 91 | + * 设置连接地址 | |
| 92 | + * | |
| 93 | + * @param url | |
| 94 | + * @return | |
| 95 | + */ | |
| 96 | + public BaseRequest setUrl(String url) { | |
| 97 | + init(); | |
| 98 | + userSetUrl = url; | |
| 99 | + return request; | |
| 100 | + } | |
| 101 | + | |
| 102 | + /** | |
| 103 | + * 添加拦截器 | |
| 104 | + * | |
| 105 | + * @param interceptor | |
| 106 | + * @return | |
| 107 | + */ | |
| 108 | + public BaseRequest addInterceptor(Interceptor interceptor) { | |
| 109 | + if (null != interceptor) { | |
| 110 | + interceptorList.add(interceptor); | |
| 111 | + } | |
| 112 | + return request; | |
| 113 | + } | |
| 114 | + | |
| 115 | + /** | |
| 116 | + * @return | |
| 117 | + */ | |
| 118 | + public static synchronized BaseRequest init() { | |
| 119 | + if (null == request) { | |
| 120 | + request = new BaseRequest(); | |
| 121 | + } | |
| 122 | + return request; | |
| 123 | + } | |
| 124 | + | |
| 125 | + public <NetService> NetService service(Class<NetService> clz) { | |
| 126 | + NetService service = null; | |
| 127 | + NetBuilder builder = new NetBuilder(clz); | |
| 128 | + if (connectTimeout > 0) { | |
| 129 | + builder.setConnectTimeout(connectTimeout); | |
| 130 | + } | |
| 131 | + if (readTimeout > 0) { | |
| 132 | + builder.setReadTimeout(readTimeout); | |
| 133 | + } | |
| 134 | + if (writeTimeout > 0) { | |
| 135 | + builder.setWriteTimeout(writeTimeout); | |
| 136 | + } | |
| 137 | + if (null != interceptorList && interceptorList.size() > 0) { | |
| 138 | + builder.addInterceptors(interceptorList); | |
| 139 | + } | |
| 140 | + //设置接口请求头地址 | |
| 141 | + if (!TextUtils.isEmpty(userSetUrl)) { | |
| 142 | + builder.setBaseUrl(userSetUrl); | |
| 143 | + userSetUrl = ""; | |
| 144 | + } else { | |
| 145 | + builder.setBaseUrl(initBaseUrl(clz)); | |
| 146 | + } | |
| 147 | + service = (NetService) builder.getService(); | |
| 148 | + builder = null; | |
| 149 | + //重置属性 | |
| 150 | + resetData(); | |
| 151 | + return service; | |
| 152 | + | |
| 153 | + } | |
| 154 | + | |
| 155 | + private void resetData() { | |
| 156 | + interceptorList.clear(); | |
| 157 | + | |
| 158 | + connectTimeout = 0; | |
| 159 | + readTimeout = 0; | |
| 160 | + writeTimeout = 0; | |
| 161 | + } | |
| 162 | + | |
| 163 | + | |
| 164 | +} | |
| 0 | 165 | \ No newline at end of file | ... | ... |
app/strike/src/main/java/com/cnlive/strike/network/api/ApiService.java
0 → 100644
| 1 | +package com.cnlive.strike.network.api; | |
| 2 | + | |
| 3 | +import com.cnlive.core.network.BaseResult; | |
| 4 | +import com.cnlive.strike.network.bean.LetHimNoSeeBean; | |
| 5 | +import com.cnlive.strike.network.bean.TestBean; | |
| 6 | + | |
| 7 | +import java.util.Map; | |
| 8 | + | |
| 9 | +import io.reactivex.Observable; | |
| 10 | +import retrofit2.http.GET; | |
| 11 | +import retrofit2.http.POST; | |
| 12 | +import retrofit2.http.QueryMap; | |
| 13 | + | |
| 14 | +public interface ApiService { | |
| 15 | + @GET("福利/10/1") | |
| 16 | + Observable<TestBean> getTest(); | |
| 17 | + | |
| 18 | + @POST("Daren/moment/getDoNotletFsids.action") | |
| 19 | + Observable<BaseResult<LetHimNoSeeBean>> getLetHimNoSee(@QueryMap() Map<String, String> maps); | |
| 20 | +} | ... | ... |
app/strike/src/main/java/com/cnlive/strike/network/bean/LetHimNoSeeBean.java
0 → 100644
| 1 | +package com.cnlive.strike.network.bean; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +public class LetHimNoSeeBean { | |
| 6 | + | |
| 7 | + private List<DoNotletFsidsBean> doNotletFsids; | |
| 8 | + | |
| 9 | + public List<DoNotletFsidsBean> getDoNotletFsids() { | |
| 10 | + return doNotletFsids; | |
| 11 | + } | |
| 12 | + | |
| 13 | + public void setDoNotletFsids(List<DoNotletFsidsBean> doNotletFsids) { | |
| 14 | + this.doNotletFsids = doNotletFsids; | |
| 15 | + } | |
| 16 | + | |
| 17 | + public static class DoNotletFsidsBean { | |
| 18 | + /** | |
| 19 | + * image : http://yweb0.cnliveimg.com/images/headImg/2018/1114/1542164956106_small.jpg | |
| 20 | + * nickName : 峨眉派掌门候选人 | |
| 21 | + * userId : 10513196 | |
| 22 | + */ | |
| 23 | + | |
| 24 | + private String image; | |
| 25 | + private String nickName; | |
| 26 | + private String userId; | |
| 27 | + | |
| 28 | + public String getImage() { | |
| 29 | + return image; | |
| 30 | + } | |
| 31 | + | |
| 32 | + public void setImage(String image) { | |
| 33 | + this.image = image; | |
| 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 getUserId() { | |
| 45 | + return userId; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public void setUserId(String userId) { | |
| 49 | + this.userId = userId; | |
| 50 | + } | |
| 51 | + } | |
| 52 | +} | ... | ... |
app/strike/src/main/java/com/cnlive/strike/network/bean/TestBean.java
0 → 100644
| 1 | +package com.cnlive.strike.network.bean; | |
| 2 | + | |
| 3 | +import java.util.List; | |
| 4 | + | |
| 5 | +public class TestBean { | |
| 6 | + /** | |
| 7 | + * error : false | |
| 8 | + * results : [{"_id":"5ccdbc219d212239df927a93","createdAt":"2019-05-04T16:21:53.523Z","desc":"2019-05-05","publishedAt":"2019-05-04T16:21:59.733Z","source":"web","type":"福利","url":"http://ww1.sinaimg.cn/large/0065oQSqly1g2pquqlp0nj30n00yiq8u.jpg","used":true,"who":"lijinshanmx"},{"_id":"5cc43919fc3326376038d233","createdAt":"2019-04-27T19:12:25.536Z","desc":"2019-04-27","publishedAt":"2019-04-27T19:12:51.865Z","source":"web","type":"福利","url":"https://ww1.sinaimg.cn/large/0065oQSqly1g2hekfwnd7j30sg0x4djy.jpg","used":true,"who":"lijinshanmx"},{"_id":"5c6a4ae99d212226776d3256","createdAt":"2019-02-18T06:04:25.571Z","desc":"2019-02-18","publishedAt":"2019-04-10T00:00:00.0Z","source":"web","type":"福利","url":"https://ws1.sinaimg.cn/large/0065oQSqly1g0ajj4h6ndj30sg11xdmj.jpg","used":true,"who":"lijinshanmx"},{"_id":"5c2dabdb9d21226e068debf9","createdAt":"2019-01-03T06:29:47.895Z","desc":"2019-01-03","publishedAt":"2019-01-03T00:00:00.0Z","source":"web","type":"福利","url":"https://ws1.sinaimg.cn/large/0065oQSqly1fytdr77urlj30sg10najf.jpg","used":true,"who":"lijinshanmx"},{"_id":"5c25db189d21221e8ada8664","createdAt":"2018-12-28T08:13:12.688Z","desc":"2018-12-28","publishedAt":"2018-12-28T00:00:00.0Z","source":"web","type":"福利","url":"https://ws1.sinaimg.cn/large/0065oQSqly1fymj13tnjmj30r60zf79k.jpg","used":true,"who":"lijinshanmx"},{"_id":"5c12216d9d21223f5a2baea2","createdAt":"2018-12-13T09:07:57.2Z","desc":"2018-12-13","publishedAt":"2018-12-13T00:00:00.0Z","source":"web","type":"福利","url":"https://ws1.sinaimg.cn/large/0065oQSqgy1fy58bi1wlgj30sg10hguu.jpg","used":true,"who":"lijinshanmx"},{"_id":"5bfe1a5b9d2122309624cbb7","createdAt":"2018-11-28T04:32:27.338Z","desc":"2018-11-28","publishedAt":"2018-11-28T00:00:00.0Z","source":"web","type":"福利","url":"https://ws1.sinaimg.cn/large/0065oQSqgy1fxno2dvxusj30sf10nqcm.jpg","used":true,"who":"lijinshanmx"},{"_id":"5bf22fd69d21223ddba8ca25","createdAt":"2018-11-19T03:36:54.950Z","desc":"2018-11-19","publishedAt":"2018-11-19T00:00:00.0Z","source":"web","type":"福利","url":"https://ws1.sinaimg.cn/large/0065oQSqgy1fxd7vcz86nj30qo0ybqc1.jpg","used":true,"who":"lijinshanmx"},{"_id":"5be14edb9d21223dd50660f8","createdAt":"2018-11-06T08:20:43.656Z","desc":"2018-11-06","publishedAt":"2018-11-06T00:00:00.0Z","source":"web","type":"福利","url":"https://ws1.sinaimg.cn/large/0065oQSqgy1fwyf0wr8hhj30ie0nhq6p.jpg","used":true,"who":"lijinshanmx"},{"_id":"5bcd71979d21220315c663fc","createdAt":"2018-10-22T06:43:35.440Z","desc":"2018-10-22","publishedAt":"2018-10-22T00:00:00.0Z","source":"web","type":"福利","url":"https://ws1.sinaimg.cn/large/0065oQSqgy1fwgzx8n1syj30sg15h7ew.jpg","used":true,"who":"lijinshanmx"}] | |
| 9 | + */ | |
| 10 | + | |
| 11 | + private boolean error; | |
| 12 | + private List<ResultsBean> results; | |
| 13 | + | |
| 14 | + public boolean isError() { | |
| 15 | + return error; | |
| 16 | + } | |
| 17 | + | |
| 18 | + public void setError(boolean error) { | |
| 19 | + this.error = error; | |
| 20 | + } | |
| 21 | + | |
| 22 | + public List<ResultsBean> getResults() { | |
| 23 | + return results; | |
| 24 | + } | |
| 25 | + | |
| 26 | + public void setResults(List<ResultsBean> results) { | |
| 27 | + this.results = results; | |
| 28 | + } | |
| 29 | + | |
| 30 | + public static class ResultsBean { | |
| 31 | + /** | |
| 32 | + * _id : 5ccdbc219d212239df927a93 | |
| 33 | + * createdAt : 2019-05-04T16:21:53.523Z | |
| 34 | + * desc : 2019-05-05 | |
| 35 | + * publishedAt : 2019-05-04T16:21:59.733Z | |
| 36 | + * source : web | |
| 37 | + * type : 福利 | |
| 38 | + * url : http://ww1.sinaimg.cn/large/0065oQSqly1g2pquqlp0nj30n00yiq8u.jpg | |
| 39 | + * used : true | |
| 40 | + * who : lijinshanmx | |
| 41 | + */ | |
| 42 | + | |
| 43 | + private String _id; | |
| 44 | + private String createdAt; | |
| 45 | + private String desc; | |
| 46 | + private String publishedAt; | |
| 47 | + private String source; | |
| 48 | + private String type; | |
| 49 | + private String url; | |
| 50 | + private boolean used; | |
| 51 | + private String who; | |
| 52 | + | |
| 53 | + public String get_id() { | |
| 54 | + return _id; | |
| 55 | + } | |
| 56 | + | |
| 57 | + public void set_id(String _id) { | |
| 58 | + this._id = _id; | |
| 59 | + } | |
| 60 | + | |
| 61 | + public String getCreatedAt() { | |
| 62 | + return createdAt; | |
| 63 | + } | |
| 64 | + | |
| 65 | + public void setCreatedAt(String createdAt) { | |
| 66 | + this.createdAt = createdAt; | |
| 67 | + } | |
| 68 | + | |
| 69 | + public String getDesc() { | |
| 70 | + return desc; | |
| 71 | + } | |
| 72 | + | |
| 73 | + public void setDesc(String desc) { | |
| 74 | + this.desc = desc; | |
| 75 | + } | |
| 76 | + | |
| 77 | + public String getPublishedAt() { | |
| 78 | + return publishedAt; | |
| 79 | + } | |
| 80 | + | |
| 81 | + public void setPublishedAt(String publishedAt) { | |
| 82 | + this.publishedAt = publishedAt; | |
| 83 | + } | |
| 84 | + | |
| 85 | + public String getSource() { | |
| 86 | + return source; | |
| 87 | + } | |
| 88 | + | |
| 89 | + public void setSource(String source) { | |
| 90 | + this.source = source; | |
| 91 | + } | |
| 92 | + | |
| 93 | + public String getType() { | |
| 94 | + return type; | |
| 95 | + } | |
| 96 | + | |
| 97 | + public void setType(String type) { | |
| 98 | + this.type = type; | |
| 99 | + } | |
| 100 | + | |
| 101 | + public String getUrl() { | |
| 102 | + return url; | |
| 103 | + } | |
| 104 | + | |
| 105 | + public void setUrl(String url) { | |
| 106 | + this.url = url; | |
| 107 | + } | |
| 108 | + | |
| 109 | + public boolean isUsed() { | |
| 110 | + return used; | |
| 111 | + } | |
| 112 | + | |
| 113 | + public void setUsed(boolean used) { | |
| 114 | + this.used = used; | |
| 115 | + } | |
| 116 | + | |
| 117 | + public String getWho() { | |
| 118 | + return who; | |
| 119 | + } | |
| 120 | + | |
| 121 | + public void setWho(String who) { | |
| 122 | + this.who = who; | |
| 123 | + } | |
| 124 | + } | |
| 125 | + | |
| 126 | +// /** | |
| 127 | +// * _id : 5ccdbc219d212239df927a93 | |
| 128 | +// * createdAt : 2019-05-04T16:21:53.523Z | |
| 129 | +// * desc : 2019-05-05 | |
| 130 | +// * publishedAt : 2019-05-04T16:21:59.733Z | |
| 131 | +// * source : web | |
| 132 | +// * type : 福利 | |
| 133 | +// * url : http://ww1.sinaimg.cn/large/0065oQSqly1g2pquqlp0nj30n00yiq8u.jpg | |
| 134 | +// * used : true | |
| 135 | +// * who : lijinshanmx | |
| 136 | +// */ | |
| 137 | +// | |
| 138 | +// private String _id; | |
| 139 | +// private String createdAt; | |
| 140 | +// private String desc; | |
| 141 | +// private String publishedAt; | |
| 142 | +// private String source; | |
| 143 | +// private String type; | |
| 144 | +// private String url; | |
| 145 | +// private boolean used; | |
| 146 | +// private String who; | |
| 147 | +// | |
| 148 | +// public String get_id() { | |
| 149 | +// return _id; | |
| 150 | +// } | |
| 151 | +// | |
| 152 | +// public void set_id(String _id) { | |
| 153 | +// this._id = _id; | |
| 154 | +// } | |
| 155 | +// | |
| 156 | +// public String getCreatedAt() { | |
| 157 | +// return createdAt; | |
| 158 | +// } | |
| 159 | +// | |
| 160 | +// public void setCreatedAt(String createdAt) { | |
| 161 | +// this.createdAt = createdAt; | |
| 162 | +// } | |
| 163 | +// | |
| 164 | +// public String getDesc() { | |
| 165 | +// return desc; | |
| 166 | +// } | |
| 167 | +// | |
| 168 | +// public void setDesc(String desc) { | |
| 169 | +// this.desc = desc; | |
| 170 | +// } | |
| 171 | +// | |
| 172 | +// public String getPublishedAt() { | |
| 173 | +// return publishedAt; | |
| 174 | +// } | |
| 175 | +// | |
| 176 | +// public void setPublishedAt(String publishedAt) { | |
| 177 | +// this.publishedAt = publishedAt; | |
| 178 | +// } | |
| 179 | +// | |
| 180 | +// public String getSource() { | |
| 181 | +// return source; | |
| 182 | +// } | |
| 183 | +// | |
| 184 | +// public void setSource(String source) { | |
| 185 | +// this.source = source; | |
| 186 | +// } | |
| 187 | +// | |
| 188 | +// public String getType() { | |
| 189 | +// return type; | |
| 190 | +// } | |
| 191 | +// | |
| 192 | +// public void setType(String type) { | |
| 193 | +// this.type = type; | |
| 194 | +// } | |
| 195 | +// | |
| 196 | +// public String getUrl() { | |
| 197 | +// return url; | |
| 198 | +// } | |
| 199 | +// | |
| 200 | +// public void setUrl(String url) { | |
| 201 | +// this.url = url; | |
| 202 | +// } | |
| 203 | +// | |
| 204 | +// public boolean isUsed() { | |
| 205 | +// return used; | |
| 206 | +// } | |
| 207 | +// | |
| 208 | +// public void setUsed(boolean used) { | |
| 209 | +// this.used = used; | |
| 210 | +// } | |
| 211 | +// | |
| 212 | +// public String getWho() { | |
| 213 | +// return who; | |
| 214 | +// } | |
| 215 | +// | |
| 216 | +// public void setWho(String who) { | |
| 217 | +// this.who = who; | |
| 218 | +// } | |
| 219 | + | |
| 220 | + | |
| 221 | +} | ... | ... |
app/strike/src/main/res/layout/activity_main.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | 2 | <layout> |
| 3 | - <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 3 | + | |
| 4 | + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 4 | 5 | xmlns:app="http://schemas.android.com/apk/res-auto" |
| 5 | 6 | xmlns:tools="http://schemas.android.com/tools" |
| 6 | 7 | android:layout_width="match_parent" |
| ... | ... | @@ -8,11 +9,11 @@ |
| 8 | 9 | android:orientation="vertical" |
| 9 | 10 | tools:context=".ui.activity.AllDeviceActivity"> |
| 10 | 11 | |
| 11 | - <Button | |
| 12 | - android:id="@+id/go_to" | |
| 13 | - android:layout_width="wrap_content" | |
| 14 | - android:layout_height="wrap_content" | |
| 15 | - android:text="跳转"/> | |
| 12 | + <Button | |
| 13 | + android:id="@+id/go_to" | |
| 14 | + android:layout_width="wrap_content" | |
| 15 | + android:layout_height="wrap_content" | |
| 16 | + android:text="跳转" /> | |
| 16 | 17 | |
| 17 | 18 | <Button |
| 18 | 19 | android:id="@+id/to_img" |
| ... | ... | @@ -20,5 +21,17 @@ |
| 20 | 21 | android:layout_height="wrap_content" |
| 21 | 22 | android:text="图片加载测试"/> |
| 22 | 23 | |
| 23 | - </RelativeLayout> | |
| 24 | + <Button | |
| 25 | + android:id="@+id/go_to1" | |
| 26 | + android:layout_width="wrap_content" | |
| 27 | + android:layout_height="wrap_content" | |
| 28 | + android:text="请求权限默认提示语" /> | |
| 29 | + | |
| 30 | + <Button | |
| 31 | + android:id="@+id/go_to2" | |
| 32 | + android:layout_width="wrap_content" | |
| 33 | + android:layout_height="wrap_content" | |
| 34 | + android:text="请求权限自定义提示语" /> | |
| 35 | + | |
| 36 | + </LinearLayout> | |
| 24 | 37 | </layout> |
| 25 | 38 | \ No newline at end of file | ... | ... |
app/strike/src/main/res/layout/activity_main1.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | 2 | <layout> |
| 3 | 3 | |
| 4 | - <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 4 | + <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
| 5 | 5 | xmlns:app="http://schemas.android.com/apk/res-auto" |
| 6 | 6 | xmlns:tools="http://schemas.android.com/tools" |
| 7 | 7 | android:layout_width="match_parent" |
| ... | ... | @@ -20,5 +20,17 @@ |
| 20 | 20 | android:layout_width="wrap_content" |
| 21 | 21 | android:layout_height="wrap_content" |
| 22 | 22 | android:text="测试view" /> |
| 23 | - </RelativeLayout> | |
| 23 | + | |
| 24 | + <Button | |
| 25 | + android:id="@+id/btn_test1" | |
| 26 | + android:layout_width="wrap_content" | |
| 27 | + android:layout_height="wrap_content" | |
| 28 | + android:text="权限申请" /> | |
| 29 | + | |
| 30 | + <Button | |
| 31 | + android:id="@+id/btn_test2" | |
| 32 | + android:layout_width="wrap_content" | |
| 33 | + android:layout_height="wrap_content" | |
| 34 | + android:text="自定义提示语权限申请" /> | |
| 35 | + </LinearLayout> | |
| 24 | 36 | </layout> |
| 25 | 37 | \ No newline at end of file | ... | ... |
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> | ... | ... |
app/strike/src/main/res/xml/network_security_config.xml
0 → 100644
build.gradle
| ... | ... | @@ -10,11 +10,11 @@ buildscript { |
| 10 | 10 | repositories { |
| 11 | 11 | google() |
| 12 | 12 | jcenter() |
| 13 | - | |
| 13 | + | |
| 14 | 14 | } |
| 15 | 15 | dependencies { |
| 16 | 16 | classpath 'com.android.tools.build:gradle:3.5.1' |
| 17 | - | |
| 17 | + | |
| 18 | 18 | // NOTE: Do not place your application dependencies here; they belong |
| 19 | 19 | // in the individual module build.gradle files |
| 20 | 20 | classpath "com.alibaba:arouter-register:1.0.2" |
| ... | ... | @@ -26,9 +26,25 @@ allprojects { |
| 26 | 26 | repositories { |
| 27 | 27 | google() |
| 28 | 28 | jcenter() |
| 29 | - | |
| 29 | + | |
| 30 | 30 | } |
| 31 | 31 | } |
| 32 | + | |
| 33 | +////配置全局变量 | |
| 34 | +//ext { | |
| 35 | +// def versionMajor = 1 | |
| 36 | +// def versionMinor = 5 | |
| 37 | +// def versionPatch = 6 | |
| 38 | +// def versionBuild = 0 | |
| 39 | +// // module依赖库公共版本号 | |
| 40 | +// versionCode = versionMajor * 1000 + versionMinor * 100 + versionPatch * 10 + versionBuild | |
| 41 | +// versionName = "${versionMajor}.${versionMinor}.${versionPatch}.${versionBuild}" | |
| 42 | +// | |
| 43 | +// compileSdkVersion = 29 | |
| 44 | +// buildToolsVersion = "29.0.2" | |
| 45 | +// minSdkVersion = 19 | |
| 46 | +// targetSdkVersion = 29 | |
| 47 | +//} | |
| 32 | 48 | allprojects { |
| 33 | 49 | afterEvaluate { |
| 34 | 50 | if (project.parent == null || project.parent == rootProject) return |
| ... | ... | @@ -37,7 +53,7 @@ allprojects { |
| 37 | 53 | compileSdkVersion 29 |
| 38 | 54 | buildToolsVersion "29.0.0" |
| 39 | 55 | defaultConfig { |
| 40 | - if (minSdkVersion == null) minSdkVersion 16 | |
| 56 | + if (minSdkVersion == null) minSdkVersion 21 | |
| 41 | 57 | if (targetSdkVersion == null) targetSdkVersion 29 |
| 42 | 58 | if (versionCode == null) versionCode 1 |
| 43 | 59 | if (versionName == null) versionName "1.2" |
| ... | ... | @@ -93,7 +109,7 @@ allprojects { |
| 93 | 109 | imput("implementation", project, moudle.core_base) |
| 94 | 110 | |
| 95 | 111 | //Tripartite Base |
| 96 | - for (String moudle : base_librarys) imput('implementation', project, moudle) | |
| 112 | + for (String moudle : base_librarys) imput('implementation', project, moudle) | |
| 97 | 113 | for (String moudle : base_compilers) imput('annotationProcessor', project, moudle) |
| 98 | 114 | |
| 99 | 115 | } | ... | ... |
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=".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 | +import android.text.TextUtils; | |
| 6 | + | |
| 7 | +import com.cnlive.core.libs.base.application.AppConfig; | |
| 8 | +import com.cnlive.core.network.BaseResult; | |
| 9 | +import com.cnlive.core.network.HttpConn; | |
| 10 | +import com.cnlive.strike.user.network.api.ApiBaseServiceOpen; | |
| 11 | +import com.cnlive.strike.user.network.api.BaseRequest; | |
| 12 | +import com.cnlive.strike.user.network.model.TokenData; | |
| 13 | +import com.cnlive.strike.user.network.model.UserData; | |
| 14 | + | |
| 15 | +import java.io.File; | |
| 16 | +import java.util.HashMap; | |
| 17 | +import java.util.Map; | |
| 18 | + | |
| 19 | +import io.reactivex.Observable; | |
| 20 | +import okhttp3.MediaType; | |
| 21 | +import okhttp3.RequestBody; | |
| 22 | + | |
| 23 | + | |
| 24 | +/** | |
| 25 | + * Created by Lynn on 2018/10/15. | |
| 26 | + */ | |
| 27 | + | |
| 28 | +public class UserUtilAction { | |
| 29 | + public static final String TOKEN_ERROR_CODE = "-900001"; | |
| 30 | + public static String TOKEN_ERROR_MSG = "用户token为空"; | |
| 31 | + | |
| 32 | + /** | |
| 33 | + * 快捷登录前发送手机验证码 | |
| 34 | + * | |
| 35 | + * @param context | |
| 36 | + * @param mobile 手机号 | |
| 37 | + * @return | |
| 38 | + */ | |
| 39 | + public static Observable<BaseResult> sendMsgBefQuickLoginAction(final Context context, final String mobile, String countryCode) { | |
| 40 | + Map<String, String> requestMap = new HashMap<>(); | |
| 41 | + requestMap.put("appId", AppConfig.getAppId()); | |
| 42 | + requestMap.put("mobile", mobile); | |
| 43 | + requestMap.put("countryCode", countryCode); | |
| 44 | + requestMap.put("clientPlat", "a"); | |
| 45 | + return BaseRequest.init().service(ApiBaseServiceOpen.class).sendVerifyCodeBefQuickLogin(requestMap); | |
| 46 | + } | |
| 47 | + | |
| 48 | + | |
| 49 | + /** | |
| 50 | + * 快捷登录 | |
| 51 | + * | |
| 52 | + * @param context | |
| 53 | + * @param userPhone 手机号 | |
| 54 | + * @param userCode 验证码 | |
| 55 | + * @return | |
| 56 | + */ | |
| 57 | + public static Observable<BaseResult<UserData>> quickLoginAction(Context context, String userPhone, String userCode, String countryCode) { | |
| 58 | + Map<String, String> requestMap = new HashMap<>(); | |
| 59 | + requestMap.put("appId", AppConfig.getAppId()); | |
| 60 | + requestMap.put("userName", userPhone); | |
| 61 | + requestMap.put("verificationCode", userCode); | |
| 62 | + requestMap.put("uuid", AppConfig.getAppUUID()); | |
| 63 | + requestMap.put("frmId", AppConfig.getAppChannel()); | |
| 64 | + requestMap.put("countryCode", countryCode); | |
| 65 | + requestMap.put("clientPlat", "a"); | |
| 66 | + return BaseRequest.init().service(ApiBaseServiceOpen.class).quickLogin(requestMap); | |
| 67 | + | |
| 68 | + } | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * 登录 | |
| 72 | + * | |
| 73 | + * @param context | |
| 74 | + * @param userName 用户名 | |
| 75 | + * @param pwd 密码 | |
| 76 | + * @return | |
| 77 | + */ | |
| 78 | + public static Observable<BaseResult<UserData>> loginAction(Context context, String userName, String pwd) { | |
| 79 | + Map<String, String> map = new HashMap<>(); | |
| 80 | + map.put("appId", AppConfig.getAppId()); | |
| 81 | + map.put("userName", userName); | |
| 82 | + map.put("pwd", pwd); | |
| 83 | + map.put("uuid", AppConfig.getAppUUID()); | |
| 84 | + map.put("frmId", ""); | |
| 85 | + map.put("clientPlat", "a"); | |
| 86 | + return BaseRequest.init().service(ApiBaseServiceOpen.class).login(map); | |
| 87 | + | |
| 88 | + } | |
| 89 | + | |
| 90 | + | |
| 91 | + /** | |
| 92 | + * 查询用户信息 | |
| 93 | + * | |
| 94 | + * @param context | |
| 95 | + * @param userId 用户ID | |
| 96 | + * @param srcUid 被查询用户ID | |
| 97 | + * @param token 查询者平台TOKEN | |
| 98 | + * @return | |
| 99 | + */ | |
| 100 | + public static Observable<BaseResult<UserData>> queryUserInfo(Context context, String userId, String srcUid, String token) { | |
| 101 | + Map<String, String> map = new HashMap<>(); | |
| 102 | + map.put("appId", AppConfig.getAppId()); | |
| 103 | + map.put("uid", userId); | |
| 104 | + map.put("srcUid", srcUid); | |
| 105 | + map.put("clientPlat", "a"); | |
| 106 | + map.put("token", token); | |
| 107 | + if (TextUtils.isEmpty(token)) { | |
| 108 | + HttpConn.error(UserUtilAction.TOKEN_ERROR_CODE, TOKEN_ERROR_MSG); | |
| 109 | + } | |
| 110 | + return BaseRequest.init().service(ApiBaseServiceOpen.class).queryUserInfo(map); | |
| 111 | + | |
| 112 | + } | |
| 113 | + | |
| 114 | + /** | |
| 115 | + * 修改用户附加信息 | |
| 116 | + * | |
| 117 | + * @param context | |
| 118 | + * @param userId 用户id | |
| 119 | + * @param extInfo 扩展信息 | |
| 120 | + * @param token 平台token | |
| 121 | + * @return | |
| 122 | + */ | |
| 123 | + public static Observable<BaseResult> updateUserExtInfo(Context context, String userId, String extInfo, String token) { | |
| 124 | + Map<String, String> map = new HashMap<>(); | |
| 125 | + map.put("appId", AppConfig.getAppId()); | |
| 126 | + map.put("uid", userId); | |
| 127 | + map.put("extInfo", extInfo); | |
| 128 | + map.put("token", token); | |
| 129 | + map.put("clientPlat", "a"); | |
| 130 | + if (TextUtils.isEmpty(token)) { | |
| 131 | + HttpConn.error(UserUtilAction.TOKEN_ERROR_CODE, TOKEN_ERROR_MSG); | |
| 132 | + } | |
| 133 | + return BaseRequest.init().service(ApiBaseServiceOpen.class).updateUserExtInfo(map); | |
| 134 | + | |
| 135 | + } | |
| 136 | + | |
| 137 | + ; | |
| 138 | + | |
| 139 | + /** | |
| 140 | + * 修改用户单项信息 | |
| 141 | + * | |
| 142 | + * @param context | |
| 143 | + * @param uid 用户Id | |
| 144 | + * @param type nickName-昵称,gender-性别,email-邮箱, location-联系方式 | |
| 145 | + * @param value 对应的信息,性别,m:男、f:女、n:未知 | |
| 146 | + * @param token 平台TOKEN | |
| 147 | + * @return | |
| 148 | + */ | |
| 149 | + public static Observable<BaseResult> modifyUserInfo(Context context, String uid, String type, String value, String token) { | |
| 150 | + Map<String, String> map = new HashMap<>(); | |
| 151 | + map.put("appId", AppConfig.getAppId()); | |
| 152 | + map.put("uid", uid); | |
| 153 | + map.put("type", type); | |
| 154 | + map.put("value", value); | |
| 155 | + map.put("clientPlat", "a"); | |
| 156 | + map.put("token", token); | |
| 157 | + if (TextUtils.isEmpty(token)) { | |
| 158 | + HttpConn.error(UserUtilAction.TOKEN_ERROR_CODE, TOKEN_ERROR_MSG); | |
| 159 | + } | |
| 160 | + return BaseRequest.init().service(ApiBaseServiceOpen.class).modifyUserInfo(map); | |
| 161 | + | |
| 162 | + } | |
| 163 | + | |
| 164 | + /** | |
| 165 | + * 注册或修改手机号前发手机验证码 | |
| 166 | + * | |
| 167 | + * @param context | |
| 168 | + * @param mobile 手机号 | |
| 169 | + * @return | |
| 170 | + */ | |
| 171 | + public static Observable<BaseResult> sendVerifyCodeForUnRegistered(Context context, String mobile, String countryCode) { | |
| 172 | + Map<String, String> map = new HashMap<>(); | |
| 173 | + map.put("appId", AppConfig.getAppId()); | |
| 174 | + map.put("mobile", mobile); | |
| 175 | + map.put("clientPlat", "a"); | |
| 176 | + map.put("countryCode", countryCode); | |
| 177 | + return BaseRequest.init().service(ApiBaseServiceOpen.class).sendVerifyCodeForUnRegistered(map); | |
| 178 | + } | |
| 179 | + | |
| 180 | + /** | |
| 181 | + * 更新手机号 | |
| 182 | + * | |
| 183 | + * @param context | |
| 184 | + * @param uid 用户ID | |
| 185 | + * @param mobile 手机号 | |
| 186 | + * @param verificationCode 手机验证码 | |
| 187 | + * @param token 平台TOKEN | |
| 188 | + * @return | |
| 189 | + */ | |
| 190 | + public static Observable<BaseResult> updateMobile(Context context, String uid, String mobile, String verificationCode, String token, String countryCode) { | |
| 191 | + Map<String, String> map = new HashMap<>(); | |
| 192 | + map.put("appId", AppConfig.getAppId()); | |
| 193 | + map.put("uid", uid); | |
| 194 | + map.put("mobile", mobile); | |
| 195 | + map.put("verificationCode", verificationCode); | |
| 196 | + map.put("clientPlat", "a"); | |
| 197 | + map.put("countryCode", countryCode); | |
| 198 | + map.put("token", token); | |
| 199 | + if (TextUtils.isEmpty(token)) { | |
| 200 | + HttpConn.error(UserUtilAction.TOKEN_ERROR_CODE, TOKEN_ERROR_MSG); | |
| 201 | + } | |
| 202 | + return BaseRequest.init().service(ApiBaseServiceOpen.class).updateMobile(map); | |
| 203 | + | |
| 204 | + } | |
| 205 | + | |
| 206 | + /** | |
| 207 | + * 注册 | |
| 208 | + * | |
| 209 | + * @param context | |
| 210 | + * @param userName 邮箱或手机 | |
| 211 | + * @param pwd 密码 | |
| 212 | + * @param verificationCode 手机验证码(手机号注册时必填) | |
| 213 | + * @return | |
| 214 | + */ | |
| 215 | + public static Observable<BaseResult<UserData>> register(Context context, String userName, String pwd, String verificationCode) { | |
| 216 | + Map<String, String> map = new HashMap<>(); | |
| 217 | + map.put("appId", AppConfig.getAppId()); | |
| 218 | + map.put("userName", userName); | |
| 219 | + map.put("pwd", pwd); | |
| 220 | + map.put("verificationCode", verificationCode); | |
| 221 | + map.put("invitationCode", ""); | |
| 222 | + map.put("uuid", AppConfig.getAppUUID()); | |
| 223 | + map.put("frmId", ""); | |
| 224 | + map.put("clientPlat", "a"); | |
| 225 | + return BaseRequest.init().service(ApiBaseServiceOpen.class).register(map); | |
| 226 | + } | |
| 227 | + | |
| 228 | + | |
| 229 | + /** | |
| 230 | + * 获取access_token | |
| 231 | + * | |
| 232 | + * @param context | |
| 233 | + * @return | |
| 234 | + */ | |
| 235 | + public static Observable<BaseResult<TokenData>> accessToken(Context context) { | |
| 236 | + Map<String, String> map = new HashMap<>(); | |
| 237 | + map.put("appId", AppConfig.getAppId()); | |
| 238 | + map.put("secret", AppConfig.getAppSceret()); | |
| 239 | + return BaseRequest.init().service(ApiBaseServiceOpen.class).accessToken(map); | |
| 240 | + } | |
| 241 | + | |
| 242 | +// /** | |
| 243 | +// * 上传头像 | |
| 244 | +// * | |
| 245 | +// * @param context | |
| 246 | +// * @param uid 用户ID | |
| 247 | +// * @param face 头像文件 | |
| 248 | +// * @param token 平台TOKEN | |
| 249 | +// * @param access_token | |
| 250 | +// * @return | |
| 251 | +// */ | |
| 252 | +// public static Disposable updateUserFace(Context context, String uid, File face, String token, String access_token, DataCallback<BaseInfo<FaceData>> callback) { | |
| 253 | +// Map<String, RequestBody> params = new HashMap<>(); | |
| 254 | +// | |
| 255 | +// if (TextUtils.isEmpty(token)) { | |
| 256 | +// callback.callback(TOKEN_ERROR_CODE, TOKEN_ERROR_MSG, null); | |
| 257 | +// } | |
| 258 | +// | |
| 259 | +// params.put("uid", getRequestString(uid)); | |
| 260 | +// params.put("clientPlat", getRequestString("a")); | |
| 261 | +// params.put("token", getRequestString(token)); | |
| 262 | +// params.put("access_token", getRequestString(access_token)); | |
| 263 | +// | |
| 264 | +// RequestBody requestFace = RequestBody.create(MediaType.parse("multipart/form-data"), face); | |
| 265 | +// MultipartBody.Part faceBody = MultipartBody.Part.createFormData("face", face.getName(), requestFace); | |
| 266 | +// | |
| 267 | +// List<MultipartBody.Part> parts = new ArrayList<>(); | |
| 268 | +// parts.add(faceBody); | |
| 269 | +// | |
| 270 | +// | |
| 271 | +// Subscriber<BaseInfo<FaceData>> subscriber = new Subscriber<BaseInfo<FaceData>>(context, ApiBaseSubscriber.subscriberBuild) { | |
| 272 | +// @Override | |
| 273 | +// public void onCompleted(String s, String s1, BaseInfo<FaceData> faceDataBaseInfo) { | |
| 274 | +// if (callback == null) return; | |
| 275 | +// callback.callback(SUCCESS, "", faceDataBaseInfo); | |
| 276 | +// } | |
| 277 | +// | |
| 278 | +// @Override | |
| 279 | +// public void onError(String s, String s1) { | |
| 280 | +// if (callback == null) return; | |
| 281 | +// int errorCode = -1; | |
| 282 | +// try { | |
| 283 | +// errorCode = Integer.valueOf(s); | |
| 284 | +// } catch (Exception ignored) { | |
| 285 | +// } finally { | |
| 286 | +// callback.callback(errorCode, s1, null); | |
| 287 | +// } | |
| 288 | +// } | |
| 289 | +// }; | |
| 290 | +// | |
| 291 | +// return ApiBaseRequest.subscribe(ApiBaseRequest.service(ApiBaseServiceOpen.class).updateUserFace(params, parts), subscriber); | |
| 292 | +//// return ApiBaseRequest.service(ApiBaseServiceOpen.class, service -> service.updateUserFace(params, parts)).subscribe(context, callback); | |
| 293 | +// } | |
| 294 | + | |
| 295 | + private static RequestBody getRequestString(String value) { | |
| 296 | + RequestBody requestString = RequestBody.create(MediaType.parse("text/plain"), value); | |
| 297 | + return requestString; | |
| 298 | + } | |
| 299 | + | |
| 300 | +// public static Disposable zipFiles(Context context, List<String> imageFiles, DataCallback<List<String>> callback) { | |
| 301 | +// if (imageFiles == null || imageFiles.size() == 0) { | |
| 302 | +// callback.callback(0, "", imageFiles); | |
| 303 | +// } else { | |
| 304 | +// return Flowable.just(imageFiles) | |
| 305 | +// .observeOn(Schedulers.io()) | |
| 306 | +// .map(list -> Luban.with(context) | |
| 307 | +// .ignoreBy(500) | |
| 308 | +// .setTargetDir(getPath()) | |
| 309 | +// .load(list) | |
| 310 | +// .get()) | |
| 311 | +// .observeOn(AndroidSchedulers.mainThread()) | |
| 312 | +// .doOnError(throwable -> callback.callback(0, "", imageFiles)) | |
| 313 | +// .onErrorResumeNext(Flowable.empty()) | |
| 314 | +// .subscribe( | |
| 315 | +// list -> { | |
| 316 | +// List<String> files = new ArrayList<>(); | |
| 317 | +// for (File file : list) files.add(file.getPath()); | |
| 318 | +// callback.callback(0, "", files); | |
| 319 | +// }); | |
| 320 | +// } | |
| 321 | +// return null; | |
| 322 | +// } | |
| 323 | + | |
| 324 | + private static String getPath() { | |
| 325 | + String path = Environment.getExternalStorageDirectory() + "/strike/image/"; | |
| 326 | + File file = new File(path); | |
| 327 | + if (file.mkdirs()) { | |
| 328 | + return path; | |
| 329 | + } | |
| 330 | + return path; | |
| 331 | + } | |
| 332 | + | |
| 333 | + | |
| 334 | +} | ... | ... |
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/FirstLoginPresenter.java
0 → 100644
| 1 | +package com.cnlive.strike.user.frame.presenter; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.text.TextUtils; | |
| 5 | + | |
| 6 | +import com.cnlive.core.libs.base.frame.presenter.BasePresenter; | |
| 7 | +import com.cnlive.core.network.BaseResult; | |
| 8 | +import com.cnlive.core.network.HttpConn; | |
| 9 | +import com.cnlive.core.network.NetCallBack; | |
| 10 | +import com.cnlive.strike.user.R; | |
| 11 | +import com.cnlive.strike.user.UserUtilAction; | |
| 12 | +import com.cnlive.strike.user.auth.UserService; | |
| 13 | +import com.cnlive.strike.user.frame.view.FirstLoginView; | |
| 14 | +import com.cnlive.strike.user.network.model.UserData; | |
| 15 | + | |
| 16 | +import java.io.File; | |
| 17 | + | |
| 18 | +import io.reactivex.ObservableSource; | |
| 19 | +import io.reactivex.functions.Function; | |
| 20 | + | |
| 21 | + | |
| 22 | +/** | |
| 23 | + * Created by xiansong on 2018/1/19. | |
| 24 | + */ | |
| 25 | + | |
| 26 | +public class FirstLoginPresenter extends BasePresenter<FirstLoginView> { | |
| 27 | + | |
| 28 | + public void loadUserInfo(Context context) { | |
| 29 | + UserService userService = UserService.getInstance(context); | |
| 30 | + if (userService != null && userService.getAppAccount() != null) { | |
| 31 | + String sid = UserService.getUid(context); | |
| 32 | + String token = userService.getAppAccount().getToken(); | |
| 33 | + HttpConn.action( | |
| 34 | + UserUtilAction.queryUserInfo(context, sid, sid, token) | |
| 35 | + , new NetCallBack<BaseResult<UserData>>() { | |
| 36 | + @Override | |
| 37 | + public void onRequestState(int state) { | |
| 38 | + | |
| 39 | + } | |
| 40 | + | |
| 41 | + @Override | |
| 42 | + public void onSuccess(BaseResult<UserData> data) { | |
| 43 | + userService.setUserInfo(data.getData()); | |
| 44 | + } | |
| 45 | + | |
| 46 | + @Override | |
| 47 | + public void onFailure(String errCode, String errMsg) { | |
| 48 | + | |
| 49 | + } | |
| 50 | + } | |
| 51 | + ); | |
| 52 | + } | |
| 53 | + } | |
| 54 | + | |
| 55 | + public void uploadName(Context context, String nickName) { | |
| 56 | + if (TextUtils.isEmpty(nickName)) { | |
| 57 | + if (getView() != null) | |
| 58 | + getView().showToast(context.getString(R.string.user_toast_edit_nickname_empty)); | |
| 59 | + return; | |
| 60 | + } | |
| 61 | + if (nickName.trim().length() == 0) { | |
| 62 | + if (getView() != null) | |
| 63 | + getView().showToast(context.getString(R.string.user_toast_edit_nickname_only_space)); | |
| 64 | + return; | |
| 65 | + } | |
| 66 | +// 请输入昵称(不支持表情符号) | |
| 67 | + UserService userService = UserService.getInstance(context); | |
| 68 | + String sid = UserService.getUid(context); | |
| 69 | + String token = userService.getAppAccount().getToken(); | |
| 70 | + HttpConn.action( | |
| 71 | + UserUtilAction.modifyUserInfo(context, sid, "nickName", nickName.trim().replaceAll("[\r\n]", ""), token) | |
| 72 | + .concatMap(new Function<BaseResult, ObservableSource<BaseResult<UserData>>>() { | |
| 73 | + @Override | |
| 74 | + public ObservableSource<BaseResult<UserData>> apply(BaseResult baseResult) throws Exception { | |
| 75 | + if (baseResult.isSuccess()) { | |
| 76 | + return UserUtilAction.queryUserInfo(context, sid, sid, token); | |
| 77 | + } | |
| 78 | + return HttpConn.error(baseResult); | |
| 79 | + } | |
| 80 | + }) | |
| 81 | + , new NetCallBack<BaseResult<UserData>>() { | |
| 82 | + @Override | |
| 83 | + public void onRequestState(int state) { | |
| 84 | + if (state == HttpConn.ON_START) { | |
| 85 | + ifViewAttached(view -> view.showProgress(R.string.upload_nickname_dialog)); | |
| 86 | + } else if (state == HttpConn.ON_END) { | |
| 87 | + ifViewAttached(view -> view.hideProgress()); | |
| 88 | + } | |
| 89 | + } | |
| 90 | + | |
| 91 | + @Override | |
| 92 | + public void onSuccess(BaseResult<UserData> data) { | |
| 93 | + userService.setUserInfo(data.getData()); | |
| 94 | + | |
| 95 | +// HelperUtil.modifyUserName(context, nickName); | |
| 96 | + userService.setUserNickName(nickName); | |
| 97 | + ifViewAttached(view -> view.showMainPage()); | |
| 98 | + } | |
| 99 | + | |
| 100 | + @Override | |
| 101 | + public void onFailure(String errCode, String errMsg) { | |
| 102 | + if ("8".equals(errCode) || "9".equals(errCode)) { | |
| 103 | +// UserOfflineUtil.userInvalid(context); | |
| 104 | +// HelperUtil.userInvalid(context); | |
| 105 | + } else if (errCode.equals(UserUtilAction.TOKEN_ERROR_CODE)) { | |
| 106 | + ifViewAttached(view -> view.showTokenErrorDialog()); | |
| 107 | + } else { | |
| 108 | + ifViewAttached(view -> view.showToast(errMsg)); | |
| 109 | + } | |
| 110 | + } | |
| 111 | + } | |
| 112 | + ); | |
| 113 | + } | |
| 114 | + | |
| 115 | +// public void uploadFile(Context context, String filePath) { | |
| 116 | +// if (updateFaceEvent != null) updateFaceEvent.cencel(); | |
| 117 | +// if (getView() == null) return; | |
| 118 | +// getView().showProgress(R.string.upload_image_dialog); | |
| 119 | +// File file = new File(filePath); | |
| 120 | +// UserService userService = UserService.getInstance(context); | |
| 121 | +// if (file.exists()) { | |
| 122 | +// | |
| 123 | +// updateFaceEvent = Logic.create() | |
| 124 | +// .action(UserUtilAction.accessToken(context)) | |
| 125 | +// .action((BaseInfo<TokenData> data, DataCallback<BaseInfo<FaceData>> callback) -> { | |
| 126 | +// UserUtilAction.updateUserFace(context, UserService.getUid(context), file, userService.getAppAccount().getToken(), data.getData().getAccess_token(), callback); | |
| 127 | +// return null; | |
| 128 | +// }) | |
| 129 | +// .<BaseInfo<FaceData>>event() | |
| 130 | +// .setStateCallback(state -> { | |
| 131 | +// if (getView() == null) return; | |
| 132 | +// if (state == STATE_LOAD) { | |
| 133 | +// | |
| 134 | +// } else if (state == STATE_IDLE) { | |
| 135 | +// getView().hideProgress(); | |
| 136 | +// } | |
| 137 | +// }) | |
| 138 | +// .setFailureCallback((state, message) -> { | |
| 139 | +// if (getView() == null) return; | |
| 140 | +// if (state == 8 || state == 9) { | |
| 141 | +//// UserOfflineUtil.userInvalid(context); | |
| 142 | +// HelperUtil.userInvalid(context); | |
| 143 | +// } else if (state == UserUtilAction.TOKEN_ERROR_CODE) { | |
| 144 | +// getView().showTokenErrorDialog(); | |
| 145 | +// } else { | |
| 146 | +// getView().showToast(message); | |
| 147 | +// } | |
| 148 | +// }) | |
| 149 | +// .setSuccessCallback(data -> { | |
| 150 | +// HelperUtil.modifyUserImage(context, data.getData().getFaceUrl()); | |
| 151 | +//// LoginManager.modifyUserImage( UserService.getUid(context), data.getData().getFaceUrl()); | |
| 152 | +// userService.setUserFaceUrl(data.getData().getFaceUrl(), data.getData().getBigFaceUrl()); | |
| 153 | +// if (getView() == null) return; | |
| 154 | +// getView().photoChange(data.getData().getFaceUrl()); | |
| 155 | +// }) | |
| 156 | +// .start(); | |
| 157 | +// } else { | |
| 158 | +// if (getView() != null) getView().showToast("文件不存在"); | |
| 159 | +// } | |
| 160 | +// } | |
| 161 | + | |
| 162 | +} | |
| 163 | + | ... | ... |
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.activity.FirstLoginActivity; | |
| 23 | +import com.cnlive.strike.user.ui.fragment.QuickLoginFragment; | |
| 24 | +import com.cnlive.strike.user.util.RegexUtils; | |
| 25 | +import com.cnlive.strike.user.util.TimeEvent; | |
| 26 | +import com.hannesdorfmann.mosby3.mvp.MvpActivity; | |
| 27 | + | |
| 28 | +import java.util.Arrays; | |
| 29 | +import java.util.Collections; | |
| 30 | + | |
| 31 | +import io.reactivex.disposables.Disposable; | |
| 32 | + | |
| 33 | + | |
| 34 | +/** | |
| 35 | + * @author Lynn | |
| 36 | + * @date 2017/12/22 | |
| 37 | + */ | |
| 38 | + | |
| 39 | +public class QuickLoginPresenter extends BasePresenter<QuickLoginView> { | |
| 40 | + private TimerUtil timerUtil; //计时工具类 | |
| 41 | + | |
| 42 | + // private Event<CNLiveUserInfo> event; | |
| 43 | + private Disposable sendMsgBefQuickLogin; | |
| 44 | +// private Event otherEvent; | |
| 45 | + | |
| 46 | + public void deleteUserInfo(Context context, String userName) { | |
| 47 | + UserService.getInstance(context).removeUser(userName, future -> { | |
| 48 | + if (getView() == null) return; | |
| 49 | + //获取已登录用户列表 | |
| 50 | + Account[] accounts = UserService.getInstance(context).getUserList(); | |
| 51 | + //倒序输出最近登录用户 | |
| 52 | + | |
| 53 | + Collections.reverse(Arrays.asList(accounts)); | |
| 54 | + getView().uploadListData(accounts); | |
| 55 | + }); | |
| 56 | + } | |
| 57 | + | |
| 58 | + public void init(Context context) { | |
| 59 | + if (getView() == null) return; | |
| 60 | + UserService us = UserService.getInstance(context); | |
| 61 | + //获取已登录用户列表 | |
| 62 | + Account[] accounts = us.getUserList(); | |
| 63 | + //倒序输出最近登录用户 | |
| 64 | + Collections.reverse(Arrays.asList(accounts)); | |
| 65 | + //获取最近登录用户数据 | |
| 66 | + Account account = accounts.length > 0 ? accounts[0] : null; | |
| 67 | + String name = account == null ? "" : account.name; | |
| 68 | + //页面填充数据 | |
| 69 | + if (!TextUtils.isEmpty(name)) { | |
| 70 | + getView().uploadInputData(name); | |
| 71 | + } | |
| 72 | + if (null != accounts) { | |
| 73 | + getView().uploadListData(accounts); | |
| 74 | + } | |
| 75 | + } | |
| 76 | + | |
| 77 | + private void startTimer() { | |
| 78 | + if (timerUtil != null) timerUtil.cancel(); | |
| 79 | + | |
| 80 | + timerUtil = new TimerUtil(); | |
| 81 | + timerUtil.setTotalTime(60_000);//设置毫秒数 | |
| 82 | + timerUtil.setIntervalTime(500);//设置间隔数 | |
| 83 | + timerUtil.start(); | |
| 84 | + timerUtil.setTimerLiener(new TimerUtil.TimeListener() { | |
| 85 | + @Override | |
| 86 | + public void onFinish() { | |
| 87 | + if (getView() != null) getView().onTimerFinish(); | |
| 88 | + } | |
| 89 | + | |
| 90 | + @Override | |
| 91 | + public void onInterval(long remainTime) { | |
| 92 | + if (getView() != null) getView().onTimerInterval(remainTime / 1000); | |
| 93 | + } | |
| 94 | + }); | |
| 95 | + } | |
| 96 | + | |
| 97 | + public void sendCode(Context context, String phone, String countryCode) { | |
| 98 | + if (getView() == null) return; | |
| 99 | + if (TimeEvent.debounce(2_000)) return; | |
| 100 | + if (TextUtils.isEmpty(phone)) { | |
| 101 | + getView().showToast(context.getString(R.string.user_toast_quick_login_empty_phone)); | |
| 102 | + return; | |
| 103 | + } | |
| 104 | + if ("86".equals(countryCode) && !RegexUtils.isMobileSimple(phone)) { | |
| 105 | + getView().showToast(context.getString(R.string.user_toast_quick_login_error_phone)); | |
| 106 | + return; | |
| 107 | + } | |
| 108 | + if (sendMsgBefQuickLogin != null && !sendMsgBefQuickLogin.isDisposed()) { | |
| 109 | + getView().showToast("处理中请稍后..."); | |
| 110 | + } else { | |
| 111 | + sendMsgBefQuickLogin = HttpConn.action(UserUtilAction.sendMsgBefQuickLoginAction(context, phone, countryCode), new NetCallBack<BaseResult>() { | |
| 112 | + @Override | |
| 113 | + public void onRequestState(int state) { | |
| 114 | + | |
| 115 | + } | |
| 116 | + | |
| 117 | + @Override | |
| 118 | + public void onSuccess(BaseResult data) { | |
| 119 | + startTimer(); | |
| 120 | + ifViewAttached(view -> view.showToast("验证码已发送")); | |
| 121 | + } | |
| 122 | + | |
| 123 | + @Override | |
| 124 | + public void onFailure(String errCode, String errMsg) { | |
| 125 | + ifViewAttached(view -> view.showToast(errMsg)); | |
| 126 | + | |
| 127 | + } | |
| 128 | + }); | |
| 129 | + } | |
| 130 | + } | |
| 131 | + | |
| 132 | + public void login(QuickLoginFragment context, QuickLoginData data, String countryCode) { | |
| 133 | + if (TextUtils.isEmpty(data.getPhone())) { | |
| 134 | + ifViewAttached(view -> view.showToast(context.getString(R.string.user_toast_quick_login_empty_phone))); | |
| 135 | + } else if (TextUtils.isEmpty(data.getCode())) { | |
| 136 | + ifViewAttached(view -> view.showToast(context.getString(R.string.user_toast_quick_login_empty_code))); | |
| 137 | + } else { | |
| 138 | + context.isLogin = true; | |
| 139 | +// UserAction.mobileLogin(context.getActivity(), data.getPhone(), data.getCode(), countryCode, initLoginEvent(context, true)); | |
| 140 | + UserAction.mobileLogin(context.getActivity(), data.getPhone(), data.getCode(), countryCode, new UserAction.CallBack() { | |
| 141 | + @Override | |
| 142 | + public void callback(int state, String msg, Object object) { | |
| 143 | + initLoginEvent(context, state, msg, true, null); | |
| 144 | + } | |
| 145 | + }); | |
| 146 | + | |
| 147 | + } | |
| 148 | + } | |
| 149 | + | |
| 150 | + private void initLoginEvent(QuickLoginFragment context, int state, String msg, Boolean retry, OtherUserInfo otherUserInfo) { | |
| 151 | + switch (state) { | |
| 152 | + //请求成功 | |
| 153 | + case 0: | |
| 154 | + CNLiveUserInfo user = UserService.getInstance(context.getActivity()).getAppAccount(); | |
| 155 | + if (user == null || (user != null && TextUtils.isEmpty(user.getToken()))) { | |
| 156 | + ifViewAttached(view -> view.showToast("用户登陆失败,再试一次吧.")); | |
| 157 | + } else if (user.isNewUser()) { | |
| 158 | + //是新用户 | |
| 159 | + //TODO 必须设置用户头像 | |
| 160 | + //OpenInstall用户注册统计 | |
| 161 | +// OpenInstall.reportRegister(); | |
| 162 | + //友盟账号登录统计,暂时只有平台登录,后续对接三方登录 | |
| 163 | +// MobclickAgent.onProfileSignIn("CNLive", user.getUid()); | |
| 164 | + //三方登陆不需要重新设置头像 otherUserInfo不为空表示三方登陆 | |
| 165 | + if (otherUserInfo != null) { | |
| 166 | + ifViewAttached(view -> view.showMainView(true, true)); | |
| 167 | + } else { | |
| 168 | + ifViewAttached(view -> view.showEditView(false)); | |
| 169 | + } | |
| 170 | + } else { | |
| 171 | + //友盟账号登录统计,暂时只有平台登录,后续对接三方登录 | |
| 172 | +// MobclickAgent.onProfileSignIn("CNLive", user.getUid()); | |
| 173 | +// ifViewAttached(view -> view.showMainView(false, false)); | |
| 174 | + //todo 测试首次用户 | |
| 175 | + ifViewAttached(view -> view.showEditView(false)); | |
| 176 | + } | |
| 177 | + AppConfig.setCountryCode(""); | |
| 178 | + AppConfig.setVerificationCode(""); | |
| 179 | + AppConfig.setUserPhone(""); | |
| 180 | + context.hasLogin = true; | |
| 181 | + if (context != null) { | |
| 182 | + context.isLogin = false; | |
| 183 | + } | |
| 184 | + break; | |
| 185 | + case HttpConn.ON_START: | |
| 186 | + ifViewAttached(view -> view.showProgress()); | |
| 187 | + break; | |
| 188 | + case HttpConn.ON_END: | |
| 189 | + ifViewAttached(view -> view.hideProgress()); | |
| 190 | + break; | |
| 191 | + case 41010: //手机号无效 | |
| 192 | + ifViewAttached(view -> view.showToast(msg)); | |
| 193 | + break; | |
| 194 | + case 41002: //验证码为6位数字 | |
| 195 | + ifViewAttached(view -> view.showToast(msg)); | |
| 196 | + break; | |
| 197 | + case 41009: //验证码错误 | |
| 198 | + ifViewAttached(view -> view.showToast(msg)); | |
| 199 | + break; | |
| 200 | + case 41006: //手机号已存在 | |
| 201 | + ifViewAttached(view -> view.showToast(msg)); | |
| 202 | + break; | |
| 203 | + case 42013: //此帐号未注册,请先注册 | |
| 204 | + ifViewAttached(view -> view.bindPhone(otherUserInfo)); | |
| 205 | + break; | |
| 206 | + case 6208: //当前用户在其他地点登陆 | |
| 207 | + if (retry) { | |
| 208 | + if (otherUserInfo == null) { | |
| 209 | + UserAction.mobileLogin(context.getActivity(), context.data.getPhone(), context.data.getCode(), "", new UserAction.CallBack() { | |
| 210 | + @Override | |
| 211 | + public void callback(int state, String msg, Object object) { | |
| 212 | + initLoginEvent(context, state, msg, false, null); | |
| 213 | + } | |
| 214 | + }); | |
| 215 | + } | |
| 216 | + return; | |
| 217 | + } else { | |
| 218 | + ifViewAttached(view -> view.showToast("用户登录失败,再试一次吧.")); | |
| 219 | + } | |
| 220 | + break; | |
| 221 | + default: //其他错误 | |
| 222 | + ifViewAttached(view -> view.showToast(msg)); | |
| 223 | + break; | |
| 224 | + } | |
| 225 | + } | |
| 226 | + | |
| 227 | +// private void initLoginEvent(QuickLoginFragment context, Boolean retry) { | |
| 228 | +// return initLoginEvent(context, retry, null); | |
| 229 | +// } | |
| 230 | + | |
| 231 | + | |
| 232 | +// | |
| 233 | +// private Event<CNLiveUserInfo> initLoginEvent(QuickLoginFragment context, Boolean retry, OtherUserInfo otherUserInfo) { | |
| 234 | +// return event = new Event<CNLiveUserInfo>() | |
| 235 | +// .setStateCallback(state -> { | |
| 236 | +// if (state == Config.STATE_LOAD) getView().showProgress(); | |
| 237 | +// else getView().hideProgress(); | |
| 238 | +// }).setFailureCallback((state, message) -> { | |
| 239 | +// if (context == null) return; | |
| 240 | +// if (getView() == null) return; | |
| 241 | +// switch (state) { | |
| 242 | +// case 41010: //手机号无效 | |
| 243 | +// getView().showToast(message); | |
| 244 | +// break; | |
| 245 | +// case 41002: //验证码为6位数字 | |
| 246 | +// getView().showToast(message); | |
| 247 | +// break; | |
| 248 | +// case 41009: //验证码错误 | |
| 249 | +// getView().showToast(message); | |
| 250 | +// break; | |
| 251 | +// case 41006: //手机号已存在 | |
| 252 | +// getView().showToast(message); | |
| 253 | +// break; | |
| 254 | +// case 42013: //此帐号未注册,请先注册 | |
| 255 | +// getView().bindPhone(otherUserInfo); | |
| 256 | +// break; | |
| 257 | +// case 6208: //当前用户在其他地点登陆 | |
| 258 | +// if (retry) { | |
| 259 | +// if (otherUserInfo == null) { | |
| 260 | +// UserAction.mobileLogin(context.getActivity(), context.data.getPhone(), context.data.getCode(), "", initLoginEvent(context, false)); | |
| 261 | +// } | |
| 262 | +// return; | |
| 263 | +// } else getView().showToast("用户登录失败,再试一次吧."); | |
| 264 | +// break; | |
| 265 | +// default: //其他错误 | |
| 266 | +// getView().showToast(message); | |
| 267 | +// break; | |
| 268 | +// } | |
| 269 | +// context.hasLogin = false; | |
| 270 | +// if (context != null) context.isLogin = false; | |
| 271 | +// }).setSuccessCallback((info) -> { | |
| 272 | +// if (context == null) return; | |
| 273 | +// if (getView() == null) return; | |
| 274 | +// CNLiveUserInfo user = UserService.getInstance(context.getActivity()).getAppAccount(); | |
| 275 | +// if (user == null || (user != null && TextUtils.isEmpty(user.getToken()))) { | |
| 276 | +// getView().showToast("用户登陆失败,再试一次吧."); | |
| 277 | +// } else if (user.isNewUser()) { | |
| 278 | +// //是新用户 | |
| 279 | +// //TODO 必须设置用户头像 | |
| 280 | +// //OpenInstall用户注册统计 | |
| 281 | +//// OpenInstall.reportRegister(); | |
| 282 | +// //友盟账号登录统计,暂时只有平台登录,后续对接三方登录 | |
| 283 | +//// MobclickAgent.onProfileSignIn("CNLive", user.getUid()); | |
| 284 | +// //三方登陆不需要重新设置头像 otherUserInfo不为空表示三方登陆 | |
| 285 | +// if (otherUserInfo != null) { | |
| 286 | +// getView().showMainView(true, true); | |
| 287 | +// } else { | |
| 288 | +// getView().showEditView(false); | |
| 289 | +// } | |
| 290 | +// | |
| 291 | +// } else { | |
| 292 | +// //友盟账号登录统计,暂时只有平台登录,后续对接三方登录 | |
| 293 | +//// MobclickAgent.onProfileSignIn("CNLive", user.getUid()); | |
| 294 | +// getView().showMainView(false, false); | |
| 295 | +// } | |
| 296 | +// AppConfig.setCountryCode(""); | |
| 297 | +// AppConfig.setVerificationCode(""); | |
| 298 | +// AppConfig.setUserPhone(""); | |
| 299 | +// context.hasLogin = true; | |
| 300 | +// if (context != null) context.isLogin = false; | |
| 301 | +// }).setCancelCallback(() -> { | |
| 302 | +// //取消操作可能被触发多次 ,根据页面逻辑选择使用 | |
| 303 | +// context.hasLogin = false; | |
| 304 | +// if (context != null) context.isLogin = false; | |
| 305 | +// }); | |
| 306 | +// } | |
| 307 | + | |
| 308 | +} | ... | ... |
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/FirstLoginView.java
0 → 100644
| 1 | +package com.cnlive.strike.user.frame.view; | |
| 2 | + | |
| 3 | +import android.app.Activity; | |
| 4 | +import android.content.Context; | |
| 5 | +import android.content.Intent; | |
| 6 | +import android.text.TextUtils; | |
| 7 | + | |
| 8 | +import com.cnlive.core.libs.base.frame.view.BaseView; | |
| 9 | +import com.cnlive.core.libs.base.util.AlertUtil; | |
| 10 | +import com.cnlive.core.libs.base.util.GlideUtil; | |
| 11 | +import com.cnlive.strike.user.R; | |
| 12 | +import com.cnlive.strike.user.model.LoginSuccessInfo; | |
| 13 | +import com.cnlive.strike.user.model.msg.UserEventMsg; | |
| 14 | +import com.cnlive.strike.user.ui.activity.FirstLoginActivity; | |
| 15 | +import com.cnlive.strike.user.ui.fragment.FirstLoginFragment; | |
| 16 | +import com.cnlive.strike.user.ui.widget.TokenErrorDialog; | |
| 17 | + | |
| 18 | +import org.greenrobot.eventbus.EventBus; | |
| 19 | + | |
| 20 | +/** | |
| 21 | + * Created by xiansong on 2018/1/19. | |
| 22 | + */ | |
| 23 | + | |
| 24 | +public class FirstLoginView extends BaseView { | |
| 25 | + private FirstLoginFragment fragment; | |
| 26 | + | |
| 27 | + public FirstLoginView(FirstLoginFragment fragment) { | |
| 28 | + this.fragment = fragment; | |
| 29 | + } | |
| 30 | + | |
| 31 | + private Activity getContext() { | |
| 32 | + return fragment.getActivity(); | |
| 33 | + } | |
| 34 | + | |
| 35 | + public void showToast(String msg) { | |
| 36 | + if (getContext() == null) return; | |
| 37 | + Context context = getContext(); | |
| 38 | + AlertUtil.showDeftToast(context, msg); | |
| 39 | + } | |
| 40 | + | |
| 41 | + public void showProgress(int stringId) { | |
| 42 | + if (!fragment.mProgressDialog.isShowing()) { | |
| 43 | + String tag = getContext().getString(stringId); | |
| 44 | + fragment.mProgressDialog.setMessage(tag); | |
| 45 | + fragment.mProgressDialog.show(); | |
| 46 | + } | |
| 47 | + } | |
| 48 | + | |
| 49 | + public void hideProgress() { | |
| 50 | + if (fragment.mProgressDialog.isShowing()) fragment.mProgressDialog.dismiss(); | |
| 51 | + } | |
| 52 | + | |
| 53 | + public void photoChange(String faceUrl) { | |
| 54 | + if (getContext() == null) return; | |
| 55 | + GlideUtil.init(fragment, faceUrl).error(R.drawable.touxiang_circle).circleCrop().into(fragment.binding.ivUserIcon); | |
| 56 | + } | |
| 57 | + | |
| 58 | + public void showMainPage() { | |
| 59 | + if (getContext() == null) return; | |
| 60 | + //设置跳转信息 | |
| 61 | + LoginSuccessInfo successInfo = new LoginSuccessInfo(); | |
| 62 | + successInfo.setClickAd(fragment.clickAd); | |
| 63 | + successInfo.setTagMsg(fragment.tagMsg); | |
| 64 | + EventBus.getDefault().post(new UserEventMsg(UserEventMsg.LOGIN_SUCCESS, successInfo)); | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | +// Intent intent = new Intent(getContext(), MainTestActivity.class); | |
| 69 | +// if (!TextUtils.isEmpty(fragment.tagMsg)) | |
| 70 | +// intent.putExtra("classifyTagMsg", fragment.tagMsg); | |
| 71 | +// | |
| 72 | +// intent.putExtra(FirstLoginActivity.TAG_CLICK_AD, fragment.clickAd); | |
| 73 | +// getContext().startActivity(intent); | |
| 74 | +// getContext().finish(); | |
| 75 | + } | |
| 76 | + | |
| 77 | + public void showTokenErrorDialog() { | |
| 78 | + if (fragment.tokenErrorDialog != null) | |
| 79 | + fragment.tokenErrorDialog.dismiss(); | |
| 80 | + fragment.tokenErrorDialog = TokenErrorDialog.showTokenErrorDialog(fragment.getActivity()); | |
| 81 | + } | |
| 82 | + | |
| 83 | + | |
| 84 | +} | ... | ... |
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.content.Intent; | |
| 7 | +import android.text.Editable; | |
| 8 | +import android.text.Spannable; | |
| 9 | +import android.text.SpannableStringBuilder; | |
| 10 | +import android.text.TextPaint; | |
| 11 | +import android.text.TextUtils; | |
| 12 | +import android.text.TextWatcher; | |
| 13 | +import android.text.method.LinkMovementMethod; | |
| 14 | +import android.text.style.ClickableSpan; | |
| 15 | +import android.text.style.ForegroundColorSpan; | |
| 16 | +import android.view.View; | |
| 17 | + | |
| 18 | +import com.alibaba.android.arouter.launcher.ARouter; | |
| 19 | +import com.cnlive.core.libs.base.application.AppConfig; | |
| 20 | +import com.cnlive.core.libs.base.frame.view.BaseView; | |
| 21 | +import com.cnlive.core.libs.base.util.AlertUtil; | |
| 22 | +import com.cnlive.core.libs.base.util.DoublePressed; | |
| 23 | +import com.cnlive.strike.user.R; | |
| 24 | +import com.cnlive.strike.user.frame.data.OtherUserInfo; | |
| 25 | +import com.cnlive.strike.user.model.LoginSuccessInfo; | |
| 26 | +import com.cnlive.strike.user.sms.OnSmsCatchListener; | |
| 27 | +import com.cnlive.strike.user.sms.SmsVerifyCatcher; | |
| 28 | +import com.cnlive.strike.user.ui.activity.FirstLoginActivity; | |
| 29 | +import com.cnlive.strike.user.ui.activity.LoginActivity; | |
| 30 | +import com.cnlive.strike.user.ui.fragment.QuickLoginFragment; | |
| 31 | + | |
| 32 | +import java.util.regex.Matcher; | |
| 33 | +import java.util.regex.Pattern; | |
| 34 | + | |
| 35 | +/** | |
| 36 | + * @author Lynn | |
| 37 | + * @date 2017/12/22 | |
| 38 | + */ | |
| 39 | + | |
| 40 | +public class QuickLoginView extends BaseView { | |
| 41 | + | |
| 42 | + private QuickLoginFragment fragment; | |
| 43 | + | |
| 44 | + public QuickLoginView(QuickLoginFragment fragment) { | |
| 45 | + this.fragment = fragment; | |
| 46 | + } | |
| 47 | + | |
| 48 | + public Activity getContext() { | |
| 49 | + return fragment.getActivity(); | |
| 50 | + } | |
| 51 | + | |
| 52 | + /** | |
| 53 | + * 更新用户信息点击事件 | |
| 54 | + */ | |
| 55 | + public void onUploadLoginUser(String name) { | |
| 56 | + uploadInputData(name); | |
| 57 | + } | |
| 58 | + | |
| 59 | + | |
| 60 | + /** | |
| 61 | + * 删除用户记录 | |
| 62 | + */ | |
| 63 | + public void onDeleteLoginUser(String name) { | |
| 64 | + fragment.getPresenter().deleteUserInfo(getContext(), name); | |
| 65 | + } | |
| 66 | + | |
| 67 | + //更新输入信息 | |
| 68 | + public void uploadInputData(String phone) { | |
| 69 | + fragment.data.setPhone(phone); | |
| 70 | + if (!TextUtils.isEmpty(phone)) { | |
| 71 | + fragment.binding.ivDelete.setVisibility(View.VISIBLE); | |
| 72 | + } | |
| 73 | + fragment.data.setCode(""); | |
| 74 | + //通过DataBinding更新文字后无法立即设置光标位置 | |
| 75 | + if (!TextUtils.isEmpty(phone)) { | |
| 76 | + fragment.binding.userName.setText(phone); | |
| 77 | + fragment.binding.userName.setSelection(phone.length()); | |
| 78 | + } | |
| 79 | + String contryCode = AppConfig.getCountryCode(); | |
| 80 | + //设置区号 | |
| 81 | +// CNLiveUserInfo userInfo = UserService.getInstance(fragment.getActivity()).getAppAccount(); | |
| 82 | + if (!TextUtils.isEmpty(contryCode)) { | |
| 83 | + fragment.binding.tvCountry.setText("+ " + contryCode); | |
| 84 | + } else { | |
| 85 | + fragment.binding.tvCountry.setText("+ " + "86"); | |
| 86 | + } | |
| 87 | + String contryName = AppConfig.getCountryName(); | |
| 88 | + if (TextUtils.isEmpty(contryName)) { | |
| 89 | + fragment.binding.tvCountryName.setText("中国"); | |
| 90 | + } else { | |
| 91 | + fragment.binding.tvCountryName.setText(contryName); | |
| 92 | + } | |
| 93 | + | |
| 94 | + | |
| 95 | + } | |
| 96 | + | |
| 97 | + public void uploadInputData(String phone, String countryCode, String verficatinCode) { | |
| 98 | + fragment.data.setPhone(phone); | |
| 99 | + if (!TextUtils.isEmpty(phone)) { | |
| 100 | + fragment.binding.ivDelete.setVisibility(View.VISIBLE); | |
| 101 | + } | |
| 102 | +// fragment.data.setCode(TextUtils.isEmpty(verficatinCode) ? "" : verficatinCode); | |
| 103 | + //通过DataBinding更新文字后无法立即设置光标位置 | |
| 104 | + if (!TextUtils.isEmpty(phone)) { | |
| 105 | + fragment.binding.userName.setText(phone); | |
| 106 | + fragment.binding.userName.setSelection(phone.length()); | |
| 107 | + } | |
| 108 | + | |
| 109 | + //设置区号 | |
| 110 | +// CNLiveUserInfo userInfo = UserService.getInstance(fragment.getActivity()).getAppAccount(); | |
| 111 | +// if (userInfo != null && !TextUtils.isEmpty(userInfo.getCountryCode())) { | |
| 112 | +// fragment.rootBinding.tvCountry.setText("+ " + userInfo.getCountryCode()); | |
| 113 | +// } else { | |
| 114 | +// fragment.rootBinding.tvCountry.setText("+ " + "86"); | |
| 115 | +// } | |
| 116 | + fragment.binding.tvCountry.setText("+ ".concat(TextUtils.isEmpty(countryCode) ? "86" : countryCode)); | |
| 117 | + | |
| 118 | + } | |
| 119 | + | |
| 120 | + public void initView() { | |
| 121 | + if (fragment == null) return; | |
| 122 | + fragment.smsVerifyCatcher = new SmsVerifyCatcher(fragment.getActivity(), new OnSmsCatchListener<String>() { | |
| 123 | + @Override | |
| 124 | + public void onSmsCatch(String message) { | |
| 125 | + String code = parseCode(message); | |
| 126 | + fragment.binding.etSms.setText(code); | |
| 127 | + } | |
| 128 | + }); | |
| 129 | + fragment.binding.userName.addTextChangedListener(new TextWatcher() { | |
| 130 | + @Override | |
| 131 | + public void beforeTextChanged(CharSequence s, int start, int count, int after) { | |
| 132 | + } | |
| 133 | + | |
| 134 | + @Override | |
| 135 | + public void onTextChanged(CharSequence s, int start, int before, int count) { | |
| 136 | + } | |
| 137 | + | |
| 138 | + @Override | |
| 139 | + public void afterTextChanged(Editable s) { | |
| 140 | + if (s.length() > 0) { | |
| 141 | + fragment.binding.ivDelete.setVisibility(View.VISIBLE); | |
| 142 | + } else { | |
| 143 | + fragment.binding.ivDelete.setVisibility(View.GONE); | |
| 144 | + } | |
| 145 | + } | |
| 146 | + }); | |
| 147 | + | |
| 148 | + fragment.binding.etSms.addTextChangedListener(new TextWatcher() { | |
| 149 | + @Override | |
| 150 | + public void beforeTextChanged(CharSequence s, int start, int count, int after) { | |
| 151 | + } | |
| 152 | + | |
| 153 | + @Override | |
| 154 | + public void onTextChanged(CharSequence s, int start, int before, int count) { | |
| 155 | + } | |
| 156 | + | |
| 157 | + @Override | |
| 158 | + public void afterTextChanged(Editable s) { | |
| 159 | + if (s.length() > 0) { | |
| 160 | + fragment.binding.ivDeleteYzm.setVisibility(View.VISIBLE); | |
| 161 | + } else { | |
| 162 | + fragment.binding.ivDeleteYzm.setVisibility(View.GONE); | |
| 163 | + } | |
| 164 | + } | |
| 165 | + }); | |
| 166 | + | |
| 167 | + | |
| 168 | + } | |
| 169 | + | |
| 170 | + //更新用户列表 | |
| 171 | + public void uploadListData(Account[] list) { | |
| 172 | + fragment.adapter.clear(); | |
| 173 | + if (list.length > 0) fragment.adapter.addAll(list); | |
| 174 | + } | |
| 175 | + | |
| 176 | + public void showToast(String msg) { | |
| 177 | + if (getContext() == null) return; | |
| 178 | + Context context = getContext(); | |
| 179 | + AlertUtil.showDeftToast(context, msg); | |
| 180 | + } | |
| 181 | + | |
| 182 | + | |
| 183 | + public void showEditView(boolean isHasOtherUserInfo) { | |
| 184 | + if (getContext() == null) return; | |
| 185 | + //设置跳转信息 | |
| 186 | +// LoginSuccessInfo successInfo = new LoginSuccessInfo(); | |
| 187 | +// successInfo.setTagMsg(TextUtils.isEmpty(fragment.tagMsg) ? "" : fragment.tagMsg); | |
| 188 | +// successInfo.setClickAd(fragment.clickAd); | |
| 189 | +// HelperUtil.isNewUser(fragment.getActivity(), successInfo, isHasOtherUserInfo); | |
| 190 | + | |
| 191 | + Intent intent = new Intent(getContext(), FirstLoginActivity.class); | |
| 192 | + intent.putExtra(LoginActivity.TAG_MSG, TextUtils.isEmpty(fragment.tagMsg) ? "" : fragment.tagMsg); | |
| 193 | + intent.putExtra(LoginActivity.TAG_CLICK_AD, fragment.clickAd); | |
| 194 | + getContext().startActivity(intent); | |
| 195 | + getContext().finish(); | |
| 196 | + } | |
| 197 | + | |
| 198 | + public void showMainView(boolean isNewUser, boolean isHasOtherUserInfo) { | |
| 199 | + if (getContext() == null) return; | |
| 200 | + //判断如果是因为token为空跳转到的登录页面则不需要跳转到MainActivity,直接关闭登录页面即可 | |
| 201 | + if (fragment.fromTokenError) { | |
| 202 | + fragment.getActivity().finish(); | |
| 203 | + return; | |
| 204 | + } | |
| 205 | + //设置跳转信息 | |
| 206 | + LoginSuccessInfo successInfo = new LoginSuccessInfo(); | |
| 207 | + successInfo.setType("login"); | |
| 208 | + successInfo.setUri(fragment.uri); | |
| 209 | + successInfo.setClickAd(fragment.clickAd); | |
| 210 | + successInfo.setTagShare(fragment.tagShare); | |
| 211 | + successInfo.setTagMsg(fragment.tagMsg); | |
| 212 | + if (isNewUser) { | |
| 213 | +// HelperUtil.isNewUser(fragment.getActivity(), successInfo, isHasOtherUserInfo); | |
| 214 | + } else { | |
| 215 | +// HelperUtil.isNotNewUser(fragment.getActivity(), successInfo); | |
| 216 | + } | |
| 217 | +// EventBus.getDefault().post(new UserEventMsg(UserEventMsg.LOGIN_SUCCESS, successInfo)); | |
| 218 | +// Intent intent = new Intent(getContext(), MainTestActivity.class); | |
| 219 | +// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); | |
| 220 | +// intent.putExtra("type", "login"); | |
| 221 | +// intent.putExtra("uri", fragment.uri); | |
| 222 | +// intent.putExtra(LoginActivity.TAG_CLICK_AD, fragment.clickAd); | |
| 223 | +// intent.putExtra("sharetype", fragment.tagShare); | |
| 224 | +// if (!TextUtils.isEmpty(fragment.tagMsg)) | |
| 225 | +// intent.putExtra("classifyTagMsg", fragment.tagMsg); | |
| 226 | +// getContext().startActivity(intent); | |
| 227 | + } | |
| 228 | + | |
| 229 | + public void showProgress() { | |
| 230 | + if (!fragment.mProgressDialog.isShowing()) fragment.mProgressDialog.show(); | |
| 231 | + } | |
| 232 | + | |
| 233 | + public void hideProgress() { | |
| 234 | + if (fragment.mProgressDialog.isShowing()) { | |
| 235 | + fragment.isLogin = false; | |
| 236 | + fragment.mProgressDialog.dismiss(); | |
| 237 | + } | |
| 238 | + } | |
| 239 | + | |
| 240 | + public void onTimerFinish() { | |
| 241 | + fragment.data.setTime(0); | |
| 242 | + fragment.binding.codeRequest.setTextColor(fragment.getActivity().getResources().getColor(R.color.white)); | |
| 243 | + } | |
| 244 | + | |
| 245 | + public void onTimerInterval(long l) { | |
| 246 | + fragment.data.setTime((int) l); | |
| 247 | + fragment.binding.codeRequest.setTextColor(fragment.getActivity().getResources().getColor(R.color.color_f2f2f2)); | |
| 248 | + } | |
| 249 | + | |
| 250 | + public void setAgreementText() { | |
| 251 | + String textContent = "登录即代表阅读并同意《用户协议》 及 《隐私政策》"; | |
| 252 | + SpannableStringBuilder ssb = new SpannableStringBuilder(textContent); | |
| 253 | + ssb.setSpan(new ClickableSpan() { | |
| 254 | + @Override | |
| 255 | + public void onClick(View widget) { | |
| 256 | + if (!fragment.isLogin) { | |
| 257 | + startWebView("yhxy"); | |
| 258 | + } | |
| 259 | + } | |
| 260 | + | |
| 261 | + @Override | |
| 262 | + public void updateDrawState(TextPaint ds) { | |
| 263 | + ds.setUnderlineText(false); | |
| 264 | + } | |
| 265 | + }, 11, 15, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); | |
| 266 | + | |
| 267 | + ssb.setSpan(new ClickableSpan() { | |
| 268 | + @Override | |
| 269 | + public void onClick(View widget) { | |
| 270 | + if (!fragment.isLogin) { | |
| 271 | + startWebView("yszc"); | |
| 272 | + } | |
| 273 | + } | |
| 274 | + | |
| 275 | + @Override | |
| 276 | + public void updateDrawState(TextPaint ds) { | |
| 277 | + ds.setUnderlineText(false); | |
| 278 | + } | |
| 279 | + }, 20, 24, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); | |
| 280 | + | |
| 281 | + ssb.setSpan(new ForegroundColorSpan(fragment.getResources().getColor(R.color.color_23d41e)), 11, 15, Spannable.SPAN_EXCLUSIVE_INCLUSIVE); | |
| 282 | + ssb.setSpan(new ForegroundColorSpan(fragment.getResources().getColor(R.color.color_23d41e)), 20, 24, Spannable.SPAN_EXCLUSIVE_INCLUSIVE); | |
| 283 | + fragment.binding.tvAgreement.setMovementMethod(LinkMovementMethod.getInstance()); | |
| 284 | + fragment.binding.tvAgreement.setText(ssb); | |
| 285 | + } | |
| 286 | + | |
| 287 | + private void startWebView(String type) { | |
| 288 | +// WWebView wWebView = new WWebView.Builder() | |
| 289 | +// .urlType(type) | |
| 290 | +// .isOther(true) | |
| 291 | +// .enableJump(true) | |
| 292 | +// .enableRefresh(false) | |
| 293 | +// .enableImageLongClick(false) | |
| 294 | +// .builder(); | |
| 295 | +// wWebView.startWebViewActivity(fragment.getActivity()); | |
| 296 | + | |
| 297 | + | |
| 298 | + ARouter.getInstance().build("/web/WebViewActivity") | |
| 299 | + .withString("rUrlType", type) | |
| 300 | + .withBoolean("rIsOther", true) | |
| 301 | + .withBoolean("rEnableJump", true) | |
| 302 | + .withBoolean("rEnableRefresh", false) | |
| 303 | + .withBoolean("rEnableImageLongClick", false) | |
| 304 | + .navigation(fragment.getActivity()); | |
| 305 | + } | |
| 306 | + | |
| 307 | + public void startWeb() { | |
| 308 | + if (fragment == null) return; | |
| 309 | + //浏览入口 | |
| 310 | + if (DoublePressed.onDoublePressed()) return; | |
| 311 | +// WWebView wWebView = new WWebView.Builder() | |
| 312 | +// // TODO: 2018/12/28 浏览页面h5地址 | |
| 313 | +// .url(AppConfig.isDebug() ? "http://wjjh5test.cnlive.com/cnLogoutPreview.html" : "http://wjjh5.cnlive.com/cnLogoutPreview.html") | |
| 314 | +// .enableTitleLayout(false) | |
| 315 | +// .enableTitle(false) | |
| 316 | +// .enableJump(true) | |
| 317 | +// .enableImageLongClick(false) | |
| 318 | +// .enableClose(false) | |
| 319 | +// .enableRefresh(false) | |
| 320 | +// .from(WWebViewOptions.FROM_PRE_BROWSE) | |
| 321 | +// .builder(); | |
| 322 | +// wWebView.startWebViewActivity(fragment.getActivity()); | |
| 323 | + | |
| 324 | + | |
| 325 | + ARouter.getInstance().build("/web/WebViewActivity") | |
| 326 | +// .withString("rSid", uid == null ? "" : uid) | |
| 327 | + .withString("rUrl", AppConfig.isDebug() ? "http://wjjh5test.cnlive.com/cnLogoutPreview.html" : "http://wjjh5.cnlive.com/cnLogoutPreview.html") | |
| 328 | + .withBoolean("rEnableTitle", false) | |
| 329 | + .withBoolean("enableMore", false) | |
| 330 | + .withBoolean("rEnableJump", true) | |
| 331 | + .withBoolean("rNeedSign", false) | |
| 332 | + .withBoolean("rEnableRefresh", false) | |
| 333 | + .withBoolean("rEnableClose", false) | |
| 334 | + .withBoolean("rEnableTitleLayout", false) | |
| 335 | + .navigation(fragment.getActivity()); | |
| 336 | + | |
| 337 | + | |
| 338 | + } | |
| 339 | + | |
| 340 | + | |
| 341 | + private String parseCode(String message) { | |
| 342 | + Pattern p = Pattern.compile("\\b\\d{6}\\b"); | |
| 343 | + Matcher m = p.matcher(message); | |
| 344 | + String code = ""; | |
| 345 | + while (m.find()) { | |
| 346 | + code = m.group(0); | |
| 347 | + } | |
| 348 | + return code; | |
| 349 | + } | |
| 350 | + | |
| 351 | + public void bindPhone(OtherUserInfo otherUserInfo) { | |
| 352 | + if (fragment == null) return; | |
| 353 | +// BindPhoneNumberActivity.startActivity(fragment.getActivity(), | |
| 354 | +// otherUserInfo, fragment.fromTokenError, fragment.tagMsg, fragment.tagShare, fragment.clickAd); | |
| 355 | + } | |
| 356 | + | |
| 357 | +} | ... | ... |
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
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
cloud/user/src/main/java/com/cnlive/strike/user/model/WalletInfo.java
0 → 100644
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 | +} | ... | ... |