wangkai

1、添加阿里播放器证书;

2、添加启动页、隐私权限
Showing 54 changed files with 3514 additions and 389 deletions
1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <project version="4"> 2 <project version="4">
3 <component name="VcsDirectoryMappings"> 3 <component name="VcsDirectoryMappings">
4 - <mapping directory="$PROJECT_DIR$" vcs="Git" /> 4 + <mapping directory="" vcs="Git" />
5 </component> 5 </component>
6 </project> 6 </project>
@@ -4,6 +4,25 @@ @@ -4,6 +4,25 @@
4 package="com.wd.fastcoding.app"> 4 package="com.wd.fastcoding.app">
5 <!-- 请求网络 --> 5 <!-- 请求网络 -->
6 <uses-permission android:name="android.permission.INTERNET" /> 6 <uses-permission android:name="android.permission.INTERNET" />
  7 + <uses-permission android:name="android.permission.RECORD_AUDIO" />
  8 + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  9 + <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
  10 + <uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
  11 + <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
  12 + <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
  13 + <uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
  14 + <uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- 相机权限,先预留,不用后面再删除 -->
  15 + <uses-permission android:name="android.permission.CAMERA" /> <!-- 语音播报申请允许悬浮窗口权限 -->
  16 + <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
  17 + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  18 + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  19 + <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
  20 + <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
  21 + <uses-permission android:name="android.hardware.camera" />
  22 + <uses-permission
  23 + android:name="android.permission.WRITE_SETTINGS"
  24 + tools:ignore="ProtectedPermissions" />
  25 +
7 <uses-feature 26 <uses-feature
8 android:name="android.software.leanback" 27 android:name="android.software.leanback"
9 android:required="false" /> 28 android:required="false" />
@@ -13,6 +32,9 @@ @@ -13,6 +32,9 @@
13 android:fullBackupContent="@xml/backup_rules" 32 android:fullBackupContent="@xml/backup_rules"
14 android:icon="@mipmap/ic_fastcode" 33 android:icon="@mipmap/ic_fastcode"
15 android:label="@string/app_name" 34 android:label="@string/app_name"
  35 + android:networkSecurityConfig="@xml/network_security_config"
  36 + android:requestLegacyExternalStorage="true"
  37 + android:resizeableActivity="true"
16 android:roundIcon="@mipmap/ic_fastcode" 38 android:roundIcon="@mipmap/ic_fastcode"
17 android:supportsRtl="true" 39 android:supportsRtl="true"
18 android:theme="@style/AppTheme" 40 android:theme="@style/AppTheme"
@@ -20,6 +42,14 @@ @@ -20,6 +42,14 @@
20 tools:ignore="Instantiatable" 42 tools:ignore="Instantiatable"
21 tools:replace="android:allowBackup,android:name"> 43 tools:replace="android:allowBackup,android:name">
22 44
  45 + <!-- 阿里视频点播 licensekey -->
  46 + <meta-data
  47 + android:name="com.aliyun.alivc_license.licensekey"
  48 + android:value="jobw8PGmd0TLigqgt7d85ea944cb34eb9a102d33b27054f83" />
  49 + <meta-data
  50 + android:name="com.aliyun.alivc_license.licensefile"
  51 + android:value="assets/cert/AliVideoCert-com_wondertek_easycode-20241030182958.crt" />
  52 +
23 <activity 53 <activity
24 android:name=".MainActivity" 54 android:name=".MainActivity"
25 android:exported="true" 55 android:exported="true"
  1 +-----BEGIN ALI VIDEO CERT-----
  2 +LmlsQS5jaUwAAWRjY2FhYTU1OTAxNzE0NDg2OWJlOGJkNzczZTc5ZjAzM2YwMDhiO
  3 +WY5ODUwNTc5MGY4NDEyOTRiMzNjMmZiYjg1NGUxZThlNjAwNzRmNTgxZTU0MDY2Mj
  4 +RiMGFiM2JkNWVmOTE3ZDE0MDJlNDQ0ZDUwNmExMTc5ZjFlYjYyODQ2MDRiYzdiYjA
  5 +zOTI2ZjYyOTE1OWVjYjY0ZDk1ZDhhN2Q5ZWZlOTRjOTdkMTA0Yzc1MWU5OGEwNGY3
  6 +OTdkOTdiYTAzMWEyMDFlMzc2Mjg0NGI1MTEyYWRkZDQzNTgyZDA2NTJkYTk0MDk1Y
  7 +TIxYjY2NWJmYjY0ZTkwMWQyZGNjNmVjMjY1ODFkYmJjZjBhY2ZmZjFhNDU3NTJjND
  8 +QwNTMzZmJlZDk3YTIzMmMyOWQ4YWVkZDY0YmZhZDc2ZDY1MTRiZGU5MmM3YTdjMGZ
  9 +iYjI3OTNhNjZiMDEzMjBkODgxYzBhMjA1YTExN2Q1YmU3ZTgyMzYyYzI5MDJhZDNk
  10 +MmFiZTcxNTQ5NzI2YzI4NTVjOTc5MWVmZDVjMGU4NDZmMDZlZDhlYTY1MjgzYWUzM
  11 +2JkOTYzOWJiZTkwOGU4ZTBmY2QwNDc1OWQ5N2U3OTk1NDNhMzdkNDQ2YzZlMDJhMj
  12 +BkODI2YTUzZGIzNTNjNWU3MDVjYmJmYzg5ODVjYjRkMWIxAAAB3FfzXgBqw5VTCVw
  13 +eYPPkcH3JGkDkehJSOhHqc479cL5JVilJqzzBFRpmhldfdptLaQTUDdVFHpt6qaS7
  14 +ebSKGd5uePCe8mNXWScMFewWwHt9hukxJMSKZNkJY9H6gc9xXBVQg2KCSNHlgrCiZ
  15 +LhnIwJD82BCDnaLqcAol9QotsxGCstzmuG70bn46xO/oUIRwK09o01r+mZP21qEbD
  16 +T4RbdFTjh7yOEx7R3D/yoEbGecBeROXDqCN2t0EQ3/brAPITFCodB8GoUM7UUnRK6
  17 +Y8flZKv8aOaH1o7m27HBzpMTyStpBTXlz0oWwVyL78kcBt3SfsuXUKcxMT3R+qmI4
  18 +XxL7D6lHAAABaqc4asomDCjl6suryaMGfbsn+buiuzM4LcHFYjyY0WI76VUS4+73G
  19 +YcE5lDn3xUfUmLGa+7kc+h6+LZYMTZ6EUH+b1ZIr6foJRzTyxJmTMPJMaJ8sAMmA3
  20 +4vGzNlvFV3PD2q2QogiZdAjCggzsaYfZmSCHL6WEAYXmMZGjjN+hIKAKn5FvMtxmn
  21 +5xOkypQ3Kf9o15sZ82JKfmuMvLkT9pmMfBdPiamlnWvhSM+1d/0pNTdtGH57Gb7gw
  22 +BhrP+vNBDE25JTRnHQ3xbSZRammY1HIg2ZcjSfH/WIXieKYLqbkfxjc+6O6NuPmr7
  23 ++k9Dn57iB5qL71gqwDJ3Ai8LmZbQZEAAAGS3PmYMQAAAL4AAAAgZ2Q1NzAzZThhYz
  24 +ViNGFmNmIzZjNjMWE5ODQ2OTkxZjgAAAAEAAAAIgAAAAAAAAACAAAAFmNvbS53b25
  25 +kZXJ0ZWsuZWFzeWNvZGUAAAAiAAAAAAAAAAEAAAAWY29tLndvbmRlcnRlay5lYXN5
  26 +Y29kZQAAACIAAAAAAAAAQAAAABZjb20ud29uZGVydGVrLmVhc3ljb2RlAAAAIAAAA
  27 +AAAAAAQAAAAFHd3dy53b25kZXJ0ZWsuY29tLmNuAAAABAAAACUAAAACAAAAAAAAAA
  28 +IAACPxAAABmjZiMKAAAAAACAAAAAEAAAAAAAAAJQAAAAIAAAAAAAAAAQAAI/EAAAG
  29 +aNmIwoAAAAAAIAAAAAQAAAAAAAAAlAAAAAgAAAAAAAAAQAAAj8QAAAZo2YjCgAAAA
  30 +AAgAAAABAAAAAAAAACUAAAACAAAAAAAAAEAAACPxAAABmjZiMKAAAAAACAAAAAEAA
  31 +AAA
  32 +-----END ALI VIDEO CERT-----
1 1
2 package com.wd.fastcoding.app; 2 package com.wd.fastcoding.app;
3 3
  4 +import androidx.appcompat.app.AppCompatDelegate;
  5 +
4 import com.hjq.toast.Toaster; 6 import com.hjq.toast.Toaster;
5 import com.wd.capability.network.RetrofitClient; 7 import com.wd.capability.network.RetrofitClient;
6 import com.wd.capability.router.ArouteInit; 8 import com.wd.capability.router.ArouteInit;
  9 +import com.wd.capability.router.WdRouterRule;
7 import com.wd.foundation.wdkit.base.BaseApplication; 10 import com.wd.foundation.wdkit.base.BaseApplication;
8 import com.wd.fastcoding.app.start.StartTaskConfig; 11 import com.wd.fastcoding.app.start.StartTaskConfig;
  12 +import com.wd.foundation.wdkit.constant.Constants;
9 import com.wd.foundation.wdkit.utils.CommonUtil; 13 import com.wd.foundation.wdkit.utils.CommonUtil;
  14 +import com.wd.foundation.wdkit.utils.SpUtils;
10 import com.wd.foundation.wdkitcore.tools.AppContext; 15 import com.wd.foundation.wdkitcore.tools.AppContext;
11 import com.wd.foundation.wdkitcore.tools.StringUtils; 16 import com.wd.foundation.wdkitcore.tools.StringUtils;
12 17
@@ -22,6 +27,26 @@ public class MyApplication extends BaseApplication { @@ -22,6 +27,26 @@ public class MyApplication extends BaseApplication {
22 // 第三方库初始化 27 // 第三方库初始化
23 if (isCurProcess()) { 28 if (isCurProcess()) {
24 initLibs(); 29 initLibs();
  30 + //是否是撤销隐私协议
  31 + Constants.isRevokePrivacy = SpUtils.isRevokePrivacyFlag();
  32 + if (!(Constants.isFirst = SpUtils.isFirstAgreementFlag())) {
  33 +// WelcomeUtils.initializeNowAfterAgree(this);
  34 +// //利用alpha初始化
  35 +// ((IStartTaskProvider) WdRouterRule.getInstance().getProvider(IStartTaskProvider.class)).startTaskInApplication(this);
  36 + }
  37 +
  38 + //设置夜间模式
  39 + String nightMode = SpUtils.getNightMode();
  40 + if (SpUtils.NIGHT_MODE.equals(nightMode)) {
  41 + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
  42 + Constants.isNightMode = true;
  43 + } else if (SpUtils.LIGHT_MODE.equals(nightMode)) {
  44 + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
  45 + Constants.isNightMode = false;
  46 + } else if (SpUtils.FOLLOWUP_SYSTEM.equals(nightMode)) {
  47 + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
  48 + Constants.isNightMode = SpUtils.isNightMode();
  49 + }
25 // 主进程,只执行一次 50 // 主进程,只执行一次
26 // 启动初始化管理,子线程管理 51 // 启动初始化管理,子线程管理
27 StartTaskConfig taskConfig = new StartTaskConfig(this); 52 StartTaskConfig taskConfig = new StartTaskConfig(this);
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<network-security-config>
  3 + <base-config cleartextTrafficPermitted="true">
  4 + <trust-anchors>
  5 + <certificates src="user" />
  6 + <certificates src="system" />
  7 + </trust-anchors>
  8 + </base-config>
  9 + <domain-config cleartextTrafficPermitted="true">
  10 + <domain includeSubdomains="true">enrichgw.10010.com</domain> <!-- 联通内部5G请求域名,开发者需要添加 -->
  11 + <domain includeSubdomains="true">onekey.cmpassport.com</domain> <!-- 移动内部请求域名,开发者需要添加 -->
  12 + </domain-config>
  13 +</network-security-config>
@@ -85,24 +85,24 @@ public class ChannelDataFetcherNews extends BaseDataFetcher<RequestApi> { @@ -85,24 +85,24 @@ public class ChannelDataFetcherNews extends BaseDataFetcher<RequestApi> {
85 //有缓存 85 //有缓存
86 // Logger.e("newsTabMd5 ==dataType="+dataType+",isNewsChannel=="+isNewsChannel); 86 // Logger.e("newsTabMd5 ==dataType="+dataType+",isNewsChannel=="+isNewsChannel);
87 // Logger.e("newsTabMd5 ==BaseConstants.newsTabMd5="+BaseConstants.newsTabMd5); 87 // Logger.e("newsTabMd5 ==BaseConstants.newsTabMd5="+BaseConstants.newsTabMd5);
88 - if (2 == dataType){ 88 + if (2 == dataType) {
89 //新闻tab 89 //新闻tab
90 - if (isNewsChannel){  
91 -// String newsTabGroupMd5 = SpUtils.getBottomNavGroupDetailMd5();  
92 -// //有数据,保存的md5不为空,并且和接口给的md5一致,不用再调接口  
93 -// if (StringUtils.isBlank(BaseConstants.newsTabMd5)){  
94 -//// Logger.e("newsTabMd5空的==不会调用");  
95 -// return;  
96 -// }  
97 -//// Logger.e("newsTabMd5 调用== firstLocation="+firstLocation);  
98 -//// Logger.e("newsTabMd5 ==newsTabGroupMd5=="+newsTabGroupMd5);  
99 -// if (1 != firstLocation && StringUtils.isNotBlank(newsTabGroupMd5)  
100 -// && newsTabGroupMd5.equals(BaseConstants.newsTabMd5)) {  
101 -//// Logger.e("newsTabMd5不变==不会调用");  
102 -// return;  
103 -// }  
104 -// SpUtils.saveBottomNavGroupDetailMd5(BaseConstants.newsTabMd5);  
105 - }else { 90 + if (isNewsChannel) {
  91 + String newsTabGroupMd5 = SpUtils.getBottomNavGroupDetailMd5();
  92 + //有数据,保存的md5不为空,并且和接口给的md5一致,不用再调接口
  93 + if (StringUtils.isBlank(BaseConstants.newsTabMd5)) {
  94 +// Logger.e("newsTabMd5空的==不会调用");
  95 + return;
  96 + }
  97 +// Logger.e("newsTabMd5 调用== firstLocation="+firstLocation);
  98 +// Logger.e("newsTabMd5 ==newsTabGroupMd5=="+newsTabGroupMd5);
  99 + if (1 != firstLocation && StringUtils.isNotBlank(newsTabGroupMd5)
  100 + && newsTabGroupMd5.equals(BaseConstants.newsTabMd5)) {
  101 +// Logger.e("newsTabMd5不变==不会调用");
  102 + return;
  103 + }
  104 + SpUtils.saveBottomNavGroupDetailMd5(BaseConstants.newsTabMd5);
  105 + } else {
106 //如果不是新闻tab并且有缓存数据,不再进行接口请求 106 //如果不是新闻tab并且有缓存数据,不再进行接口请求
107 return; 107 return;
108 } 108 }
1 plugins { 1 plugins {
2 id 'com.android.library' 2 id 'com.android.library'
  3 + id 'kotlin-android'
3 } 4 }
4 5
5 android { 6 android {
@@ -200,22 +200,6 @@ public abstract class BaseActivity extends BaseMvvmActivity implements CustomTit @@ -200,22 +200,6 @@ public abstract class BaseActivity extends BaseMvvmActivity implements CustomTit
200 flowTooBigDialog.setIsflowtoobig(false); 200 flowTooBigDialog.setIsflowtoobig(false);
201 } 201 }
202 }); 202 });
203 -  
204 -// /**  
205 -// * 全局监听  
206 -// * 1.夜间模式切换  
207 -// */  
208 -// LiveDataBus.getInstance().with(EventConstants.EVENT_GLOBALLISTENING, Integer.class).observe(this, eventType -> {  
209 -// forLiveDataBus = 1;  
210 -// switch (eventType) {  
211 -// case 1:  
212 -// //夜间模式切换,需要重新创建页面  
213 -// recreate();  
214 -// break;  
215 -// default:  
216 -// break;  
217 -// }  
218 -// });  
219 } 203 }
220 204
221 205
  1 +/*
  2 + * Copyright (c) People Technologies Co., Ltd. 2019-2022. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.common.content;
  6 +
  7 +
  8 +import com.wd.common.content.model.api.service.IContentService;
  9 +import com.wd.common.content.model.impl.service.ContentServiceImpl;
  10 +import com.wd.foundation.wdkitcore.scheduler.BaseComponent;
  11 +
  12 +/**
  13 + * 内容获取逻辑组件<BR>
  14 + *
  15 + * @author zhangbo
  16 + * @version [V1.0.0, 2022/5/20]
  17 + * @since V1.0.0
  18 + */
  19 +public class ContentComponent extends BaseComponent {
  20 + @Override
  21 + public void registerServices() {
  22 + registerService(IContentService.class, ContentServiceImpl.class);
  23 + }
  24 +}
  1 +/*
  2 + * Copyright (c) People Technologies Co., Ltd. 2019-2022. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.common.content.model.api;
  6 +
  7 +import android.content.Context;
  8 +
  9 +import com.wd.foundation.wdkit.mvvm.model.IBaseModel;
  10 +import com.wd.foundation.wdkit.mvvm.model.IBaseTask;
  11 +import com.wd.foundation.wdkit.network.IDownloadListener;
  12 +
  13 +
  14 +/**
  15 + * 内容获取相关接口<BR>
  16 + *
  17 + * @author zhangbo
  18 + * @version [V1.0.0, 2022/5/20]
  19 + * @since V1.0.0
  20 + */
  21 +public interface IContentModel extends IBaseModel {
  22 +
  23 +
  24 + /**
  25 + * 下载启动广告视频
  26 + *
  27 + * @param downloadUrl
  28 + * @param callBack
  29 + * @return 任务实例
  30 + */
  31 +
  32 + IBaseTask downloadAdData(Context context, String downloadUrl, IDownloadListener callBack);
  33 +
  34 +}
  1 +/*
  2 + * Copyright (c) People Technologies Co., Ltd. 2019-2022. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.common.content.model.api.service;
  6 +
  7 +
  8 +import com.wd.common.content.model.api.IContentModel;
  9 +import com.wd.foundation.wdkitcore.scheduler.IService;
  10 +
  11 +/**
  12 + * 内容获取服务接口<BR>
  13 + *
  14 + * @author zhangbo
  15 + * @version [V1.0.0, 2020/9/29]
  16 + * @since V1.0.0
  17 + */
  18 +public interface IContentService extends IService {
  19 + /**
  20 + * 获取内容的model实例
  21 + *
  22 + * @return IContentModel实例
  23 + */
  24 + IContentModel getContentModel();
  25 +}
  1 +/*
  2 + * Copyright (c) People Technologies Co., Ltd. 2019-2022. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.common.content.model.impl;
  6 +
  7 +import android.content.Context;
  8 +
  9 +import com.wd.common.content.model.api.IContentModel;
  10 +import com.wd.foundation.wdkit.mvvm.model.IBaseTask;
  11 +import com.wd.foundation.wdkit.network.DownloadUtil;
  12 +import com.wd.foundation.wdkit.network.IDownloadListener;
  13 +
  14 +
  15 +/**
  16 + * 内容获取实现类<BR>
  17 + *
  18 + * @author zhangbo
  19 + * @version [V1.0.0, 2022/5/20]
  20 + * @since V1.0.0
  21 + */
  22 +public class ContentModelImpl implements IContentModel {
  23 + private static final String TAG = "ContentModelImpl";
  24 +
  25 +
  26 +
  27 + @Override
  28 + public IBaseTask downloadAdData(Context context, String downloadUrl, IDownloadListener callBack) {
  29 + DownloadUtil.get().download(context, downloadUrl, callBack);
  30 + //SplashAdDownloadTask task = new SplashAdDownloadTask(downloadUrl, callBack);
  31 + //task.startAsync();
  32 + return null;
  33 + }
  34 +
  35 +
  36 +}
  1 +/*
  2 + * Copyright (c) People Technologies Co., Ltd. 2019-2022. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.common.content.model.impl.service;
  6 +
  7 +
  8 +import com.wd.common.content.model.api.IContentModel;
  9 +import com.wd.common.content.model.api.service.IContentService;
  10 +import com.wd.common.content.model.impl.ContentModelImpl;
  11 +
  12 +/**
  13 + * 内容获取服务的实现类<BR>
  14 + *
  15 + * @author zhangbo
  16 + * @version [V1.0.0, 2020/9/29]
  17 + * @since V1.0.0
  18 + */
  19 +public class ContentServiceImpl implements IContentService {
  20 + @Override
  21 + public IContentModel getContentModel() {
  22 + return new ContentModelImpl();
  23 + }
  24 +}
@@ -43,6 +43,7 @@ dependencies { @@ -43,6 +43,7 @@ dependencies {
43 implementation project(path: ':wdlayout') 43 implementation project(path: ':wdlayout')
44 implementation project(path: ':lib_base') 44 implementation project(path: ':lib_base')
45 implementation project(path: ':base_comment') 45 implementation project(path: ':base_comment')
  46 + implementation project(path: ':base_location')
46 api project(path: ':wdrouter') 47 api project(path: ':wdrouter')
47 api project(path: ':wdinterface') 48 api project(path: ':wdinterface')
48 annotationProcessor 'com.alibaba:arouter-compiler:1.5.2' 49 annotationProcessor 'com.alibaba:arouter-compiler:1.5.2'
@@ -21,11 +21,13 @@ import android.view.LayoutInflater; @@ -21,11 +21,13 @@ import android.view.LayoutInflater;
21 import android.view.MotionEvent; 21 import android.view.MotionEvent;
22 import android.view.View; 22 import android.view.View;
23 import android.view.ViewGroup; 23 import android.view.ViewGroup;
  24 +import android.widget.FrameLayout;
24 import android.widget.ImageView; 25 import android.widget.ImageView;
25 import android.widget.TextView; 26 import android.widget.TextView;
26 27
27 import androidx.annotation.NonNull; 28 import androidx.annotation.NonNull;
28 import androidx.annotation.Nullable; 29 import androidx.annotation.Nullable;
  30 +import androidx.appcompat.app.AppCompatDelegate;
29 import androidx.constraintlayout.widget.ConstraintLayout; 31 import androidx.constraintlayout.widget.ConstraintLayout;
30 import androidx.core.content.ContextCompat; 32 import androidx.core.content.ContextCompat;
31 import androidx.fragment.app.Fragment; 33 import androidx.fragment.app.Fragment;
@@ -38,15 +40,22 @@ import com.alibaba.android.arouter.facade.annotation.Route; @@ -38,15 +40,22 @@ import com.alibaba.android.arouter.facade.annotation.Route;
38 import com.google.android.material.tabs.TabLayout; 40 import com.google.android.material.tabs.TabLayout;
39 import com.wd.base.log.Logger; 41 import com.wd.base.log.Logger;
40 import com.wd.capability.layout.comp.layoutmanager.view.WTabLayout; 42 import com.wd.capability.layout.comp.layoutmanager.view.WTabLayout;
  43 +import com.wd.capability.layout.constant.LaunchPageConstant;
41 import com.wd.capability.layout.fragment.MainFragment; 44 import com.wd.capability.layout.fragment.MainFragment;
42 import com.wd.capability.layout.fragment.NewsHomeFragment; 45 import com.wd.capability.layout.fragment.NewsHomeFragment;
43 import com.wd.capability.network.constant.NetConstant; 46 import com.wd.capability.network.constant.NetConstant;
  47 +import com.wd.capability.router.WdRouterRule;
44 import com.wd.common.base.BaseActivity; 48 import com.wd.common.base.BaseActivity;
45 -//import com.wd.common.base.BaseDialog; 49 +import com.wd.common.base.BaseDialog;
  50 +import com.wd.common.incentive.constants.TaskOperateTypeConstants;
  51 +import com.wd.common.incentive.task.TaskManager;
  52 +import com.wd.foundation.bean.launch.AppAgreementBean;
  53 +import com.wd.foundation.bean.launch.LaunchPageBean;
46 import com.wd.foundation.wdkit.constant.Constants; 54 import com.wd.foundation.wdkit.constant.Constants;
47 import com.wd.foundation.wdkit.constant.EventConstants; 55 import com.wd.foundation.wdkit.constant.EventConstants;
48 import com.wd.common.constant.RouterConstants; 56 import com.wd.common.constant.RouterConstants;
49 import com.wd.common.net.NetStateChangeReceiver; 57 import com.wd.common.net.NetStateChangeReceiver;
  58 +import com.wd.foundation.wdkit.system.DeviceUtil;
50 import com.wd.foundation.wdkit.utils.GrayManager; 59 import com.wd.foundation.wdkit.utils.GrayManager;
51 import com.wd.common.utils.ProcessUtils; 60 import com.wd.common.utils.ProcessUtils;
52 import com.wd.foundation.wdkit.constant.ProtocolConstant; 61 import com.wd.foundation.wdkit.constant.ProtocolConstant;
@@ -63,13 +72,19 @@ import com.wd.foundation.wdkit.utils.FilletUtil; @@ -63,13 +72,19 @@ import com.wd.foundation.wdkit.utils.FilletUtil;
63 import com.wd.foundation.wdkit.utils.SpUtils; 72 import com.wd.foundation.wdkit.utils.SpUtils;
64 import com.wd.foundation.wdkit.utils.ViewUtils; 73 import com.wd.foundation.wdkit.utils.ViewUtils;
65 import com.wd.foundation.wdkitcore.livedata.LiveDataBus; 74 import com.wd.foundation.wdkitcore.livedata.LiveDataBus;
  75 +import com.wd.foundation.wdkitcore.thread.ThreadPoolUtils;
66 import com.wd.foundation.wdkitcore.tools.ArrayUtils; 76 import com.wd.foundation.wdkitcore.tools.ArrayUtils;
67 import com.wd.foundation.wdkitcore.tools.ResUtils; 77 import com.wd.foundation.wdkitcore.tools.ResUtils;
68 import com.wd.foundation.wdkitcore.tools.StringUtils; 78 import com.wd.foundation.wdkitcore.tools.StringUtils;
69 import com.wd.module_home.adapter.MainFragmentAdapter; 79 import com.wd.module_home.adapter.MainFragmentAdapter;
  80 +import com.wd.module_home.util.GuideHelper;
  81 +import com.wd.module_home.util.SplashHelper;
70 import com.wd.module_home.util.WelcomeUtils; 82 import com.wd.module_home.util.WelcomeUtils;
  83 +import com.wd.module_home.vm.AgreementViewModel;
  84 +import com.wd.module_home.vm.IAgreementListener;
71 import com.wd.module_home.vm.IMainDataListener; 85 import com.wd.module_home.vm.IMainDataListener;
72 import com.wd.module_home.vm.MainViewModel; 86 import com.wd.module_home.vm.MainViewModel;
  87 +import com.wd.module_home.vm.SplashViewModel;
73 88
74 import org.libpag.PAGView; 89 import org.libpag.PAGView;
75 90
@@ -135,12 +150,12 @@ public class AppMainActivity extends BaseActivity { @@ -135,12 +150,12 @@ public class AppMainActivity extends BaseActivity {
135 /** 150 /**
136 * 引导页工具类 151 * 引导页工具类
137 */ 152 */
138 -// private GuideHelper guideHelper; 153 + private GuideHelper guideHelper;
139 154
140 /** 155 /**
141 * 闪屏页工具类 156 * 闪屏页工具类
142 */ 157 */
143 -// private SplashHelper splashHelper; 158 + private SplashHelper splashHelper;
144 159
145 /** 160 /**
146 * 首次安装同意隐私政策 161 * 首次安装同意隐私政策
@@ -209,7 +224,7 @@ public class AppMainActivity extends BaseActivity { @@ -209,7 +224,7 @@ public class AppMainActivity extends BaseActivity {
209 /** 224 /**
210 * 隐私弹框 225 * 隐私弹框
211 */ 226 */
212 -// private BaseDialog agreepomentDialog; 227 + private BaseDialog agreepomentDialog;
213 228
214 /** 229 /**
215 * 夜间模式 230 * 夜间模式
@@ -309,25 +324,23 @@ public class AppMainActivity extends BaseActivity { @@ -309,25 +324,23 @@ public class AppMainActivity extends BaseActivity {
309 setUnMvvm(true); 324 setUnMvvm(true);
310 super.onCreate(savedInstanceState); 325 super.onCreate(savedInstanceState);
311 Constants.restart = false; 326 Constants.restart = false;
312 -  
313 -// ((IStartTaskProvider) WdRouterRule.getInstance().getProvider(IStartTaskProvider.class)).startPrivate(AppMainActivity.this);  
314 // CacheDataManager.isClearAllCache = false; 327 // CacheDataManager.isClearAllCache = false;
315 -// nightMode = SpUtils.getNightMode();  
316 -// if (!restart) { 328 + nightMode = SpUtils.getNightMode();
  329 + if (!restart) {
317 // if (!SpUtils.isFirstAgreementFlag()) { 330 // if (!SpUtils.isFirstAgreementFlag()) {
318 // //同意了隐私政策 通知mpaas 331 // //同意了隐私政策 通知mpaas
319 // QuinoxlessPrivacyUtil.sendPrivacyAgreedBroadcast(this); 332 // QuinoxlessPrivacyUtil.sendPrivacyAgreedBroadcast(this);
320 // } 333 // }
321 -// //设置夜间模式  
322 -// if (SpUtils.NIGHT_MODE.equals(nightMode)) {  
323 -// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);  
324 -// } else if (SpUtils.LIGHT_MODE.equals(nightMode)) {  
325 -// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);  
326 -// } else if (SpUtils.FOLLOWUP_SYSTEM.equals(nightMode)) {  
327 -// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);  
328 -// }  
329 -// SpUtils.saveNoUseWifiForVideo(true);  
330 -// } 334 + //设置夜间模式
  335 + if (SpUtils.NIGHT_MODE.equals(nightMode)) {
  336 + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
  337 + } else if (SpUtils.LIGHT_MODE.equals(nightMode)) {
  338 + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
  339 + } else if (SpUtils.FOLLOWUP_SYSTEM.equals(nightMode)) {
  340 + AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
  341 + }
  342 + SpUtils.saveNoUseWifiForVideo(true);
  343 + }
331 344
332 //根布局 345 //根布局
333 rootView = new ConstraintLayout(this); 346 rootView = new ConstraintLayout(this);
@@ -362,28 +375,28 @@ public class AppMainActivity extends BaseActivity { @@ -362,28 +375,28 @@ public class AppMainActivity extends BaseActivity {
362 bottomLine.setVisibility(View.INVISIBLE); 375 bottomLine.setVisibility(View.INVISIBLE);
363 bottomLine.setLayoutParams(params); 376 bottomLine.setLayoutParams(params);
364 rootView.addView(bottomLine); 377 rootView.addView(bottomLine);
365 -// //引导/开屏布局  
366 -// params = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);  
367 -// flsplashContainer = new FrameLayout(this);  
368 -// flsplashContainer.setLayoutParams(params);  
369 -// rootView.addView(flsplashContainer);  
370 -// //底部logo  
371 -// params = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) getResources().getDimension(R.dimen.btmlogo_dimen));  
372 -// params.bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID;  
373 -// welcomeIvLogo = new ImageView(this);  
374 -// welcomeIvLogo.setLayoutParams(params);  
375 -// welcomeIvLogo.setBackgroundColor(0xffffffff);  
376 -// welcomeIvLogo.setScaleType(ImageView.ScaleType.CENTER);  
377 -// welcomeIvLogo.setImageResource(R.drawable.icon_splash_tra_bottom_logo);  
378 -// rootView.addView(welcomeIvLogo); 378 + //引导/开屏布局
  379 + params = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
  380 + flsplashContainer = new FrameLayout(this);
  381 + flsplashContainer.setLayoutParams(params);
  382 + rootView.addView(flsplashContainer);
  383 + //底部logo
  384 + params = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) getResources().getDimension(R.dimen.btmlogo_dimen));
  385 + params.bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID;
  386 + welcomeIvLogo = new ImageView(this);
  387 + welcomeIvLogo.setLayoutParams(params);
  388 + welcomeIvLogo.setBackgroundColor(0xffffffff);
  389 + welcomeIvLogo.setScaleType(ImageView.ScaleType.CENTER);
  390 + welcomeIvLogo.setImageResource(R.drawable.icon_splash_tra_bottom_logo);
  391 + rootView.addView(welcomeIvLogo);
379 setContentView(rootView); 392 setContentView(rootView);
380 // 最多5个底部导航按钮 393 // 最多5个底部导航按钮
381 mainViewPager.setOffscreenPageLimit(5); 394 mainViewPager.setOffscreenPageLimit(5);
382 mainViewPager.setUserInputEnabled(false); 395 mainViewPager.setUserInputEnabled(false);
383 // mainBottomBar.setTabRippleColorResource(R.color.transparent); 396 // mainBottomBar.setTabRippleColorResource(R.color.transparent);
384 initAppMainViewModel(); 397 initAppMainViewModel();
385 -// splashHelper = new SplashHelper(AppMainActivity.this);  
386 -// splashHelper.viewModel = (new ViewModelProvider(AppMainActivity.this)).get(SplashViewModel.class); 398 + splashHelper = new SplashHelper(AppMainActivity.this);
  399 + splashHelper.viewModel = (new ViewModelProvider(AppMainActivity.this)).get(SplashViewModel.class);
387 initWelcome(); 400 initWelcome();
388 // 初始化发布视频进度浮窗 401 // 初始化发布视频进度浮窗
389 // PublishFloatViewManager.getInstance().addWhiteList(AppMainActivity.class); 402 // PublishFloatViewManager.getInstance().addWhiteList(AppMainActivity.class);
@@ -418,38 +431,29 @@ public class AppMainActivity extends BaseActivity { @@ -418,38 +431,29 @@ public class AppMainActivity extends BaseActivity {
418 */ 431 */
419 private void initWelcome() { 432 private void initWelcome() {
420 //更新主题后自动重启 433 //更新主题后自动重启
421 -// if (restart) {  
422 - finishPage();  
423 - if(mourningModelBean != null){  
424 - getMourningModeSuccess(mourningModelBean); 434 + if (restart) {
  435 + finishPage();
  436 + if(mourningModelBean != null){
  437 + getMourningModeSuccess(mourningModelBean);
  438 + }
  439 + setAppMainData();
  440 + } else {
  441 + //首次安装或者覆盖安装播放启动页动画
  442 + if (SpUtils.isFirstAgreementFlag()) {
  443 + if(!SpUtils.isRevokePrivacyFlag()){
  444 + //不是撤销协议,才是真的首次
  445 + //更新数据
  446 + DeviceUtil.saveCurrentVersion();
  447 + if (GuideHelper.HASGUIDE) {
  448 + guideHelper = new GuideHelper(AppMainActivity.this);
  449 + guideHelper.init(true);
  450 + }
  451 + }
  452 + startTaskInMain(true);
  453 + } else {
  454 + startTaskInMain(false);
  455 + }
425 } 456 }
426 - setAppMainData();  
427 -// } else {  
428 -// //首次安装或者覆盖安装播放启动页动画  
429 -// if (SpUtils.isFirstAgreementFlag()) {  
430 -//// if(!SpUtils.isRevokePrivacyFlag()){  
431 -//// //不是撤销协议,才是真的首次  
432 -//// //更新数据  
433 -//// DeviceUtil.saveCurrentVersion(this);  
434 -////// if (GuideHelper.HASGUIDE) {  
435 -////// guideHelper = new GuideHelper(AppMainActivity.this);  
436 -////// guideHelper.init(true);  
437 -////// }  
438 -//// }  
439 -// startTaskInMain(true);  
440 -// }  
441 -//// else if (!DeviceUtil.isSameVersion()) {  
442 -//// //升级还需要弹这个一张引导页吗?  
443 -//// if (GuideHelper.HASGUIDE) {  
444 -//// guideHelper = new GuideHelper(AppMainActivity.this);  
445 -//// guideHelper.init(false);  
446 -//// }  
447 -//// startTaskInMain(false);  
448 -//// }  
449 -// else {  
450 -// startTaskInMain(false);  
451 -// }  
452 -// }  
453 457
454 } 458 }
455 459
@@ -464,10 +468,10 @@ public class AppMainActivity extends BaseActivity { @@ -464,10 +468,10 @@ public class AppMainActivity extends BaseActivity {
464 if (first) { 468 if (first) {
465 popAgreepomentDialog(1, -1, -1); 469 popAgreepomentDialog(1, -1, -1);
466 } else { 470 } else {
467 -// if (guideHelper == null || guideHelper.guideFragmentList == null || guideHelper.guideFragmentList.size() <= 1) {  
468 -// //正常启动  
469 -// onGuideEnd();  
470 -// } 471 + if (guideHelper == null || guideHelper.guideFragmentList == null || guideHelper.guideFragmentList.size() <= 1) {
  472 + //正常启动
  473 + onGuideEnd();
  474 + }
471 // //非拉起、非第一次启动 475 // //非拉起、非第一次启动
472 // if (!ispull) { 476 // if (!ispull) {
473 // GeneralTrack.getInstance().appStart(null); 477 // GeneralTrack.getInstance().appStart(null);
@@ -538,21 +542,21 @@ public class AppMainActivity extends BaseActivity { @@ -538,21 +542,21 @@ public class AppMainActivity extends BaseActivity {
538 new float[]{0,0,0,0, 542 new float[]{0,0,0,0,
539 getResources().getDimension(R.dimen.rmrb_dp6), 543 getResources().getDimension(R.dimen.rmrb_dp6),
540 getResources().getDimension(R.dimen.rmrb_dp6),0,0}); 544 getResources().getDimension(R.dimen.rmrb_dp6),0,0});
541 -// agreepomentDialog = BaseDialog.Companion.getInstance()  
542 -// .isCancelable(false)  
543 -// .setLayoutView(view)  
544 -// .setWindow(0.73, 0.0)  
545 -// .setOnCancelClickListener(view.findViewById(R.id.tv_disagree), dialog -> {  
546 -// dialog.dismiss();  
547 -// System.exit(0);  
548 -// })  
549 -// .setOnSureClickListener(view.findViewById(R.id.tv_agree), dialog -> {  
550 -// dialog.dismiss(); 545 + agreepomentDialog = BaseDialog.Companion.getInstance()
  546 + .isCancelable(false)
  547 + .setLayoutView(view)
  548 + .setWindow(0.73, 0.0)
  549 + .setOnCancelClickListener(view.findViewById(R.id.tv_disagree), dialog -> {
  550 + dialog.dismiss();
  551 + System.exit(0);
  552 + })
  553 + .setOnSureClickListener(view.findViewById(R.id.tv_agree), dialog -> {
  554 + dialog.dismiss();
551 // QuinoxlessPrivacyUtil.sendPrivacyAgreedBroadcast(AppMainActivity.this); 555 // QuinoxlessPrivacyUtil.sendPrivacyAgreedBroadcast(AppMainActivity.this);
552 -// //隐私弹窗隐藏  
553 -// Constants.agreepomentDialogIsShow = "0";  
554 -// //首次  
555 -// if (1 == first || 3 == first) { 556 + //隐私弹窗隐藏
  557 + Constants.agreepomentDialogIsShow = "0";
  558 + //首次
  559 + if (1 == first || 3 == first) {
556 // if (SpUtils.isFirstAgreementFlag()) { 560 // if (SpUtils.isFirstAgreementFlag()) {
557 // //由于同意隐私政策之后才能初始化,所以同意隐私政策后立即初始化。与application相互呼应 561 // //由于同意隐私政策之后才能初始化,所以同意隐私政策后立即初始化。与application相互呼应
558 // WelcomeUtils.initializeNowAfterAgree(getApplicationContext()); 562 // WelcomeUtils.initializeNowAfterAgree(getApplicationContext());
@@ -563,33 +567,33 @@ public class AppMainActivity extends BaseActivity { @@ -563,33 +567,33 @@ public class AppMainActivity extends BaseActivity {
563 // //首次安装 点击隐私弹窗同意执行过,不重复执行 567 // //首次安装 点击隐私弹窗同意执行过,不重复执行
564 // ((IStartTaskProvider) WdRouterRule.getInstance().getProvider(IStartTaskProvider.class)).startPrivate(AppMainActivity.this); 568 // ((IStartTaskProvider) WdRouterRule.getInstance().getProvider(IStartTaskProvider.class)).startPrivate(AppMainActivity.this);
565 // } 569 // }
566 -//  
567 -// if(SpUtils.isRevokePrivacyFlag()){  
568 -// //撤销隐私  
569 -// onGuideEnd();  
570 -// }else if (GuideHelper.HASGUIDE) {  
571 -// guideHelper.showGuide(true);  
572 -// } else {  
573 -// toInterestTag();  
574 -// }  
575 -// SpUtils.editRevokePrivacyFlag(false);  
576 -// SpUtils.editFirstAgreementFlag();  
577 -// hashAgreement = true;  
578 -//  
579 -// //请求下协议  
580 -//// getUserAgreement();  
581 -// //首次启动非拉起 570 +
  571 + if(SpUtils.isRevokePrivacyFlag()){
  572 + //撤销隐私
  573 + onGuideEnd();
  574 + }else if (GuideHelper.HASGUIDE) {
  575 + guideHelper.showGuide(true);
  576 + } else {
  577 + toInterestTag();
  578 + }
  579 + SpUtils.editRevokePrivacyFlag(false);
  580 + SpUtils.editFirstAgreementFlag();
  581 + hashAgreement = true;
  582 +
  583 + //请求下协议
  584 +// getUserAgreement();
  585 + //首次启动非拉起
582 // if (!Constants.isRevokePrivacy && Constants.isFirst && !ispull) { 586 // if (!Constants.isRevokePrivacy && Constants.isFirst && !ispull) {
583 // GeneralTrack.getInstance().appStart(null); 587 // GeneralTrack.getInstance().appStart(null);
584 // } 588 // }
585 -// } else {  
586 -// //保存用户协议版本号  
587 -// SpUtils.saveUserAgreeVersion(serviceUserAgreeVersion + "");  
588 -// //保存隐私协议版本号  
589 -// SpUtils.savePrivateAgreeVersion(servicePrivateAgreeVersion + "");  
590 -// }  
591 -// })  
592 -// .showCenter(); 589 + } else {
  590 + //保存用户协议版本号
  591 + SpUtils.saveUserAgreeVersion(serviceUserAgreeVersion + "");
  592 + //保存隐私协议版本号
  593 + SpUtils.savePrivateAgreeVersion(servicePrivateAgreeVersion + "");
  594 + }
  595 + })
  596 + .showCenter();
593 } 597 }
594 598
595 public synchronized void toInterestTag() { 599 public synchronized void toInterestTag() {
@@ -597,8 +601,10 @@ public class AppMainActivity extends BaseActivity { @@ -597,8 +601,10 @@ public class AppMainActivity extends BaseActivity {
597 return; 601 return;
598 } 602 }
599 isToInterestTag = true; 603 isToInterestTag = true;
600 - //跳转兴趣标签页 604 +// //跳转兴趣标签页
601 // ProcessUtils.toInterestTagActivity(true); 605 // ProcessUtils.toInterestTagActivity(true);
  606 + //暂不做趣标签页,之间进首页
  607 + AppMainActivity.this.onGuideEnd();
602 } 608 }
603 609
604 private void setSpan(SpannableString spannableString, String descStr, int startIndex, String jumpPage) { 610 private void setSpan(SpannableString spannableString, String descStr, int startIndex, String jumpPage) {
@@ -631,33 +637,33 @@ public class AppMainActivity extends BaseActivity { @@ -631,33 +637,33 @@ public class AppMainActivity extends BaseActivity {
631 /** 637 /**
632 * 作为更新使用 638 * 作为更新使用
633 */ 639 */
634 -// public void getUserAgreement(List<AppAgreementBean> bean) {  
635 -// if (isUserAgreement) {  
636 -// return;  
637 -// }  
638 -// isUserAgreement = true;  
639 -// AgreementViewModel agreementViewModel = (new ViewModelProvider(AppMainActivity.this)).get(AgreementViewModel.class);  
640 -// agreementViewModel.observeAgreementListener(this, new IAgreementListener() {  
641 -// @Override  
642 -// public void result(int need, int serviceUserAgreeVersion, int servicePrivateAgreeVersion) {  
643 -// if (Constants.isFirst) {  
644 -// if (need != -1) {  
645 -// //保存用户协议版本号  
646 -// SpUtils.saveUserAgreeVersion(serviceUserAgreeVersion + "");  
647 -// //保存隐私协议版本号  
648 -// SpUtils.savePrivateAgreeVersion(servicePrivateAgreeVersion + "");  
649 -// }  
650 -// return;  
651 -// }  
652 -//  
653 -// if (need == 1) {  
654 -// popAgreepomentDialog(2, serviceUserAgreeVersion, servicePrivateAgreeVersion);  
655 -// }  
656 -// }  
657 -// });  
658 -// //接口合并到统一  
659 -// agreementViewModel.getAppAgreementV2(bean);  
660 -// } 640 + public void getUserAgreement(List<AppAgreementBean> bean) {
  641 + if (isUserAgreement) {
  642 + return;
  643 + }
  644 + isUserAgreement = true;
  645 + AgreementViewModel agreementViewModel = (new ViewModelProvider(AppMainActivity.this)).get(AgreementViewModel.class);
  646 + agreementViewModel.observeAgreementListener(this, new IAgreementListener() {
  647 + @Override
  648 + public void result(int need, int serviceUserAgreeVersion, int servicePrivateAgreeVersion) {
  649 + if (Constants.isFirst) {
  650 + if (need != -1) {
  651 + //保存用户协议版本号
  652 + SpUtils.saveUserAgreeVersion(serviceUserAgreeVersion + "");
  653 + //保存隐私协议版本号
  654 + SpUtils.savePrivateAgreeVersion(servicePrivateAgreeVersion + "");
  655 + }
  656 + return;
  657 + }
  658 +
  659 + if (need == 1) {
  660 + popAgreepomentDialog(2, serviceUserAgreeVersion, servicePrivateAgreeVersion);
  661 + }
  662 + }
  663 + });
  664 + //接口合并到统一
  665 + agreementViewModel.getAppAgreementV2(bean);
  666 + }
661 667
662 668
663 /** 669 /**
@@ -794,27 +800,28 @@ public class AppMainActivity extends BaseActivity { @@ -794,27 +800,28 @@ public class AppMainActivity extends BaseActivity {
794 /** 800 /**
795 * 启动接口成功 801 * 启动接口成功
796 */ 802 */
797 -// public void getLaunchPageFinish(LaunchPageBean launchPageBean){  
798 -// if(getLaunchPageFinish){  
799 -// return;  
800 -// }  
801 -// if(finishPageLoad){  
802 -// //执行任务:打开客户端  
803 -// TaskManager.getInstance().executePointLevelOperate(TaskOperateTypeConstants.OPEN_CLIENT);  
804 -// }  
805 -// getLaunchPageFinish = true;  
806 -// if (null == launchPageBean) {  
807 -// return;  
808 -// }  
809 -// //处理搜索词  
810 -// if(launchPageBean.getHits() != null){  
811 -// LaunchPageConstant.hintsBeans = launchPageBean.getHits().getHitList();  
812 -// }  
813 -// LiveDataBus.getInstance().with(EventConstants.LAUNCHPAGE_SUCCESS).postValue(true);  
814 -// } 803 + public void getLaunchPageFinish(LaunchPageBean launchPageBean){
  804 + if(getLaunchPageFinish){
  805 + return;
  806 + }
  807 + if(finishPageLoad){
  808 + //执行任务:打开客户端
  809 + TaskManager.getInstance().executePointLevelOperate(TaskOperateTypeConstants.OPEN_CLIENT);
  810 + }
  811 + getLaunchPageFinish = true;
  812 + if (null == launchPageBean) {
  813 + return;
  814 + }
  815 + //处理搜索词
  816 + if(launchPageBean.getHits() != null){
  817 + LaunchPageConstant.hintsBeans = launchPageBean.getHits().getHitList();
  818 + }
  819 + LiveDataBus.getInstance().with(EventConstants.LAUNCHPAGE_SUCCESS).postValue(true);
  820 + }
815 821
816 /** 822 /**
817 * 接口合并,处理国殇模式 823 * 接口合并,处理国殇模式
  824 + *
818 * @param modelBean 825 * @param modelBean
819 */ 826 */
820 public void getMourningModeSuccess(MourningModelBean modelBean) { 827 public void getMourningModeSuccess(MourningModelBean modelBean) {
@@ -1234,10 +1241,10 @@ public class AppMainActivity extends BaseActivity { @@ -1234,10 +1241,10 @@ public class AppMainActivity extends BaseActivity {
1234 /** 1241 /**
1235 * 获取新闻tab频道 1242 * 获取新闻tab频道
1236 */ 1243 */
1237 - public void getNewsTabBottomNavGroupDetail(){  
1238 - if (null != mainFragmentAdapter){ 1244 + public void getNewsTabBottomNavGroupDetail() {
  1245 + if (null != mainFragmentAdapter) {
1239 Fragment fragment = mainFragmentAdapter.getCurFragment(0); 1246 Fragment fragment = mainFragmentAdapter.getCurFragment(0);
1240 - if (null != fragment){ 1247 + if (null != fragment) {
1241 if (fragment instanceof NewsHomeFragment) { 1248 if (fragment instanceof NewsHomeFragment) {
1242 NewsHomeFragment newsHomeFragment = (NewsHomeFragment) fragment; 1249 NewsHomeFragment newsHomeFragment = (NewsHomeFragment) fragment;
1243 newsHomeFragment.request(); 1250 newsHomeFragment.request();
@@ -1339,8 +1346,8 @@ public class AppMainActivity extends BaseActivity { @@ -1339,8 +1346,8 @@ public class AppMainActivity extends BaseActivity {
1339 // 先获取底部导航数据,再展示view 1346 // 先获取底部导航数据,再展示view
1340 hasData = mViewModel.getBottomBarData(); 1347 hasData = mViewModel.getBottomBarData();
1341 1348
1342 - requestBottomGroup();  
1343 - getNewsTabBottomNavGroupDetail(); 1349 +// requestBottomGroup();
  1350 +// getNewsTabBottomNavGroupDetail();
1344 } 1351 }
1345 1352
1346 } 1353 }
@@ -1348,8 +1355,8 @@ public class AppMainActivity extends BaseActivity { @@ -1348,8 +1355,8 @@ public class AppMainActivity extends BaseActivity {
1348 /** 1355 /**
1349 * 请求首页底部tab数据 1356 * 请求首页底部tab数据
1350 */ 1357 */
1351 - public void requestBottomGroup(){  
1352 - if (mViewModel != null){ 1358 + public void requestBottomGroup() {
  1359 + if (mViewModel != null) {
1353 mViewModel.loadBottomBarData(hasData); 1360 mViewModel.loadBottomBarData(hasData);
1354 } 1361 }
1355 } 1362 }
@@ -1553,21 +1560,21 @@ public class AppMainActivity extends BaseActivity { @@ -1553,21 +1560,21 @@ public class AppMainActivity extends BaseActivity {
1553 */ 1560 */
1554 private void delayInitialization() { 1561 private void delayInitialization() {
1555 //重启不需要多余操作 1562 //重启不需要多余操作
1556 -// ThreadPoolUtils.postToMainDelay(new Runnable() {  
1557 -// @Override  
1558 -// public void run() {  
1559 -// WelcomeUtils.delayInit(AppMainActivity.this);  
1560 -// //延后释放释放资源,防止黑屏  
1561 -// splashHelper.releasePlayer();  
1562 -// welcomeIvLogo.setImageResource(0);  
1563 -// rootView.removeView(flsplashContainer);  
1564 -// rootView.removeView(welcomeIvLogo);  
1565 -// if (splashHelper.splashRlJumpAd != null) {  
1566 -// rootView.removeView(splashHelper.splashRlJumpAd);  
1567 -// }  
1568 -// System.gc();  
1569 -// }  
1570 -// }, 200); 1563 + ThreadPoolUtils.postToMainDelay(new Runnable() {
  1564 + @Override
  1565 + public void run() {
  1566 + WelcomeUtils.delayInit(AppMainActivity.this);
  1567 + //延后释放释放资源,防止黑屏
  1568 + splashHelper.releasePlayer();
  1569 + welcomeIvLogo.setImageResource(0);
  1570 + rootView.removeView(flsplashContainer);
  1571 + rootView.removeView(welcomeIvLogo);
  1572 + if (splashHelper.splashRlJumpAd != null) {
  1573 + rootView.removeView(splashHelper.splashRlJumpAd);
  1574 + }
  1575 + System.gc();
  1576 + }
  1577 + }, 200);
1571 } 1578 }
1572 1579
1573 /** 1580 /**
@@ -1583,11 +1590,11 @@ public class AppMainActivity extends BaseActivity { @@ -1583,11 +1590,11 @@ public class AppMainActivity extends BaseActivity {
1583 //是否跳推送 1590 //是否跳推送
1584 WelcomeUtils.toPushActivity(); 1591 WelcomeUtils.toPushActivity();
1585 // 是否跳桌面组件 1592 // 是否跳桌面组件
1586 -// WelcomeUtils.toWidgetActivity();  
1587 -// if(getLaunchPageFinish){  
1588 -// //执行任务:打开客户端  
1589 -// TaskManager.getInstance().executePointLevelOperate(TaskOperateTypeConstants.OPEN_CLIENT);  
1590 -// } 1593 + WelcomeUtils.toWidgetActivity();
  1594 + if(getLaunchPageFinish){
  1595 + //执行任务:打开客户端
  1596 + TaskManager.getInstance().executePointLevelOperate(TaskOperateTypeConstants.OPEN_CLIENT);
  1597 + }
1591 } 1598 }
1592 1599
1593 /** 1600 /**
@@ -1595,19 +1602,19 @@ public class AppMainActivity extends BaseActivity { @@ -1595,19 +1602,19 @@ public class AppMainActivity extends BaseActivity {
1595 */ 1602 */
1596 private void onWelcomeEnd() { 1603 private void onWelcomeEnd() {
1597 //主页背景适配夜间模式 1604 //主页背景适配夜间模式
1598 -// rootView.setBackgroundColor(ContextCompat.getColor(this, R.color.res_color_common_C8));  
1599 -// flsplashContainer.setVisibility(View.GONE);  
1600 -// if (guideHelper != null) {  
1601 -// guideHelper.releaseResources();  
1602 -// }  
1603 -// splashHelper.releaseResources();  
1604 -// ViewUtils.setVisible(splashHelper.splashRlJumpAd, View.GONE);  
1605 -// ViewUtils.setVisible(splashHelper.splashTimeView, View.GONE);  
1606 -// ViewUtils.setVisible(splashHelper.splashAdTipTextView, View.GONE);  
1607 -// welcomeIvLogo.setVisibility(View.GONE);  
1608 -// Constants.finishPageLoad = true; 1605 + rootView.setBackgroundColor(ContextCompat.getColor(this, R.color.res_color_common_C8));
  1606 + flsplashContainer.setVisibility(View.GONE);
  1607 + if (guideHelper != null) {
  1608 + guideHelper.releaseResources();
  1609 + }
  1610 + splashHelper.releaseResources();
  1611 + ViewUtils.setVisible(splashHelper.splashRlJumpAd, View.GONE);
  1612 + ViewUtils.setVisible(splashHelper.splashTimeView, View.GONE);
  1613 + ViewUtils.setVisible(splashHelper.splashAdTipTextView, View.GONE);
  1614 + welcomeIvLogo.setVisibility(View.GONE);
  1615 + Constants.finishPageLoad = true;
1609 // initCommand(); 1616 // initCommand();
1610 -// LiveDataBus.getInstance().with(EventConstants.WELCOME_END).postValue(true); 1617 + LiveDataBus.getInstance().with(EventConstants.WELCOME_END).postValue(true);
1611 } 1618 }
1612 1619
1613 /** 1620 /**
@@ -1615,8 +1622,8 @@ public class AppMainActivity extends BaseActivity { @@ -1615,8 +1622,8 @@ public class AppMainActivity extends BaseActivity {
1615 */ 1622 */
1616 public void onGuideEnd() { 1623 public void onGuideEnd() {
1617 // 跳转启动页 1624 // 跳转启动页
1618 -// splashHelper.jumpSplash(Constants.isFirst && !Constants.isRevokePrivacy);  
1619 -// setAppMainData(); 1625 + splashHelper.jumpSplash(Constants.isFirst && !Constants.isRevokePrivacy);
  1626 + setAppMainData();
1620 } 1627 }
1621 1628
1622 @Override 1629 @Override
@@ -1627,7 +1634,7 @@ public class AppMainActivity extends BaseActivity { @@ -1627,7 +1634,7 @@ public class AppMainActivity extends BaseActivity {
1627 @Override 1634 @Override
1628 protected void onPause() { 1635 protected void onPause() {
1629 super.onPause(); 1636 super.onPause();
1630 -// splashHelper.onPause(); 1637 + splashHelper.onPause();
1631 } 1638 }
1632 1639
1633 @Override 1640 @Override
@@ -1651,7 +1658,7 @@ public class AppMainActivity extends BaseActivity { @@ -1651,7 +1658,7 @@ public class AppMainActivity extends BaseActivity {
1651 1658
1652 @Override 1659 @Override
1653 protected void onStop() { 1660 protected void onStop() {
1654 -// splashHelper.onStop(); 1661 + splashHelper.onStop();
1655 super.onStop(); 1662 super.onStop();
1656 // if(Constants.finishPageLoad && !SpUtils.isFirstAgreementFlag()){ 1663 // if(Constants.finishPageLoad && !SpUtils.isFirstAgreementFlag()){
1657 // //更新小组件数据,如果已经调用过不会再调用 1664 // //更新小组件数据,如果已经调用过不会再调用
@@ -1671,15 +1678,15 @@ public class AppMainActivity extends BaseActivity { @@ -1671,15 +1678,15 @@ public class AppMainActivity extends BaseActivity {
1671 @Override 1678 @Override
1672 protected void onDestroy() { 1679 protected void onDestroy() {
1673 super.onDestroy(); 1680 super.onDestroy();
1674 -// String vistorMergeDataTag = SpUtils.getVistorMergeDataTag();  
1675 -// if(StringUtils.isEqual("2",vistorMergeDataTag)){  
1676 -// SpUtils.setVistorMergeDataTag("0");  
1677 -// }  
1678 -// if(SpUtils.getAgreeClipboard() == 2){  
1679 -// SpUtils.saveAgreeClipboard(0);  
1680 -// } 1681 + String vistorMergeDataTag = SpUtils.getVistorMergeDataTag();
  1682 + if(StringUtils.isEqual("2",vistorMergeDataTag)){
  1683 + SpUtils.setVistorMergeDataTag("0");
  1684 + }
  1685 + if(SpUtils.getAgreeClipboard() == 2){
  1686 + SpUtils.saveAgreeClipboard(0);
  1687 + }
1681 1688
1682 -// BaseDialog.Companion.getInstance().dismiss(); 1689 + BaseDialog.Companion.getInstance().dismiss();
1683 if (mReceiver != null) { 1690 if (mReceiver != null) {
1684 unregisterReceiver(mReceiver); 1691 unregisterReceiver(mReceiver);
1685 } 1692 }
@@ -1771,7 +1778,6 @@ public class AppMainActivity extends BaseActivity { @@ -1771,7 +1778,6 @@ public class AppMainActivity extends BaseActivity {
1771 } 1778 }
1772 1779
1773 1780
1774 -  
1775 /** 1781 /**
1776 * 游客数据合并 1782 * 游客数据合并
1777 */ 1783 */
@@ -1903,9 +1909,9 @@ public class AppMainActivity extends BaseActivity { @@ -1903,9 +1909,9 @@ public class AppMainActivity extends BaseActivity {
1903 @Override 1909 @Override
1904 public void onConfigurationChanged(@NonNull Configuration newConfig) { 1910 public void onConfigurationChanged(@NonNull Configuration newConfig) {
1905 super.onConfigurationChanged(newConfig); 1911 super.onConfigurationChanged(newConfig);
1906 -// if(StringUtils.isEqual("1",Constants.agreepomentDialogIsShow) && agreepomentDialog != null){  
1907 -// agreepomentDialog.showCenter();  
1908 -// } 1912 + if(StringUtils.isEqual("1",Constants.agreepomentDialogIsShow) && agreepomentDialog != null){
  1913 + agreepomentDialog.showCenter();
  1914 + }
1909 //跟随系统,但系统深色模式与当前不一致 1915 //跟随系统,但系统深色模式与当前不一致
1910 boolean isFollowChange = StringUtils.isEqual(SpUtils.FOLLOWUP_SYSTEM, 1916 boolean isFollowChange = StringUtils.isEqual(SpUtils.FOLLOWUP_SYSTEM,
1911 SpUtils.getNightMode()) && Constants.isNightMode != SpUtils.isNightMode(); 1917 SpUtils.getNightMode()) && Constants.isNightMode != SpUtils.isNightMode();
  1 +package com.wd.module_home.adapter;
  2 +
  3 +import androidx.annotation.NonNull;
  4 +import androidx.fragment.app.Fragment;
  5 +import androidx.fragment.app.FragmentActivity;
  6 +import androidx.viewpager2.adapter.FragmentStateAdapter;
  7 +
  8 +
  9 +import com.wd.module_home.fragment.GuideFragment;
  10 +
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * Time:2022/9/25
  15 + * Author:ypf
  16 + * Description:引导页适配器
  17 + */
  18 +public class GuideAdapter extends FragmentStateAdapter {
  19 +
  20 +
  21 + private final List<GuideFragment> fragmentList;
  22 +
  23 + public GuideAdapter(@NonNull FragmentActivity fragmentActivity, List<GuideFragment> fragmentList) {
  24 + super(fragmentActivity);
  25 + this.fragmentList = fragmentList;
  26 + }
  27 +
  28 + @NonNull
  29 + @Override
  30 + public Fragment createFragment(int position) {
  31 + return fragmentList.get(position);
  32 + }
  33 +
  34 + @Override
  35 + public int getItemCount() {
  36 + return fragmentList.size();
  37 + }
  38 + @Override
  39 + public long getItemId(int position) {
  40 + return fragmentList.get(position).hashCode();
  41 + }
  42 +
  43 + @Override
  44 + public boolean containsItem(long itemId) {
  45 + return fragmentList.contains(itemId);
  46 + }
  47 +}
  1 +package com.wd.module_home.adapter;
  2 +
  3 +import android.view.LayoutInflater;
  4 +import android.view.View;
  5 +import android.view.ViewGroup;
  6 +import android.widget.ImageView;
  7 +
  8 +import androidx.annotation.NonNull;
  9 +import androidx.recyclerview.widget.RecyclerView;
  10 +
  11 +import com.wd.module_home.R;
  12 +
  13 +public class GuideIndexAdapter extends RecyclerView.Adapter<GuideIndexAdapter.MyViewHolder> {
  14 + /**
  15 + * center_index当前需要高亮显示的view的位置
  16 + */
  17 + private int selectIndex = 0;
  18 + /**
  19 + * last_index将高亮的item恢复为默认状态时使用
  20 + */
  21 + private int beforeSelectIndex = 0;
  22 + private int size;
  23 + public GuideIndexAdapter(int size) {
  24 + this.size = size;
  25 + }
  26 +
  27 + @NonNull
  28 + @Override
  29 + public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
  30 + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_guideindex, parent, false);
  31 + return new MyViewHolder(view);
  32 + }
  33 +
  34 + @Override
  35 + public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
  36 + if(selectIndex == position){
  37 + //选中
  38 + holder.ivindex.setImageResource(R.mipmap.icon_guideindexselect);
  39 + }else{
  40 + //未选中
  41 + holder.ivindex.setImageResource(R.mipmap.icon_guideindexunselect);
  42 + }
  43 + }
  44 +
  45 + @Override
  46 + public int getItemCount() {
  47 + return size;
  48 + }
  49 +
  50 + public static class MyViewHolder extends RecyclerView.ViewHolder {
  51 + public ImageView ivindex;
  52 +
  53 + public MyViewHolder(@NonNull View itemView) {
  54 + super(itemView);
  55 + ivindex = itemView.findViewById(R.id.ivindex);
  56 + }
  57 + }
  58 +
  59 + public void setSelectPosition(int index){
  60 + if (index == selectIndex) {
  61 + return;
  62 + }
  63 + beforeSelectIndex = selectIndex;
  64 + selectIndex = index;
  65 + notifyItemChanged(beforeSelectIndex);
  66 + notifyItemChanged(selectIndex);
  67 + }
  68 +}
  1 +package com.wd.module_home.fragment;
  2 +
  3 +import android.os.Bundle;
  4 +import android.view.View;
  5 +import android.widget.ImageView;
  6 +import android.widget.RelativeLayout;
  7 +import android.widget.TextView;
  8 +
  9 +import com.wd.foundation.wdkit.base.fragment.BaseFragment;
  10 +import com.wd.foundation.wdkit.viewclick.BaseClickListener;
  11 +import com.wd.module_home.AppMainActivity;
  12 +import com.wd.module_home.R;
  13 +import com.wd.module_home.util.GuideConstants;
  14 +
  15 +
  16 +/**
  17 + * Time:2022/9/25
  18 + * Author:ypf
  19 + * Description:引导页1
  20 + */
  21 +public class GuideFragment extends BaseFragment {
  22 + /**
  23 + * 静态引导页
  24 + * */
  25 + private final int[] GUIDE_STATIC_IMG = {R.mipmap.guide_static1, R.mipmap.guide_static2
  26 + , R.mipmap.guide_static3, R.mipmap.guide_static4, R.mipmap.guide_static5};
  27 + /**
  28 + * 静态引导页文字
  29 + * */
  30 + private final int[] GUIDE_TITLE_IMG = {R.mipmap.guide_title1, R.mipmap.guide_title2
  31 + , R.mipmap.guide_title3, R.mipmap.guide_title4, R.mipmap.guide_title5};
  32 +
  33 + private ImageView ivglide;
  34 + /**
  35 + * 点击按钮--开启7.0全新体验
  36 + */
  37 + private TextView imgFirstGoMain;
  38 + private int index,mScreenType, mScreenHeight,mScreenWidth;
  39 +
  40 + /**
  41 + * 一张引导页
  42 + */
  43 + private RelativeLayout rlGuideFragment;
  44 +
  45 + /**
  46 + * @param screenType 1折叠屏(或者宽屏当作折叠屏处理)
  47 + * */
  48 + public static GuideFragment newInstance(int index,int screenType, int screenHeight, int screenWidth) {
  49 + Bundle args = new Bundle();
  50 + args.putInt(GuideConstants.ARGUMENTS_INDEX, index);
  51 + args.putInt(GuideConstants.SCREEN_TYPE,screenType);
  52 + args.putInt(GuideConstants.SCREEN_HEIGHT,screenHeight);
  53 + args.putInt(GuideConstants.SCREEN_WIDTH,screenWidth);
  54 + GuideFragment fragment = new GuideFragment();
  55 + fragment.setArguments(args);
  56 + return fragment;
  57 + }
  58 +
  59 +
  60 + @Override
  61 + protected String getLogTag() {
  62 + return GuideFragment.class.getSimpleName();
  63 + }
  64 +
  65 + @Override
  66 + protected int getLayout() {
  67 + index = GuideConstants.WELCOME_INDEX_0;
  68 + Bundle arguments = getArguments();
  69 + if (arguments != null) {
  70 + index = arguments.getInt(GuideConstants.ARGUMENTS_INDEX);
  71 + mScreenType = arguments.getInt(GuideConstants.SCREEN_TYPE);
  72 + mScreenHeight = arguments.getInt(GuideConstants.SCREEN_HEIGHT);
  73 + mScreenWidth = arguments.getInt(GuideConstants.SCREEN_WIDTH);
  74 + }
  75 + if(index == GuideConstants.WELCOME_INDEX_0){
  76 + //欢迎页
  77 + return R.layout.fragment_guidedefault;
  78 + }else{
  79 + //引导页7.0
  80 + return R.layout.fragment_guide_new;
  81 + }
  82 + }
  83 +
  84 + @Override
  85 + protected void initView(View rootView) {
  86 + initGuideView(rootView);
  87 + }
  88 +
  89 + private void initGuideView(View rootView) {
  90 + if(GuideConstants.WELCOME_INDEX_0 != index){
  91 + //静态引导页
  92 + ivglide = rootView.findViewById(R.id.ivstatic);
  93 + rlGuideFragment = rootView.findViewById(R.id.rl_guide_fragment);
  94 + //静态引导页
  95 + imgFirstGoMain = rootView.findViewById(R.id.img_act_first_go_main);
  96 +
  97 + //设置图片资源
  98 + if(mScreenType == 1){
  99 + //宽屏处理
  100 + RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ivglide.getLayoutParams();
  101 + params.width = mScreenHeight /2;
  102 + params.addRule(RelativeLayout.CENTER_IN_PARENT);
  103 + ivglide.setLayoutParams(params);
  104 + //保证不变形,至少宽或者高填充满,另一边不到边则留白
  105 + ivglide.setScaleType(ImageView.ScaleType.FIT_CENTER);
  106 + }
  107 +
  108 + ivglide.setImageResource(GUIDE_STATIC_IMG[index]);
  109 +
  110 + //设置一张引导页
  111 + if(GuideConstants.GUIDE_INDEX_0 == index){
  112 + rlGuideFragment.setVisibility(View.VISIBLE);
  113 + imgFirstGoMain.setOnClickListener(new BaseClickListener() {
  114 + @Override
  115 + protected void onNoDoubleClick(View v) {
  116 +
  117 + if(getActivity()!=null && getActivity() instanceof AppMainActivity){
  118 + //引导页结束
  119 + ((AppMainActivity)getActivity()).toInterestTag();
  120 + }
  121 +
  122 + }
  123 + });
  124 +
  125 + }
  126 +
  127 +// //设置尺寸
  128 +// if(GuideConstants.GUIDE_INDEX_0 == index){
  129 +// RelativeLayout.LayoutParams img2param = (RelativeLayout.LayoutParams) iv_static_img_2.getLayoutParams();
  130 +// if(mScreenType == 1){
  131 +// img2param.width = mScreenWidth*252/(2*375);
  132 +// img2param.height = mScreenWidth*58/(2*375);
  133 +// }else{
  134 +// img2param.width = mScreenWidth*252/375;
  135 +// img2param.height = mScreenWidth*58/375;
  136 +// }
  137 +// iv_static_img_2.setLayoutParams(img2param);
  138 +// iv_static_img_2.setVisibility(View.VISIBLE);
  139 +// iv_static_img.setVisibility(View.GONE);
  140 +// iv_static_img_2.setImageResource(GUIDE_TITLE_IMG[index]);
  141 +// }else if(GuideConstants.GUIDE_INDEX_1 == index){
  142 +// RelativeLayout.LayoutParams img2param = (RelativeLayout.LayoutParams) iv_static_img_2.getLayoutParams();
  143 +// if(mScreenType == 1){
  144 +// img2param.width = mScreenWidth*228/(2*375);
  145 +// img2param.height = mScreenWidth*58/(2*375);
  146 +// }else{
  147 +// img2param.width = mScreenWidth*228/375;
  148 +// img2param.height = mScreenWidth*58/375;
  149 +// }
  150 +// iv_static_img_2.setLayoutParams(img2param);
  151 +// iv_static_img_2.setVisibility(View.VISIBLE);
  152 +// iv_static_img.setVisibility(View.GONE);
  153 +// iv_static_img_2.setImageResource(GUIDE_TITLE_IMG[index]);
  154 +// }else if(GuideConstants.GUIDE_INDEX_2 == index){
  155 +// RelativeLayout.LayoutParams img2param = (RelativeLayout.LayoutParams) iv_static_img_2.getLayoutParams();
  156 +// if(mScreenType == 1){
  157 +// img2param.width = mScreenWidth*228/(2*375);
  158 +// img2param.height = mScreenWidth*58/(2*375);
  159 +// }else{
  160 +// img2param.width = mScreenWidth*228/375;
  161 +// img2param.height = mScreenWidth*58/375;
  162 +// }
  163 +// iv_static_img_2.setLayoutParams(img2param);
  164 +// iv_static_img_2.setVisibility(View.VISIBLE);
  165 +// iv_static_img.setVisibility(View.GONE);
  166 +// iv_static_img_2.setImageResource(GUIDE_TITLE_IMG[index]);
  167 +// }else if(GuideConstants.GUIDE_INDEX_3 == index){
  168 +// RelativeLayout.LayoutParams img2param = (RelativeLayout.LayoutParams) iv_static_img_2.getLayoutParams();
  169 +// if(mScreenType == 1){
  170 +// img2param.width = mScreenWidth*228/(2*375);
  171 +// img2param.height = mScreenWidth*58/(2*375);
  172 +// }else{
  173 +// img2param.width = mScreenWidth*228/375;
  174 +// img2param.height = mScreenWidth*58/375;
  175 +// }
  176 +// iv_static_img_2.setLayoutParams(img2param);
  177 +// iv_static_img_2.setVisibility(View.VISIBLE);
  178 +// iv_static_img.setVisibility(View.GONE);
  179 +// iv_static_img_2.setImageResource(GUIDE_TITLE_IMG[index]);
  180 +// }else if(GuideConstants.GUIDE_INDEX_4 == index){
  181 +// RelativeLayout.LayoutParams img1param = (RelativeLayout.LayoutParams) iv_static_img.getLayoutParams();
  182 +// if(mScreenType == 1){
  183 +// img1param.width = mScreenWidth*289/(2*375);
  184 +// img1param.height = mScreenWidth*30/(2*375);
  185 +// }else{
  186 +// img1param.width = mScreenWidth*289/375;
  187 +// img1param.height = mScreenWidth*30/375;
  188 +// }
  189 +// iv_static_img.setLayoutParams(img1param);
  190 +// iv_static_img.setVisibility(View.VISIBLE);
  191 +// iv_static_img_2.setVisibility(View.GONE);
  192 +// iv_static_img.setImageResource(GUIDE_TITLE_IMG[index]);
  193 +// }
  194 + }
  195 + }
  196 +
  197 +
  198 + @Override
  199 + public void onDestroy() {
  200 + super.onDestroy();
  201 + if(ivglide != null){
  202 + //释放资源
  203 + ivglide.setImageResource(0);
  204 + }
  205 + //通知回收资源
  206 + System.gc();
  207 + }
  208 +
  209 +
  210 +}
  1 +
  2 +package com.wd.module_home.model;
  3 +
  4 +import android.text.TextUtils;
  5 +
  6 +
  7 +import com.wd.base.log.Logger;
  8 +import com.wd.capability.network.BaseObserver;
  9 +import com.wd.capability.network.fetcher.BaseDataFetcher;
  10 +import com.wd.capability.network.response.BaseResponse;
  11 +import com.wd.common.api.RequestApi;
  12 +import com.wd.foundation.bean.launch.AppAgreementBean;
  13 +import com.wd.foundation.wdkit.constant.Constants;
  14 +import com.wd.foundation.wdkit.utils.SpUtils;
  15 +import com.wd.foundation.wdkitcore.tools.StringUtils;
  16 +import com.wd.module_home.vm.IAgreementListener;
  17 +
  18 +import java.util.List;
  19 +
  20 +import io.reactivex.Observable;
  21 +
  22 +/**
  23 + * 描述:获取隐私协议
  24 + *
  25 + * @author : lvjinhui
  26 + * @since: 2022/7/15
  27 + */
  28 +public class AppAgreementFetcher extends BaseDataFetcher<RequestApi> {
  29 +
  30 + private final String userType = "1";
  31 +
  32 + private final String privacyType = "2";
  33 +
  34 + /**
  35 + * 4:用户注销协议
  36 + */
  37 + private final String logoutType = "4";
  38 +
  39 + /**
  40 + * 5-留言板-用户协议
  41 + */
  42 + private final String messageBoardUserType = "5";
  43 +
  44 + /**
  45 + * 7-留言板-发布提问规定
  46 + */
  47 + private final String messageBoardPublishType = "7";
  48 +
  49 + /**
  50 + * 8-留言板-隐私政策
  51 + */
  52 + private final String messageBoardPrivateType = "8";
  53 +
  54 +
  55 +
  56 + /**
  57 + * APP个人信息收集清单
  58 + */
  59 + private final String personalInformationType = "9";
  60 +
  61 + /**
  62 + * 第三方信息共享清单
  63 + */
  64 + private final String thirdInformationType = "10";
  65 +
  66 + /**
  67 + * APP权限清单
  68 + */
  69 + private final String permissionsListType = "11";
  70 +
  71 +
  72 + private final IAgreementListener mListener;
  73 +
  74 + public AppAgreementFetcher(IAgreementListener mListener) {
  75 + this.mListener = mListener;
  76 + }
  77 +
  78 + /**
  79 + * 获取隐私,用户协议
  80 + */
  81 + public void getAppAgreementData(List<AppAgreementBean> bean) {
  82 + if(bean != null){
  83 + int localUserVersion = 0;
  84 + int localPrivacyVersion = 0;
  85 + int serviceUserAgreeVersion = 0;
  86 + int servicePrivateAgreeVersion = 0;
  87 + try{
  88 + if(TextUtils.isEmpty(SpUtils.getUserAgreeVersion())){
  89 + localUserVersion = Constants.USER_AGREE_VERSION;
  90 + }else{
  91 + localUserVersion = Integer.parseInt(SpUtils.getUserAgreeVersion());
  92 + }
  93 + if(TextUtils.isEmpty(SpUtils.getPrivateAgreeVersion())){
  94 + localPrivacyVersion = Constants.PRIVATE_AGREE_VERSION;
  95 + }else{
  96 + localPrivacyVersion = Integer.parseInt(SpUtils.getPrivateAgreeVersion());
  97 + }
  98 + for(int i = 0; i < bean.size(); i++){
  99 + AppAgreementBean appAgreementBean = bean.get(i);
  100 + if(appAgreementBean == null || StringUtils.isEmpty(appAgreementBean.linkUrl)){
  101 + continue;
  102 + }
  103 + if(userType.equals(appAgreementBean.type)){
  104 + if(!TextUtils.isEmpty(appAgreementBean.versionCode)){
  105 + serviceUserAgreeVersion = Integer.parseInt(appAgreementBean.versionCode);
  106 + }
  107 + if(!TextUtils.isEmpty(appAgreementBean.linkUrl)){
  108 + SpUtils.saveUserAgreeUrl(appAgreementBean.linkUrl);
  109 + }
  110 + }else if(privacyType.equals(appAgreementBean.type)){
  111 + if(!TextUtils.isEmpty(appAgreementBean.versionCode)){
  112 + servicePrivateAgreeVersion = Integer.parseInt(appAgreementBean.versionCode);
  113 + }
  114 + if(!TextUtils.isEmpty(appAgreementBean.linkUrl)){
  115 + SpUtils.savePrivateAgreeUrl(appAgreementBean.linkUrl);
  116 + }
  117 + }else if (logoutType.equals(appAgreementBean.type)){
  118 + SpUtils.saveLogoutAgreeUrl(appAgreementBean.linkUrl);
  119 + Logger.t("AppAgreementFetcher").d("注销协议保存成功");
  120 + }else if (messageBoardUserType.equals(appAgreementBean.type)){
  121 + SpUtils.saveMessageBoardUserUrl(appAgreementBean.linkUrl);
  122 + Logger.t("AppAgreementFetcher").d("保存留言板用户协议保存成功");
  123 + }else if (messageBoardPrivateType.equals(appAgreementBean.type)){
  124 + SpUtils.saveMessageBoardPrivateUrl(appAgreementBean.linkUrl);
  125 + Logger.t("AppAgreementFetcher").d("保存留言板隐私协议保存成功");
  126 + }else if (messageBoardPublishType.equals(appAgreementBean.type)){
  127 + SpUtils.saveMessageBoardPublishUrl(appAgreementBean.linkUrl);
  128 + Logger.t("AppAgreementFetcher").d("保存留言板发布提问规定保存成功");
  129 + }else if (personalInformationType.equals(appAgreementBean.type)){
  130 + SpUtils.savePersonalInformationUrl(appAgreementBean.linkUrl);
  131 + Logger.t("AppAgreementFetcher").d("APP个人信息收集清单");
  132 + }else if (thirdInformationType.equals(appAgreementBean.type)){
  133 + SpUtils.saveThirdInformationUrl(appAgreementBean.linkUrl);
  134 + Logger.t("AppAgreementFetcher").d("第三方信息共享清单");
  135 + }else if (permissionsListType.equals(appAgreementBean.type)){
  136 + SpUtils.savePermissionsListUrl(appAgreementBean.linkUrl);
  137 + Logger.t("AppAgreementFetcher").d("APP权限清单");
  138 + }
  139 + }
  140 + }catch (Exception e){
  141 + Logger.t("AppAgreementFetcher").d("Exception");
  142 + }
  143 +
  144 + if(localUserVersion<serviceUserAgreeVersion||
  145 + localPrivacyVersion<servicePrivateAgreeVersion){
  146 + //用户协议版本号或隐私协议版本号有升级
  147 + if(mListener!=null){
  148 + mListener.result(1,serviceUserAgreeVersion,servicePrivateAgreeVersion);
  149 + }
  150 + }else {
  151 + if(mListener!=null){
  152 + mListener.result(0,serviceUserAgreeVersion,servicePrivateAgreeVersion);
  153 + }
  154 + }
  155 + }else {
  156 + if(mListener!=null){
  157 + mListener.result(-1,0,0);
  158 + }
  159 + }
  160 + }
  161 +
  162 + /**
  163 + * 用户隐私协议接口请求
  164 + */
  165 + public void requestAppAgreementData(){
  166 + Observable<BaseResponse<List<AppAgreementBean>>> splashAdInfo = getRetrofit().getAppAgreement();
  167 + request(splashAdInfo, new BaseObserver<List<AppAgreementBean>>() {
  168 +
  169 + @Override
  170 + protected void dealSpecialCode(int code, String message) {
  171 + }
  172 +
  173 + @Override
  174 + public void onSuccess(List<AppAgreementBean> bean) {
  175 + getAppAgreementData(bean);
  176 + }
  177 +
  178 + @Override
  179 + public void _onError(String e) {
  180 + Logger.t("AppAgreementFetcher").d("获取隐私数据失败");
  181 + }
  182 + });
  183 + }
  184 +
  185 +}
  1 +/*
  2 + * Copyright (c) Wondertek Technologies Co., Ltd. 2019-2022. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.module_home.model;
  6 +
  7 +import android.content.Context;
  8 +import android.text.TextUtils;
  9 +
  10 +
  11 +import com.wd.capability.network.BaseObserver;
  12 +import com.wd.capability.network.bean.MetaBean;
  13 +import com.wd.capability.network.fetcher.BaseDataFetcher;
  14 +import com.wd.capability.network.response.BaseResponse;
  15 +import com.wd.common.api.RequestApi;
  16 +import com.wd.common.content.model.impl.ContentModelImpl;
  17 +import com.wd.foundation.bean.launch.LaunchPageBean;
  18 +import com.wd.foundation.wdkit.network.IDownloadListener;
  19 +import com.wd.foundation.wdkit.utils.SpUtils;
  20 +import com.wd.module_home.vm.ISplashListener;
  21 +
  22 +import java.util.HashMap;
  23 +
  24 +import io.reactivex.Observable;
  25 +
  26 +/**
  27 + * 描述:获取数据方法
  28 + *
  29 + * @author : lvjinhui
  30 + * @since: 2022/6/1
  31 + */
  32 +public class SplashDataFetcher extends BaseDataFetcher<RequestApi> {
  33 +
  34 + private ISplashListener mListener;
  35 +
  36 +
  37 + /**
  38 + * 构造器
  39 + *
  40 + * @param listener 监听回调
  41 + */
  42 + public SplashDataFetcher(ISplashListener listener) {
  43 + this.mListener = listener;
  44 + }
  45 +
  46 + public void setmListener(ISplashListener mListener) {
  47 + this.mListener = mListener;
  48 + }
  49 +
  50 +
  51 + /**
  52 + * 获取广告数据
  53 + * height 是
  54 + * 分辨率高
  55 + * <p>
  56 + * width 是
  57 + * 分辨率宽
  58 + */
  59 + public void getSplashAdInfo(String width, String height) {
  60 + HashMap<String, Object> queryMap = new HashMap<>();
  61 + queryMap.put("width", width);
  62 + queryMap.put("height", height);
  63 +
  64 + if (!TextUtils.isEmpty(SpUtils.getProvinceCode())) {
  65 + queryMap.put("provinceCode", SpUtils.getProvinceCode());
  66 + }
  67 +
  68 + if (!TextUtils.isEmpty(SpUtils.getCityCode())) {
  69 + queryMap.put("cityCode", SpUtils.getCityCode());
  70 + }
  71 + if (!TextUtils.isEmpty(SpUtils.getDistrictCode())) {
  72 + queryMap.put("districtCode", SpUtils.getDistrictCode());
  73 + }
  74 +
  75 + Observable<BaseResponse<LaunchPageBean>> splashAdInfo = getRetrofit().getSplashAdInfo(queryMap);
  76 + request(splashAdInfo, new BaseObserver<LaunchPageBean>() {
  77 +
  78 + @Override
  79 + protected void dealSpecialCode(int code, String message) {
  80 + if (mListener != null) {
  81 + mListener.onGetAdlFailed(message);
  82 + }
  83 + }
  84 +
  85 + @Override
  86 + public void onSuccess(LaunchPageBean infoBean) {
  87 +
  88 +
  89 + }
  90 +
  91 + @Override
  92 + protected void onSuccess(LaunchPageBean launchPageBean, MetaBean metaBean, String msg, int code) {
  93 + if (mListener != null) {
  94 + mListener.onGetAdlSuccess(launchPageBean,metaBean);
  95 + }
  96 + }
  97 +
  98 + @Override
  99 + public void _onError(String e) {
  100 + if (mListener != null) {
  101 + mListener.onGetAdlFailed(e);
  102 + }
  103 + }
  104 + });
  105 + }
  106 +
  107 + /**
  108 + * 下载广告
  109 + *
  110 + * @param downloadUrl
  111 + * @param listener
  112 + */
  113 + public void downloadAdData(Context context, String downloadUrl, IDownloadListener listener) {
  114 + new ContentModelImpl().downloadAdData(context.getApplicationContext(), downloadUrl, listener);
  115 + }
  116 +
  117 +
  118 +}
  1 +package com.wd.module_home.util;
  2 +
  3 +/**
  4 + * Time:2022/9/25
  5 + * Author:ypf
  6 + * Description:
  7 + */
  8 +public class GuideConstants {
  9 +
  10 + /**
  11 + * 引导页序列号
  12 + */
  13 + public static String ARGUMENTS_INDEX = "index";
  14 + /**
  15 + * 引导页屏幕类型
  16 + */
  17 + public static String SCREEN_TYPE = "screen_type";
  18 +
  19 + /**
  20 + * 引导页屏幕高度
  21 + */
  22 + public static String SCREEN_HEIGHT = "screen_height";
  23 +
  24 + /**
  25 + * 引导页屏幕宽度
  26 + */
  27 + public static String SCREEN_WIDTH = "screen_width";
  28 + /**
  29 + * 引导页序列号0
  30 + */
  31 + public static int WELCOME_INDEX_0 = -1;
  32 + /**
  33 + * 引导页序列号0
  34 + */
  35 + public static int GUIDE_INDEX_0 = 0;
  36 +
  37 + /**
  38 + * 引导页序列号1
  39 + */
  40 + public static int GUIDE_INDEX_1 = 1;
  41 +
  42 + /**
  43 + * 引导页序列号2
  44 + */
  45 + public static int GUIDE_INDEX_2 = 2;
  46 +
  47 + /**
  48 + * 引导页序列号3
  49 + */
  50 + public static int GUIDE_INDEX_3 = 3;
  51 +
  52 + /**
  53 + * 引导页序列号3
  54 + */
  55 + public static int GUIDE_INDEX_4 = 4;
  56 +
  57 +}
  1 +package com.wd.module_home.util;
  2 +
  3 +import android.view.LayoutInflater;
  4 +import android.view.View;
  5 +
  6 +import androidx.annotation.NonNull;
  7 +import androidx.recyclerview.widget.LinearLayoutManager;
  8 +import androidx.viewpager2.widget.ViewPager2;
  9 +
  10 +
  11 +import com.wd.foundation.wdkit.utils.ScreenUtils;
  12 +import com.wd.foundation.wdkit.utils.ViewUtils;
  13 +import com.wd.module_home.AppMainActivity;
  14 +import com.wd.module_home.R;
  15 +import com.wd.module_home.adapter.GuideAdapter;
  16 +import com.wd.module_home.adapter.GuideIndexAdapter;
  17 +import com.wd.module_home.fragment.GuideFragment;
  18 +
  19 +import java.util.ArrayList;
  20 +import java.util.List;
  21 +
  22 +/**
  23 + * @ProjectName: PeopleDailyVideo
  24 + * @Package: com.people.displayui.main.guide
  25 + * @ClassName: GuideHelper
  26 + * @Description: 引导页管理
  27 + * @Author: wd
  28 + * @CreateDate: 2022/11/15 10:26
  29 + * @UpdateUser: wd
  30 + * @UpdateDate: 2022/11/15 10:26
  31 + * @UpdateRemark: 更新说明:
  32 + * @Version: 1.0
  33 + */
  34 +
  35 +public class GuideHelper {
  36 + private AppMainActivity appMainActivity;
  37 + /**
  38 + * 引导页布局
  39 + * */
  40 + public ViewPager2 guideViewPager;
  41 +
  42 + private GuideIndexAdapter rvIndexAdapter;
  43 + /**
  44 + * 引导页指示器
  45 + * */
  46 +// private RecyclerView rvindex;
  47 +// /**
  48 +// * 引导页指示器
  49 +// * */
  50 +// public ViewPagerIndicator guideViewPagerIndicator;
  51 + /**
  52 + * 引导页立即进入按钮
  53 + * */
  54 +// public ImageView guideTvEnter;
  55 + /**
  56 + * 引导页列表
  57 + * */
  58 + public List<GuideFragment> guideFragmentList;
  59 + /**
  60 + * 引导页适配器
  61 + * */
  62 + public GuideAdapter guideAdapter;
  63 + /**
  64 + * 没有引导页
  65 + * */
  66 + public final static boolean HASGUIDE = true;
  67 +
  68 + private int counterPageScroll = 0;
  69 + public GuideHelper(AppMainActivity appMainActivity){
  70 + this.appMainActivity = appMainActivity;
  71 + }
  72 +
  73 +
  74 + /**
  75 + * 初始化欢迎页
  76 + * */
  77 + public void initGuide() {
  78 + View view = LayoutInflater.from(appMainActivity).inflate(R.layout.activity_guide, null);
  79 + guideViewPager = ViewUtils.findViewById(view, R.id.viewpager2);
  80 +// rvindex = ViewUtils.findViewById(view,R.id.rvindex);
  81 + //去除动画
  82 + guideViewPager.setPageTransformer(new ViewPager2.PageTransformer() {
  83 + @Override
  84 + public void transformPage(@NonNull View view, float position) {
  85 + }
  86 + });
  87 +// guideTvEnter = ViewUtils.findViewById(view, R.id.tvEnter);
  88 +//
  89 +// guideTvEnter.setOnClickListener(new View.OnClickListener() {
  90 +// @Override
  91 +// public void onClick(View v) {
  92 +// //引导页结束
  93 +// appMainActivity.toInterestTag();
  94 +// }
  95 +// });
  96 +
  97 +// rvindex.setHasFixedSize(true);
  98 + LinearLayoutManager layoutManager = new LinearLayoutManager(appMainActivity, LinearLayoutManager.HORIZONTAL, false);
  99 +// rvindex.setLayoutManager(layoutManager);
  100 +
  101 + appMainActivity.flsplashContainer.addView(view);
  102 + appMainActivity.flsplashContainer.setVisibility(View.VISIBLE);
  103 + }
  104 +
  105 +
  106 +
  107 + /**
  108 + * 显示引导页
  109 + * @param hasfirst true首次安装、false覆盖安装(版本号不一样)
  110 + */
  111 + public void init(boolean hasfirst) {
  112 + initGuide();
  113 + guideFragmentList = new ArrayList<>();
  114 + //获取屏幕宽高
  115 + int screenType = 0;
  116 + int screenWidth = 0;
  117 + int screenHeight = 0;
  118 + int[] wh = ScreenUtils.getScreenWH();
  119 + if(wh != null){
  120 + screenWidth = wh[0];
  121 + screenHeight = wh[1];
  122 + if(screenWidth*1f/screenHeight > 3/4f){
  123 + screenType = 1;
  124 + }
  125 + }
  126 +
  127 + if(hasfirst){
  128 + guideFragmentList.add(GuideFragment.newInstance(GuideConstants.WELCOME_INDEX_0,screenType,screenHeight,screenWidth));
  129 + guideViewPager.setUserInputEnabled(false);
  130 + }
  131 + guideFragmentList.add(GuideFragment.newInstance(GuideConstants.GUIDE_INDEX_0,screenType,screenHeight,screenWidth));
  132 +// guideFragmentList.add(GuideFragment.newInstance(GuideConstants.GUIDE_INDEX_1,screenType,screenHeight,screenWidth));
  133 +// guideFragmentList.add(GuideFragment.newInstance(GuideConstants.GUIDE_INDEX_2,screenType,screenHeight,screenWidth));
  134 +// guideFragmentList.add(GuideFragment.newInstance(GuideConstants.GUIDE_INDEX_3,screenType,screenHeight,screenWidth));
  135 +// guideFragmentList.add(GuideFragment.newInstance(GuideConstants.GUIDE_INDEX_4,screenType,screenHeight,screenWidth));
  136 + guideAdapter = new GuideAdapter(appMainActivity, guideFragmentList);
  137 + guideViewPager.setAdapter(guideAdapter);
  138 + guideViewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
  139 + @Override
  140 + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
  141 + super.onPageScrolled(position, positionOffset, positionOffsetPixels);
  142 + if (position == guideFragmentList.size() - 1) {
  143 + if (counterPageScroll != 0) {
  144 + //引导页结束
  145 + appMainActivity.toInterestTag();
  146 + }
  147 + counterPageScroll++;
  148 + } else {
  149 + counterPageScroll = 0;
  150 + }
  151 + }
  152 +
  153 + @Override
  154 + public void onPageSelected(int position) {
  155 + super.onPageSelected(position);
  156 + //处理引导动效页面滑动后事件
  157 + dealGuidePageSelected(position);
  158 + }
  159 +
  160 + @Override
  161 + public void onPageScrollStateChanged(int state) {
  162 + super.onPageScrollStateChanged(state);
  163 + }
  164 +
  165 + /**
  166 + * 处理引导动效页面滑动后事件
  167 + *
  168 + * @param position 位置
  169 + */
  170 + private void dealGuidePageSelected(int position) {
  171 +// if(position == guideFragmentList.size() - 1){
  172 +// rvindex.setVisibility(View.GONE);
  173 +// guideTvEnter.setVisibility(View.VISIBLE);
  174 +// }else{
  175 +// rvindex.setVisibility(View.VISIBLE);
  176 +// rvIndexAdapter.setSelectPosition(position);
  177 +// guideTvEnter.setVisibility(View.GONE);
  178 +// }
  179 + }
  180 + });
  181 + guideViewPager.setOffscreenPageLimit(2);
  182 +// rvindex.addItemDecoration(new SpacesItemDecoration((int) ResUtils.getDimension(R.dimen.rmrb_dp4),hasfirst?guideFragmentList.size()-1:guideFragmentList.size()));
  183 +// rvIndexAdapter = new GuideIndexAdapter(hasfirst?guideFragmentList.size()-1:guideFragmentList.size());
  184 +// rvindex.setAdapter(rvIndexAdapter);
  185 + if(!hasfirst){
  186 + showGuide(false);
  187 + }
  188 + }
  189 +
  190 + /**
  191 + * 展示引导页
  192 + * @param needRemove true首次安装、false覆盖安装
  193 + */
  194 + public void showGuide(boolean needRemove) {
  195 + if(guideFragmentList == null || guideFragmentList.size()<1){
  196 + appMainActivity.toInterestTag();
  197 + return;
  198 + }
  199 + guideViewPager.setVisibility(View.VISIBLE);
  200 + if (needRemove && guideFragmentList.size() > 1) {
  201 + //移除欢迎页动画
  202 + guideFragmentList.remove(0);
  203 + //刷新
  204 + guideAdapter.notifyItemRemoved(0);
  205 + //可滑动
  206 + guideViewPager.setUserInputEnabled(true);
  207 + }
  208 + ViewUtils.setVisible(appMainActivity.welcomeIvLogo, View.GONE);
  209 + }
  210 +
  211 + /**
  212 + * 释放资源
  213 + * */
  214 + public void releaseResources(){
  215 +// if(guideTvEnter != null){
  216 +// guideTvEnter.setBackgroundResource(0);
  217 +// }
  218 + }
  219 +}
  1 +package com.wd.module_home.util;
  2 +
  3 +import android.graphics.drawable.Drawable;
  4 +import android.os.Handler;
  5 +import android.os.Message;
  6 +import android.text.TextUtils;
  7 +import android.util.TypedValue;
  8 +import android.view.LayoutInflater;
  9 +import android.view.View;
  10 +import android.view.ViewGroup;
  11 +import android.view.ViewStub;
  12 +import android.widget.ImageView;
  13 +import android.widget.RelativeLayout;
  14 +import android.widget.TextView;
  15 +
  16 +import androidx.annotation.NonNull;
  17 +import androidx.annotation.Nullable;
  18 +import androidx.constraintlayout.widget.ConstraintLayout;
  19 +import androidx.core.content.ContextCompat;
  20 +
  21 +import com.aliyun.player.IPlayer;
  22 +import com.aliyun.player.source.UrlSource;
  23 +import com.bumptech.glide.load.DataSource;
  24 +import com.bumptech.glide.load.engine.GlideException;
  25 +import com.bumptech.glide.request.RequestListener;
  26 +import com.bumptech.glide.request.target.Target;
  27 +import com.people.model.ProvinceDataManager;
  28 +import com.people.room.LaunchAdHelper;
  29 +import com.people.room.entity.LaunchAdModel;
  30 +import com.wd.base.log.Logger;
  31 +import com.wd.capability.network.bean.MetaBean;
  32 +import com.wd.common.constant.RegionNameConstants;
  33 +import com.wd.common.utils.H5JsApiPermissionUtil;
  34 +import com.wd.common.utils.ProcessUtils;
  35 +import com.wd.foundation.bean.adv.CompAdvBean;
  36 +import com.wd.foundation.bean.adv.CompAdvMatInfoBean;
  37 +import com.wd.foundation.bean.adv.CompH5Bean;
  38 +import com.wd.foundation.bean.analytics.ActionConstants;
  39 +import com.wd.foundation.bean.analytics.TrackContentBean;
  40 +import com.wd.foundation.bean.custom.content.ContentBean;
  41 +import com.wd.foundation.bean.incentive.TaskRuleSwitchBean;
  42 +import com.wd.foundation.bean.launch.AppAgreementBean;
  43 +import com.wd.foundation.bean.launch.LaunchPageBean;
  44 +import com.wd.foundation.bean.launch.OperationUrlBean;
  45 +import com.wd.foundation.bean.launch.SplashAdBean;
  46 +import com.wd.foundation.bean.response.AppAtvConfigBean;
  47 +import com.wd.foundation.bean.response.AppPublishConfigBean;
  48 +import com.wd.foundation.bean.response.CommonConfigBean;
  49 +import com.wd.foundation.bean.utils.TimeUtil;
  50 +import com.wd.foundation.wdkit.adv.AdvUtils;
  51 +import com.wd.foundation.wdkit.constant.Constants;
  52 +import com.wd.foundation.wdkit.constant.PageNameConstants;
  53 +import com.wd.foundation.wdkit.file.MyFileUtils;
  54 +import com.wd.foundation.wdkit.imageglide.ImageUtils;
  55 +import com.wd.foundation.wdkit.json.GsonUtils;
  56 +import com.wd.foundation.wdkit.network.DownloadUtil;
  57 +import com.wd.foundation.wdkit.network.IDownloadListener;
  58 +import com.wd.foundation.wdkit.system.DeviceUtil;
  59 +import com.wd.foundation.wdkit.system.FastClickUtil;
  60 +import com.wd.foundation.wdkit.utils.FilletUtil;
  61 +import com.wd.foundation.wdkit.utils.ScreenUtils;
  62 +import com.wd.foundation.wdkit.utils.SpUtils;
  63 +import com.wd.foundation.wdkit.utils.UiUtils;
  64 +import com.wd.foundation.wdkit.utils.ViewUtils;
  65 +import com.wd.foundation.wdkit.view.customtextview.RegularTextView;
  66 +import com.wd.foundation.wdkitcore.constant.BaseConstants;
  67 +import com.wd.foundation.wdkitcore.storage.MemStoreUtils;
  68 +import com.wd.foundation.wdkitcore.thread.ThreadPoolUtils;
  69 +import com.wd.foundation.wdkitcore.tools.AppContext;
  70 +import com.wd.foundation.wdkitcore.tools.ArrayUtils;
  71 +import com.wd.foundation.wdkitcore.tools.ResUtils;
  72 +import com.wd.foundation.wdkitcore.tools.StringUtils;
  73 +import com.wd.module_home.AppMainActivity;
  74 +import com.wd.module_home.R;
  75 +import com.wd.module_home.model.SplashDataFetcher;
  76 +import com.wd.module_home.vm.ISplashListener;
  77 +import com.wd.module_home.vm.SplashViewModel;
  78 +import com.wd.player.widget.AliyunRenderView;
  79 +
  80 +import org.apache.commons.lang3.SerializationUtils;
  81 +
  82 +import java.io.File;
  83 +import java.io.Serializable;
  84 +import java.util.List;
  85 +
  86 +
  87 +/**
  88 + * @ProjectName: PeopleDailyVideo
  89 + * @Package: com.people.displayui.main.splash.utils
  90 + * @ClassName: SplashHelper
  91 + * @Description: 开屏页/广告页管理
  92 + * @Author: wd
  93 + * @CreateDate: 2022/11/15 10:26
  94 + * @UpdateUser: wd
  95 + * @UpdateDate: 2022/11/15 10:26
  96 + * @UpdateRemark: 更新说明:
  97 + * @Version: 1.0
  98 + */
  99 +
  100 +public class SplashHelper {
  101 +
  102 + /**
  103 + * 运营配置的启动页数据 开屏页
  104 + */
  105 + public SplashAdBean mSplashAdBean;
  106 +
  107 + /**
  108 + * 广告中心开屏广告数据
  109 + */
  110 + public CompAdvBean launchAdInfoBean;
  111 + /**
  112 + * 闪屏页倒计时初始值
  113 + */
  114 + public int totalTime = 6000;
  115 +
  116 + public String downtimeWord = "s 跳过";
  117 +
  118 + /**
  119 + * 闪屏页倒计时控件
  120 + */
  121 + public TextView splashTimeView;
  122 + /**
  123 + * 闪屏页广告图片
  124 + */
  125 + public ImageView splashAdImageVew;
  126 +
  127 + public RelativeLayout splashRlJumpAd;
  128 + /**
  129 + * 闪屏页跳过广告布局
  130 + */
  131 + public TextView splashTvJumpAd;
  132 + /**
  133 + * 闪屏页视频
  134 + */
  135 + public ViewStub splashAdVideoStub;
  136 + /**
  137 + * 闪屏页跳过广告标识
  138 + */
  139 + public TextView splashAdTipTextView;
  140 +
  141 + private AppMainActivity appMainActivity;
  142 + /**
  143 + * 闪屏页播放器视图
  144 + */
  145 + private AliyunRenderView aliyunRenderView;
  146 +
  147 + /**
  148 + * 闪屏页下载逻辑处理
  149 + */
  150 + public SplashViewModel viewModel;
  151 +
  152 + /**
  153 + * 开屏广告类型
  154 + * 0:默认,1:展现中心,2:广告中心
  155 + */
  156 + private int launchType = 0;
  157 + /**
  158 + * 闪屏广告图片加载回调
  159 + */
  160 + private String linkType = "";
  161 +
  162 + RequestListener<Drawable> adRequestListener = new RequestListener<Drawable>() {
  163 + @Override
  164 + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
  165 + visibleJumpAdAndAdTip();
  166 + return false;
  167 + }
  168 +
  169 + @Override
  170 + public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
  171 + visibleJumpAdAndAdTip();
  172 + return false;
  173 + }
  174 + };
  175 +
  176 + public SplashHelper(AppMainActivity appMainActivity) {
  177 + this.appMainActivity = appMainActivity;
  178 + }
  179 +
  180 + /**
  181 + * 视频使用本地缓存
  182 + *
  183 + * @param unPrepare 非预加载
  184 + */
  185 + private boolean downloadAd(boolean unPrepare,SplashAdBean splashAdBean) {
  186 + if (TextUtils.isEmpty(splashAdBean.bootScreenUrl)) {
  187 + SpUtils.setSplashCacheType(1);
  188 + SpUtils.saveSplashCache(GsonUtils.objectToJson(splashAdBean));
  189 + return false;
  190 + }
  191 +
  192 + String finalPath = DownloadUtil.getDownloadCachePath(appMainActivity, DownloadUtil.getNameFromUrl(splashAdBean.bootScreenUrl));
  193 + if (MyFileUtils.isExist(finalPath)) {
  194 + if (unPrepare) {
  195 + loadVideoAd(finalPath);
  196 + }else{
  197 + SpUtils.setSplashCacheType(1);
  198 + SpUtils.saveSplashCache(GsonUtils.objectToJson(splashAdBean));
  199 + }
  200 + } else {
  201 + if (unPrepare) {
  202 + //本地没有视频,直接跳过视频
  203 + return showImageAd(splashAdBean.bootVideoScreenUrl);
  204 + }
  205 + // 同时下载
  206 + viewModel.downLoadAdData(appMainActivity, splashAdBean.bootScreenUrl, new IDownloadListener() {
  207 +
  208 + @Override
  209 + public void onStart() {
  210 + }
  211 +
  212 + @Override
  213 + public void onProgress(int progress) {
  214 + }
  215 +
  216 + @Override
  217 + public void onFailure() {
  218 + }
  219 +
  220 + @Override
  221 + public void onDone() {
  222 + SpUtils.setSplashCacheType(1);
  223 + SpUtils.saveSplashCache(GsonUtils.objectToJson(splashAdBean));
  224 + }
  225 + });
  226 + if(!StringUtils.isEmpty(splashAdBean.bootVideoScreenUrl)){
  227 + ThreadPoolUtils.backgroundSubmit(new Runnable() {
  228 + @Override
  229 + public void run() {
  230 + ImageUtils.getInstance().preloadImage(AppContext.getContext(), splashAdBean.bootVideoScreenUrl,new RequestListener<Drawable>() {
  231 + @Override
  232 + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target,
  233 + boolean isFirstResource) {
  234 + return false;
  235 + }
  236 +
  237 + @Override
  238 + public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target,
  239 + DataSource dataSource, boolean isFirstResource) {
  240 + SpUtils.setSplashCacheType(1);
  241 + SpUtils.saveSplashCache(GsonUtils.objectToJson(splashAdBean));
  242 + return true;
  243 + }
  244 + });
  245 + }
  246 + });
  247 + }
  248 + }
  249 + return true;
  250 + }
  251 +
  252 + /**
  253 + * 异步预加载下次启动需要用到的图片
  254 + *
  255 + * @param splashAdBean
  256 + */
  257 + private void prepareLaunchPageResource(SplashAdBean splashAdBean) {
  258 + ThreadPoolUtils.backgroundSubmit(new Runnable() {
  259 + @Override
  260 + public void run() {
  261 + dealLaunchInfo(splashAdBean, true);
  262 + }
  263 + });
  264 + }
  265 +
  266 + /**
  267 + * 处理开屏页
  268 + *
  269 + * @param splashAdBean
  270 + * @param isPrepare true预加载,false加载
  271 + */
  272 + private void dealLaunchInfo(SplashAdBean splashAdBean, boolean isPrepare) {
  273 + if(isPrepare){
  274 + SpUtils.saveSplashCache("");
  275 + SpUtils.setSplashCacheType(0);
  276 + }
  277 + //没有开机屏封面图/视频地址
  278 + if (splashAdBean == null || TextUtils.isEmpty(splashAdBean.bootScreenUrl)) {
  279 + if(!isPrepare){
  280 + appMainActivity.finishPage();
  281 + }
  282 + return;
  283 + }
  284 + launchType = 1;
  285 + //预加载
  286 + if (isPrepare) {
  287 + //图片
  288 + if ("1".equals(splashAdBean.showType)) {
  289 + // 2022/11/21 预加载所有(下次要使用的)图片,避免首次加载慢白屏问题
  290 + ThreadPoolUtils.backgroundSubmit(new Runnable() {
  291 + @Override
  292 + public void run() {
  293 + ImageUtils.getInstance().preloadImage(AppContext.getContext(), splashAdBean.bootScreenUrl,new RequestListener<Drawable>() {
  294 + @Override
  295 + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target,
  296 + boolean isFirstResource) {
  297 + return false;
  298 + }
  299 +
  300 + @Override
  301 + public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target,
  302 + DataSource dataSource, boolean isFirstResource) {
  303 + SpUtils.setSplashCacheType(1);
  304 + SpUtils.saveSplashCache(GsonUtils.objectToJson(splashAdBean));
  305 + return true;
  306 + }
  307 + });
  308 + }
  309 + });
  310 + } else if ("2".equals(splashAdBean.showType)) {
  311 + //视频
  312 + downloadAd(false,splashAdBean);
  313 + }
  314 + } else {
  315 + mSplashAdBean = splashAdBean;
  316 + //图片
  317 + if (mSplashAdBean !=null && ("1".equals(mSplashAdBean.showType) || "2".equals(mSplashAdBean.showType))) {
  318 + //运营配置的启动页
  319 + initSplash();
  320 + } else {
  321 + appMainActivity.finishPage();
  322 + }
  323 + }
  324 + }
  325 +
  326 + /**
  327 + * 加载闪屏页视频
  328 + * 使用网络url
  329 + */
  330 + private void loadVideoAd(String url) {
  331 + initPlayer(url);
  332 + initTimer();
  333 + trackExposure(true);
  334 + }
  335 +
  336 + /**
  337 + * 初始化闪屏页播放器
  338 + */
  339 + private void initPlayer(String playUrl) {
  340 + aliyunRenderView = ViewUtils.findViewById(splashAdVideoStub.inflate(), R.id.splash_ad_video);
  341 + // 设置渲染View的类型,可选 SurfaceType.TEXTURE_VIEW 和 SurfaceType.SURFACE_VIEW
  342 + aliyunRenderView.setSurfaceType(AliyunRenderView.SurfaceType.SURFACE_VIEW);
  343 + UrlSource urlSource = new UrlSource();
  344 + urlSource.setUri(playUrl);
  345 + // 设置播放源,setDataSource为重载方法,还可以设置 sts,playAuth 等数据源
  346 + aliyunRenderView.setDataSource(urlSource);
  347 + aliyunRenderView.setLoop(true);
  348 + aliyunRenderView.setScaleModel(IPlayer.ScaleMode.SCALE_ASPECT_FILL);
  349 + aliyunRenderView.setMute(true);
  350 + // 播放相关
  351 + aliyunRenderView.prepare();
  352 + //优化起播黑屏,等播放第一帧后,在展示视频
  353 + aliyunRenderView.setOnRenderingStartListener(() -> {
  354 + visibleJumpAdAndAdTip();
  355 + ViewUtils.setVisible(aliyunRenderView, View.VISIBLE);
  356 + });
  357 + aliyunRenderView.setOnErrorListener(errorInfo -> {
  358 + visibleJumpAdAndAdTip();
  359 + });
  360 + aliyunRenderView.start();
  361 + //闪屏页视频标识
  362 + initJump();
  363 + appMainActivity.mainBottomBar.setVisibility(View.VISIBLE);
  364 + appMainActivity.bottomLine.setVisibility(View.VISIBLE);
  365 + appMainActivity.mainViewPager.setVisibility(View.VISIBLE);
  366 + }
  367 +
  368 + /**
  369 + * 闪屏页图片加载完成\视频第一帧加载出来后,要展示的其他内容
  370 + * 启动页展示:跳过按钮
  371 + * 广告页展示:跳过按钮、广告、进入详情
  372 + */
  373 + private void visibleJumpAdAndAdTip() {
  374 + //广告标签处理
  375 + if (splashAdTipTextView != null) {
  376 + splashAdTipTextView.setVisibility(View.VISIBLE);
  377 + }
  378 + if(launchType == 2){
  379 + //广告中心广告
  380 + //全屏/展示底部logo样式处理
  381 + if(launchAdInfoBean != null && launchAdInfoBean.getMatInfo()!=null){
  382 + CompAdvMatInfoBean compAdvMatInfoBean = launchAdInfoBean.getMatInfo();
  383 + String startStyle = compAdvMatInfoBean.getStartStyle();
  384 + if ("1".equals(startStyle)) {
  385 + //全屏展示
  386 + ViewUtils.setVisible(appMainActivity.welcomeIvLogo, View.GONE);
  387 + } else {
  388 + //默认非全屏,展示底部logo
  389 + ViewUtils.setVisible(appMainActivity.welcomeIvLogo, View.VISIBLE);
  390 + }
  391 + }
  392 +
  393 + }else {
  394 + //全屏/展示底部logo样式处理
  395 + if (mSplashAdBean != null && "2".equals(mSplashAdBean.screenType)) {
  396 + //全屏展示
  397 + ViewUtils.setVisible(appMainActivity.welcomeIvLogo, View.GONE);
  398 + } else {
  399 + //默认非全屏,展示底部logo
  400 + ViewUtils.setVisible(appMainActivity.welcomeIvLogo, View.VISIBLE);
  401 + }
  402 + }
  403 +
  404 + //跳转入口处理
  405 + if (splashRlJumpAd != null) {
  406 + splashRlJumpAd.setVisibility(View.VISIBLE);
  407 + }
  408 + //倒计时处理
  409 + splashAdImageVew.postDelayed(new Runnable() {
  410 + @Override
  411 + public void run() {
  412 + ViewUtils.setVisible(splashTimeView, View.VISIBLE);
  413 + //华为手机开机屏会闪动,先注释
  414 + /*appMainActivity.mainBottomBar.setVisibility(View.VISIBLE);
  415 + appMainActivity.bottomLine.setVisibility(View.VISIBLE);
  416 + appMainActivity.mainViewPager.setVisibility(View.VISIBLE);*/
  417 + }
  418 + }, 2);
  419 + }
  420 +
  421 + /**
  422 + * 配置的是运营启动页,不显示广告的信息
  423 + */
  424 + private void hideAdInfo() {
  425 + if (splashTimeView != null) {
  426 + splashTimeView.setVisibility(View.VISIBLE);
  427 + }
  428 +
  429 + }
  430 +
  431 + /**
  432 + * 显示闪屏页面广告
  433 + */
  434 + private boolean showImageAd(String screenUrl) {
  435 + if (TextUtils.isEmpty(screenUrl)) {
  436 + return false;
  437 + }
  438 + File file = ImageUtils.getCache(appMainActivity,screenUrl);
  439 + //如果本地没有预加载出来图片,直接跳过
  440 + if(file == null){
  441 + return false;
  442 + }
  443 + ImageUtils.getInstance().loadImageHighLev(splashAdImageVew, file, adRequestListener);
  444 + initTimer();
  445 + // 处理广告跳转
  446 + initJump();
  447 + trackExposure(true);
  448 + return true;
  449 + }
  450 +
  451 + /**
  452 + * 初始化闪屏页面广告倒计时计数器
  453 + */
  454 + public void initTimer() {
  455 + splashTimeView.setVisibility(View.VISIBLE);
  456 + startCountdown();
  457 + }
  458 +
  459 + /**
  460 + * 开屏页点击跳转
  461 + */
  462 + private void initJump() {
  463 + if(launchType == 2){
  464 + if (launchAdInfoBean == null) {
  465 + return;
  466 + }
  467 + CompAdvMatInfoBean matInfoBean = launchAdInfoBean.getMatInfo();
  468 + if(matInfoBean == null){
  469 + return;
  470 + }
  471 + if (StringUtils.isNotBlank(matInfoBean.getOpenType())){
  472 + linkType = matInfoBean.getOpenType();
  473 + }else {
  474 + linkType = matInfoBean.getLinkType();
  475 + }
  476 + if(StringUtils.isEqual("0",linkType)){
  477 + return;
  478 + }
  479 + initTvJump();
  480 + splashRlJumpAd.setOnClickListener(v -> {
  481 + if (FastClickUtil.isFastClick()) {
  482 + return;
  483 + }
  484 + if(StringUtils.isEqual("0",linkType)){
  485 + // 0:无链接;
  486 + return;
  487 + }
  488 + String linkUrl = matInfoBean.getLinkUrl();
  489 + if(StringUtils.isEmpty(linkUrl)){
  490 + return;
  491 + }
  492 + if(StringUtils.isEqual("1",linkType)){
  493 + //内链
  494 + ProcessUtils.goToH5Page(new ContentBean(linkUrl));
  495 + }else if(StringUtils.isEqual("2",linkType)){
  496 + //外链
  497 + ProcessUtils.jumpBrowser(appMainActivity,linkUrl);
  498 + }
  499 + //开屏广告点击埋点
  500 + trackExposure(false);
  501 + appMainActivity.finishPage();
  502 + });
  503 +
  504 + }else {
  505 + //展现中心
  506 + if (mSplashAdBean == null || TextUtils.isEmpty(mSplashAdBean.objectType) || "0".equals(mSplashAdBean.objectType)) {
  507 + return;
  508 + }
  509 + initTvJump();
  510 + splashRlJumpAd.setOnClickListener(v -> {
  511 + if (FastClickUtil.isFastClick()) {
  512 + return;
  513 + }
  514 + /*mHandle.removeMessages(0);
  515 + isDoCountDown = false;*/
  516 + //开机屏公共跳转
  517 + ContentBean contentBean = new ContentBean();
  518 + contentBean.setPageId(TextUtils.isEmpty(mSplashAdBean.pageId)? mSplashAdBean.objectId: mSplashAdBean.pageId);
  519 + contentBean.setObjectType(mSplashAdBean.objectType);
  520 + contentBean.setObjectId(mSplashAdBean.objectId);
  521 + contentBean.setObjectLevel(mSplashAdBean.objectLevel);
  522 + contentBean.setLinkUrl(mSplashAdBean.linkUrl);
  523 + contentBean.setBottomNavId(mSplashAdBean.bottomNavId);
  524 + contentBean.setRelId(mSplashAdBean.relId);
  525 + //专题模板 --->专题样式 1:常规, 2:作者, 3:时间线
  526 + //contentBean.setTopicTemplate(mSplashAdBean.topicTemplate);
  527 + ProcessUtils.processPage(contentBean);
  528 + //开屏广告点击埋点
  529 + trackExposure(false);
  530 + /*splashTimeView.postDelayed(new Runnable() {
  531 + @Override
  532 + public void run() {
  533 + splashTimeView.setVisibility(View.GONE);
  534 + appMainActivity.finishPage();
  535 + }
  536 + },500);*/
  537 + appMainActivity.finishPage();
  538 + });
  539 + }
  540 + }
  541 +
  542 + private void initTvJump() {
  543 + splashRlJumpAd = new RelativeLayout(appMainActivity);
  544 + ConstraintLayout.LayoutParams splashRlparams = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
  545 + if(launchType == 2){
  546 + //广告中心
  547 + if(launchAdInfoBean != null && launchAdInfoBean.getMatInfo()!= null){
  548 + CompAdvMatInfoBean matInfo = launchAdInfoBean.getMatInfo();
  549 + splashRlparams.setMargins(0, 0, 0,
  550 + (int) appMainActivity.getResources().
  551 + getDimension("1".equals(matInfo.getStartStyle()) ?
  552 + R.dimen.btmjump_dimensmall : R.dimen.btmjump_dimen));
  553 + }
  554 + }else if(mSplashAdBean !=null){
  555 + //展现中心
  556 + splashRlparams.setMargins(0, 0, 0,
  557 + (int) appMainActivity.getResources().
  558 + getDimension("2".equals(mSplashAdBean.screenType) ?
  559 + R.dimen.btmjump_dimensmall : R.dimen.btmjump_dimen));
  560 + }
  561 + splashRlparams.startToStart = ConstraintLayout.LayoutParams.PARENT_ID;
  562 + splashRlparams.endToEnd = ConstraintLayout.LayoutParams.PARENT_ID;
  563 + splashRlparams.topToTop = -1;
  564 + splashRlparams.bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID;
  565 + int screenWidth = ScreenUtils.getScreenSize(appMainActivity, true);
  566 + splashRlparams.width = 300*screenWidth/375;
  567 + splashRlparams.height = 58*screenWidth/375;
  568 + splashRlJumpAd.setLayoutParams(splashRlparams);
  569 + splashRlJumpAd.setBackground(FilletUtil.createRectangleDrawable(0x7f000000, 0x80FFFFFF, UiUtils.dp2px(1), UiUtils.dp2px(40)));
  570 + //动态添加布局
  571 + RelativeLayout.LayoutParams splashTvJumpAdParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
  572 + splashTvJumpAdParams.addRule(RelativeLayout.CENTER_IN_PARENT);
  573 + splashTvJumpAd = new TextView(appMainActivity);
  574 + splashTvJumpAd.setLayoutParams(splashTvJumpAdParams);
  575 + splashRlJumpAd.addView(splashTvJumpAd);
  576 + splashRlJumpAd.setVisibility(View.INVISIBLE);
  577 + splashTvJumpAd.setCompoundDrawablePadding(UiUtils.dp2px(6));
  578 + splashTvJumpAd.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
  579 + splashTvJumpAd.setText( ResUtils.getString(launchType == 2 ?
  580 + R.string.res_splash_adv : R.string.res_splash));
  581 + splashTvJumpAd.setTextColor(0xFFFFFFFF);
  582 + Drawable drawable = ContextCompat.getDrawable(appMainActivity, R.drawable.ic_arrow_right_2);
  583 + drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
  584 + splashTvJumpAd.setCompoundDrawables(null, null, drawable, null);
  585 + appMainActivity.rootView.addView(splashRlJumpAd);
  586 + }
  587 +
  588 + public void initAdTip(ViewGroup view) {
  589 + splashAdTipTextView = new RegularTextView(appMainActivity);
  590 + view.addView(splashAdTipTextView);
  591 + ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) splashAdTipTextView.getLayoutParams();
  592 + params.startToStart = ConstraintLayout.LayoutParams.PARENT_ID;
  593 + params.endToEnd = -1;
  594 + params.topToTop = ConstraintLayout.LayoutParams.PARENT_ID;
  595 + params.bottomToBottom = -1;
  596 + params.leftMargin = (int) appMainActivity.getResources().getDimension(R.dimen.rmrb_dp10);
  597 + params.baselineToBaseline = R.id.tvdowntime;
  598 + splashAdTipTextView.setVisibility(View.INVISIBLE);
  599 + splashAdTipTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
  600 + splashAdTipTextView.setTextColor(0xffffffff);
  601 + splashAdTipTextView.setText(R.string.comp_adv);
  602 + splashAdTipTextView.setBackgroundResource(R.drawable.shape_corner_black_2);
  603 + int lr = (int) splashAdTipTextView.getResources().getDimension(R.dimen.rmrb_dp4);
  604 + int tb = (int) splashAdTipTextView.getResources().getDimension(R.dimen.rmrb_dp1);
  605 + splashAdTipTextView.setPadding(lr, tb, lr, tb);
  606 + }
  607 +
  608 + /**
  609 + * 初始化闪屏广告页
  610 + */
  611 + public void initSplash() {
  612 + View view = LayoutInflater.from(appMainActivity).inflate(R.layout.activity_splash, null);
  613 + splashAdVideoStub = ViewUtils.findViewById(view, R.id.ad_video_vstub);
  614 + splashTimeView = ViewUtils.findViewById(view, R.id.tvdowntime);
  615 + FilletUtil.setRoundBg(splashTimeView, "#80000000", appMainActivity.getResources().getDimension(R.dimen.rmrb_dp27));
  616 + splashAdImageVew = ViewUtils.findViewById(view, R.id.splash_ad_img);
  617 + splashTimeView.setOnClickListener(new View.OnClickListener() {
  618 + @Override
  619 + public void onClick(View v) {
  620 + if (FastClickUtil.isFastClick()) {
  621 + return;
  622 + }
  623 + isDoCountDown = false;
  624 + splashTimeView.setVisibility(View.GONE);
  625 + appMainActivity.finishPage();
  626 +// GeneralTrack.getInstance().skipClick();
  627 +
  628 + }
  629 + });
  630 + appMainActivity.flsplashContainer.addView(view);
  631 + appMainActivity.flsplashContainer.setVisibility(View.VISIBLE);
  632 + boolean unfinish = true;
  633 +
  634 + if(launchType == 2){
  635 + //广告中心
  636 + initAdTip((ViewGroup) view);
  637 + try {
  638 + if (launchAdInfoBean == null || launchAdInfoBean.getMatInfo() == null) {
  639 + unfinish = false;
  640 + } else {
  641 + CompAdvMatInfoBean matInfoBean = launchAdInfoBean.getMatInfo();
  642 + if (!TextUtils.isEmpty(launchAdInfoBean.getDisplayDuration())) {
  643 + totalTime = Integer.parseInt(launchAdInfoBean.getDisplayDuration()) * 1000;
  644 + }
  645 + if ("0".equals(matInfoBean.getMatType())) {
  646 + if(ArrayUtils.isEmpty(matInfoBean.getMatImageUrl())){
  647 + unfinish = false;
  648 + }else {
  649 + unfinish = showImageAd(matInfoBean.getMatImageUrl().get(0));
  650 + }
  651 + } else if ("1".equals(matInfoBean.getMatType())) {
  652 + // 视频 闪屏页面视频类型 闪屏页视频标识
  653 + unfinish = downloadLaunchAdInfoVideo(true,launchAdInfoBean);
  654 + } else {
  655 + unfinish = false;
  656 + }
  657 + }
  658 + } catch (Exception e) {
  659 + unfinish = false;
  660 + }
  661 + }else {
  662 + //展现中心广告
  663 + //动态处理广告标签
  664 + if (mSplashAdBean != null && "1".equals(mSplashAdBean.isAd)) {
  665 + initAdTip((ViewGroup) view);
  666 + } else {
  667 + hideAdInfo();
  668 + }
  669 + try {
  670 + if (mSplashAdBean == null) {
  671 + unfinish = false;
  672 + } else {
  673 + if (!TextUtils.isEmpty(mSplashAdBean.durations)) {
  674 + totalTime = Integer.parseInt(mSplashAdBean.durations) * 1000;
  675 + }
  676 + if ("1".equals(mSplashAdBean.showType)) {
  677 + unfinish = showImageAd(mSplashAdBean.bootScreenUrl);
  678 + } else if ("2".equals(mSplashAdBean.showType)) {
  679 + // 视频 闪屏页面视频类型 闪屏页视频标识
  680 + unfinish = downloadAd(true,mSplashAdBean);
  681 + } else {
  682 + unfinish = false;
  683 + }
  684 + }
  685 + } catch (Exception e) {
  686 + unfinish = false;
  687 + }
  688 + }
  689 +
  690 +
  691 + //页面未结束标识
  692 + if (unfinish) {
  693 + //设置跳过广告的顶部距离
  694 + setAdTipViewTop();
  695 + } else {
  696 + appMainActivity.finishPage();
  697 + }
  698 + }
  699 +
  700 + /**
  701 + * 设置跳过广告的顶部距离
  702 + */
  703 + private void setAdTipViewTop() {
  704 + ConstraintLayout.LayoutParams timeViewParams = (ConstraintLayout.LayoutParams) splashTimeView.getLayoutParams();
  705 + timeViewParams.topMargin = appMainActivity.topBarHeight + 10;
  706 + }
  707 +
  708 + /**
  709 + * 展示本地广告数据
  710 + */
  711 + private void showLocalSplash() {
  712 + //请求开机屏广告
  713 + loadSplashData();
  714 + //是否有符合要求的本地数据
  715 + int cacheType = SpUtils.getSplashCacheType();
  716 + if (cacheType == 1){
  717 + //展现中心广告
  718 + String json = SpUtils.getSplashCache();
  719 + if(!TextUtils.isEmpty(json)){
  720 + SplashAdBean launchPageBean = GsonUtils.fromJson(json, SplashAdBean.class);
  721 + if(launchPageBean == null){
  722 + appMainActivity.finishPage();
  723 + }else{
  724 + dealLaunchInfo(launchPageBean, false);
  725 + }
  726 + }else{
  727 + appMainActivity.finishPage();
  728 + }
  729 + }else if (cacheType == 2){
  730 + //广告中心广告
  731 + String json = SpUtils.getSplashCache();
  732 + if(!TextUtils.isEmpty(json)){
  733 + CompAdvBean compAdvBean = GsonUtils.fromJson(json, CompAdvBean.class);
  734 + if(compAdvBean == null){
  735 + appMainActivity.finishPage();
  736 + }else{
  737 + dealLaunchAdInfo(compAdvBean, false);
  738 + }
  739 + }else{
  740 + appMainActivity.finishPage();
  741 + }
  742 + }else {
  743 + //没有缓存
  744 + appMainActivity.finishPage();
  745 + }
  746 + }
  747 + /**
  748 + * 1 展示、2不展示、3只刷新数据库
  749 + * */
  750 + public void loadSplashData() {
  751 + new SplashDataFetcher(new ISplashListener() {
  752 + @Override
  753 + public void onGetAdlSuccess(LaunchPageBean launchPageBean, MetaBean metaBean) {
  754 +// launchPageBean = GsonUtils.fromJson("{\"launchPageInfo\":{\"bootScreenUrl\":\"https://cdnpdcontentuat.aikan.pdnews.cn/vod/content/2023032309/fecbf51627494a048d8775249442fc7a.mp4\",\"bottomNavId\":null,\"durations\":\"6000\",\"id\":32,\"isAd\":1,\"linkUrl\":\"\",\"objectId\":\"20000000096\",\"objectLevel\":\"1\",\"objectType\":\"2\",\"pageId\":\"\",\"screenName\":\"开机屏-视频\",\"screenType\":\"1\",\"showType\":2}}", LaunchPageBean.class);
  755 + if (null == launchPageBean) {
  756 + return;
  757 + }
  758 + //是否请求底部导航bottomNavGroup
  759 + BaseConstants.bottomNavGroupMd5 = launchPageBean.getBottomNavGroupMd5();
  760 + if (StringUtils.isBlank(launchPageBean.getNewsTabMd5())){
  761 + BaseConstants.newsTabMd5 = System.currentTimeMillis()+"";
  762 + }else {
  763 + BaseConstants.newsTabMd5 = launchPageBean.getNewsTabMd5();
  764 + }
  765 +
  766 + //用户激励开关
  767 + TaskRuleSwitchBean taskRuleSwitchBean = launchPageBean.getPointOperate();
  768 + if (taskRuleSwitchBean != null) {
  769 + Constants.taskRuleSwitchBean = taskRuleSwitchBean;
  770 + }
  771 + if(appMainActivity != null){
  772 + appMainActivity.getLaunchPageFinish(launchPageBean);
  773 + //底部频道数据
  774 + appMainActivity.requestBottomGroup();
  775 + //请求新闻tab的groupDetail
  776 + appMainActivity.getNewsTabBottomNavGroupDetail();
  777 + }
  778 + //h5白名单
  779 + dealH5WhiteHost(launchPageBean);
  780 +
  781 + if(metaBean != null){
  782 + String md5Str = metaBean.getMd5();
  783 + String localMd5 = SpUtils.getSplashCacheMd5();
  784 + if(StringUtils.isEmpty(localMd5) || !StringUtils.isEqual(md5Str,localMd5)){
  785 + //md5值变化,清除缓存数据
  786 + SpUtils.setSplashCacheType(0);
  787 + SpUtils.saveSplashCache("");
  788 + LaunchAdHelper.getInstance(appMainActivity).clear();
  789 + SpUtils.setSplashCacheMd5(md5Str);
  790 + }
  791 + }
  792 +
  793 + //处理公共配置
  794 + if(launchPageBean.getCommons() != null){
  795 + dealCommons(launchPageBean.getCommons());
  796 + }
  797 +
  798 + //处理国殇模式
  799 + if(launchPageBean.getMourns() != null){
  800 + appMainActivity.getMourningModeSuccess(launchPageBean.getMourns());
  801 + }
  802 +
  803 + //处理融云APPKey
  804 + if(StringUtils.isNotBlank(launchPageBean.getRongyunKey())){
  805 + SpUtils.saveIMAppkey(launchPageBean.getRongyunKey());
  806 + }
  807 +
  808 + //处理H5模板下载
  809 + if(launchPageBean.h5Template != null && launchPageBean.h5Template.size() > 0){
  810 + CompH5Bean compH5Bean = launchPageBean.h5Template.get(0);
  811 + if(compH5Bean != null )
  812 + {
  813 + downloadH5Template(compH5Bean.getH5TemplateUrl(),compH5Bean.getVersion(),
  814 + compH5Bean.getVersionRangeMin(),compH5Bean.getVersionRangeMax());
  815 + }
  816 +
  817 + }
  818 + //隐私协议
  819 + LaunchPageBean.AgreementsBean agreementsBean = launchPageBean.getAgreements();
  820 + if (agreementsBean != null){
  821 + List<AppAgreementBean> agreementList = agreementsBean.getAgreementList();
  822 + appMainActivity.getUserAgreement(agreementList);
  823 + }
  824 + //地区文件
  825 + LaunchPageBean.AreasBean areasBean = launchPageBean.getAreas();
  826 + if (areasBean != null){
  827 + // 省份信息初始化
  828 + ProvinceDataManager.getInstance().init(areasBean);
  829 + }
  830 +
  831 + if(launchPageBean.launchPageInfo != null){
  832 + //展现中心开机屏有数据,预加载数据
  833 + prepareLaunchPageResource(launchPageBean.launchPageInfo);
  834 + return;
  835 + }
  836 +
  837 + if(ArrayUtils.isEmpty(launchPageBean.launchAdInfo)){
  838 + //无数据
  839 + return;
  840 + }
  841 + List<CompAdvBean> tempDatas = null;
  842 + try {
  843 + tempDatas = (List<CompAdvBean>) SerializationUtils.
  844 + clone((Serializable) launchPageBean.launchAdInfo);
  845 + } catch (Exception e) {
  846 + e.printStackTrace();
  847 + }
  848 + //缓存的展示过的开机屏广告数据
  849 + List<LaunchAdModel> launchAdModels = LaunchAdHelper.getInstance(appMainActivity).
  850 + getAll();
  851 + if(!ArrayUtils.isEmpty(launchAdModels) ){
  852 + //本地有缓存数据
  853 + int totalRounds = 0;
  854 + for (CompAdvBean compAdvBean:launchPageBean.launchAdInfo) {
  855 + for (LaunchAdModel launchAdModel:launchAdModels) {
  856 + if(launchAdModel.advId == compAdvBean.getId()){
  857 + compAdvBean.setDisplayRound(launchAdModel.displayRound);
  858 + }
  859 + }
  860 + totalRounds = totalRounds + compAdvBean.getDisplayRound();
  861 + }
  862 + if(totalRounds == 0){
  863 + //新一轮开始,清除缓存数据,使用接口返回的数据
  864 + LaunchAdHelper.getInstance(appMainActivity).clear();
  865 + CompAdvBean compAdvBean = AdvUtils.getLaunchAdInfoForRule(tempDatas);
  866 + if(compAdvBean != null){
  867 + //广告中心开机屏有数据,预加载数据
  868 + prepareLaunchAdInfoResource(compAdvBean);
  869 + return;
  870 + }
  871 + }
  872 + }
  873 + CompAdvBean compAdvBean = AdvUtils.getLaunchAdInfoForRule(launchPageBean.launchAdInfo);
  874 + if(compAdvBean != null){
  875 + //广告中心开机屏有数据,预加载数据
  876 + prepareLaunchAdInfoResource(compAdvBean);
  877 + }
  878 +
  879 +
  880 +
  881 + }
  882 +
  883 + @Override
  884 + public void onGetAdlFailed(String error) {
  885 + BaseConstants.newsTabMd5 = System.currentTimeMillis()+"";
  886 + if(appMainActivity != null){
  887 + appMainActivity.getLaunchPageFinish(null);
  888 + //底部频道数据,失败也调用
  889 + appMainActivity.requestBottomGroup();
  890 + //请求新闻tab的groupDetail
  891 + appMainActivity.getNewsTabBottomNavGroupDetail();
  892 + }
  893 + //接口报错,读取下文件添加到白名单
  894 + H5JsApiPermissionUtil.getInstance().addH5WhiteHostList();
  895 + }
  896 + }).getSplashAdInfo(ScreenUtils.getScreenSize(appMainActivity, true) + "", ScreenUtils.getScreenSize(appMainActivity, false) + "");
  897 + }
  898 +
  899 + /**
  900 + * 公共配置
  901 + * @param commonConfigBean
  902 + */
  903 + private void dealCommons(CommonConfigBean commonConfigBean){
  904 + if (commonConfigBean == null) {
  905 + return;
  906 + }
  907 + //移动生产开关
  908 + AppPublishConfigBean appPublishConfigBean = commonConfigBean.getAppPublish();
  909 + if (appPublishConfigBean != null) {
  910 + Constants.publishHideSwitch = appPublishConfigBean.isPublishHideSwitch();
  911 + }
  912 + //活动开关
  913 + AppAtvConfigBean appAtvConfigBean = commonConfigBean.getAppAtv();
  914 + if (appAtvConfigBean != null) {
  915 + Constants.atvHideSwitch = appAtvConfigBean.isAtvHideSwitch();
  916 + }
  917 +
  918 + //定制化表情包
  919 + if (commonConfigBean !=null && commonConfigBean.getCommentPics() != null &&
  920 + ArrayUtils.isNotEmpty(commonConfigBean.getCommentPics().getCommentPicList())) {
  921 + MemStoreUtils.put("commentgif",commonConfigBean.getCommentPics().getCommentPicList());
  922 + }
  923 + }
  924 +
  925 + /**
  926 + * 处理白名单
  927 + * @param launchPageBean
  928 + */
  929 + private void dealH5WhiteHost(LaunchPageBean launchPageBean){
  930 + if (launchPageBean != null){
  931 + OperationUrlBean operationUrl = launchPageBean.getOperationUrl();
  932 + if (operationUrl != null){
  933 + // false--不校验白名单;ture校验
  934 + boolean enabled = operationUrl.isEnabled();
  935 + H5JsApiPermissionUtil.enabled = enabled;
  936 + //1、本地保存的md5和接口md5比较,不一致需要更新
  937 + String localMd5 = SpUtils.getH5WhiteHostDataMD5();
  938 + //更新下载文件md5
  939 + String md5 = operationUrl.getMd5();
  940 + //2、本地保存的文件不存在也更新
  941 + if (!localMd5.equals(md5) || H5JsApiPermissionUtil.getInstance().isH5WhiteHostFileNoExists()){
  942 + SpUtils.saveH5WhiteHostDataMD5(md5);
  943 + //更新下载文件地址
  944 + String linkUrl = operationUrl.getLinkUrl();
  945 + if (StringUtils.isNotBlank(linkUrl)){
  946 + //异步下载
  947 + H5JsApiPermissionUtil.getInstance().saveH5WhiteHostFile(linkUrl);
  948 + }
  949 + }else {
  950 + //不用保存,读取下文件添加到白名单
  951 + H5JsApiPermissionUtil.getInstance().addH5WhiteHostList();
  952 + }
  953 + }
  954 + }
  955 + }
  956 +
  957 + /**
  958 + * 跳转启动页
  959 + */
  960 + public void jumpSplash(boolean isfirst) {
  961 + Constants.easterEggsCanShow = "1";
  962 + //首次不展示
  963 + if(isfirst){
  964 + appMainActivity.finishPage();
  965 + //请求开机屏广告
  966 + loadSplashData();
  967 + return;
  968 + }
  969 + if (Constants.isPullup){
  970 + //拉起不展现广告
  971 + appMainActivity.finishPage();
  972 + //请求合并接口
  973 + loadSplashData();
  974 + }else {
  975 + //展示本地广告数据
  976 + showLocalSplash();
  977 + }
  978 +
  979 + }
  980 +
  981 + /**
  982 + * 倒计时控制标识
  983 + */
  984 + private boolean isDoCountDown = false;
  985 + private Handler mHandle = new Handler(new Handler.Callback() {
  986 + @Override
  987 + public boolean handleMessage(@NonNull Message message) {
  988 + switch (message.what) {
  989 + case 0:
  990 + if (isDoCountDown) {
  991 + int value = (int) message.obj;
  992 + message = Message.obtain();
  993 + message.what = 0;
  994 + message.obj = value - 1000;
  995 + if (value > 0) {
  996 + splashTimeView.setText(String.valueOf(value / 1000) + downtimeWord);
  997 + mHandle.sendMessageDelayed(message, 1000);
  998 + } else {
  999 + isDoCountDown = false;
  1000 + splashTimeView.setVisibility(View.GONE);
  1001 + appMainActivity.finishPage();
  1002 + }
  1003 + }
  1004 + break;
  1005 + default:
  1006 + break;
  1007 + }
  1008 + return false;
  1009 + }
  1010 + });
  1011 +
  1012 + /**
  1013 + * 开启倒计时+进度条
  1014 + */
  1015 + private void startCountdown() {
  1016 + //进度条开始读秒
  1017 + splashTimeView.setText(totalTime / 1000 + downtimeWord);
  1018 + Message message = Message.obtain();
  1019 + message.what = 0;
  1020 + message.obj = totalTime;
  1021 + mHandle.sendMessage(message);
  1022 + isDoCountDown = true;
  1023 + }
  1024 +
  1025 + public void releasePlayer() {
  1026 +// if (aliyunRenderView != null) {
  1027 +// aliyunRenderView.setVisibility(View.GONE);
  1028 +// aliyunRenderView.stop();
  1029 +// aliyunRenderView.release();
  1030 +// aliyunRenderView = null;
  1031 +// }
  1032 + }
  1033 +
  1034 + public void onPause() {
  1035 +// if (aliyunRenderView != null) {
  1036 +// aliyunRenderView.pause();
  1037 +// }
  1038 + }
  1039 +
  1040 + public void onStop() {
  1041 +// if (aliyunRenderView != null) {
  1042 +// aliyunRenderView.stop();
  1043 +// }
  1044 + }
  1045 +
  1046 + /**
  1047 + * 释放资源
  1048 + */
  1049 + public void releaseResources() {
  1050 + //倒计时
  1051 + if (splashTimeView != null) {
  1052 + splashTimeView.setBackgroundResource(0);
  1053 + }
  1054 + //开屏图
  1055 + if (splashAdImageVew != null) {
  1056 + splashAdImageVew.setImageResource(0);
  1057 + }
  1058 + //跳到第三方入口
  1059 + if (splashRlJumpAd != null) {
  1060 + splashRlJumpAd.setBackgroundResource(0);
  1061 + }
  1062 + }
  1063 +
  1064 + /**
  1065 + * 开屏广告内容曝光埋点
  1066 + * isExposure true曝光、false点击
  1067 + * */
  1068 + private void trackExposure(boolean isExposure) {
  1069 + TrackContentBean trackContentBean = new TrackContentBean();
  1070 + //页面名称 page_name
  1071 + trackContentBean.setPage_name(PageNameConstants.OPEN_SCREEN_PAGE);
  1072 + //页面ID page_id
  1073 + trackContentBean.setPage_id(PageNameConstants.OPEN_SCREEN_PAGE);
  1074 + //所属区域 region_name 0开屏
  1075 + trackContentBean.setRegion_name(RegionNameConstants.OPEN_SCREEN);
  1076 + trackContentBean.ad_type = RegionNameConstants.OPEN_SCREEN;
  1077 + if(launchType == 1 && mSplashAdBean != null){
  1078 + //展现中心广告
  1079 + //内容ID content_id
  1080 + trackContentBean.setContent_id(mSplashAdBean.id);
  1081 + trackContentBean.setContent_type(mSplashAdBean.objectType);
  1082 + //内容名称 content_name
  1083 + trackContentBean.setContent_name(mSplashAdBean.screenName);
  1084 +// trackContentBean.ad_type = mSplashAdBean.showType;
  1085 + if(StringUtils.isEqual("1",mSplashAdBean.isAd)){
  1086 + trackContentBean.setAdId(mSplashAdBean.id);
  1087 + trackContentBean.setAdName(mSplashAdBean.screenName);
  1088 + trackContentBean.setContent_name(mSplashAdBean.screenName);
  1089 + trackContentBean.setAdType("0");
  1090 + }
  1091 + }else if(launchAdInfoBean != null ){
  1092 + //广告中心广告
  1093 + //内容ID content_id
  1094 + trackContentBean.setContent_id(launchAdInfoBean.getId()+"");
  1095 + //内容名称 content_name
  1096 +// trackContentBean.setContent_name(launchAdInfoBean.get);
  1097 + trackContentBean.setContent_type("4");
  1098 + trackContentBean.setAdId(launchAdInfoBean.getId()+"");
  1099 + trackContentBean.setAdType("0");
  1100 + //开机屏广告没有标题,产品要求写死
  1101 + trackContentBean.setContent_name("启动广告");
  1102 + trackContentBean.setAdName("启动广告");
  1103 + }else{
  1104 + return;
  1105 + }
  1106 +
  1107 +// if(isExposure){
  1108 +// //曝光
  1109 +// trackContentBean.setAction(ActionConstants.SHOW);
  1110 +// CommonTrack.getInstance().contentShowTrack(trackContentBean);
  1111 +// }else{
  1112 +// //点击
  1113 +// trackContentBean.setAction(ActionConstants.DETAIL_PAGE_SHOW);
  1114 +// CommonTrack.getInstance().contentClickTrack(trackContentBean);
  1115 +// }
  1116 + }
  1117 +
  1118 +
  1119 + /**
  1120 + * 异步预加载下次启动需要用到的图片
  1121 + *
  1122 + * @param compAdvBean
  1123 + */
  1124 + private void prepareLaunchAdInfoResource(CompAdvBean compAdvBean) {
  1125 + ThreadPoolUtils.backgroundSubmit(new Runnable() {
  1126 + @Override
  1127 + public void run() {
  1128 + dealLaunchAdInfo(compAdvBean, true);
  1129 + }
  1130 + });
  1131 + }
  1132 +
  1133 + /**
  1134 + * 处理开屏页
  1135 + *
  1136 + * @param compAdvBean
  1137 + * @param isPrepare true预加载,false加载
  1138 + */
  1139 + private void dealLaunchAdInfo(CompAdvBean compAdvBean, boolean isPrepare) {
  1140 + if(compAdvBean == null || compAdvBean.getMatInfo() == null){
  1141 + if(!isPrepare){
  1142 + //不是预加载,要处理finishPage
  1143 + appMainActivity.finishPage();
  1144 + }
  1145 + return;
  1146 + }
  1147 + CompAdvMatInfoBean compAdvMatInfoBean = compAdvBean.getMatInfo();
  1148 + String matType = compAdvMatInfoBean.getMatType();
  1149 + launchType = 2;
  1150 + if (isPrepare) {
  1151 + //预加载
  1152 + if ("0".equals(matType)) {
  1153 + //图片
  1154 + if(ArrayUtils.isEmpty(compAdvMatInfoBean.getMatImageUrl())){
  1155 + return;
  1156 + }
  1157 + String matImageUrl = compAdvMatInfoBean.getMatImageUrl().get(0);
  1158 + if(StringUtils.isEmpty(matImageUrl)){
  1159 + return;
  1160 + }
  1161 + ThreadPoolUtils.backgroundSubmit(new Runnable() {
  1162 + @Override
  1163 + public void run() {
  1164 + ImageUtils.getInstance().preloadImage(AppContext.getContext(), matImageUrl,new RequestListener<Drawable>() {
  1165 + @Override
  1166 + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target,
  1167 + boolean isFirstResource) {
  1168 + return false;
  1169 + }
  1170 +
  1171 + @Override
  1172 + public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target,
  1173 + DataSource dataSource, boolean isFirstResource) {
  1174 + SpUtils.setSplashCacheType(2);
  1175 + SpUtils.saveSplashCache(GsonUtils.objectToJson(compAdvBean));
  1176 + return true;
  1177 + }
  1178 + });
  1179 + }
  1180 + });
  1181 + } else if ("1".equals(matType)) {
  1182 + //视频
  1183 + downloadLaunchAdInfoVideo(false,compAdvBean);
  1184 + }
  1185 + } else {
  1186 + //非预加载
  1187 + launchAdInfoBean = compAdvBean;
  1188 + //先判断是否符合时间要求
  1189 + long currentTimeLong = TimeUtil.millis();
  1190 + long startLong = compAdvBean.getStartTime();
  1191 + long endLong = compAdvBean.getEndTime();
  1192 + if (currentTimeLong < startLong || currentTimeLong > endLong) {
  1193 + //不符合开始时间和结束时间要求
  1194 + appMainActivity.finishPage();
  1195 + return;
  1196 + }
  1197 + if ("0".equals(matType) || "1".equals(matType)) {
  1198 + //运营配置的启动页
  1199 + initSplash();
  1200 + //缓存展示的数据,将displayRound-1
  1201 + LaunchAdModel launchAdModel = new LaunchAdModel();
  1202 + launchAdModel.advId = compAdvBean.getId();
  1203 + if(compAdvBean.getDisplayRound() < 1){
  1204 + launchAdModel.displayRound = 0;
  1205 + }else {
  1206 + launchAdModel.displayRound = compAdvBean.getDisplayRound() - 1;
  1207 + }
  1208 + LaunchAdHelper.getInstance(appMainActivity).insert(launchAdModel);
  1209 + } else {
  1210 + appMainActivity.finishPage();
  1211 + }
  1212 + }
  1213 + }
  1214 +
  1215 + /**
  1216 + * 视频使用本地缓存
  1217 + *
  1218 + * @param unPrepare 非预加载
  1219 + */
  1220 + private boolean downloadLaunchAdInfoVideo(boolean unPrepare,CompAdvBean compAdvBean) {
  1221 + if(compAdvBean == null || compAdvBean.getMatInfo() == null){
  1222 + return false;
  1223 + }
  1224 + CompAdvMatInfoBean compAdvMatInfoBean = compAdvBean.getMatInfo();
  1225 + if (TextUtils.isEmpty(compAdvMatInfoBean.getMatVideoUrl())) {
  1226 + return false;
  1227 + }
  1228 +
  1229 + String finalPath = DownloadUtil.getDownloadCachePath(appMainActivity,
  1230 + DownloadUtil.getNameFromUrl(compAdvMatInfoBean.getMatVideoUrl()));
  1231 + if (MyFileUtils.isExist(finalPath)) {
  1232 + //文件存在
  1233 + if (unPrepare) {
  1234 + loadVideoAd(finalPath);
  1235 + }else{
  1236 + SpUtils.setSplashCacheType(2);
  1237 + SpUtils.saveSplashCache(GsonUtils.objectToJson(compAdvBean));
  1238 + }
  1239 + } else {
  1240 + //文件不存在
  1241 + // 同时下载
  1242 + viewModel.downLoadAdData(appMainActivity, compAdvMatInfoBean.getMatVideoUrl(), new IDownloadListener() {
  1243 +
  1244 + @Override
  1245 + public void onStart() {
  1246 + }
  1247 +
  1248 + @Override
  1249 + public void onProgress(int progress) {
  1250 + }
  1251 +
  1252 + @Override
  1253 + public void onFailure() {
  1254 + }
  1255 +
  1256 + @Override
  1257 + public void onDone() {
  1258 + SpUtils.setSplashCacheType(2);
  1259 + SpUtils.saveSplashCache(GsonUtils.objectToJson(compAdvBean));
  1260 + }
  1261 + });
  1262 + if(!ArrayUtils.isEmpty(compAdvMatInfoBean.getMatImageUrl())){
  1263 + if(!unPrepare){
  1264 + File file = ImageUtils.getCache(appMainActivity,
  1265 + compAdvMatInfoBean.getMatImageUrl().get(0));
  1266 + //如果本地没有预加载该图片,进行预加载
  1267 + if(file == null){
  1268 + ThreadPoolUtils.backgroundSubmit(new Runnable() {
  1269 + @Override
  1270 + public void run() {
  1271 + ImageUtils.getInstance().preloadImage(AppContext.getContext(),
  1272 + compAdvMatInfoBean.getMatImageUrl().get(0),new RequestListener<Drawable>() {
  1273 + @Override
  1274 + public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target,
  1275 + boolean isFirstResource) {
  1276 + return false;
  1277 + }
  1278 +
  1279 + @Override
  1280 + public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target,
  1281 + DataSource dataSource, boolean isFirstResource) {
  1282 + SpUtils.setSplashCacheType(2);
  1283 + SpUtils.saveSplashCache(GsonUtils.objectToJson(compAdvBean));
  1284 + return true;
  1285 + }
  1286 + });
  1287 + }
  1288 + });
  1289 + }
  1290 + }
  1291 + if(unPrepare){
  1292 + //本地没有视频,直接跳过视频
  1293 + return showImageAd(compAdvMatInfoBean.getMatImageUrl().get(0));
  1294 + }
  1295 + }
  1296 + return false;
  1297 + }
  1298 + return true;
  1299 + }
  1300 +
  1301 +
  1302 + /**
  1303 + * 下载H5模板文件
  1304 + */
  1305 + private void downloadH5Template(String h5url,String serVersion,String minAPPV,String MaxAPPV) {
  1306 +
  1307 + String localAppCode = DeviceUtil.getVersionCode() + "";
  1308 + Logger.t("DownLoadH5").d("localAppCode=" + localAppCode + "&minAPPV=" + minAPPV + "&MaxAPPV=" + MaxAPPV );
  1309 + //当前APP版本code,在服务器给的版本范围内才去下载更新模板
  1310 + try {
  1311 + if (Long.parseLong(localAppCode) < Long.parseLong(minAPPV) ||
  1312 + Long.parseLong(localAppCode) > Long.parseLong(MaxAPPV)) {
  1313 + return;
  1314 + }
  1315 + }catch (NumberFormatException e){
  1316 + e.printStackTrace();
  1317 + return;
  1318 + }
  1319 +
  1320 + //判断本地版本比服务器版本小才下载
  1321 + String h5TempVersion = SpUtils.getH5Template();
  1322 + if(!TextUtils.isEmpty(h5TempVersion)){
  1323 + String lversion = h5TempVersion.substring(h5TempVersion.indexOf("_") + 1);
  1324 + Logger.t("DownLoadH5").d("local_version=" + lversion + "&serVersion=" + serVersion );
  1325 + try {
  1326 + if( Long.parseLong(lversion) >= Long.parseLong(serVersion)){
  1327 + return;
  1328 + }
  1329 + }catch (NumberFormatException e){
  1330 + e.printStackTrace();
  1331 + return;
  1332 + }
  1333 +
  1334 + }
  1335 +
  1336 + DownloadUtil.get().download(AppContext.getContext(), h5url, new IDownloadListener() {
  1337 + @Override
  1338 + public void onStart() {
  1339 + }
  1340 +
  1341 + @Override
  1342 + public void onProgress(int progress) {
  1343 + }
  1344 +
  1345 + @Override
  1346 + public void onFailure() {
  1347 +
  1348 + }
  1349 +
  1350 + @Override
  1351 + public void onDone() {
  1352 + try {
  1353 + Logger.t("DownLoadH5").d("success");
  1354 +
  1355 + String filename = h5url.substring(h5url.lastIndexOf('/')+1);
  1356 + File downLoadZip = new File(AppContext.getContext().getExternalCacheDir(), filename);
  1357 + if (downLoadZip != null && downLoadZip.exists()) {
  1358 + Logger.t("DownLoadH5").d(downLoadZip.getAbsolutePath());
  1359 + String h5TempVersion = SpUtils.getH5Template();
  1360 + File h5cacheDir = null;
  1361 + String unUseTemp = "h5web1";
  1362 + //缓存的模板在使用,不影响,使用另一个不用的模板覆盖
  1363 + if(h5TempVersion.startsWith("h5web1")){
  1364 + h5cacheDir = new File(AppContext.getContext().getCacheDir(), "h5web2");
  1365 + unUseTemp = "h5web2";
  1366 + }else if(h5TempVersion.startsWith("h5web2")){
  1367 + h5cacheDir = new File(AppContext.getContext().getCacheDir(), "h5web1");
  1368 + unUseTemp = "h5web1";
  1369 + }else{
  1370 + h5cacheDir = new File(AppContext.getContext().getCacheDir(), "h5web1");
  1371 + unUseTemp = "h5web1";
  1372 + }
  1373 +
  1374 + //解压文件
  1375 + boolean isUnpackZip = MyFileUtils.unpackZip(downLoadZip, h5cacheDir);
  1376 + if (isUnpackZip) {
  1377 + Logger.t("DownLoadH5").d("onSuccess:unUseTemp=" + unUseTemp + "_" + serVersion);
  1378 + Logger.t("DownLoadH5").d("onSuccess:absolutePath=" + downLoadZip.getAbsolutePath());
  1379 + SpUtils.saveH5Template(unUseTemp + "_" + serVersion);
  1380 + } else {
  1381 + Logger.t("DownLoadH5").d("onSuccess: 解压失败");
  1382 + }
  1383 + }
  1384 + } catch (Exception e) {
  1385 + Logger.t("DownLoadH5").d("fail:" + e.getMessage());
  1386 + e.printStackTrace();
  1387 + }
  1388 + }
  1389 + });
  1390 +
  1391 + }
  1392 +
  1393 +}
@@ -5,11 +5,23 @@ import android.app.Activity; @@ -5,11 +5,23 @@ import android.app.Activity;
5 import android.os.Environment; 5 import android.os.Environment;
6 import android.os.SystemClock; 6 import android.os.SystemClock;
7 import android.text.TextUtils; 7 import android.text.TextUtils;
  8 +import android.view.Gravity;
8 9
9 import androidx.core.content.FileProvider; 10 import androidx.core.content.FileProvider;
10 import androidx.fragment.app.FragmentActivity; 11 import androidx.fragment.app.FragmentActivity;
11 12
12 - 13 +import com.people.location.LocationUtils;
  14 +import com.wd.common.listener.ResultCallback;
  15 +import com.wd.common.notify.CookieBar;
  16 +import com.wd.common.permissions.IInterCeptorCallBack;
  17 +import com.wd.common.permissions.IPmsCallBack;
  18 +import com.wd.common.permissions.PermissionsUtils;
  19 +import com.wd.common.permissions.PmsConstant;
  20 +import com.wd.common.utils.CommonNetUtils;
  21 +import com.wd.common.utils.CommonVarUtils;
  22 +import com.wd.foundation.bean.custom.comp.PageBean;
  23 +import com.wd.foundation.bean.custom.content.ContentBean;
  24 +import com.wd.foundation.bean.custom.content.ContentTypeConstant;
13 import com.wd.foundation.wdkit.base.BaseApplication; 25 import com.wd.foundation.wdkit.base.BaseApplication;
14 import com.wd.foundation.wdinterface.config.INetConfig; 26 import com.wd.foundation.wdinterface.config.INetConfig;
15 import com.wd.foundation.wdinterface.constant.InterfaceConstant; 27 import com.wd.foundation.wdinterface.constant.InterfaceConstant;
@@ -19,9 +31,12 @@ import com.wd.common.utils.ProcessUtils; @@ -19,9 +31,12 @@ import com.wd.common.utils.ProcessUtils;
19 import com.wd.foundation.bean.custom.MenuBean; 31 import com.wd.foundation.bean.custom.MenuBean;
20 import com.wd.foundation.bean.response.BottomNavBean; 32 import com.wd.foundation.bean.response.BottomNavBean;
21 import com.wd.foundation.bean.response.ChannelBean; 33 import com.wd.foundation.bean.response.ChannelBean;
  34 +import com.wd.foundation.wdkit.system.DeviceUtil;
22 import com.wd.foundation.wdkit.utils.SpUtils; 35 import com.wd.foundation.wdkit.utils.SpUtils;
  36 +import com.wd.foundation.wdkit.utils.ToastNightUtil;
23 import com.wd.foundation.wdkitcore.livedata.LiveDataBus; 37 import com.wd.foundation.wdkitcore.livedata.LiveDataBus;
24 import com.wd.foundation.wdkitcore.router.ArouterServiceManager; 38 import com.wd.foundation.wdkitcore.router.ArouterServiceManager;
  39 +import com.wd.foundation.wdkitcore.thread.ThreadPoolUtils;
25 import com.wd.foundation.wdkitcore.tools.JsonUtils; 40 import com.wd.foundation.wdkitcore.tools.JsonUtils;
26 import com.wd.foundation.wdkitcore.tools.StringUtils; 41 import com.wd.foundation.wdkitcore.tools.StringUtils;
27 import com.wd.module_home.R; 42 import com.wd.module_home.R;
@@ -46,7 +61,7 @@ public class WelcomeUtils { @@ -46,7 +61,7 @@ public class WelcomeUtils {
46 /** 61 /**
47 * 定位工具 62 * 定位工具
48 */ 63 */
49 -// private static LocationUtils locationUtils; 64 + private static LocationUtils locationUtils;
50 65
51 /** 66 /**
52 * 定位弹窗,弹过了,可以弹升级了 67 * 定位弹窗,弹过了,可以弹升级了
@@ -141,37 +156,37 @@ public class WelcomeUtils { @@ -141,37 +156,37 @@ public class WelcomeUtils {
141 /** 156 /**
142 * 桌面组件逻辑处理 157 * 桌面组件逻辑处理
143 */ 158 */
144 -// public static void toWidgetActivity() {  
145 -// String widgetData = SpUtils.getWidgetData();  
146 -// if (!TextUtils.isEmpty(widgetData)) {  
147 -// // 跳转到电子报页面  
148 -// if ("1".equalsIgnoreCase(widgetData)) {  
149 -// ProcessUtils.goToPaperActivity();  
150 -// }else if ("2".equalsIgnoreCase(widgetData)){  
151 -// // 跳转到早晚报专题页面  
152 -// CommonNetUtils.getInstance().getDailyPaperId(new ResultCallback<PageBean>() {  
153 -// @Override  
154 -// public void onSuccess(PageBean pageBean) {  
155 -// if (pageBean != null) {  
156 -// ContentBean bean = new ContentBean();  
157 -// bean.setObjectLevel(String.valueOf(ContentTypeConstant.SUBJECT_TOPICTYPE_25));  
158 -// bean.setPageId(pageBean.getId());  
159 -// bean.setNewsTitle(pageBean.getName());  
160 -// ProcessUtils.goToCommonSubjectPage(bean);  
161 -//  
162 -// } else {  
163 -// ToastNightUtil.showShort("暂无数据");  
164 -// }  
165 -// }  
166 -//  
167 -// @Override  
168 -// public void onError(String errorCode) {  
169 -// }  
170 -// });  
171 -// }  
172 -// SpUtils.saveWidgetData("");  
173 -// }  
174 -// } 159 + public static void toWidgetActivity() {
  160 + String widgetData = SpUtils.getWidgetData();
  161 + if (!TextUtils.isEmpty(widgetData)) {
  162 + // 跳转到电子报页面
  163 + if ("1".equalsIgnoreCase(widgetData)) {
  164 + ProcessUtils.goToPaperActivity();
  165 + }else if ("2".equalsIgnoreCase(widgetData)){
  166 + // 跳转到早晚报专题页面
  167 + CommonNetUtils.getInstance().getDailyPaperId(new ResultCallback<PageBean>() {
  168 + @Override
  169 + public void onSuccess(PageBean pageBean) {
  170 + if (pageBean != null) {
  171 + ContentBean bean = new ContentBean();
  172 + bean.setObjectLevel(String.valueOf(ContentTypeConstant.SUBJECT_TOPICTYPE_25));
  173 + bean.setPageId(pageBean.getId());
  174 + bean.setNewsTitle(pageBean.getName());
  175 + ProcessUtils.goToCommonSubjectPage(bean);
  176 +
  177 + } else {
  178 + ToastNightUtil.showShort("暂无数据");
  179 + }
  180 + }
  181 +
  182 + @Override
  183 + public void onError(String errorCode) {
  184 + }
  185 + });
  186 + }
  187 + SpUtils.saveWidgetData("");
  188 + }
  189 + }
175 190
176 /** 191 /**
177 * 刷新彩蛋数据 192 * 刷新彩蛋数据
@@ -249,7 +264,7 @@ public class WelcomeUtils { @@ -249,7 +264,7 @@ public class WelcomeUtils {
249 /** 264 /**
250 * 同意了隐私政策,在线程里初始化 265 * 同意了隐私政策,在线程里初始化
251 */ 266 */
252 -// public static void delayInit(Activity context) { 267 + public static void delayInit(Activity context) {
253 // //个推初始化 268 // //个推初始化
254 // GeTuiSdkHelper.initialize(context); 269 // GeTuiSdkHelper.initialize(context);
255 // //设备信息上传,随机延迟 1-10秒调用 270 // //设备信息上传,随机延迟 1-10秒调用
@@ -265,7 +280,7 @@ public class WelcomeUtils { @@ -265,7 +280,7 @@ public class WelcomeUtils {
265 // TingYunSDKHelper.init(context); 280 // TingYunSDKHelper.init(context);
266 // //TingYun 设置用户标识 281 // //TingYun 设置用户标识
267 // TingYunSDKHelper.setUserIdentifier(DeviceUtil.getDeviceId()); 282 // TingYunSDKHelper.setUserIdentifier(DeviceUtil.getDeviceId());
268 -// } 283 + }
269 284
270 /** 285 /**
271 * 是否是正式环境 286 * 是否是正式环境
@@ -344,84 +359,84 @@ public class WelcomeUtils { @@ -344,84 +359,84 @@ public class WelcomeUtils {
344 * 首次申请定位权限 359 * 首次申请定位权限
345 */ 360 */
346 public static void getLocation(FragmentActivity activity) { 361 public static void getLocation(FragmentActivity activity) {
347 -//  
348 -// //拒绝过  
349 -// if (!SpUtils.getRefusedLocation()) {  
350 -// CommonVarUtils.isShowLocation = true;  
351 -// final CookieBar[] mCookieBar = new CookieBar[1];  
352 -// PermissionsUtils.getLocation(activity, null, new IInterCeptorCallBack() {  
353 -// @Override  
354 -// public void interceotor() {  
355 -// if (activity == null || activity.isFinishing() || activity.isDestroyed()) {  
356 -// return;  
357 -// }  
358 -// //需要请求权限拦截,此时弹出 定位权限消息提醒  
359 -// mCookieBar[0] = new CookieBar.Builder(activity)  
360 -// .setTitle("")  
361 -// .setMessage("")  
362 -// .setImgUrl("")  
363 -// .setPushScene(5)  
364 -// .setPlanStartTime(0)  
365 -// .setDuration(10000)  
366 -// .setLayoutGravity(Gravity.TOP)  
367 -// .setActionListener((type) -> {  
368 -// }).setDismissListener(type -> {  
369 -// }).show();  
370 -//  
371 -// }  
372 -// }, new IPmsCallBack() {  
373 -// @Override  
374 -// public void granted() {  
375 -// //关闭定位提醒  
376 -// if (mCookieBar[0] != null) {  
377 -// mCookieBar[0].dismiss();  
378 -// }  
379 -// CommonVarUtils.isShowLocation = false;  
380 -// requestLocation();  
381 -// // 检测弹窗  
382 -// locationIsShow = true;  
383 -// WelcomeUtils.upVersion(activity);  
384 -// }  
385 -//  
386 -// @Override  
387 -// public void notGranted() {  
388 -// //未授权  
389 -// //授权或未授权,获取到定位请求过不要设置,保留上一次的位置信息  
390 -// int firstLocation = SpUtils.getFirstLocation();  
391 -// if (-1 == firstLocation){  
392 -// SpUtils.saveFirstLocation(0);  
393 -// }  
394 -// if (mCookieBar[0] != null) {  
395 -// mCookieBar[0].dismiss();  
396 -// }  
397 -//  
398 -// CommonVarUtils.isShowLocation = false;  
399 -// // 检测弹窗  
400 -// locationIsShow = true;  
401 -// WelcomeUtils.upVersion(activity);  
402 -// SpUtils.saveRefusedLocation(true);  
403 -// }  
404 -// });  
405 -// } else {  
406 -// CommonVarUtils.isShowLocation = false;  
407 -// // 检测弹窗  
408 -// locationIsShow = true;  
409 -// WelcomeUtils.upVersion(activity);  
410 -// //检测下是否有可能用户自己在设置里面开启权限  
411 -// String[] permissions = new String[]{PmsConstant.ACCESS_FINE_LOCATION,  
412 -// PmsConstant.ACCESS_COARSE_LOCATION};  
413 -// boolean hPermission = PermissionsUtils.checkPermissionsGroup(activity, permissions);  
414 -// if (hPermission){  
415 -// //开启定位  
416 -// requestLocation();  
417 -// }else {  
418 -// int firstLocation = SpUtils.getFirstLocation();  
419 -// if (-1 == firstLocation){  
420 -// SpUtils.saveFirstLocation(0);  
421 -// }  
422 -// }  
423 -// }  
424 -// 362 +
  363 + //拒绝过
  364 + if (!SpUtils.getRefusedLocation()) {
  365 + CommonVarUtils.isShowLocation = true;
  366 + final CookieBar[] mCookieBar = new CookieBar[1];
  367 + PermissionsUtils.getLocation(activity, null, new IInterCeptorCallBack() {
  368 + @Override
  369 + public void interceotor() {
  370 + if (activity == null || activity.isFinishing() || activity.isDestroyed()) {
  371 + return;
  372 + }
  373 + //需要请求权限拦截,此时弹出 定位权限消息提醒
  374 + mCookieBar[0] = new CookieBar.Builder(activity)
  375 + .setTitle("")
  376 + .setMessage("")
  377 + .setImgUrl("")
  378 + .setPushScene(5)
  379 + .setPlanStartTime(0)
  380 + .setDuration(10000)
  381 + .setLayoutGravity(Gravity.TOP)
  382 + .setActionListener((type) -> {
  383 + }).setDismissListener(type -> {
  384 + }).show();
  385 +
  386 + }
  387 + }, new IPmsCallBack() {
  388 + @Override
  389 + public void granted() {
  390 + //关闭定位提醒
  391 + if (mCookieBar[0] != null) {
  392 + mCookieBar[0].dismiss();
  393 + }
  394 + CommonVarUtils.isShowLocation = false;
  395 + requestLocation();
  396 + // 检测弹窗
  397 + locationIsShow = true;
  398 + WelcomeUtils.upVersion(activity);
  399 + }
  400 +
  401 + @Override
  402 + public void notGranted() {
  403 + //未授权
  404 + //授权或未授权,获取到定位请求过不要设置,保留上一次的位置信息
  405 + int firstLocation = SpUtils.getFirstLocation();
  406 + if (-1 == firstLocation){
  407 + SpUtils.saveFirstLocation(0);
  408 + }
  409 + if (mCookieBar[0] != null) {
  410 + mCookieBar[0].dismiss();
  411 + }
  412 +
  413 + CommonVarUtils.isShowLocation = false;
  414 + // 检测弹窗
  415 + locationIsShow = true;
  416 + WelcomeUtils.upVersion(activity);
  417 + SpUtils.saveRefusedLocation(true);
  418 + }
  419 + });
  420 + } else {
  421 + CommonVarUtils.isShowLocation = false;
  422 + // 检测弹窗
  423 + locationIsShow = true;
  424 + WelcomeUtils.upVersion(activity);
  425 + //检测下是否有可能用户自己在设置里面开启权限
  426 + String[] permissions = new String[]{PmsConstant.ACCESS_FINE_LOCATION,
  427 + PmsConstant.ACCESS_COARSE_LOCATION};
  428 + boolean hPermission = PermissionsUtils.checkPermissionsGroup(activity, permissions);
  429 + if (hPermission){
  430 + //开启定位
  431 + requestLocation();
  432 + }else {
  433 + int firstLocation = SpUtils.getFirstLocation();
  434 + if (-1 == firstLocation){
  435 + SpUtils.saveFirstLocation(0);
  436 + }
  437 + }
  438 + }
  439 +
425 } 440 }
426 441
427 /** 442 /**
@@ -493,15 +508,15 @@ public class WelcomeUtils { @@ -493,15 +508,15 @@ public class WelcomeUtils {
493 /** 508 /**
494 * 获取定位信息 509 * 获取定位信息
495 */ 510 */
496 -// public static void requestLocation() {  
497 -// locationUtils = new LocationUtils();  
498 -// locationUtils.startLocation();  
499 -// } 511 + public static void requestLocation() {
  512 + locationUtils = new LocationUtils();
  513 + locationUtils.startLocation();
  514 + }
500 515
501 public static void onDestory() { 516 public static void onDestory() {
502 -// if (locationUtils != null) {  
503 -// locationUtils.destroyLocation();  
504 -// } 517 + if (locationUtils != null) {
  518 + locationUtils.destroyLocation();
  519 + }
505 } 520 }
506 521
507 /** 522 /**
  1 +
  2 +package com.wd.module_home.vm;
  3 +
  4 +import androidx.lifecycle.LifecycleOwner;
  5 +
  6 +
  7 +import com.wd.foundation.bean.launch.AppAgreementBean;
  8 +import com.wd.foundation.wdkit.mvvm.vm.UIViewModel;
  9 +import com.wd.module_home.model.AppAgreementFetcher;
  10 +
  11 +import java.util.List;
  12 +
  13 +
  14 +/**
  15 + * 描述:获取隐私政策
  16 + *
  17 + * @author : lvjinhui
  18 + * @since: 2022/7/15
  19 + */
  20 +public class AgreementViewModel extends UIViewModel {
  21 +
  22 + private AppAgreementFetcher fetcher;
  23 +
  24 + private IAgreementListener mAgreementListener;
  25 +
  26 + /**
  27 + * 注册vm回调对象
  28 + *
  29 + * @param lifecycleOwner 生命周期对象
  30 + * @param listener 监听对象
  31 + */
  32 + public void observeAgreementListener(LifecycleOwner lifecycleOwner, IAgreementListener listener) {
  33 + if (mAgreementListener == null) {
  34 + mAgreementListener = observe(lifecycleOwner, listener, IAgreementListener.class);
  35 + } else {
  36 + observeRepeat(lifecycleOwner, listener, mAgreementListener);
  37 + }
  38 + }
  39 +
  40 + /**
  41 + * 获取隐私政策,单独接口请求的
  42 + */
  43 + public void getAppAgreement() {
  44 + if (fetcher == null) {
  45 + fetcher = new AppAgreementFetcher(mAgreementListener);
  46 + }
  47 + fetcher.requestAppAgreementData();
  48 + }
  49 +
  50 + /**
  51 + * 获取隐私政策,后来改成了合并接口里,避免重复使用
  52 + */
  53 + public void getAppAgreementV2(List<AppAgreementBean> bean) {
  54 + if (fetcher == null) {
  55 + fetcher = new AppAgreementFetcher(mAgreementListener);
  56 + }
  57 + fetcher.getAppAgreementData(bean);
  58 + }
  59 +
  60 +}
  1 +package com.wd.module_home.vm;
  2 +
  3 +
  4 +import com.wd.foundation.wdkit.mvvm.vm.IVMCallback;
  5 +
  6 +/**
  7 + * @author baozhaoxin
  8 + * @version [V1.0.0, 2022/8/8]
  9 + * @description
  10 + * @since V1.0.0
  11 + */
  12 +public interface IAgreementListener extends IVMCallback {
  13 +
  14 + void result(int need,int serviceUserAgreeVersion,int servicePrivateAgreeVersion);
  15 +}
  1 +/*
  2 + * Copyright (c) Wondertek Technologies Co., Ltd. 2019-2022. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.module_home.vm;
  6 +
  7 +
  8 +import com.wd.capability.network.bean.MetaBean;
  9 +import com.wd.foundation.bean.launch.LaunchPageBean;
  10 +import com.wd.foundation.wdkit.mvvm.vm.IVMCallback;
  11 +
  12 +/**
  13 + * 描述:获取数据监听
  14 + *
  15 + * @author : lvjinhui
  16 + * @since: 2022/6/1
  17 + */
  18 +public interface ISplashListener extends IVMCallback {
  19 +
  20 + /**
  21 + * 获取到广告数据
  22 + * @param splashAdBean
  23 + * @param metaBean
  24 + */
  25 + void onGetAdlSuccess(LaunchPageBean splashAdBean, MetaBean metaBean);
  26 +
  27 + /**
  28 + * 获取广告数据失败返回
  29 + *
  30 + * @param error 错误信息
  31 + */
  32 + void onGetAdlFailed(String error);
  33 +}
  1 +package com.wd.module_home.vm;
  2 +
  3 +/*
  4 + * Copyright (c) Wondertek Technologies Co., Ltd. 2019-2022. All rights reserved.
  5 + */
  6 +
  7 +import android.content.Context;
  8 +
  9 +import androidx.lifecycle.LifecycleOwner;
  10 +
  11 +import com.wd.foundation.wdkit.mvvm.vm.UIViewModel;
  12 +import com.wd.foundation.wdkit.network.IDownloadListener;
  13 +import com.wd.module_home.model.SplashDataFetcher;
  14 +
  15 +
  16 +/**
  17 + * 描述:广告页
  18 + *
  19 + * @author : lvjinhui
  20 + * @since: 2022/6/1
  21 + */
  22 +public class SplashViewModel extends UIViewModel {
  23 +
  24 + private static final String TAG = "SplashViewModel";
  25 +
  26 + private ISplashListener splashListener;
  27 +
  28 + private SplashDataFetcher splashDataFetcher;
  29 +
  30 + private IMainDataListener mainDataListener;
  31 +
  32 + /**
  33 + * 注册vm回调对象
  34 + *
  35 + * @param lifecycleOwner 生命周期对象
  36 + * @param listener 监听对象
  37 + */
  38 + public void observeSplashListener(LifecycleOwner lifecycleOwner, ISplashListener listener) {
  39 + if (splashListener == null) {
  40 + splashListener = observe(lifecycleOwner, listener, ISplashListener.class);
  41 + } else {
  42 + observeRepeat(lifecycleOwner, listener, splashListener);
  43 + }
  44 + }
  45 +
  46 + public void observMainDataListener(LifecycleOwner lifecycleOwner, IMainDataListener listener){
  47 + if (mainDataListener == null) {
  48 + mainDataListener = observe(lifecycleOwner, listener, IMainDataListener.class);
  49 + } else {
  50 + observeRepeat(lifecycleOwner, listener, splashListener);
  51 + }
  52 +
  53 + }
  54 +
  55 +// /**
  56 +// * 获取广告数据
  57 +// */
  58 +// public void getSplashAdInfo(String provinceCode,String cityCode,String districtCode) {
  59 +// if (splashDataFetcher == null) {
  60 +// splashDataFetcher = new SplashDataFetcher(splashListener);
  61 +// }else {
  62 +// splashDataFetcher.setmListener(splashListener);
  63 +// }
  64 +// splashDataFetcher.getSplashAdInfo(ScreenUtils.getScreenSize(this, true) + "", ScreenUtils.getScreenSize(this, false) + "");
  65 +// }
  66 +
  67 + /**
  68 + * 下载
  69 + *
  70 + * @param url
  71 + * @param callBack
  72 + */
  73 + public void downLoadAdData(Context context, String url, IDownloadListener callBack) {
  74 + if (splashDataFetcher == null) {
  75 + splashDataFetcher = new SplashDataFetcher(splashListener);
  76 + }else {
  77 + splashDataFetcher.setmListener(splashListener);
  78 + }
  79 + splashDataFetcher.downloadAdData(context, url, callBack);
  80 + }
  81 +
  82 +
  83 +
  84 +}
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:app="http://schemas.android.com/apk/res-auto"
  4 + xmlns:tools="http://schemas.android.com/tools"
  5 + android:layout_width="match_parent"
  6 + android:layout_height="match_parent"
  7 + android:clickable="true">
  8 + <!-- 引导页布局 -->
  9 + <androidx.viewpager2.widget.ViewPager2
  10 + android:id="@+id/viewpager2"
  11 + android:layout_width="match_parent"
  12 + android:layout_height="match_parent"
  13 + android:overScrollMode="never"
  14 + app:layout_constraintLeft_toLeftOf="parent"
  15 + app:layout_constraintRight_toRightOf="parent"
  16 + app:layout_constraintTop_toTopOf="parent"
  17 + app:layout_constraintBottom_toBottomOf="parent"
  18 + />
  19 +<!-- <androidx.recyclerview.widget.RecyclerView-->
  20 +<!-- android:id="@+id/rvindex"-->
  21 +<!-- android:layout_width="wrap_content"-->
  22 +<!-- android:layout_height="@dimen/rmrb_dp6"-->
  23 +<!-- android:orientation="horizontal"-->
  24 +<!-- android:scrollbars="none"-->
  25 +<!-- android:layout_marginBottom="@dimen/rmrb_dp82"-->
  26 +<!-- app:layout_constraintBottom_toBottomOf="parent"-->
  27 +<!-- app:layout_constraintLeft_toLeftOf="parent"-->
  28 +<!-- app:layout_constraintRight_toRightOf="parent"-->
  29 +<!-- tools:background="@color/red_theme_bg"-->
  30 +<!-- />-->
  31 +
  32 +<!-- &lt;!&ndash; 引导页立即开启按钮 &ndash;&gt;-->
  33 +<!-- <ImageView-->
  34 +<!-- android:id="@+id/tvEnter"-->
  35 +<!-- android:layout_width="@dimen/rmrb_dp140"-->
  36 +<!-- android:layout_height="@dimen/rmrb_dp44"-->
  37 +<!-- android:src="@mipmap/guide_button"-->
  38 +<!-- android:scaleType="centerCrop"-->
  39 +<!-- android:visibility="gone"-->
  40 +<!-- app:layout_constraintBottom_toBottomOf="parent"-->
  41 +<!-- app:layout_constraintLeft_toLeftOf="parent"-->
  42 +<!-- app:layout_constraintRight_toRightOf="parent"-->
  43 +<!-- android:layout_marginBottom="@dimen/rmrb_dp67"-->
  44 +<!-- tools:visibility="visible"-->
  45 +<!-- />-->
  46 +</androidx.constraintlayout.widget.ConstraintLayout>
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<androidx.constraintlayout.widget.ConstraintLayout
  3 + xmlns:android="http://schemas.android.com/apk/res/android"
  4 + xmlns:app="http://schemas.android.com/apk/res-auto"
  5 + android:layout_width="match_parent"
  6 + android:layout_height="match_parent"
  7 + android:background="#ffffff"
  8 + android:clickable="true">
  9 + <ImageView android:id="@+id/splash_ad_img"
  10 + android:layout_width="match_parent"
  11 + android:layout_height="match_parent"
  12 + android:scaleType="centerCrop" />
  13 + <ViewStub android:id="@+id/ad_video_vstub"
  14 + android:layout_width="match_parent"
  15 + android:layout_height="match_parent"
  16 + android:layout="@layout/ad_video_viewstub_layout" />
  17 + <com.wd.foundation.wdkit.view.customtextview.RegularTextView
  18 + android:id="@+id/tvdowntime"
  19 + android:layout_width="@dimen/rmrb_dp79"
  20 + android:layout_height="wrap_content"
  21 + android:layout_marginTop="@dimen/rmrb_dp30"
  22 + android:layout_marginRight="@dimen/rmrb_dp15"
  23 + android:gravity="center_horizontal"
  24 + android:paddingVertical="@dimen/rmrb_dp5"
  25 + android:textSize="@dimen/rmrb_dp14"
  26 + android:textColor="#ffffff"
  27 + android:visibility="invisible"
  28 + app:layout_constraintRight_toRightOf="parent"
  29 + app:layout_constraintTop_toTopOf="parent" />
  30 +
  31 +
  32 +</androidx.constraintlayout.widget.ConstraintLayout>
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<com.wd.player.widget.AliyunRenderView xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:id="@+id/splash_ad_video"
  4 + android:layout_width="match_parent"
  5 + android:layout_height="match_parent"
  6 + android:visibility="invisible" />
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:tools="http://schemas.android.com/tools"
  4 + android:layout_width="match_parent"
  5 + android:layout_height="match_parent">
  6 +
  7 + <ImageView
  8 + android:id="@+id/ivstatic"
  9 + android:layout_width="match_parent"
  10 + android:layout_height="match_parent"
  11 + android:scaleType="centerCrop" />
  12 + <!-- #ED2800 #212228 -->
  13 +
  14 + <RelativeLayout
  15 + android:id="@+id/rl_guide_fragment"
  16 + android:layout_width="match_parent"
  17 + android:layout_height="match_parent"
  18 + android:background="@color/res_color_C1"
  19 + android:visibility="gone"
  20 + tools:visibility="visible">
  21 +
  22 + <FrameLayout
  23 + android:layout_width="match_parent"
  24 + android:layout_height="match_parent"
  25 + android:layout_below="@id/frag_first_start_img"
  26 + android:layout_marginBottom="@dimen/rmrb_dp140">
  27 +
  28 + <ImageView
  29 + android:id="@+id/iv_act_first_content"
  30 + android:layout_width="wrap_content"
  31 + android:layout_height="wrap_content"
  32 + android:layout_gravity="center"
  33 + android:src="@mipmap/bg_guide_img_5_text"
  34 + android:visibility="visible" />
  35 +
  36 + </FrameLayout>
  37 +
  38 + <FrameLayout
  39 + android:id="@+id/first_go_main_group"
  40 + android:layout_width="match_parent"
  41 + android:layout_height="wrap_content"
  42 + android:layout_alignParentBottom="true">
  43 +
  44 + <TextView
  45 + android:id="@+id/img_act_first_go_main"
  46 + android:layout_width="wrap_content"
  47 + android:layout_height="@dimen/rmrb_dp44"
  48 + android:layout_gravity="center_horizontal"
  49 + android:layout_marginBottom="@dimen/rmrb_dp93"
  50 + android:background="@mipmap/bg_first_go_main_select"
  51 + android:gravity="center"
  52 + android:text="开启7.0全新体验"
  53 + android:textColor="@color/res_color_C1"
  54 + android:textSize="@dimen/rmrb_dp14" />
  55 +
  56 + </FrameLayout>
  57 +
  58 + <ImageView
  59 + android:id="@+id/frag_first_start_img"
  60 + android:layout_width="match_parent"
  61 + android:layout_height="wrap_content"
  62 + android:layout_marginTop="@dimen/rmrb_dp30"
  63 + android:scaleType="fitCenter"
  64 + android:src="@mipmap/bg_guide_img_5" />
  65 + </RelativeLayout>
  66 +
  67 +</RelativeLayout>
  68 +
  69 +
  70 +
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:app="http://schemas.android.com/apk/res-auto"
  4 + android:layout_width="match_parent"
  5 + android:layout_height="match_parent">
  6 + <!-- 动态开始 -->
  7 + <!-- <ImageView-->
  8 + <!-- android:id="@+id/ivMessage"-->
  9 + <!-- android:layout_width="@dimen/rmrb_dp168"-->
  10 + <!-- android:layout_height="@dimen/btmlogo_dimen"-->
  11 + <!-- android:scaleType="center"-->
  12 + <!-- android:src="@drawable/startbg_3"-->
  13 + <!-- android:layout_gravity="center_horizontal|bottom"-->
  14 + <!-- app:layout_constraintStart_toStartOf="parent"-->
  15 + <!-- app:layout_constraintEnd_toEndOf="parent"-->
  16 + <!-- app:layout_constraintBottom_toBottomOf="parent"-->
  17 + <!-- />-->
  18 +
  19 +
  20 +
  21 + <ImageView
  22 + android:id="@+id/ivstatic"
  23 + android:layout_width="@dimen/rmrb_dp168"
  24 + android:layout_height="@dimen/btmlogo_dimen"
  25 + android:scaleType="center"
  26 + android:src="@drawable/icon_splash_tra_bottom_logo"
  27 + android:layout_gravity="center_horizontal|bottom"
  28 + app:layout_constraintStart_toStartOf="parent"
  29 + app:layout_constraintEnd_toEndOf="parent"
  30 + app:layout_constraintBottom_toBottomOf="parent"
  31 + />
  32 +
  33 +</androidx.constraintlayout.widget.ConstraintLayout>
  34 +
  35 +
  36 +
1 package com.wd.foundation.wdkit.animator 1 package com.wd.foundation.wdkit.animator
2 2
  3 +import android.animation.Animator
  4 +import android.animation.ObjectAnimator
3 import android.app.Dialog 5 import android.app.Dialog
4 import android.os.Handler 6 import android.os.Handler
5 import android.view.View 7 import android.view.View
6 import android.view.animation.Animation 8 import android.view.animation.Animation
7 import android.view.animation.LinearInterpolator 9 import android.view.animation.LinearInterpolator
8 import android.view.animation.RotateAnimation 10 import android.view.animation.RotateAnimation
  11 +import com.wd.kittools.density.DensityUtils
9 12
10 /** 13 /**
11 * AnimatorUtil 14 * AnimatorUtil
@@ -17,36 +20,36 @@ import android.view.animation.RotateAnimation @@ -17,36 +20,36 @@ import android.view.animation.RotateAnimation
17 object AnimatorUtil { 20 object AnimatorUtil {
18 21
19 fun startVerticalUp(view: View?) { 22 fun startVerticalUp(view: View?) {
20 -// view?.apply {  
21 -// val h = DensityUtils.getViewSize(this)[1].toFloat()  
22 -// val objectAnimator = ObjectAnimator.ofFloat(this, "y", h, 0f)  
23 -// objectAnimator.duration = 300  
24 -// objectAnimator.start()  
25 -// } 23 + view?.apply {
  24 + val h = DensityUtils.getViewSize(this)[1].toFloat()
  25 + val objectAnimator = ObjectAnimator.ofFloat(this, "y", h, 0f)
  26 + objectAnimator.duration = 300
  27 + objectAnimator.start()
  28 + }
26 } 29 }
27 30
28 fun startVerticalDown(view: View?, dialog: Dialog?) { 31 fun startVerticalDown(view: View?, dialog: Dialog?) {
29 -// view?.apply {  
30 -// val h = DensityUtils.getViewSize(this)[1].toFloat()  
31 -// val objectAnimator = ObjectAnimator.ofFloat(this, "y", 0f, h)  
32 -// objectAnimator.duration = 300  
33 -// objectAnimator.start()  
34 -// objectAnimator.addListener(object : Animator.AnimatorListener {  
35 -// override fun onAnimationStart(animation: Animator?) {  
36 -// }  
37 -//  
38 -// override fun onAnimationEnd(animation: Animator?) {  
39 -// dialog?.dismiss()  
40 -// }  
41 -//  
42 -// override fun onAnimationCancel(animation: Animator?) {  
43 -// }  
44 -//  
45 -// override fun onAnimationRepeat(animation: Animator?) {  
46 -// }  
47 -//  
48 -// })  
49 -// } 32 + view?.apply {
  33 + val h = DensityUtils.getViewSize(this)[1].toFloat()
  34 + val objectAnimator = ObjectAnimator.ofFloat(this, "y", 0f, h)
  35 + objectAnimator.duration = 300
  36 + objectAnimator.start()
  37 + objectAnimator.addListener(object : Animator.AnimatorListener {
  38 + override fun onAnimationStart(animation: Animator?) {
  39 + }
  40 +
  41 + override fun onAnimationEnd(animation: Animator?) {
  42 + dialog?.dismiss()
  43 + }
  44 +
  45 + override fun onAnimationCancel(animation: Animator?) {
  46 + }
  47 +
  48 + override fun onAnimationRepeat(animation: Animator?) {
  49 + }
  50 +
  51 + })
  52 + }
50 } 53 }
51 54
52 fun spinView(view: View?) { 55 fun spinView(view: View?) {
  1 +/*
  2 + * Copyright (c) Wondertek Technologies Co., Ltd. 2019-2022. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.foundation.wdkit.network;
  6 +
  7 +import android.content.Context;
  8 +import android.text.TextUtils;
  9 +
  10 +import androidx.annotation.NonNull;
  11 +
  12 +import java.io.File;
  13 +import java.io.FileOutputStream;
  14 +import java.io.IOException;
  15 +import java.io.InputStream;
  16 +
  17 +import okhttp3.Call;
  18 +import okhttp3.Callback;
  19 +import okhttp3.OkHttpClient;
  20 +import okhttp3.Request;
  21 +import okhttp3.Response;
  22 +
  23 +/**
  24 + * 描述:简单下载工具
  25 + *
  26 + * @author : lvjinhui
  27 + * @since: 2022/6/7
  28 + */
  29 +public class DownloadUtil {
  30 + private static final String TAG = DownloadUtil.class.getName();
  31 +
  32 + private static final String DOWNLOAD = "Download";
  33 +
  34 + private static DownloadUtil downloadUtil;
  35 +
  36 + private final OkHttpClient okHttpClient;
  37 +
  38 + private DownloadUtil() {
  39 + okHttpClient = new OkHttpClient();
  40 + }
  41 +
  42 + /**
  43 + * 获取实例
  44 + *
  45 + * @return 获取实例
  46 + */
  47 + public static DownloadUtil get() {
  48 + if (downloadUtil == null) {
  49 + downloadUtil = new DownloadUtil();
  50 + }
  51 + return downloadUtil;
  52 + }
  53 +
  54 + /**
  55 + * 下载
  56 + *
  57 + * @param url 下载连接
  58 + * @param listener 下载监听
  59 + */
  60 + public void download(Context context, final String url, final IDownloadListener listener) {
  61 + Request request = new Request.Builder().url(url).build();
  62 + okHttpClient.newCall(request).enqueue(new Callback() {
  63 + @Override
  64 + public void onFailure(Call call, IOException e) {
  65 + // 下载失败
  66 + listener.onFailure();
  67 + }
  68 +
  69 + @Override
  70 + public void onResponse(Call call, Response response) throws IOException {
  71 + //404等错误导致,视频下载失败,却保存了文件,导致视频播放不了
  72 + if(!response.isSuccessful()){
  73 + //isSuccessful为true,code200才行
  74 + listener.onFailure();
  75 + return;
  76 + }
  77 + InputStream is = null;
  78 + byte[] buf = new byte[2048];
  79 + int len = 0;
  80 + FileOutputStream fos = null;
  81 + try {
  82 + is = response.body().byteStream();
  83 + long total = response.body().contentLength();
  84 + String fileName = getDownloadCachePath(context,getNameFromUrl(url));
  85 + String tempFileName = "";
  86 + if(fileName.contains(".")){
  87 + tempFileName = fileName.substring(0,fileName.lastIndexOf("."))+".temp";
  88 + }
  89 + File file = new File(TextUtils.isEmpty(tempFileName)?fileName:tempFileName);
  90 + fos = new FileOutputStream(file);
  91 + long sum = 0;
  92 + while ((len = is.read(buf)) != -1) {
  93 + fos.write(buf, 0, len);
  94 + sum += len;
  95 + int progress = (int) (sum * 1.0f / total * 100);
  96 + // 下载中
  97 + listener.onProgress(progress);
  98 + }
  99 + fos.flush();
  100 + // 下载完成
  101 + listener.onDone();
  102 + if(!TextUtils.isEmpty(tempFileName)){
  103 + file.renameTo(new File(fileName));
  104 + }
  105 + } catch (Exception e) {
  106 + listener.onFailure();
  107 + } finally {
  108 + try {
  109 + if (is != null) {
  110 + is.close();
  111 + }
  112 + } catch (IOException e) {
  113 + }
  114 + try {
  115 + if (fos != null) {
  116 + fos.close();
  117 + }
  118 + } catch (IOException e) {
  119 + }
  120 + }
  121 + }
  122 + });
  123 + }
  124 +
  125 + /**
  126 + * 从下载连接中解析出文件名
  127 + *
  128 + * @param url
  129 + * @return getNameFromUrl
  130 + */
  131 + @NonNull
  132 + public static String getNameFromUrl(String url) {
  133 + return url.substring(url.lastIndexOf("/") + 1);
  134 + }
  135 +
  136 + /**
  137 + * 下载到外置缓存目录
  138 + */
  139 + public static String getDownloadCachePath(Context context, String fileName) {
  140 + return new File(context.getApplicationContext().getExternalCacheDir(), fileName).getAbsolutePath();
  141 + }
  142 +}
  1 +/*
  2 + * Copyright (c) Wondertek Technologies Co., Ltd. 2019-2022. All rights reserved.
  3 + */
  4 +
  5 +package com.wd.foundation.wdkit.network;
  6 +
  7 +/**
  8 + * 描述:下载监听
  9 + *
  10 + * @author : lvjinhui
  11 + * @since: 2022/6/7
  12 + */
  13 +public interface IDownloadListener {
  14 + /**
  15 + * 开始
  16 + */
  17 + void onStart();
  18 +
  19 + /**
  20 + * 下载进度
  21 + *
  22 + * @param progress
  23 + */
  24 + void onProgress(int progress);
  25 +
  26 + /**
  27 + * 下载失败
  28 + */
  29 + void onFailure();
  30 +
  31 + /**
  32 + * 下载完成
  33 + */
  34 + void onDone();
  35 +}
@@ -225,6 +225,21 @@ public class ScreenUtils { @@ -225,6 +225,21 @@ public class ScreenUtils {
225 } 225 }
226 226
227 /** 227 /**
  228 + * 屏幕宽高比
  229 + * */
  230 + public static int[] getScreenWH() {
  231 + WindowManager wm = (WindowManager) AppContext.getContext().getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
  232 + Point point = new Point();
  233 + wm.getDefaultDisplay().getRealSize(point);
  234 + int w = point.x;
  235 + int h = point.y;
  236 + if(w == 0 || h == 0){
  237 + return null;
  238 + }
  239 + return new int[]{w,h};
  240 + }
  241 +
  242 + /**
228 * Return the density of screen. 243 * Return the density of screen.
229 * 244 *
230 * @return the density of screen 245 * @return the density of screen