Commit 182c6c1a3947e9b42434a62a5c2ebd52a8c3db17
1 parent
c7ad6817
1 优化基类
2 重构视频库 3 优化网络请求库
Showing
12 changed files
with
452 additions
and
48 deletions
app/strike/src/main/java/com/cnlive/strike/demo/activity/CNplayerActivity.java
| 1 | 1 | package com.cnlive.strike.demo.activity; |
| 2 | 2 | |
| 3 | +import android.content.Intent; | |
| 4 | + | |
| 3 | 5 | import androidx.databinding.ViewDataBinding; |
| 4 | 6 | |
| 5 | 7 | import com.cnlive.cloud.BuildConfig; |
| ... | ... | @@ -9,6 +11,7 @@ import com.cnlive.cloud.user.auth.UserService; |
| 9 | 11 | import com.cnlive.core.libs.base.frame.activity.BaseActivity; |
| 10 | 12 | import com.cnlive.core.libs.base.util.AlertUtil; |
| 11 | 13 | import com.cnlive.core.libs.base.util.ChannelUtil; |
| 14 | +import com.cnlive.core.libs.base.util.QMUITipDialogUtil; | |
| 12 | 15 | import com.libs.video.util.Config; |
| 13 | 16 | import com.libs.video.util.ProbeUtil; |
| 14 | 17 | import com.libs.video.video.VideoView; |
| ... | ... | @@ -18,6 +21,7 @@ public class CNplayerActivity extends BaseActivity implements IMediaPlayer.OnPre |
| 18 | 21 | IMediaPlayer.OnCompletionListener, IMediaPlayer.OnErrorListener, IMediaPlayer.OnInfoListener, |
| 19 | 22 | IMediaPlayer.OnPlayStateListener { |
| 20 | 23 | private ActivityCnvideoBinding binding; |
| 24 | + private String type = "0"; | |
| 21 | 25 | |
| 22 | 26 | @Override |
| 23 | 27 | protected int getBindLayoutId() { |
| ... | ... | @@ -30,10 +34,15 @@ public class CNplayerActivity extends BaseActivity implements IMediaPlayer.OnPre |
| 30 | 34 | } |
| 31 | 35 | |
| 32 | 36 | @Override |
| 37 | + protected void initParams(Intent params) { | |
| 38 | + super.initParams(params); | |
| 39 | + type = params.getStringExtra("type"); | |
| 40 | + } | |
| 41 | + | |
| 42 | + @Override | |
| 33 | 43 | protected void initView() { |
| 34 | 44 | //视讯云配置单 |
| 35 | - ProbeUtil.setSid(UserService.getUid(me)); | |
| 36 | - | |
| 45 | +// ProbeUtil.setSid(UserService.getUid(me)); | |
| 37 | 46 | Config.setFromId(ChannelUtil.getChannelFromApk(this)); |
| 38 | 47 | Config.init(this, BuildConfig.APP_ID, BuildConfig.APP_KEY); |
| 39 | 48 | binding.videoview.setOnPreparedListener(this); |
| ... | ... | @@ -41,14 +50,33 @@ public class CNplayerActivity extends BaseActivity implements IMediaPlayer.OnPre |
| 41 | 50 | binding.videoview.setOnPlayStateListener(this); |
| 42 | 51 | binding.videoview.setOnErrorListener(this); |
| 43 | 52 | binding.videoview.setOnInfoListener(this); |
| 44 | - binding.videoview.setDataSource(new DataSource("223_88c98ab1395f4762b703fbdd9d59d2e5", Config.TYPE_VOD, Config.TYPE_PLAY_RATE_2)); | |
| 45 | - binding.videoview.setMirror(true); | |
| 53 | + if ("0".equals(type)) { | |
| 54 | + QMUITipDialogUtil.loadingDialog(me,"点播"); | |
| 55 | + binding.videoview.setDataSource(new DataSource("223_88c98ab1395f4762b703fbdd9d59d2e5", Config.TYPE_VOD, Config.TYPE_PLAY_RATE_2)); | |
| 56 | + } else { | |
| 57 | + QMUITipDialogUtil.loadingDialog(me,"直播"); | |
| 58 | +// binding.videoview.setDataSource(new DataSource("604_233216be9552476b93d2c0cac7819222", Config.TYPE_LIVE, Config.TYPE_PLAY_RATE_2)); | |
| 59 | +// binding.videoview.setDataSource(new DataSource("223_b66053d9eaf147efa58eb1ae4b47661e", Config.TYPE_VOD, Config.TYPE_PLAY_RATE_2)); | |
| 60 | + binding.videoview.setDataSource(new DataSource("604_75ca27cce3a043b1876f694dd1125234", Config.TYPE_LIVE, Config.TYPE_PLAY_RATE_2)); | |
| 61 | + | |
| 62 | + } | |
| 46 | 63 | binding.videoview.start(); |
| 47 | 64 | |
| 48 | 65 | |
| 49 | 66 | } |
| 50 | 67 | |
| 51 | 68 | @Override |
| 69 | + protected void onDestroy() { | |
| 70 | + super.onDestroy(); | |
| 71 | + } | |
| 72 | + | |
| 73 | + @Override | |
| 74 | + public void onBackPressed() { | |
| 75 | + super.onBackPressed(); | |
| 76 | + binding.videoview.stop(); | |
| 77 | + } | |
| 78 | + | |
| 79 | + @Override | |
| 52 | 80 | public boolean onInfo(IMediaPlayer mediaplayer, int what, int extra) { |
| 53 | 81 | return false; |
| 54 | 82 | } |
| ... | ... | @@ -69,12 +97,13 @@ public class CNplayerActivity extends BaseActivity implements IMediaPlayer.OnPre |
| 69 | 97 | @Override |
| 70 | 98 | public void onPrepared(IMediaPlayer mediaplayer) { |
| 71 | 99 | AlertUtil.showDeftToast(me, "onPrepared"); |
| 100 | + QMUITipDialogUtil.dismessDialog(); | |
| 72 | 101 | mediaplayer.start(); |
| 73 | 102 | } |
| 74 | 103 | |
| 75 | 104 | @Override |
| 76 | 105 | public void onPlayState(boolean isPlay) { |
| 77 | - AlertUtil.showDeftToast(me, "onPlayState" + isPlay); | |
| 106 | + AlertUtil.showDeftToast(me, "onPlayState:" + isPlay); | |
| 78 | 107 | |
| 79 | 108 | } |
| 80 | 109 | } | ... | ... |
app/strike/src/main/java/com/cnlive/strike/demo/activity/DemoMvpActivity.java
| ... | ... | @@ -391,9 +391,19 @@ public class DemoMvpActivity extends BaseActivity<DemoActivityView, DemoActivity |
| 391 | 391 | binding.btnCnPlayer.setOnClickListener(new View.OnClickListener() { |
| 392 | 392 | @Override |
| 393 | 393 | public void onClick(View v) { |
| 394 | - startActivity(new Intent(me,CNplayerActivity.class)); | |
| 394 | + Intent intent=new Intent(me,CNplayerActivity.class); | |
| 395 | + intent.putExtra("type","0"); | |
| 396 | + startActivity(intent); | |
| 395 | 397 | } |
| 396 | 398 | }); |
| 399 | + binding.btnLivePlayer.setOnClickListener(new View.OnClickListener() { | |
| 400 | + @Override | |
| 401 | + public void onClick(View v) { | |
| 402 | + Intent intent=new Intent(me,CNplayerActivity.class); | |
| 403 | + intent.putExtra("type","1"); | |
| 404 | + startActivity(intent); } | |
| 405 | + }); | |
| 406 | + | |
| 397 | 407 | } |
| 398 | 408 | |
| 399 | 409 | @Subscribe(threadMode = ThreadMode.MAIN) | ... | ... |
app/strike/src/main/res/layout/activity_cnvideo.xml
app/strike/src/main/res/layout/activity_demo_mvp_main.xml
| ... | ... | @@ -97,8 +97,13 @@ |
| 97 | 97 | android:layout_width="match_parent" |
| 98 | 98 | android:layout_height="wrap_content" |
| 99 | 99 | android:layout_margin="5dp" |
| 100 | - android:text="视频" /> | |
| 101 | - | |
| 100 | + android:text="点播" /> | |
| 101 | + <Button | |
| 102 | + android:id="@+id/btn_livePlayer" | |
| 103 | + android:layout_width="match_parent" | |
| 104 | + android:layout_height="wrap_content" | |
| 105 | + android:layout_margin="5dp" | |
| 106 | + android:text="直播" /> | |
| 102 | 107 | <Button |
| 103 | 108 | android:id="@+id/btn_pay" |
| 104 | 109 | android:layout_width="match_parent" | ... | ... |
cloud/user/src/main/java/com/cnlive/cloud/user/router/user/CNLiveUserServiceImpl.java
0 → 100644
| 1 | +package com.cnlive.cloud.user.router.user; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | +import android.text.TextUtils; | |
| 5 | + | |
| 6 | +import com.alibaba.android.arouter.facade.annotation.Route; | |
| 7 | +import com.alibaba.android.arouter.launcher.ARouter; | |
| 8 | +import com.cnlive.cloud.user.auth.UserService; | |
| 9 | +import com.cnlive.core.libs.base.arouter.user.CNLiveUserService; | |
| 10 | +import com.cnlive.core.libs.base.arouter.user.OpenUserInfo; | |
| 11 | + | |
| 12 | +/** | |
| 13 | + * 对上海电商开放信息 | |
| 14 | + * | |
| 15 | + * @author ys | |
| 16 | + */ | |
| 17 | +@Route(path = CNLiveUserService.PATH, name = CNLiveUserService.NAME) | |
| 18 | +public class CNLiveUserServiceImpl implements CNLiveUserService { | |
| 19 | + | |
| 20 | + @Override | |
| 21 | + public void jumpToLoginActivity(Context context, String s) { | |
| 22 | + ARouter.getInstance().build("/cnmain/LoginActivity") | |
| 23 | + .withString("tagurl", s) | |
| 24 | + .withBoolean("needEntranceBtn", false)//是否需要展示浏览入口按钮 | |
| 25 | + .navigation(context); | |
| 26 | + } | |
| 27 | + | |
| 28 | + @Override | |
| 29 | + public void jumpToLoginDialog(Context context, String s) { | |
| 30 | + ARouter.getInstance().build("/cnmain/LoginDialogActivity") | |
| 31 | + .withString("tagurl", s) | |
| 32 | + .navigation(context); | |
| 33 | + } | |
| 34 | + | |
| 35 | + @Override | |
| 36 | + public void jumpToLoginActivity(Context context) { | |
| 37 | + ARouter.getInstance().build("/cnmain/LoginActivity") | |
| 38 | + .withBoolean("needEntranceBtn", false)//是否需要展示浏览入口按钮 | |
| 39 | + .navigation(context); | |
| 40 | + } | |
| 41 | + | |
| 42 | + @Override | |
| 43 | + public void jumpToLoginDialog(Context context) { | |
| 44 | + ARouter.getInstance().build("/cnmain/LoginDialogActivity") | |
| 45 | + .navigation(context); | |
| 46 | + } | |
| 47 | + | |
| 48 | + @Override | |
| 49 | + public boolean isUserOnline(Context context) { | |
| 50 | +// return !TextUtils.isEmpty(LoginManager.getUserId()) ? true : false; | |
| 51 | + return true; | |
| 52 | + } | |
| 53 | + | |
| 54 | + @Override | |
| 55 | + public boolean isUserLogin(Context context) { | |
| 56 | + return !TextUtils.isEmpty(UserService.getUid(context)) ? true : false; | |
| 57 | + } | |
| 58 | + | |
| 59 | + @Override | |
| 60 | + public OpenUserInfo getUserInfo(Context context) { | |
| 61 | + OpenUserInfo openUserInfo = null; | |
| 62 | + if (null != UserService.getInstance(context).getAppAccount()) { | |
| 63 | + openUserInfo = new OpenUserInfo(); | |
| 64 | + //设置用户id | |
| 65 | + openUserInfo.setUid(UserService.getInstance(context).getAppAccount().getUid()); | |
| 66 | + //设置用户昵称 | |
| 67 | + openUserInfo.setNickName(UserService.getInstance(context).getAppAccount().getNickName()); | |
| 68 | + //设置用户性别 | |
| 69 | + openUserInfo.setGender(UserService.getInstance(context).getAppAccount().getGender()); | |
| 70 | + //设置用户地区 | |
| 71 | + openUserInfo.setLocation(UserService.getInstance(context).getAppAccount().getLocation()); | |
| 72 | + //设置用户头像地址 | |
| 73 | + openUserInfo.setFaceUrl(UserService.getInstance(context).getAppAccount().getFaceUrl()); | |
| 74 | + //设置用户手机号 | |
| 75 | + openUserInfo.setMobile(UserService.getInstance(context).getAppAccount().getMobile()); | |
| 76 | + //设置用户email | |
| 77 | + openUserInfo.setEmail(UserService.getInstance(context).getAppAccount().getEmail()); | |
| 78 | + //设置用户token | |
| 79 | + openUserInfo.setToken(UserService.getInstance(context).getAppAccount().getToken()); | |
| 80 | + //设置用户是否是新用户 | |
| 81 | + openUserInfo.setNewUser(UserService.getInstance(context).getAppAccount().isNewUser()); | |
| 82 | + //设置用户个性签名 | |
| 83 | + openUserInfo.setUserSign(UserService.getInstance(context).getAppAccount().getUserSign()); | |
| 84 | + //设置用户大图头像地址 | |
| 85 | + openUserInfo.setBigFaceUrl(UserService.getInstance(context).getAppAccount().getBigFaceUrl()); | |
| 86 | + //设置用户区码 | |
| 87 | + openUserInfo.setCountryCode(UserService.getInstance(context).getAppAccount().getCountryCode()); | |
| 88 | + //设置用户qqId | |
| 89 | + openUserInfo.setQqUid(UserService.getInstance(context).getAppAccount().getQqUid()); | |
| 90 | + //设置用户微信id | |
| 91 | + openUserInfo.setWxUid(UserService.getInstance(context).getAppAccount().getWxUid()); | |
| 92 | + //设置用户新浪id | |
| 93 | + openUserInfo.setSinaUid(UserService.getInstance(context).getAppAccount().getSinaUid()); | |
| 94 | + } | |
| 95 | + return openUserInfo; | |
| 96 | + } | |
| 97 | + | |
| 98 | + @Override | |
| 99 | + public String getUid(Context context) { | |
| 100 | + return !TextUtils.isEmpty(UserService.getUid(context)) ? UserService.getUid(context) : null; | |
| 101 | + } | |
| 102 | + | |
| 103 | + @Override | |
| 104 | + public void init(Context context) { | |
| 105 | + } | |
| 106 | +} | ... | ... |
cloud/video/src/main/java/com/libs/video/data/network/HttpRequest.java
| ... | ... | @@ -88,16 +88,16 @@ public class HttpRequest { |
| 88 | 88 | parames.put("uid", UUIDUtils.getUUID(Config.getContext())); |
| 89 | 89 | parames.put("platform_id", Config.getContext().getPackageName()); |
| 90 | 90 | parames.put("timestamp", String.valueOf(HttpUtils.getTime() / 1000)); |
| 91 | - Map<String, String> map = SignUtil.order(parames,false); | |
| 91 | + Map<String, String> map = SignUtil.order(parames, false); | |
| 92 | 92 | String signValue = SHA1Util |
| 93 | 93 | .SHA1Digest(HttpUtils.mapJoin(map, false).concat("&key=").concat(Config.getSpKey())) |
| 94 | 94 | .toUpperCase(Locale.getDefault()); |
| 95 | 95 | map.put("sign", signValue); |
| 96 | - return getPlayUrl(map, isLive, callback); | |
| 96 | + return getPlayUrl(map, isLive,null, callback); | |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | 99 | |
| 100 | - private static Disposable getPlayUrl(Map<String, String> parames, boolean isLive, final NetCallBack<String> callback) { | |
| 100 | + private static Disposable getPlayUrl(Map<String, String> parames, boolean isLive, String backUrl, final NetCallBack<String> callback) { | |
| 101 | 101 | NetCallBack<Response<ResponseBody>> result = new NetCallBack<Response<ResponseBody>>() { |
| 102 | 102 | @Override |
| 103 | 103 | public void onRequestState(int state) { |
| ... | ... | @@ -113,11 +113,12 @@ public class HttpRequest { |
| 113 | 113 | callback.onSuccess(data.raw().request().url().toString()); |
| 114 | 114 | } |
| 115 | 115 | } else { |
| 116 | -// String backUrl = data.headers().get("Location"); | |
| 116 | + String backUrl = data.headers().get("Location"); | |
| 117 | 117 | // if (null != callback) { |
| 118 | 118 | // callback.onSuccess(backUrl); |
| 119 | 119 | // } |
| 120 | - getPlayUrl(parames, isLive, callback); | |
| 120 | +// getPlayUrl(parames, isLive, backUrl,callback); | |
| 121 | + HttpUtils.resolveRedirect(backUrl,callback); | |
| 121 | 122 | } |
| 122 | 123 | } |
| 123 | 124 | |
| ... | ... | @@ -126,10 +127,15 @@ public class HttpRequest { |
| 126 | 127 | callback.onFailure(errCode, errMsg, e); |
| 127 | 128 | } |
| 128 | 129 | }; |
| 130 | + String url=BASE_URL; | |
| 131 | + if (!TextUtils.isEmpty(backUrl)){ | |
| 132 | + url=backUrl; | |
| 133 | + } | |
| 129 | 134 | //是直播 |
| 130 | 135 | if (isLive) { |
| 131 | 136 | return HttpConn.action( |
| 132 | 137 | VideoRequest.init() |
| 138 | + .setUrl(url) | |
| 133 | 139 | .setReadTimeout(60) |
| 134 | 140 | .setConnectTimeout(60) |
| 135 | 141 | .setWriteTimeout(60) |
| ... | ... | @@ -141,6 +147,7 @@ public class HttpRequest { |
| 141 | 147 | else { |
| 142 | 148 | return HttpConn.action( |
| 143 | 149 | VideoRequest.init() |
| 150 | + .setUrl(url) | |
| 144 | 151 | .setReadTimeout(60) |
| 145 | 152 | .setConnectTimeout(60) |
| 146 | 153 | .setWriteTimeout(60) | ... | ... |
cloud/video/src/main/java/com/libs/video/data/network/HttpUtils.java
| ... | ... | @@ -8,6 +8,7 @@ import android.util.Log; |
| 8 | 8 | |
| 9 | 9 | import com.cnlive.core.libs.base.application.AppConfig; |
| 10 | 10 | import com.cnlive.core.libs.base.util.UUIDUtils; |
| 11 | +import com.cnlive.core.network.NetCallBack; | |
| 11 | 12 | import com.cnlive.core.network.util.SHA1Util; |
| 12 | 13 | import com.libs.video.util.Config; |
| 13 | 14 | |
| ... | ... | @@ -89,34 +90,34 @@ public class HttpUtils { |
| 89 | 90 | // |
| 90 | 91 | // } |
| 91 | 92 | |
| 92 | -// //直播播放地址302重定向rtmp播放地址 | |
| 93 | -// private static String resolveRedirect(String urlStr) { | |
| 94 | -//// Log.i(TAG,"Get "+urlStr); | |
| 95 | -// try { | |
| 96 | -// //创建okHttpClient对象 | |
| 97 | -// OkHttpClient mOkHttpClient = new OkHttpClient.Builder() | |
| 98 | -// .connectTimeout(60 * 1000, TimeUnit.MILLISECONDS) | |
| 99 | -// .readTimeout(60 * 1000, TimeUnit.MILLISECONDS) | |
| 100 | -// .writeTimeout(60 * 1000, TimeUnit.MILLISECONDS) | |
| 101 | -// .build(); | |
| 102 | -// //创建一个Request | |
| 103 | -// Request request = new Request.Builder() | |
| 104 | -// .url(urlStr) | |
| 105 | -// .build(); | |
| 106 | -// //new call | |
| 107 | -// Call call = mOkHttpClient.newCall(request); | |
| 108 | -// //请求加入调度 | |
| 109 | -// Response response = call.execute(); | |
| 110 | -// String backUrl = response.header("Location"); | |
| 111 | -// if (response.code() != HttpURLConnection.HTTP_MOVED_TEMP && response.code() != HttpURLConnection.HTTP_MOVED_PERM) { | |
| 112 | -// return response.request().url().toString(); | |
| 113 | -// } else { | |
| 114 | -// return resolveRedirect(backUrl); | |
| 115 | -// } | |
| 116 | -// } catch (Exception e) { | |
| 117 | -// return urlStr; | |
| 118 | -// } | |
| 119 | -// } | |
| 93 | + //直播播放地址302重定向rtmp播放地址 | |
| 94 | + public static void resolveRedirect(String urlStr,final NetCallBack<String> callback) { | |
| 95 | +// Log.i(TAG,"Get "+urlStr); | |
| 96 | + try { | |
| 97 | + //创建okHttpClient对象 | |
| 98 | + OkHttpClient mOkHttpClient = new OkHttpClient.Builder() | |
| 99 | + .connectTimeout(60 * 1000, TimeUnit.MILLISECONDS) | |
| 100 | + .readTimeout(60 * 1000, TimeUnit.MILLISECONDS) | |
| 101 | + .writeTimeout(60 * 1000, TimeUnit.MILLISECONDS) | |
| 102 | + .build(); | |
| 103 | + //创建一个Request | |
| 104 | + Request request = new Request.Builder() | |
| 105 | + .url(urlStr) | |
| 106 | + .build(); | |
| 107 | + //new call | |
| 108 | + Call call = mOkHttpClient.newCall(request); | |
| 109 | + //请求加入调度 | |
| 110 | + Response response = call.execute(); | |
| 111 | + String backUrl = response.header("Location"); | |
| 112 | + if (response.code() != HttpURLConnection.HTTP_MOVED_TEMP && response.code() != HttpURLConnection.HTTP_MOVED_PERM) { | |
| 113 | + callback.onSuccess(response.request().url().toString()); | |
| 114 | + } else { | |
| 115 | + resolveRedirect(backUrl,callback); | |
| 116 | + } | |
| 117 | + } catch (Exception e) { | |
| 118 | + callback.onFailure("-1",e.toString(),e); | |
| 119 | + } | |
| 120 | + } | |
| 120 | 121 | |
| 121 | 122 | public interface resolveRedirectCallBack { |
| 122 | 123 | void onSuccess(String result); | ... | ... |
config.gradle
| ... | ... | @@ -100,12 +100,12 @@ ext { |
| 100 | 100 | rxlifecycle_android : 'com.trello.rxlifecycle3:rxlifecycle-android:3.1.0', |
| 101 | 101 | rxlifecycle_components : 'com.trello.rxlifecycle3:rxlifecycle-components:3.1.0', |
| 102 | 102 | //Retrofit |
| 103 | - retrofit : 'com.squareup.retrofit2:retrofit:2.6.0', | |
| 104 | - retrofitConverterGson : 'com.squareup.retrofit2:converter-gson:2.6.0', | |
| 105 | - retrofitAdapterRxjava2 : 'com.squareup.retrofit2:adapter-rxjava2:2.6.0', | |
| 103 | + retrofit : 'com.squareup.retrofit2:retrofit:2.6.3', | |
| 104 | + retrofitConverterGson : 'com.squareup.retrofit2:converter-gson:2.6.3', | |
| 105 | + retrofitAdapterRxjava2 : 'com.squareup.retrofit2:adapter-rxjava2:2.6.3', | |
| 106 | 106 | //OKhttp |
| 107 | - okhttp : 'com.squareup.okhttp3:okhttp:3.14.2', | |
| 108 | - okhttpLoggingInterceptor: 'com.squareup.okhttp3:logging-interceptor:3.14.2', | |
| 107 | + okhttp : 'com.squareup.okhttp3:okhttp:4.2.2', | |
| 108 | + okhttpLoggingInterceptor: 'com.squareup.okhttp3:logging-interceptor:4.2.2', | |
| 109 | 109 | //GreenDao |
| 110 | 110 | greendao : 'org.greenrobot:greendao:3.2.2', |
| 111 | 111 | //兼容旧版 | ... | ... |
core/base/src/main/java/com/cnlive/core/libs/base/arouter/RouterConst.java
0 → 100644
core/base/src/main/java/com/cnlive/core/libs/base/arouter/user/CNLiveUserService.java
0 → 100644
| 1 | +package com.cnlive.core.libs.base.arouter.user; | |
| 2 | + | |
| 3 | +import android.content.Context; | |
| 4 | + | |
| 5 | +import com.alibaba.android.arouter.facade.template.IProvider; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 给上海电商 用户库 | |
| 9 | + */ | |
| 10 | +public interface CNLiveUserService extends IProvider { | |
| 11 | + public static final String PATH = "/openService/CNLiveUserService"; | |
| 12 | + public static final String NAME = "开放用户信息的服务接口"; | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * 跳转到登录页 | |
| 16 | + * | |
| 17 | + * @param tagUrl 跳转地址 | |
| 18 | + */ | |
| 19 | + void jumpToLoginActivity(Context context, String tagUrl); | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * 跳转到登录对话框 | |
| 23 | + * | |
| 24 | + * @param tagUrl 跳转地址 | |
| 25 | + */ | |
| 26 | + void jumpToLoginDialog(Context context, String tagUrl); | |
| 27 | + | |
| 28 | + /** | |
| 29 | + * 跳转到登录页 | |
| 30 | + */ | |
| 31 | + void jumpToLoginActivity(Context context); | |
| 32 | + | |
| 33 | + /** | |
| 34 | + * 跳转到登录对话框 | |
| 35 | + */ | |
| 36 | + void jumpToLoginDialog(Context context); | |
| 37 | + | |
| 38 | + /** | |
| 39 | + * 判断用户是否在线 | |
| 40 | + * author ys | |
| 41 | + * | |
| 42 | + * @param context | |
| 43 | + * @return | |
| 44 | + */ | |
| 45 | + boolean isUserOnline(Context context); | |
| 46 | + | |
| 47 | + /** | |
| 48 | + * 判断用户是否登录 | |
| 49 | + * author ys | |
| 50 | + * | |
| 51 | + * @param context | |
| 52 | + * @return | |
| 53 | + */ | |
| 54 | + boolean isUserLogin(Context context); | |
| 55 | + | |
| 56 | + /** | |
| 57 | + * 获取用户信息 | |
| 58 | + * author ys | |
| 59 | + * | |
| 60 | + * @param context | |
| 61 | + * @return | |
| 62 | + */ | |
| 63 | + OpenUserInfo getUserInfo(Context context); | |
| 64 | + | |
| 65 | + /** | |
| 66 | + * 获取用户id | |
| 67 | + * author ys | |
| 68 | + * | |
| 69 | + * @param context | |
| 70 | + * @return | |
| 71 | + */ | |
| 72 | + String getUid(Context context); | |
| 73 | + | |
| 74 | +} | ... | ... |
core/base/src/main/java/com/cnlive/core/libs/base/arouter/user/OpenUserInfo.java
0 → 100644
| 1 | +package com.cnlive.core.libs.base.arouter.user; | |
| 2 | + | |
| 3 | +import android.text.TextUtils; | |
| 4 | + | |
| 5 | +import java.io.Serializable; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 开放平台-用户信息 | |
| 9 | + * | |
| 10 | + * @author ys | |
| 11 | + */ | |
| 12 | + | |
| 13 | +public class OpenUserInfo implements Serializable { | |
| 14 | + //用户id | |
| 15 | + private String uid; | |
| 16 | + //昵称 | |
| 17 | + private String nickName; | |
| 18 | + //性别 | |
| 19 | + private String gender; | |
| 20 | + //地址 | |
| 21 | + private String location; | |
| 22 | + //头像 | |
| 23 | + private String faceUrl; | |
| 24 | + //手机号 | |
| 25 | + private String mobile; | |
| 26 | + //邮箱 | |
| 27 | + private String email; | |
| 28 | + //平台TOKEN | |
| 29 | + private String token; | |
| 30 | + //新用户 | |
| 31 | + private boolean isNewUser; | |
| 32 | + //个性签名 | |
| 33 | + private String userSign; | |
| 34 | + //用户头像大图 | |
| 35 | + private String bigFaceUrl; | |
| 36 | + //手机号国家码 | |
| 37 | + private String countryCode; | |
| 38 | + //qqid | |
| 39 | + private String qqUid; | |
| 40 | + //微信id | |
| 41 | + private String wxUid; | |
| 42 | + //微博id | |
| 43 | + private String sinaUid; | |
| 44 | + | |
| 45 | + | |
| 46 | + public String getUid() { | |
| 47 | + return uid == null ? "" : uid; | |
| 48 | + } | |
| 49 | + | |
| 50 | + public void setUid(String uid) { | |
| 51 | + this.uid = uid; | |
| 52 | + } | |
| 53 | + | |
| 54 | + public String getNickName() { | |
| 55 | + return nickName; | |
| 56 | + } | |
| 57 | + | |
| 58 | + public void setNickName(String nickName) { | |
| 59 | + this.nickName = nickName; | |
| 60 | + } | |
| 61 | + | |
| 62 | + public String getGender() { | |
| 63 | + return gender; | |
| 64 | + } | |
| 65 | + | |
| 66 | + public void setGender(String gender) { | |
| 67 | + this.gender = gender; | |
| 68 | + } | |
| 69 | + | |
| 70 | + public String getLocation() { | |
| 71 | + return location; | |
| 72 | + } | |
| 73 | + | |
| 74 | + public void setLocation(String location) { | |
| 75 | + this.location = location; | |
| 76 | + } | |
| 77 | + | |
| 78 | + public String getFaceUrl() { | |
| 79 | + return faceUrl; | |
| 80 | + } | |
| 81 | + | |
| 82 | + public void setFaceUrl(String faceUrl) { | |
| 83 | + this.faceUrl = faceUrl; | |
| 84 | + } | |
| 85 | + | |
| 86 | + public String getBigFaceUrl() { | |
| 87 | + if (TextUtils.isEmpty(bigFaceUrl)) return faceUrl; | |
| 88 | + return bigFaceUrl; | |
| 89 | + } | |
| 90 | + | |
| 91 | + public void setBigFaceUrl(String bigFaceUrl) { | |
| 92 | + this.bigFaceUrl = bigFaceUrl; | |
| 93 | + } | |
| 94 | + | |
| 95 | + public String getMobile() { | |
| 96 | + return mobile; | |
| 97 | + } | |
| 98 | + | |
| 99 | + public void setMobile(String mobile) { | |
| 100 | + this.mobile = mobile; | |
| 101 | + } | |
| 102 | + | |
| 103 | + public String getEmail() { | |
| 104 | + return email; | |
| 105 | + } | |
| 106 | + | |
| 107 | + public void setEmail(String email) { | |
| 108 | + this.email = email; | |
| 109 | + } | |
| 110 | + | |
| 111 | + public String getToken() { | |
| 112 | + return token; | |
| 113 | + } | |
| 114 | + | |
| 115 | + public void setToken(String token) { | |
| 116 | + this.token = token; | |
| 117 | + } | |
| 118 | + | |
| 119 | + public boolean isNewUser() { | |
| 120 | + return isNewUser; | |
| 121 | + } | |
| 122 | + | |
| 123 | + public void setNewUser(boolean newUser) { | |
| 124 | + isNewUser = newUser; | |
| 125 | + } | |
| 126 | + | |
| 127 | + public String getQqUid() { | |
| 128 | + return qqUid; | |
| 129 | + } | |
| 130 | + | |
| 131 | + public void setQqUid(String qqUid) { | |
| 132 | + this.qqUid = qqUid; | |
| 133 | + } | |
| 134 | + | |
| 135 | + public String getWxUid() { | |
| 136 | + return wxUid; | |
| 137 | + } | |
| 138 | + | |
| 139 | + public void setWxUid(String wxUid) { | |
| 140 | + this.wxUid = wxUid; | |
| 141 | + } | |
| 142 | + | |
| 143 | + public String getSinaUid() { | |
| 144 | + return sinaUid; | |
| 145 | + } | |
| 146 | + | |
| 147 | + public void setSinaUid(String sinaUid) { | |
| 148 | + this.sinaUid = sinaUid; | |
| 149 | + } | |
| 150 | + | |
| 151 | + public String getUserSign() { | |
| 152 | + return userSign; | |
| 153 | + } | |
| 154 | + | |
| 155 | + public void setUserSign(String userSign) { | |
| 156 | + this.userSign = userSign; | |
| 157 | + } | |
| 158 | + | |
| 159 | + public String getCountryCode() { | |
| 160 | + return countryCode; | |
| 161 | + } | |
| 162 | + | |
| 163 | + public void setCountryCode(String countryCode) { | |
| 164 | + this.countryCode = countryCode; | |
| 165 | + } | |
| 166 | +} | ... | ... |
core/base/src/main/java/com/cnlive/core/libs/base/util/CheckUtil.java
| ... | ... | @@ -136,7 +136,7 @@ public class CheckUtil { |
| 136 | 136 | public static boolean isIgnoringBatteryOptimizationss(Activity context) { |
| 137 | 137 | try { |
| 138 | 138 | String carrier = android.os.Build.MANUFACTURER; |
| 139 | - if (!"smartisan".equals(carrier)) { | |
| 139 | + if (!"smartisan".equals(carrier)&&!"blackshark".equals(carrier)) { | |
| 140 | 140 | PowerManager powerManager = (PowerManager) context.getSystemService(POWER_SERVICE); |
| 141 | 141 | if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) { |
| 142 | 142 | boolean hasIgnored = powerManager.isIgnoringBatteryOptimizations(context.getPackageName()); | ... | ... |