wangkai

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

2、添加启动页、隐私权限
Showing 54 changed files with 3510 additions and 385 deletions
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="" vcs="Git" />
</component>
</project>
\ No newline at end of file
... ...
... ... @@ -4,6 +4,25 @@
package="com.wd.fastcoding.app">
<!-- 请求网络 -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.WAKE_LOCK" /> <!-- 相机权限,先预留,不用后面再删除 -->
<uses-permission android:name="android.permission.CAMERA" /> <!-- 语音播报申请允许悬浮窗口权限 -->
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
<uses-permission android:name="android.hardware.camera" />
<uses-permission
android:name="android.permission.WRITE_SETTINGS"
tools:ignore="ProtectedPermissions" />
<uses-feature
android:name="android.software.leanback"
android:required="false" />
... ... @@ -13,6 +32,9 @@
android:fullBackupContent="@xml/backup_rules"
android:icon="@mipmap/ic_fastcode"
android:label="@string/app_name"
android:networkSecurityConfig="@xml/network_security_config"
android:requestLegacyExternalStorage="true"
android:resizeableActivity="true"
android:roundIcon="@mipmap/ic_fastcode"
android:supportsRtl="true"
android:theme="@style/AppTheme"
... ... @@ -20,6 +42,14 @@
tools:ignore="Instantiatable"
tools:replace="android:allowBackup,android:name">
<!-- 阿里视频点播 licensekey -->
<meta-data
android:name="com.aliyun.alivc_license.licensekey"
android:value="jobw8PGmd0TLigqgt7d85ea944cb34eb9a102d33b27054f83" />
<meta-data
android:name="com.aliyun.alivc_license.licensefile"
android:value="assets/cert/AliVideoCert-com_wondertek_easycode-20241030182958.crt" />
<activity
android:name=".MainActivity"
android:exported="true"
... ...
-----BEGIN ALI VIDEO CERT-----
LmlsQS5jaUwAAWRjY2FhYTU1OTAxNzE0NDg2OWJlOGJkNzczZTc5ZjAzM2YwMDhiO
WY5ODUwNTc5MGY4NDEyOTRiMzNjMmZiYjg1NGUxZThlNjAwNzRmNTgxZTU0MDY2Mj
RiMGFiM2JkNWVmOTE3ZDE0MDJlNDQ0ZDUwNmExMTc5ZjFlYjYyODQ2MDRiYzdiYjA
zOTI2ZjYyOTE1OWVjYjY0ZDk1ZDhhN2Q5ZWZlOTRjOTdkMTA0Yzc1MWU5OGEwNGY3
OTdkOTdiYTAzMWEyMDFlMzc2Mjg0NGI1MTEyYWRkZDQzNTgyZDA2NTJkYTk0MDk1Y
TIxYjY2NWJmYjY0ZTkwMWQyZGNjNmVjMjY1ODFkYmJjZjBhY2ZmZjFhNDU3NTJjND
QwNTMzZmJlZDk3YTIzMmMyOWQ4YWVkZDY0YmZhZDc2ZDY1MTRiZGU5MmM3YTdjMGZ
iYjI3OTNhNjZiMDEzMjBkODgxYzBhMjA1YTExN2Q1YmU3ZTgyMzYyYzI5MDJhZDNk
MmFiZTcxNTQ5NzI2YzI4NTVjOTc5MWVmZDVjMGU4NDZmMDZlZDhlYTY1MjgzYWUzM
2JkOTYzOWJiZTkwOGU4ZTBmY2QwNDc1OWQ5N2U3OTk1NDNhMzdkNDQ2YzZlMDJhMj
BkODI2YTUzZGIzNTNjNWU3MDVjYmJmYzg5ODVjYjRkMWIxAAAB3FfzXgBqw5VTCVw
eYPPkcH3JGkDkehJSOhHqc479cL5JVilJqzzBFRpmhldfdptLaQTUDdVFHpt6qaS7
ebSKGd5uePCe8mNXWScMFewWwHt9hukxJMSKZNkJY9H6gc9xXBVQg2KCSNHlgrCiZ
LhnIwJD82BCDnaLqcAol9QotsxGCstzmuG70bn46xO/oUIRwK09o01r+mZP21qEbD
T4RbdFTjh7yOEx7R3D/yoEbGecBeROXDqCN2t0EQ3/brAPITFCodB8GoUM7UUnRK6
Y8flZKv8aOaH1o7m27HBzpMTyStpBTXlz0oWwVyL78kcBt3SfsuXUKcxMT3R+qmI4
XxL7D6lHAAABaqc4asomDCjl6suryaMGfbsn+buiuzM4LcHFYjyY0WI76VUS4+73G
YcE5lDn3xUfUmLGa+7kc+h6+LZYMTZ6EUH+b1ZIr6foJRzTyxJmTMPJMaJ8sAMmA3
4vGzNlvFV3PD2q2QogiZdAjCggzsaYfZmSCHL6WEAYXmMZGjjN+hIKAKn5FvMtxmn
5xOkypQ3Kf9o15sZ82JKfmuMvLkT9pmMfBdPiamlnWvhSM+1d/0pNTdtGH57Gb7gw
BhrP+vNBDE25JTRnHQ3xbSZRammY1HIg2ZcjSfH/WIXieKYLqbkfxjc+6O6NuPmr7
+k9Dn57iB5qL71gqwDJ3Ai8LmZbQZEAAAGS3PmYMQAAAL4AAAAgZ2Q1NzAzZThhYz
ViNGFmNmIzZjNjMWE5ODQ2OTkxZjgAAAAEAAAAIgAAAAAAAAACAAAAFmNvbS53b25
kZXJ0ZWsuZWFzeWNvZGUAAAAiAAAAAAAAAAEAAAAWY29tLndvbmRlcnRlay5lYXN5
Y29kZQAAACIAAAAAAAAAQAAAABZjb20ud29uZGVydGVrLmVhc3ljb2RlAAAAIAAAA
AAAAAAQAAAAFHd3dy53b25kZXJ0ZWsuY29tLmNuAAAABAAAACUAAAACAAAAAAAAAA
IAACPxAAABmjZiMKAAAAAACAAAAAEAAAAAAAAAJQAAAAIAAAAAAAAAAQAAI/EAAAG
aNmIwoAAAAAAIAAAAAQAAAAAAAAAlAAAAAgAAAAAAAAAQAAAj8QAAAZo2YjCgAAAA
AAgAAAABAAAAAAAAACUAAAACAAAAAAAAAEAAACPxAAABmjZiMKAAAAAACAAAAAEAA
AAA
-----END ALI VIDEO CERT-----
\ No newline at end of file
... ...
rmrb_china_0000
\ No newline at end of file
... ...
package com.wd.fastcoding.app;
import androidx.appcompat.app.AppCompatDelegate;
import com.hjq.toast.Toaster;
import com.wd.capability.network.RetrofitClient;
import com.wd.capability.router.ArouteInit;
import com.wd.capability.router.WdRouterRule;
import com.wd.foundation.wdkit.base.BaseApplication;
import com.wd.fastcoding.app.start.StartTaskConfig;
import com.wd.foundation.wdkit.constant.Constants;
import com.wd.foundation.wdkit.utils.CommonUtil;
import com.wd.foundation.wdkit.utils.SpUtils;
import com.wd.foundation.wdkitcore.tools.AppContext;
import com.wd.foundation.wdkitcore.tools.StringUtils;
... ... @@ -22,6 +27,26 @@ public class MyApplication extends BaseApplication {
// 第三方库初始化
if (isCurProcess()) {
initLibs();
//是否是撤销隐私协议
Constants.isRevokePrivacy = SpUtils.isRevokePrivacyFlag();
if (!(Constants.isFirst = SpUtils.isFirstAgreementFlag())) {
// WelcomeUtils.initializeNowAfterAgree(this);
// //利用alpha初始化
// ((IStartTaskProvider) WdRouterRule.getInstance().getProvider(IStartTaskProvider.class)).startTaskInApplication(this);
}
//设置夜间模式
String nightMode = SpUtils.getNightMode();
if (SpUtils.NIGHT_MODE.equals(nightMode)) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
Constants.isNightMode = true;
} else if (SpUtils.LIGHT_MODE.equals(nightMode)) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
Constants.isNightMode = false;
} else if (SpUtils.FOLLOWUP_SYSTEM.equals(nightMode)) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
Constants.isNightMode = SpUtils.isNightMode();
}
// 主进程,只执行一次
// 启动初始化管理,子线程管理
StartTaskConfig taskConfig = new StartTaskConfig(this);
... ...
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true">
<trust-anchors>
<certificates src="user" />
<certificates src="system" />
</trust-anchors>
</base-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">enrichgw.10010.com</domain> <!-- 联通内部5G请求域名,开发者需要添加 -->
<domain includeSubdomains="true">onekey.cmpassport.com</domain> <!-- 移动内部请求域名,开发者需要添加 -->
</domain-config>
</network-security-config>
\ No newline at end of file
... ...
... ... @@ -85,24 +85,24 @@ public class ChannelDataFetcherNews extends BaseDataFetcher<RequestApi> {
//有缓存
// Logger.e("newsTabMd5 ==dataType="+dataType+",isNewsChannel=="+isNewsChannel);
// Logger.e("newsTabMd5 ==BaseConstants.newsTabMd5="+BaseConstants.newsTabMd5);
if (2 == dataType){
if (2 == dataType) {
//新闻tab
if (isNewsChannel){
// String newsTabGroupMd5 = SpUtils.getBottomNavGroupDetailMd5();
// //有数据,保存的md5不为空,并且和接口给的md5一致,不用再调接口
// if (StringUtils.isBlank(BaseConstants.newsTabMd5)){
//// Logger.e("newsTabMd5空的==不会调用");
// return;
// }
//// Logger.e("newsTabMd5 调用== firstLocation="+firstLocation);
//// Logger.e("newsTabMd5 ==newsTabGroupMd5=="+newsTabGroupMd5);
// if (1 != firstLocation && StringUtils.isNotBlank(newsTabGroupMd5)
// && newsTabGroupMd5.equals(BaseConstants.newsTabMd5)) {
//// Logger.e("newsTabMd5不变==不会调用");
// return;
// }
// SpUtils.saveBottomNavGroupDetailMd5(BaseConstants.newsTabMd5);
}else {
if (isNewsChannel) {
String newsTabGroupMd5 = SpUtils.getBottomNavGroupDetailMd5();
//有数据,保存的md5不为空,并且和接口给的md5一致,不用再调接口
if (StringUtils.isBlank(BaseConstants.newsTabMd5)) {
// Logger.e("newsTabMd5空的==不会调用");
return;
}
// Logger.e("newsTabMd5 调用== firstLocation="+firstLocation);
// Logger.e("newsTabMd5 ==newsTabGroupMd5=="+newsTabGroupMd5);
if (1 != firstLocation && StringUtils.isNotBlank(newsTabGroupMd5)
&& newsTabGroupMd5.equals(BaseConstants.newsTabMd5)) {
// Logger.e("newsTabMd5不变==不会调用");
return;
}
SpUtils.saveBottomNavGroupDetailMd5(BaseConstants.newsTabMd5);
} else {
//如果不是新闻tab并且有缓存数据,不再进行接口请求
return;
}
... ...
plugins {
id 'com.android.library'
id 'kotlin-android'
}
android {
... ...
... ... @@ -200,22 +200,6 @@ public abstract class BaseActivity extends BaseMvvmActivity implements CustomTit
flowTooBigDialog.setIsflowtoobig(false);
}
});
// /**
// * 全局监听
// * 1.夜间模式切换
// */
// LiveDataBus.getInstance().with(EventConstants.EVENT_GLOBALLISTENING, Integer.class).observe(this, eventType -> {
// forLiveDataBus = 1;
// switch (eventType) {
// case 1:
// //夜间模式切换,需要重新创建页面
// recreate();
// break;
// default:
// break;
// }
// });
}
... ...
/*
* Copyright (c) People Technologies Co., Ltd. 2019-2022. All rights reserved.
*/
package com.wd.common.content;
import com.wd.common.content.model.api.service.IContentService;
import com.wd.common.content.model.impl.service.ContentServiceImpl;
import com.wd.foundation.wdkitcore.scheduler.BaseComponent;
/**
* 内容获取逻辑组件<BR>
*
* @author zhangbo
* @version [V1.0.0, 2022/5/20]
* @since V1.0.0
*/
public class ContentComponent extends BaseComponent {
@Override
public void registerServices() {
registerService(IContentService.class, ContentServiceImpl.class);
}
}
... ...
/*
* Copyright (c) People Technologies Co., Ltd. 2019-2022. All rights reserved.
*/
package com.wd.common.content.model.api;
import android.content.Context;
import com.wd.foundation.wdkit.mvvm.model.IBaseModel;
import com.wd.foundation.wdkit.mvvm.model.IBaseTask;
import com.wd.foundation.wdkit.network.IDownloadListener;
/**
* 内容获取相关接口<BR>
*
* @author zhangbo
* @version [V1.0.0, 2022/5/20]
* @since V1.0.0
*/
public interface IContentModel extends IBaseModel {
/**
* 下载启动广告视频
*
* @param downloadUrl
* @param callBack
* @return 任务实例
*/
IBaseTask downloadAdData(Context context, String downloadUrl, IDownloadListener callBack);
}
... ...
/*
* Copyright (c) People Technologies Co., Ltd. 2019-2022. All rights reserved.
*/
package com.wd.common.content.model.api.service;
import com.wd.common.content.model.api.IContentModel;
import com.wd.foundation.wdkitcore.scheduler.IService;
/**
* 内容获取服务接口<BR>
*
* @author zhangbo
* @version [V1.0.0, 2020/9/29]
* @since V1.0.0
*/
public interface IContentService extends IService {
/**
* 获取内容的model实例
*
* @return IContentModel实例
*/
IContentModel getContentModel();
}
... ...
/*
* Copyright (c) People Technologies Co., Ltd. 2019-2022. All rights reserved.
*/
package com.wd.common.content.model.impl;
import android.content.Context;
import com.wd.common.content.model.api.IContentModel;
import com.wd.foundation.wdkit.mvvm.model.IBaseTask;
import com.wd.foundation.wdkit.network.DownloadUtil;
import com.wd.foundation.wdkit.network.IDownloadListener;
/**
* 内容获取实现类<BR>
*
* @author zhangbo
* @version [V1.0.0, 2022/5/20]
* @since V1.0.0
*/
public class ContentModelImpl implements IContentModel {
private static final String TAG = "ContentModelImpl";
@Override
public IBaseTask downloadAdData(Context context, String downloadUrl, IDownloadListener callBack) {
DownloadUtil.get().download(context, downloadUrl, callBack);
//SplashAdDownloadTask task = new SplashAdDownloadTask(downloadUrl, callBack);
//task.startAsync();
return null;
}
}
... ...
/*
* Copyright (c) People Technologies Co., Ltd. 2019-2022. All rights reserved.
*/
package com.wd.common.content.model.impl.service;
import com.wd.common.content.model.api.IContentModel;
import com.wd.common.content.model.api.service.IContentService;
import com.wd.common.content.model.impl.ContentModelImpl;
/**
* 内容获取服务的实现类<BR>
*
* @author zhangbo
* @version [V1.0.0, 2020/9/29]
* @since V1.0.0
*/
public class ContentServiceImpl implements IContentService {
@Override
public IContentModel getContentModel() {
return new ContentModelImpl();
}
}
... ...
... ... @@ -43,6 +43,7 @@ dependencies {
implementation project(path: ':wdlayout')
implementation project(path: ':lib_base')
implementation project(path: ':base_comment')
implementation project(path: ':base_location')
api project(path: ':wdrouter')
api project(path: ':wdinterface')
annotationProcessor 'com.alibaba:arouter-compiler:1.5.2'
... ...
... ... @@ -21,11 +21,13 @@ import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatDelegate;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import androidx.fragment.app.Fragment;
... ... @@ -38,15 +40,22 @@ import com.alibaba.android.arouter.facade.annotation.Route;
import com.google.android.material.tabs.TabLayout;
import com.wd.base.log.Logger;
import com.wd.capability.layout.comp.layoutmanager.view.WTabLayout;
import com.wd.capability.layout.constant.LaunchPageConstant;
import com.wd.capability.layout.fragment.MainFragment;
import com.wd.capability.layout.fragment.NewsHomeFragment;
import com.wd.capability.network.constant.NetConstant;
import com.wd.capability.router.WdRouterRule;
import com.wd.common.base.BaseActivity;
//import com.wd.common.base.BaseDialog;
import com.wd.common.base.BaseDialog;
import com.wd.common.incentive.constants.TaskOperateTypeConstants;
import com.wd.common.incentive.task.TaskManager;
import com.wd.foundation.bean.launch.AppAgreementBean;
import com.wd.foundation.bean.launch.LaunchPageBean;
import com.wd.foundation.wdkit.constant.Constants;
import com.wd.foundation.wdkit.constant.EventConstants;
import com.wd.common.constant.RouterConstants;
import com.wd.common.net.NetStateChangeReceiver;
import com.wd.foundation.wdkit.system.DeviceUtil;
import com.wd.foundation.wdkit.utils.GrayManager;
import com.wd.common.utils.ProcessUtils;
import com.wd.foundation.wdkit.constant.ProtocolConstant;
... ... @@ -63,13 +72,19 @@ import com.wd.foundation.wdkit.utils.FilletUtil;
import com.wd.foundation.wdkit.utils.SpUtils;
import com.wd.foundation.wdkit.utils.ViewUtils;
import com.wd.foundation.wdkitcore.livedata.LiveDataBus;
import com.wd.foundation.wdkitcore.thread.ThreadPoolUtils;
import com.wd.foundation.wdkitcore.tools.ArrayUtils;
import com.wd.foundation.wdkitcore.tools.ResUtils;
import com.wd.foundation.wdkitcore.tools.StringUtils;
import com.wd.module_home.adapter.MainFragmentAdapter;
import com.wd.module_home.util.GuideHelper;
import com.wd.module_home.util.SplashHelper;
import com.wd.module_home.util.WelcomeUtils;
import com.wd.module_home.vm.AgreementViewModel;
import com.wd.module_home.vm.IAgreementListener;
import com.wd.module_home.vm.IMainDataListener;
import com.wd.module_home.vm.MainViewModel;
import com.wd.module_home.vm.SplashViewModel;
import org.libpag.PAGView;
... ... @@ -135,12 +150,12 @@ public class AppMainActivity extends BaseActivity {
/**
* 引导页工具类
*/
// private GuideHelper guideHelper;
private GuideHelper guideHelper;
/**
* 闪屏页工具类
*/
// private SplashHelper splashHelper;
private SplashHelper splashHelper;
/**
* 首次安装同意隐私政策
... ... @@ -209,7 +224,7 @@ public class AppMainActivity extends BaseActivity {
/**
* 隐私弹框
*/
// private BaseDialog agreepomentDialog;
private BaseDialog agreepomentDialog;
/**
* 夜间模式
... ... @@ -309,25 +324,23 @@ public class AppMainActivity extends BaseActivity {
setUnMvvm(true);
super.onCreate(savedInstanceState);
Constants.restart = false;
// ((IStartTaskProvider) WdRouterRule.getInstance().getProvider(IStartTaskProvider.class)).startPrivate(AppMainActivity.this);
// CacheDataManager.isClearAllCache = false;
// nightMode = SpUtils.getNightMode();
// if (!restart) {
nightMode = SpUtils.getNightMode();
if (!restart) {
// if (!SpUtils.isFirstAgreementFlag()) {
// //同意了隐私政策 通知mpaas
// QuinoxlessPrivacyUtil.sendPrivacyAgreedBroadcast(this);
// }
// //设置夜间模式
// if (SpUtils.NIGHT_MODE.equals(nightMode)) {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
// } else if (SpUtils.LIGHT_MODE.equals(nightMode)) {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
// } else if (SpUtils.FOLLOWUP_SYSTEM.equals(nightMode)) {
// AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
// }
// SpUtils.saveNoUseWifiForVideo(true);
// }
//设置夜间模式
if (SpUtils.NIGHT_MODE.equals(nightMode)) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_YES);
} else if (SpUtils.LIGHT_MODE.equals(nightMode)) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_NO);
} else if (SpUtils.FOLLOWUP_SYSTEM.equals(nightMode)) {
AppCompatDelegate.setDefaultNightMode(AppCompatDelegate.MODE_NIGHT_FOLLOW_SYSTEM);
}
SpUtils.saveNoUseWifiForVideo(true);
}
//根布局
rootView = new ConstraintLayout(this);
... ... @@ -362,28 +375,28 @@ public class AppMainActivity extends BaseActivity {
bottomLine.setVisibility(View.INVISIBLE);
bottomLine.setLayoutParams(params);
rootView.addView(bottomLine);
// //引导/开屏布局
// params = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
// flsplashContainer = new FrameLayout(this);
// flsplashContainer.setLayoutParams(params);
// rootView.addView(flsplashContainer);
// //底部logo
// params = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) getResources().getDimension(R.dimen.btmlogo_dimen));
// params.bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID;
// welcomeIvLogo = new ImageView(this);
// welcomeIvLogo.setLayoutParams(params);
// welcomeIvLogo.setBackgroundColor(0xffffffff);
// welcomeIvLogo.setScaleType(ImageView.ScaleType.CENTER);
// welcomeIvLogo.setImageResource(R.drawable.icon_splash_tra_bottom_logo);
// rootView.addView(welcomeIvLogo);
//引导/开屏布局
params = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
flsplashContainer = new FrameLayout(this);
flsplashContainer.setLayoutParams(params);
rootView.addView(flsplashContainer);
//底部logo
params = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) getResources().getDimension(R.dimen.btmlogo_dimen));
params.bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID;
welcomeIvLogo = new ImageView(this);
welcomeIvLogo.setLayoutParams(params);
welcomeIvLogo.setBackgroundColor(0xffffffff);
welcomeIvLogo.setScaleType(ImageView.ScaleType.CENTER);
welcomeIvLogo.setImageResource(R.drawable.icon_splash_tra_bottom_logo);
rootView.addView(welcomeIvLogo);
setContentView(rootView);
// 最多5个底部导航按钮
mainViewPager.setOffscreenPageLimit(5);
mainViewPager.setUserInputEnabled(false);
// mainBottomBar.setTabRippleColorResource(R.color.transparent);
initAppMainViewModel();
// splashHelper = new SplashHelper(AppMainActivity.this);
// splashHelper.viewModel = (new ViewModelProvider(AppMainActivity.this)).get(SplashViewModel.class);
splashHelper = new SplashHelper(AppMainActivity.this);
splashHelper.viewModel = (new ViewModelProvider(AppMainActivity.this)).get(SplashViewModel.class);
initWelcome();
// 初始化发布视频进度浮窗
// PublishFloatViewManager.getInstance().addWhiteList(AppMainActivity.class);
... ... @@ -418,38 +431,29 @@ public class AppMainActivity extends BaseActivity {
*/
private void initWelcome() {
//更新主题后自动重启
// if (restart) {
if (restart) {
finishPage();
if(mourningModelBean != null){
getMourningModeSuccess(mourningModelBean);
}
setAppMainData();
// } else {
// //首次安装或者覆盖安装播放启动页动画
// if (SpUtils.isFirstAgreementFlag()) {
//// if(!SpUtils.isRevokePrivacyFlag()){
//// //不是撤销协议,才是真的首次
//// //更新数据
//// DeviceUtil.saveCurrentVersion(this);
////// if (GuideHelper.HASGUIDE) {
////// guideHelper = new GuideHelper(AppMainActivity.this);
////// guideHelper.init(true);
////// }
//// }
// startTaskInMain(true);
// }
//// else if (!DeviceUtil.isSameVersion()) {
//// //升级还需要弹这个一张引导页吗?
//// if (GuideHelper.HASGUIDE) {
//// guideHelper = new GuideHelper(AppMainActivity.this);
//// guideHelper.init(false);
//// }
//// startTaskInMain(false);
//// }
// else {
// startTaskInMain(false);
// }
// }
} else {
//首次安装或者覆盖安装播放启动页动画
if (SpUtils.isFirstAgreementFlag()) {
if(!SpUtils.isRevokePrivacyFlag()){
//不是撤销协议,才是真的首次
//更新数据
DeviceUtil.saveCurrentVersion();
if (GuideHelper.HASGUIDE) {
guideHelper = new GuideHelper(AppMainActivity.this);
guideHelper.init(true);
}
}
startTaskInMain(true);
} else {
startTaskInMain(false);
}
}
}
... ... @@ -464,10 +468,10 @@ public class AppMainActivity extends BaseActivity {
if (first) {
popAgreepomentDialog(1, -1, -1);
} else {
// if (guideHelper == null || guideHelper.guideFragmentList == null || guideHelper.guideFragmentList.size() <= 1) {
// //正常启动
// onGuideEnd();
// }
if (guideHelper == null || guideHelper.guideFragmentList == null || guideHelper.guideFragmentList.size() <= 1) {
//正常启动
onGuideEnd();
}
// //非拉起、非第一次启动
// if (!ispull) {
// GeneralTrack.getInstance().appStart(null);
... ... @@ -538,21 +542,21 @@ public class AppMainActivity extends BaseActivity {
new float[]{0,0,0,0,
getResources().getDimension(R.dimen.rmrb_dp6),
getResources().getDimension(R.dimen.rmrb_dp6),0,0});
// agreepomentDialog = BaseDialog.Companion.getInstance()
// .isCancelable(false)
// .setLayoutView(view)
// .setWindow(0.73, 0.0)
// .setOnCancelClickListener(view.findViewById(R.id.tv_disagree), dialog -> {
// dialog.dismiss();
// System.exit(0);
// })
// .setOnSureClickListener(view.findViewById(R.id.tv_agree), dialog -> {
// dialog.dismiss();
agreepomentDialog = BaseDialog.Companion.getInstance()
.isCancelable(false)
.setLayoutView(view)
.setWindow(0.73, 0.0)
.setOnCancelClickListener(view.findViewById(R.id.tv_disagree), dialog -> {
dialog.dismiss();
System.exit(0);
})
.setOnSureClickListener(view.findViewById(R.id.tv_agree), dialog -> {
dialog.dismiss();
// QuinoxlessPrivacyUtil.sendPrivacyAgreedBroadcast(AppMainActivity.this);
// //隐私弹窗隐藏
// Constants.agreepomentDialogIsShow = "0";
// //首次
// if (1 == first || 3 == first) {
//隐私弹窗隐藏
Constants.agreepomentDialogIsShow = "0";
//首次
if (1 == first || 3 == first) {
// if (SpUtils.isFirstAgreementFlag()) {
// //由于同意隐私政策之后才能初始化,所以同意隐私政策后立即初始化。与application相互呼应
// WelcomeUtils.initializeNowAfterAgree(getApplicationContext());
... ... @@ -563,33 +567,33 @@ public class AppMainActivity extends BaseActivity {
// //首次安装 点击隐私弹窗同意执行过,不重复执行
// ((IStartTaskProvider) WdRouterRule.getInstance().getProvider(IStartTaskProvider.class)).startPrivate(AppMainActivity.this);
// }
//
// if(SpUtils.isRevokePrivacyFlag()){
// //撤销隐私
// onGuideEnd();
// }else if (GuideHelper.HASGUIDE) {
// guideHelper.showGuide(true);
// } else {
// toInterestTag();
// }
// SpUtils.editRevokePrivacyFlag(false);
// SpUtils.editFirstAgreementFlag();
// hashAgreement = true;
//
// //请求下协议
//// getUserAgreement();
// //首次启动非拉起
if(SpUtils.isRevokePrivacyFlag()){
//撤销隐私
onGuideEnd();
}else if (GuideHelper.HASGUIDE) {
guideHelper.showGuide(true);
} else {
toInterestTag();
}
SpUtils.editRevokePrivacyFlag(false);
SpUtils.editFirstAgreementFlag();
hashAgreement = true;
//请求下协议
// getUserAgreement();
//首次启动非拉起
// if (!Constants.isRevokePrivacy && Constants.isFirst && !ispull) {
// GeneralTrack.getInstance().appStart(null);
// }
// } else {
// //保存用户协议版本号
// SpUtils.saveUserAgreeVersion(serviceUserAgreeVersion + "");
// //保存隐私协议版本号
// SpUtils.savePrivateAgreeVersion(servicePrivateAgreeVersion + "");
// }
// })
// .showCenter();
} else {
//保存用户协议版本号
SpUtils.saveUserAgreeVersion(serviceUserAgreeVersion + "");
//保存隐私协议版本号
SpUtils.savePrivateAgreeVersion(servicePrivateAgreeVersion + "");
}
})
.showCenter();
}
public synchronized void toInterestTag() {
... ... @@ -597,8 +601,10 @@ public class AppMainActivity extends BaseActivity {
return;
}
isToInterestTag = true;
//跳转兴趣标签页
// //跳转兴趣标签页
// ProcessUtils.toInterestTagActivity(true);
//暂不做趣标签页,之间进首页
AppMainActivity.this.onGuideEnd();
}
private void setSpan(SpannableString spannableString, String descStr, int startIndex, String jumpPage) {
... ... @@ -631,33 +637,33 @@ public class AppMainActivity extends BaseActivity {
/**
* 作为更新使用
*/
// public void getUserAgreement(List<AppAgreementBean> bean) {
// if (isUserAgreement) {
// return;
// }
// isUserAgreement = true;
// AgreementViewModel agreementViewModel = (new ViewModelProvider(AppMainActivity.this)).get(AgreementViewModel.class);
// agreementViewModel.observeAgreementListener(this, new IAgreementListener() {
// @Override
// public void result(int need, int serviceUserAgreeVersion, int servicePrivateAgreeVersion) {
// if (Constants.isFirst) {
// if (need != -1) {
// //保存用户协议版本号
// SpUtils.saveUserAgreeVersion(serviceUserAgreeVersion + "");
// //保存隐私协议版本号
// SpUtils.savePrivateAgreeVersion(servicePrivateAgreeVersion + "");
// }
// return;
// }
//
// if (need == 1) {
// popAgreepomentDialog(2, serviceUserAgreeVersion, servicePrivateAgreeVersion);
// }
// }
// });
// //接口合并到统一
// agreementViewModel.getAppAgreementV2(bean);
// }
public void getUserAgreement(List<AppAgreementBean> bean) {
if (isUserAgreement) {
return;
}
isUserAgreement = true;
AgreementViewModel agreementViewModel = (new ViewModelProvider(AppMainActivity.this)).get(AgreementViewModel.class);
agreementViewModel.observeAgreementListener(this, new IAgreementListener() {
@Override
public void result(int need, int serviceUserAgreeVersion, int servicePrivateAgreeVersion) {
if (Constants.isFirst) {
if (need != -1) {
//保存用户协议版本号
SpUtils.saveUserAgreeVersion(serviceUserAgreeVersion + "");
//保存隐私协议版本号
SpUtils.savePrivateAgreeVersion(servicePrivateAgreeVersion + "");
}
return;
}
if (need == 1) {
popAgreepomentDialog(2, serviceUserAgreeVersion, servicePrivateAgreeVersion);
}
}
});
//接口合并到统一
agreementViewModel.getAppAgreementV2(bean);
}
/**
... ... @@ -794,27 +800,28 @@ public class AppMainActivity extends BaseActivity {
/**
* 启动接口成功
*/
// public void getLaunchPageFinish(LaunchPageBean launchPageBean){
// if(getLaunchPageFinish){
// return;
// }
// if(finishPageLoad){
// //执行任务:打开客户端
// TaskManager.getInstance().executePointLevelOperate(TaskOperateTypeConstants.OPEN_CLIENT);
// }
// getLaunchPageFinish = true;
// if (null == launchPageBean) {
// return;
// }
// //处理搜索词
// if(launchPageBean.getHits() != null){
// LaunchPageConstant.hintsBeans = launchPageBean.getHits().getHitList();
// }
// LiveDataBus.getInstance().with(EventConstants.LAUNCHPAGE_SUCCESS).postValue(true);
// }
public void getLaunchPageFinish(LaunchPageBean launchPageBean){
if(getLaunchPageFinish){
return;
}
if(finishPageLoad){
//执行任务:打开客户端
TaskManager.getInstance().executePointLevelOperate(TaskOperateTypeConstants.OPEN_CLIENT);
}
getLaunchPageFinish = true;
if (null == launchPageBean) {
return;
}
//处理搜索词
if(launchPageBean.getHits() != null){
LaunchPageConstant.hintsBeans = launchPageBean.getHits().getHitList();
}
LiveDataBus.getInstance().with(EventConstants.LAUNCHPAGE_SUCCESS).postValue(true);
}
/**
* 接口合并,处理国殇模式
*
* @param modelBean
*/
public void getMourningModeSuccess(MourningModelBean modelBean) {
... ... @@ -1234,10 +1241,10 @@ public class AppMainActivity extends BaseActivity {
/**
* 获取新闻tab频道
*/
public void getNewsTabBottomNavGroupDetail(){
if (null != mainFragmentAdapter){
public void getNewsTabBottomNavGroupDetail() {
if (null != mainFragmentAdapter) {
Fragment fragment = mainFragmentAdapter.getCurFragment(0);
if (null != fragment){
if (null != fragment) {
if (fragment instanceof NewsHomeFragment) {
NewsHomeFragment newsHomeFragment = (NewsHomeFragment) fragment;
newsHomeFragment.request();
... ... @@ -1339,8 +1346,8 @@ public class AppMainActivity extends BaseActivity {
// 先获取底部导航数据,再展示view
hasData = mViewModel.getBottomBarData();
requestBottomGroup();
getNewsTabBottomNavGroupDetail();
// requestBottomGroup();
// getNewsTabBottomNavGroupDetail();
}
}
... ... @@ -1348,8 +1355,8 @@ public class AppMainActivity extends BaseActivity {
/**
* 请求首页底部tab数据
*/
public void requestBottomGroup(){
if (mViewModel != null){
public void requestBottomGroup() {
if (mViewModel != null) {
mViewModel.loadBottomBarData(hasData);
}
}
... ... @@ -1553,21 +1560,21 @@ public class AppMainActivity extends BaseActivity {
*/
private void delayInitialization() {
//重启不需要多余操作
// ThreadPoolUtils.postToMainDelay(new Runnable() {
// @Override
// public void run() {
// WelcomeUtils.delayInit(AppMainActivity.this);
// //延后释放释放资源,防止黑屏
// splashHelper.releasePlayer();
// welcomeIvLogo.setImageResource(0);
// rootView.removeView(flsplashContainer);
// rootView.removeView(welcomeIvLogo);
// if (splashHelper.splashRlJumpAd != null) {
// rootView.removeView(splashHelper.splashRlJumpAd);
// }
// System.gc();
// }
// }, 200);
ThreadPoolUtils.postToMainDelay(new Runnable() {
@Override
public void run() {
WelcomeUtils.delayInit(AppMainActivity.this);
//延后释放释放资源,防止黑屏
splashHelper.releasePlayer();
welcomeIvLogo.setImageResource(0);
rootView.removeView(flsplashContainer);
rootView.removeView(welcomeIvLogo);
if (splashHelper.splashRlJumpAd != null) {
rootView.removeView(splashHelper.splashRlJumpAd);
}
System.gc();
}
}, 200);
}
/**
... ... @@ -1583,11 +1590,11 @@ public class AppMainActivity extends BaseActivity {
//是否跳推送
WelcomeUtils.toPushActivity();
// 是否跳桌面组件
// WelcomeUtils.toWidgetActivity();
// if(getLaunchPageFinish){
// //执行任务:打开客户端
// TaskManager.getInstance().executePointLevelOperate(TaskOperateTypeConstants.OPEN_CLIENT);
// }
WelcomeUtils.toWidgetActivity();
if(getLaunchPageFinish){
//执行任务:打开客户端
TaskManager.getInstance().executePointLevelOperate(TaskOperateTypeConstants.OPEN_CLIENT);
}
}
/**
... ... @@ -1595,19 +1602,19 @@ public class AppMainActivity extends BaseActivity {
*/
private void onWelcomeEnd() {
//主页背景适配夜间模式
// rootView.setBackgroundColor(ContextCompat.getColor(this, R.color.res_color_common_C8));
// flsplashContainer.setVisibility(View.GONE);
// if (guideHelper != null) {
// guideHelper.releaseResources();
// }
// splashHelper.releaseResources();
// ViewUtils.setVisible(splashHelper.splashRlJumpAd, View.GONE);
// ViewUtils.setVisible(splashHelper.splashTimeView, View.GONE);
// ViewUtils.setVisible(splashHelper.splashAdTipTextView, View.GONE);
// welcomeIvLogo.setVisibility(View.GONE);
// Constants.finishPageLoad = true;
rootView.setBackgroundColor(ContextCompat.getColor(this, R.color.res_color_common_C8));
flsplashContainer.setVisibility(View.GONE);
if (guideHelper != null) {
guideHelper.releaseResources();
}
splashHelper.releaseResources();
ViewUtils.setVisible(splashHelper.splashRlJumpAd, View.GONE);
ViewUtils.setVisible(splashHelper.splashTimeView, View.GONE);
ViewUtils.setVisible(splashHelper.splashAdTipTextView, View.GONE);
welcomeIvLogo.setVisibility(View.GONE);
Constants.finishPageLoad = true;
// initCommand();
// LiveDataBus.getInstance().with(EventConstants.WELCOME_END).postValue(true);
LiveDataBus.getInstance().with(EventConstants.WELCOME_END).postValue(true);
}
/**
... ... @@ -1615,8 +1622,8 @@ public class AppMainActivity extends BaseActivity {
*/
public void onGuideEnd() {
// 跳转启动页
// splashHelper.jumpSplash(Constants.isFirst && !Constants.isRevokePrivacy);
// setAppMainData();
splashHelper.jumpSplash(Constants.isFirst && !Constants.isRevokePrivacy);
setAppMainData();
}
@Override
... ... @@ -1627,7 +1634,7 @@ public class AppMainActivity extends BaseActivity {
@Override
protected void onPause() {
super.onPause();
// splashHelper.onPause();
splashHelper.onPause();
}
@Override
... ... @@ -1651,7 +1658,7 @@ public class AppMainActivity extends BaseActivity {
@Override
protected void onStop() {
// splashHelper.onStop();
splashHelper.onStop();
super.onStop();
// if(Constants.finishPageLoad && !SpUtils.isFirstAgreementFlag()){
// //更新小组件数据,如果已经调用过不会再调用
... ... @@ -1671,15 +1678,15 @@ public class AppMainActivity extends BaseActivity {
@Override
protected void onDestroy() {
super.onDestroy();
// String vistorMergeDataTag = SpUtils.getVistorMergeDataTag();
// if(StringUtils.isEqual("2",vistorMergeDataTag)){
// SpUtils.setVistorMergeDataTag("0");
// }
// if(SpUtils.getAgreeClipboard() == 2){
// SpUtils.saveAgreeClipboard(0);
// }
String vistorMergeDataTag = SpUtils.getVistorMergeDataTag();
if(StringUtils.isEqual("2",vistorMergeDataTag)){
SpUtils.setVistorMergeDataTag("0");
}
if(SpUtils.getAgreeClipboard() == 2){
SpUtils.saveAgreeClipboard(0);
}
// BaseDialog.Companion.getInstance().dismiss();
BaseDialog.Companion.getInstance().dismiss();
if (mReceiver != null) {
unregisterReceiver(mReceiver);
}
... ... @@ -1771,7 +1778,6 @@ public class AppMainActivity extends BaseActivity {
}
/**
* 游客数据合并
*/
... ... @@ -1903,9 +1909,9 @@ public class AppMainActivity extends BaseActivity {
@Override
public void onConfigurationChanged(@NonNull Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// if(StringUtils.isEqual("1",Constants.agreepomentDialogIsShow) && agreepomentDialog != null){
// agreepomentDialog.showCenter();
// }
if(StringUtils.isEqual("1",Constants.agreepomentDialogIsShow) && agreepomentDialog != null){
agreepomentDialog.showCenter();
}
//跟随系统,但系统深色模式与当前不一致
boolean isFollowChange = StringUtils.isEqual(SpUtils.FOLLOWUP_SYSTEM,
SpUtils.getNightMode()) && Constants.isNightMode != SpUtils.isNightMode();
... ...
package com.wd.module_home.adapter;
import androidx.annotation.NonNull;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import androidx.viewpager2.adapter.FragmentStateAdapter;
import com.wd.module_home.fragment.GuideFragment;
import java.util.List;
/**
* Time:2022/9/25
* Author:ypf
* Description:引导页适配器
*/
public class GuideAdapter extends FragmentStateAdapter {
private final List<GuideFragment> fragmentList;
public GuideAdapter(@NonNull FragmentActivity fragmentActivity, List<GuideFragment> fragmentList) {
super(fragmentActivity);
this.fragmentList = fragmentList;
}
@NonNull
@Override
public Fragment createFragment(int position) {
return fragmentList.get(position);
}
@Override
public int getItemCount() {
return fragmentList.size();
}
@Override
public long getItemId(int position) {
return fragmentList.get(position).hashCode();
}
@Override
public boolean containsItem(long itemId) {
return fragmentList.contains(itemId);
}
}
... ...
package com.wd.module_home.adapter;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.wd.module_home.R;
public class GuideIndexAdapter extends RecyclerView.Adapter<GuideIndexAdapter.MyViewHolder> {
/**
* center_index当前需要高亮显示的view的位置
*/
private int selectIndex = 0;
/**
* last_index将高亮的item恢复为默认状态时使用
*/
private int beforeSelectIndex = 0;
private int size;
public GuideIndexAdapter(int size) {
this.size = size;
}
@NonNull
@Override
public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_guideindex, parent, false);
return new MyViewHolder(view);
}
@Override
public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
if(selectIndex == position){
//选中
holder.ivindex.setImageResource(R.mipmap.icon_guideindexselect);
}else{
//未选中
holder.ivindex.setImageResource(R.mipmap.icon_guideindexunselect);
}
}
@Override
public int getItemCount() {
return size;
}
public static class MyViewHolder extends RecyclerView.ViewHolder {
public ImageView ivindex;
public MyViewHolder(@NonNull View itemView) {
super(itemView);
ivindex = itemView.findViewById(R.id.ivindex);
}
}
public void setSelectPosition(int index){
if (index == selectIndex) {
return;
}
beforeSelectIndex = selectIndex;
selectIndex = index;
notifyItemChanged(beforeSelectIndex);
notifyItemChanged(selectIndex);
}
}
\ No newline at end of file
... ...
package com.wd.module_home.fragment;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import com.wd.foundation.wdkit.base.fragment.BaseFragment;
import com.wd.foundation.wdkit.viewclick.BaseClickListener;
import com.wd.module_home.AppMainActivity;
import com.wd.module_home.R;
import com.wd.module_home.util.GuideConstants;
/**
* Time:2022/9/25
* Author:ypf
* Description:引导页1
*/
public class GuideFragment extends BaseFragment {
/**
* 静态引导页
* */
private final int[] GUIDE_STATIC_IMG = {R.mipmap.guide_static1, R.mipmap.guide_static2
, R.mipmap.guide_static3, R.mipmap.guide_static4, R.mipmap.guide_static5};
/**
* 静态引导页文字
* */
private final int[] GUIDE_TITLE_IMG = {R.mipmap.guide_title1, R.mipmap.guide_title2
, R.mipmap.guide_title3, R.mipmap.guide_title4, R.mipmap.guide_title5};
private ImageView ivglide;
/**
* 点击按钮--开启7.0全新体验
*/
private TextView imgFirstGoMain;
private int index,mScreenType, mScreenHeight,mScreenWidth;
/**
* 一张引导页
*/
private RelativeLayout rlGuideFragment;
/**
* @param screenType 1折叠屏(或者宽屏当作折叠屏处理)
* */
public static GuideFragment newInstance(int index,int screenType, int screenHeight, int screenWidth) {
Bundle args = new Bundle();
args.putInt(GuideConstants.ARGUMENTS_INDEX, index);
args.putInt(GuideConstants.SCREEN_TYPE,screenType);
args.putInt(GuideConstants.SCREEN_HEIGHT,screenHeight);
args.putInt(GuideConstants.SCREEN_WIDTH,screenWidth);
GuideFragment fragment = new GuideFragment();
fragment.setArguments(args);
return fragment;
}
@Override
protected String getLogTag() {
return GuideFragment.class.getSimpleName();
}
@Override
protected int getLayout() {
index = GuideConstants.WELCOME_INDEX_0;
Bundle arguments = getArguments();
if (arguments != null) {
index = arguments.getInt(GuideConstants.ARGUMENTS_INDEX);
mScreenType = arguments.getInt(GuideConstants.SCREEN_TYPE);
mScreenHeight = arguments.getInt(GuideConstants.SCREEN_HEIGHT);
mScreenWidth = arguments.getInt(GuideConstants.SCREEN_WIDTH);
}
if(index == GuideConstants.WELCOME_INDEX_0){
//欢迎页
return R.layout.fragment_guidedefault;
}else{
//引导页7.0
return R.layout.fragment_guide_new;
}
}
@Override
protected void initView(View rootView) {
initGuideView(rootView);
}
private void initGuideView(View rootView) {
if(GuideConstants.WELCOME_INDEX_0 != index){
//静态引导页
ivglide = rootView.findViewById(R.id.ivstatic);
rlGuideFragment = rootView.findViewById(R.id.rl_guide_fragment);
//静态引导页
imgFirstGoMain = rootView.findViewById(R.id.img_act_first_go_main);
//设置图片资源
if(mScreenType == 1){
//宽屏处理
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) ivglide.getLayoutParams();
params.width = mScreenHeight /2;
params.addRule(RelativeLayout.CENTER_IN_PARENT);
ivglide.setLayoutParams(params);
//保证不变形,至少宽或者高填充满,另一边不到边则留白
ivglide.setScaleType(ImageView.ScaleType.FIT_CENTER);
}
ivglide.setImageResource(GUIDE_STATIC_IMG[index]);
//设置一张引导页
if(GuideConstants.GUIDE_INDEX_0 == index){
rlGuideFragment.setVisibility(View.VISIBLE);
imgFirstGoMain.setOnClickListener(new BaseClickListener() {
@Override
protected void onNoDoubleClick(View v) {
if(getActivity()!=null && getActivity() instanceof AppMainActivity){
//引导页结束
((AppMainActivity)getActivity()).toInterestTag();
}
}
});
}
// //设置尺寸
// if(GuideConstants.GUIDE_INDEX_0 == index){
// RelativeLayout.LayoutParams img2param = (RelativeLayout.LayoutParams) iv_static_img_2.getLayoutParams();
// if(mScreenType == 1){
// img2param.width = mScreenWidth*252/(2*375);
// img2param.height = mScreenWidth*58/(2*375);
// }else{
// img2param.width = mScreenWidth*252/375;
// img2param.height = mScreenWidth*58/375;
// }
// iv_static_img_2.setLayoutParams(img2param);
// iv_static_img_2.setVisibility(View.VISIBLE);
// iv_static_img.setVisibility(View.GONE);
// iv_static_img_2.setImageResource(GUIDE_TITLE_IMG[index]);
// }else if(GuideConstants.GUIDE_INDEX_1 == index){
// RelativeLayout.LayoutParams img2param = (RelativeLayout.LayoutParams) iv_static_img_2.getLayoutParams();
// if(mScreenType == 1){
// img2param.width = mScreenWidth*228/(2*375);
// img2param.height = mScreenWidth*58/(2*375);
// }else{
// img2param.width = mScreenWidth*228/375;
// img2param.height = mScreenWidth*58/375;
// }
// iv_static_img_2.setLayoutParams(img2param);
// iv_static_img_2.setVisibility(View.VISIBLE);
// iv_static_img.setVisibility(View.GONE);
// iv_static_img_2.setImageResource(GUIDE_TITLE_IMG[index]);
// }else if(GuideConstants.GUIDE_INDEX_2 == index){
// RelativeLayout.LayoutParams img2param = (RelativeLayout.LayoutParams) iv_static_img_2.getLayoutParams();
// if(mScreenType == 1){
// img2param.width = mScreenWidth*228/(2*375);
// img2param.height = mScreenWidth*58/(2*375);
// }else{
// img2param.width = mScreenWidth*228/375;
// img2param.height = mScreenWidth*58/375;
// }
// iv_static_img_2.setLayoutParams(img2param);
// iv_static_img_2.setVisibility(View.VISIBLE);
// iv_static_img.setVisibility(View.GONE);
// iv_static_img_2.setImageResource(GUIDE_TITLE_IMG[index]);
// }else if(GuideConstants.GUIDE_INDEX_3 == index){
// RelativeLayout.LayoutParams img2param = (RelativeLayout.LayoutParams) iv_static_img_2.getLayoutParams();
// if(mScreenType == 1){
// img2param.width = mScreenWidth*228/(2*375);
// img2param.height = mScreenWidth*58/(2*375);
// }else{
// img2param.width = mScreenWidth*228/375;
// img2param.height = mScreenWidth*58/375;
// }
// iv_static_img_2.setLayoutParams(img2param);
// iv_static_img_2.setVisibility(View.VISIBLE);
// iv_static_img.setVisibility(View.GONE);
// iv_static_img_2.setImageResource(GUIDE_TITLE_IMG[index]);
// }else if(GuideConstants.GUIDE_INDEX_4 == index){
// RelativeLayout.LayoutParams img1param = (RelativeLayout.LayoutParams) iv_static_img.getLayoutParams();
// if(mScreenType == 1){
// img1param.width = mScreenWidth*289/(2*375);
// img1param.height = mScreenWidth*30/(2*375);
// }else{
// img1param.width = mScreenWidth*289/375;
// img1param.height = mScreenWidth*30/375;
// }
// iv_static_img.setLayoutParams(img1param);
// iv_static_img.setVisibility(View.VISIBLE);
// iv_static_img_2.setVisibility(View.GONE);
// iv_static_img.setImageResource(GUIDE_TITLE_IMG[index]);
// }
}
}
@Override
public void onDestroy() {
super.onDestroy();
if(ivglide != null){
//释放资源
ivglide.setImageResource(0);
}
//通知回收资源
System.gc();
}
}
... ...
package com.wd.module_home.model;
import android.text.TextUtils;
import com.wd.base.log.Logger;
import com.wd.capability.network.BaseObserver;
import com.wd.capability.network.fetcher.BaseDataFetcher;
import com.wd.capability.network.response.BaseResponse;
import com.wd.common.api.RequestApi;
import com.wd.foundation.bean.launch.AppAgreementBean;
import com.wd.foundation.wdkit.constant.Constants;
import com.wd.foundation.wdkit.utils.SpUtils;
import com.wd.foundation.wdkitcore.tools.StringUtils;
import com.wd.module_home.vm.IAgreementListener;
import java.util.List;
import io.reactivex.Observable;
/**
* 描述:获取隐私协议
*
* @author : lvjinhui
* @since: 2022/7/15
*/
public class AppAgreementFetcher extends BaseDataFetcher<RequestApi> {
private final String userType = "1";
private final String privacyType = "2";
/**
* 4:用户注销协议
*/
private final String logoutType = "4";
/**
* 5-留言板-用户协议
*/
private final String messageBoardUserType = "5";
/**
* 7-留言板-发布提问规定
*/
private final String messageBoardPublishType = "7";
/**
* 8-留言板-隐私政策
*/
private final String messageBoardPrivateType = "8";
/**
* APP个人信息收集清单
*/
private final String personalInformationType = "9";
/**
* 第三方信息共享清单
*/
private final String thirdInformationType = "10";
/**
* APP权限清单
*/
private final String permissionsListType = "11";
private final IAgreementListener mListener;
public AppAgreementFetcher(IAgreementListener mListener) {
this.mListener = mListener;
}
/**
* 获取隐私,用户协议
*/
public void getAppAgreementData(List<AppAgreementBean> bean) {
if(bean != null){
int localUserVersion = 0;
int localPrivacyVersion = 0;
int serviceUserAgreeVersion = 0;
int servicePrivateAgreeVersion = 0;
try{
if(TextUtils.isEmpty(SpUtils.getUserAgreeVersion())){
localUserVersion = Constants.USER_AGREE_VERSION;
}else{
localUserVersion = Integer.parseInt(SpUtils.getUserAgreeVersion());
}
if(TextUtils.isEmpty(SpUtils.getPrivateAgreeVersion())){
localPrivacyVersion = Constants.PRIVATE_AGREE_VERSION;
}else{
localPrivacyVersion = Integer.parseInt(SpUtils.getPrivateAgreeVersion());
}
for(int i = 0; i < bean.size(); i++){
AppAgreementBean appAgreementBean = bean.get(i);
if(appAgreementBean == null || StringUtils.isEmpty(appAgreementBean.linkUrl)){
continue;
}
if(userType.equals(appAgreementBean.type)){
if(!TextUtils.isEmpty(appAgreementBean.versionCode)){
serviceUserAgreeVersion = Integer.parseInt(appAgreementBean.versionCode);
}
if(!TextUtils.isEmpty(appAgreementBean.linkUrl)){
SpUtils.saveUserAgreeUrl(appAgreementBean.linkUrl);
}
}else if(privacyType.equals(appAgreementBean.type)){
if(!TextUtils.isEmpty(appAgreementBean.versionCode)){
servicePrivateAgreeVersion = Integer.parseInt(appAgreementBean.versionCode);
}
if(!TextUtils.isEmpty(appAgreementBean.linkUrl)){
SpUtils.savePrivateAgreeUrl(appAgreementBean.linkUrl);
}
}else if (logoutType.equals(appAgreementBean.type)){
SpUtils.saveLogoutAgreeUrl(appAgreementBean.linkUrl);
Logger.t("AppAgreementFetcher").d("注销协议保存成功");
}else if (messageBoardUserType.equals(appAgreementBean.type)){
SpUtils.saveMessageBoardUserUrl(appAgreementBean.linkUrl);
Logger.t("AppAgreementFetcher").d("保存留言板用户协议保存成功");
}else if (messageBoardPrivateType.equals(appAgreementBean.type)){
SpUtils.saveMessageBoardPrivateUrl(appAgreementBean.linkUrl);
Logger.t("AppAgreementFetcher").d("保存留言板隐私协议保存成功");
}else if (messageBoardPublishType.equals(appAgreementBean.type)){
SpUtils.saveMessageBoardPublishUrl(appAgreementBean.linkUrl);
Logger.t("AppAgreementFetcher").d("保存留言板发布提问规定保存成功");
}else if (personalInformationType.equals(appAgreementBean.type)){
SpUtils.savePersonalInformationUrl(appAgreementBean.linkUrl);
Logger.t("AppAgreementFetcher").d("APP个人信息收集清单");
}else if (thirdInformationType.equals(appAgreementBean.type)){
SpUtils.saveThirdInformationUrl(appAgreementBean.linkUrl);
Logger.t("AppAgreementFetcher").d("第三方信息共享清单");
}else if (permissionsListType.equals(appAgreementBean.type)){
SpUtils.savePermissionsListUrl(appAgreementBean.linkUrl);
Logger.t("AppAgreementFetcher").d("APP权限清单");
}
}
}catch (Exception e){
Logger.t("AppAgreementFetcher").d("Exception");
}
if(localUserVersion<serviceUserAgreeVersion||
localPrivacyVersion<servicePrivateAgreeVersion){
//用户协议版本号或隐私协议版本号有升级
if(mListener!=null){
mListener.result(1,serviceUserAgreeVersion,servicePrivateAgreeVersion);
}
}else {
if(mListener!=null){
mListener.result(0,serviceUserAgreeVersion,servicePrivateAgreeVersion);
}
}
}else {
if(mListener!=null){
mListener.result(-1,0,0);
}
}
}
/**
* 用户隐私协议接口请求
*/
public void requestAppAgreementData(){
Observable<BaseResponse<List<AppAgreementBean>>> splashAdInfo = getRetrofit().getAppAgreement();
request(splashAdInfo, new BaseObserver<List<AppAgreementBean>>() {
@Override
protected void dealSpecialCode(int code, String message) {
}
@Override
public void onSuccess(List<AppAgreementBean> bean) {
getAppAgreementData(bean);
}
@Override
public void _onError(String e) {
Logger.t("AppAgreementFetcher").d("获取隐私数据失败");
}
});
}
}
... ...
/*
* Copyright (c) Wondertek Technologies Co., Ltd. 2019-2022. All rights reserved.
*/
package com.wd.module_home.model;
import android.content.Context;
import android.text.TextUtils;
import com.wd.capability.network.BaseObserver;
import com.wd.capability.network.bean.MetaBean;
import com.wd.capability.network.fetcher.BaseDataFetcher;
import com.wd.capability.network.response.BaseResponse;
import com.wd.common.api.RequestApi;
import com.wd.common.content.model.impl.ContentModelImpl;
import com.wd.foundation.bean.launch.LaunchPageBean;
import com.wd.foundation.wdkit.network.IDownloadListener;
import com.wd.foundation.wdkit.utils.SpUtils;
import com.wd.module_home.vm.ISplashListener;
import java.util.HashMap;
import io.reactivex.Observable;
/**
* 描述:获取数据方法
*
* @author : lvjinhui
* @since: 2022/6/1
*/
public class SplashDataFetcher extends BaseDataFetcher<RequestApi> {
private ISplashListener mListener;
/**
* 构造器
*
* @param listener 监听回调
*/
public SplashDataFetcher(ISplashListener listener) {
this.mListener = listener;
}
public void setmListener(ISplashListener mListener) {
this.mListener = mListener;
}
/**
* 获取广告数据
* height 是
* 分辨率高
* <p>
* width 是
* 分辨率宽
*/
public void getSplashAdInfo(String width, String height) {
HashMap<String, Object> queryMap = new HashMap<>();
queryMap.put("width", width);
queryMap.put("height", height);
if (!TextUtils.isEmpty(SpUtils.getProvinceCode())) {
queryMap.put("provinceCode", SpUtils.getProvinceCode());
}
if (!TextUtils.isEmpty(SpUtils.getCityCode())) {
queryMap.put("cityCode", SpUtils.getCityCode());
}
if (!TextUtils.isEmpty(SpUtils.getDistrictCode())) {
queryMap.put("districtCode", SpUtils.getDistrictCode());
}
Observable<BaseResponse<LaunchPageBean>> splashAdInfo = getRetrofit().getSplashAdInfo(queryMap);
request(splashAdInfo, new BaseObserver<LaunchPageBean>() {
@Override
protected void dealSpecialCode(int code, String message) {
if (mListener != null) {
mListener.onGetAdlFailed(message);
}
}
@Override
public void onSuccess(LaunchPageBean infoBean) {
}
@Override
protected void onSuccess(LaunchPageBean launchPageBean, MetaBean metaBean, String msg, int code) {
if (mListener != null) {
mListener.onGetAdlSuccess(launchPageBean,metaBean);
}
}
@Override
public void _onError(String e) {
if (mListener != null) {
mListener.onGetAdlFailed(e);
}
}
});
}
/**
* 下载广告
*
* @param downloadUrl
* @param listener
*/
public void downloadAdData(Context context, String downloadUrl, IDownloadListener listener) {
new ContentModelImpl().downloadAdData(context.getApplicationContext(), downloadUrl, listener);
}
}
... ...
package com.wd.module_home.util;
/**
* Time:2022/9/25
* Author:ypf
* Description:
*/
public class GuideConstants {
/**
* 引导页序列号
*/
public static String ARGUMENTS_INDEX = "index";
/**
* 引导页屏幕类型
*/
public static String SCREEN_TYPE = "screen_type";
/**
* 引导页屏幕高度
*/
public static String SCREEN_HEIGHT = "screen_height";
/**
* 引导页屏幕宽度
*/
public static String SCREEN_WIDTH = "screen_width";
/**
* 引导页序列号0
*/
public static int WELCOME_INDEX_0 = -1;
/**
* 引导页序列号0
*/
public static int GUIDE_INDEX_0 = 0;
/**
* 引导页序列号1
*/
public static int GUIDE_INDEX_1 = 1;
/**
* 引导页序列号2
*/
public static int GUIDE_INDEX_2 = 2;
/**
* 引导页序列号3
*/
public static int GUIDE_INDEX_3 = 3;
/**
* 引导页序列号3
*/
public static int GUIDE_INDEX_4 = 4;
}
... ...
package com.wd.module_home.util;
import android.view.LayoutInflater;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.viewpager2.widget.ViewPager2;
import com.wd.foundation.wdkit.utils.ScreenUtils;
import com.wd.foundation.wdkit.utils.ViewUtils;
import com.wd.module_home.AppMainActivity;
import com.wd.module_home.R;
import com.wd.module_home.adapter.GuideAdapter;
import com.wd.module_home.adapter.GuideIndexAdapter;
import com.wd.module_home.fragment.GuideFragment;
import java.util.ArrayList;
import java.util.List;
/**
* @ProjectName: PeopleDailyVideo
* @Package: com.people.displayui.main.guide
* @ClassName: GuideHelper
* @Description: 引导页管理
* @Author: wd
* @CreateDate: 2022/11/15 10:26
* @UpdateUser: wd
* @UpdateDate: 2022/11/15 10:26
* @UpdateRemark: 更新说明:
* @Version: 1.0
*/
public class GuideHelper {
private AppMainActivity appMainActivity;
/**
* 引导页布局
* */
public ViewPager2 guideViewPager;
private GuideIndexAdapter rvIndexAdapter;
/**
* 引导页指示器
* */
// private RecyclerView rvindex;
// /**
// * 引导页指示器
// * */
// public ViewPagerIndicator guideViewPagerIndicator;
/**
* 引导页立即进入按钮
* */
// public ImageView guideTvEnter;
/**
* 引导页列表
* */
public List<GuideFragment> guideFragmentList;
/**
* 引导页适配器
* */
public GuideAdapter guideAdapter;
/**
* 没有引导页
* */
public final static boolean HASGUIDE = true;
private int counterPageScroll = 0;
public GuideHelper(AppMainActivity appMainActivity){
this.appMainActivity = appMainActivity;
}
/**
* 初始化欢迎页
* */
public void initGuide() {
View view = LayoutInflater.from(appMainActivity).inflate(R.layout.activity_guide, null);
guideViewPager = ViewUtils.findViewById(view, R.id.viewpager2);
// rvindex = ViewUtils.findViewById(view,R.id.rvindex);
//去除动画
guideViewPager.setPageTransformer(new ViewPager2.PageTransformer() {
@Override
public void transformPage(@NonNull View view, float position) {
}
});
// guideTvEnter = ViewUtils.findViewById(view, R.id.tvEnter);
//
// guideTvEnter.setOnClickListener(new View.OnClickListener() {
// @Override
// public void onClick(View v) {
// //引导页结束
// appMainActivity.toInterestTag();
// }
// });
// rvindex.setHasFixedSize(true);
LinearLayoutManager layoutManager = new LinearLayoutManager(appMainActivity, LinearLayoutManager.HORIZONTAL, false);
// rvindex.setLayoutManager(layoutManager);
appMainActivity.flsplashContainer.addView(view);
appMainActivity.flsplashContainer.setVisibility(View.VISIBLE);
}
/**
* 显示引导页
* @param hasfirst true首次安装、false覆盖安装(版本号不一样)
*/
public void init(boolean hasfirst) {
initGuide();
guideFragmentList = new ArrayList<>();
//获取屏幕宽高
int screenType = 0;
int screenWidth = 0;
int screenHeight = 0;
int[] wh = ScreenUtils.getScreenWH();
if(wh != null){
screenWidth = wh[0];
screenHeight = wh[1];
if(screenWidth*1f/screenHeight > 3/4f){
screenType = 1;
}
}
if(hasfirst){
guideFragmentList.add(GuideFragment.newInstance(GuideConstants.WELCOME_INDEX_0,screenType,screenHeight,screenWidth));
guideViewPager.setUserInputEnabled(false);
}
guideFragmentList.add(GuideFragment.newInstance(GuideConstants.GUIDE_INDEX_0,screenType,screenHeight,screenWidth));
// guideFragmentList.add(GuideFragment.newInstance(GuideConstants.GUIDE_INDEX_1,screenType,screenHeight,screenWidth));
// guideFragmentList.add(GuideFragment.newInstance(GuideConstants.GUIDE_INDEX_2,screenType,screenHeight,screenWidth));
// guideFragmentList.add(GuideFragment.newInstance(GuideConstants.GUIDE_INDEX_3,screenType,screenHeight,screenWidth));
// guideFragmentList.add(GuideFragment.newInstance(GuideConstants.GUIDE_INDEX_4,screenType,screenHeight,screenWidth));
guideAdapter = new GuideAdapter(appMainActivity, guideFragmentList);
guideViewPager.setAdapter(guideAdapter);
guideViewPager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
@Override
public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
super.onPageScrolled(position, positionOffset, positionOffsetPixels);
if (position == guideFragmentList.size() - 1) {
if (counterPageScroll != 0) {
//引导页结束
appMainActivity.toInterestTag();
}
counterPageScroll++;
} else {
counterPageScroll = 0;
}
}
@Override
public void onPageSelected(int position) {
super.onPageSelected(position);
//处理引导动效页面滑动后事件
dealGuidePageSelected(position);
}
@Override
public void onPageScrollStateChanged(int state) {
super.onPageScrollStateChanged(state);
}
/**
* 处理引导动效页面滑动后事件
*
* @param position 位置
*/
private void dealGuidePageSelected(int position) {
// if(position == guideFragmentList.size() - 1){
// rvindex.setVisibility(View.GONE);
// guideTvEnter.setVisibility(View.VISIBLE);
// }else{
// rvindex.setVisibility(View.VISIBLE);
// rvIndexAdapter.setSelectPosition(position);
// guideTvEnter.setVisibility(View.GONE);
// }
}
});
guideViewPager.setOffscreenPageLimit(2);
// rvindex.addItemDecoration(new SpacesItemDecoration((int) ResUtils.getDimension(R.dimen.rmrb_dp4),hasfirst?guideFragmentList.size()-1:guideFragmentList.size()));
// rvIndexAdapter = new GuideIndexAdapter(hasfirst?guideFragmentList.size()-1:guideFragmentList.size());
// rvindex.setAdapter(rvIndexAdapter);
if(!hasfirst){
showGuide(false);
}
}
/**
* 展示引导页
* @param needRemove true首次安装、false覆盖安装
*/
public void showGuide(boolean needRemove) {
if(guideFragmentList == null || guideFragmentList.size()<1){
appMainActivity.toInterestTag();
return;
}
guideViewPager.setVisibility(View.VISIBLE);
if (needRemove && guideFragmentList.size() > 1) {
//移除欢迎页动画
guideFragmentList.remove(0);
//刷新
guideAdapter.notifyItemRemoved(0);
//可滑动
guideViewPager.setUserInputEnabled(true);
}
ViewUtils.setVisible(appMainActivity.welcomeIvLogo, View.GONE);
}
/**
* 释放资源
* */
public void releaseResources(){
// if(guideTvEnter != null){
// guideTvEnter.setBackgroundResource(0);
// }
}
}
... ...
package com.wd.module_home.util;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.constraintlayout.widget.ConstraintLayout;
import androidx.core.content.ContextCompat;
import com.aliyun.player.IPlayer;
import com.aliyun.player.source.UrlSource;
import com.bumptech.glide.load.DataSource;
import com.bumptech.glide.load.engine.GlideException;
import com.bumptech.glide.request.RequestListener;
import com.bumptech.glide.request.target.Target;
import com.people.model.ProvinceDataManager;
import com.people.room.LaunchAdHelper;
import com.people.room.entity.LaunchAdModel;
import com.wd.base.log.Logger;
import com.wd.capability.network.bean.MetaBean;
import com.wd.common.constant.RegionNameConstants;
import com.wd.common.utils.H5JsApiPermissionUtil;
import com.wd.common.utils.ProcessUtils;
import com.wd.foundation.bean.adv.CompAdvBean;
import com.wd.foundation.bean.adv.CompAdvMatInfoBean;
import com.wd.foundation.bean.adv.CompH5Bean;
import com.wd.foundation.bean.analytics.ActionConstants;
import com.wd.foundation.bean.analytics.TrackContentBean;
import com.wd.foundation.bean.custom.content.ContentBean;
import com.wd.foundation.bean.incentive.TaskRuleSwitchBean;
import com.wd.foundation.bean.launch.AppAgreementBean;
import com.wd.foundation.bean.launch.LaunchPageBean;
import com.wd.foundation.bean.launch.OperationUrlBean;
import com.wd.foundation.bean.launch.SplashAdBean;
import com.wd.foundation.bean.response.AppAtvConfigBean;
import com.wd.foundation.bean.response.AppPublishConfigBean;
import com.wd.foundation.bean.response.CommonConfigBean;
import com.wd.foundation.bean.utils.TimeUtil;
import com.wd.foundation.wdkit.adv.AdvUtils;
import com.wd.foundation.wdkit.constant.Constants;
import com.wd.foundation.wdkit.constant.PageNameConstants;
import com.wd.foundation.wdkit.file.MyFileUtils;
import com.wd.foundation.wdkit.imageglide.ImageUtils;
import com.wd.foundation.wdkit.json.GsonUtils;
import com.wd.foundation.wdkit.network.DownloadUtil;
import com.wd.foundation.wdkit.network.IDownloadListener;
import com.wd.foundation.wdkit.system.DeviceUtil;
import com.wd.foundation.wdkit.system.FastClickUtil;
import com.wd.foundation.wdkit.utils.FilletUtil;
import com.wd.foundation.wdkit.utils.ScreenUtils;
import com.wd.foundation.wdkit.utils.SpUtils;
import com.wd.foundation.wdkit.utils.UiUtils;
import com.wd.foundation.wdkit.utils.ViewUtils;
import com.wd.foundation.wdkit.view.customtextview.RegularTextView;
import com.wd.foundation.wdkitcore.constant.BaseConstants;
import com.wd.foundation.wdkitcore.storage.MemStoreUtils;
import com.wd.foundation.wdkitcore.thread.ThreadPoolUtils;
import com.wd.foundation.wdkitcore.tools.AppContext;
import com.wd.foundation.wdkitcore.tools.ArrayUtils;
import com.wd.foundation.wdkitcore.tools.ResUtils;
import com.wd.foundation.wdkitcore.tools.StringUtils;
import com.wd.module_home.AppMainActivity;
import com.wd.module_home.R;
import com.wd.module_home.model.SplashDataFetcher;
import com.wd.module_home.vm.ISplashListener;
import com.wd.module_home.vm.SplashViewModel;
import com.wd.player.widget.AliyunRenderView;
import org.apache.commons.lang3.SerializationUtils;
import java.io.File;
import java.io.Serializable;
import java.util.List;
/**
* @ProjectName: PeopleDailyVideo
* @Package: com.people.displayui.main.splash.utils
* @ClassName: SplashHelper
* @Description: 开屏页/广告页管理
* @Author: wd
* @CreateDate: 2022/11/15 10:26
* @UpdateUser: wd
* @UpdateDate: 2022/11/15 10:26
* @UpdateRemark: 更新说明:
* @Version: 1.0
*/
public class SplashHelper {
/**
* 运营配置的启动页数据 开屏页
*/
public SplashAdBean mSplashAdBean;
/**
* 广告中心开屏广告数据
*/
public CompAdvBean launchAdInfoBean;
/**
* 闪屏页倒计时初始值
*/
public int totalTime = 6000;
public String downtimeWord = "s 跳过";
/**
* 闪屏页倒计时控件
*/
public TextView splashTimeView;
/**
* 闪屏页广告图片
*/
public ImageView splashAdImageVew;
public RelativeLayout splashRlJumpAd;
/**
* 闪屏页跳过广告布局
*/
public TextView splashTvJumpAd;
/**
* 闪屏页视频
*/
public ViewStub splashAdVideoStub;
/**
* 闪屏页跳过广告标识
*/
public TextView splashAdTipTextView;
private AppMainActivity appMainActivity;
/**
* 闪屏页播放器视图
*/
private AliyunRenderView aliyunRenderView;
/**
* 闪屏页下载逻辑处理
*/
public SplashViewModel viewModel;
/**
* 开屏广告类型
* 0:默认,1:展现中心,2:广告中心
*/
private int launchType = 0;
/**
* 闪屏广告图片加载回调
*/
private String linkType = "";
RequestListener<Drawable> adRequestListener = new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target, boolean isFirstResource) {
visibleJumpAdAndAdTip();
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target, DataSource dataSource, boolean isFirstResource) {
visibleJumpAdAndAdTip();
return false;
}
};
public SplashHelper(AppMainActivity appMainActivity) {
this.appMainActivity = appMainActivity;
}
/**
* 视频使用本地缓存
*
* @param unPrepare 非预加载
*/
private boolean downloadAd(boolean unPrepare,SplashAdBean splashAdBean) {
if (TextUtils.isEmpty(splashAdBean.bootScreenUrl)) {
SpUtils.setSplashCacheType(1);
SpUtils.saveSplashCache(GsonUtils.objectToJson(splashAdBean));
return false;
}
String finalPath = DownloadUtil.getDownloadCachePath(appMainActivity, DownloadUtil.getNameFromUrl(splashAdBean.bootScreenUrl));
if (MyFileUtils.isExist(finalPath)) {
if (unPrepare) {
loadVideoAd(finalPath);
}else{
SpUtils.setSplashCacheType(1);
SpUtils.saveSplashCache(GsonUtils.objectToJson(splashAdBean));
}
} else {
if (unPrepare) {
//本地没有视频,直接跳过视频
return showImageAd(splashAdBean.bootVideoScreenUrl);
}
// 同时下载
viewModel.downLoadAdData(appMainActivity, splashAdBean.bootScreenUrl, new IDownloadListener() {
@Override
public void onStart() {
}
@Override
public void onProgress(int progress) {
}
@Override
public void onFailure() {
}
@Override
public void onDone() {
SpUtils.setSplashCacheType(1);
SpUtils.saveSplashCache(GsonUtils.objectToJson(splashAdBean));
}
});
if(!StringUtils.isEmpty(splashAdBean.bootVideoScreenUrl)){
ThreadPoolUtils.backgroundSubmit(new Runnable() {
@Override
public void run() {
ImageUtils.getInstance().preloadImage(AppContext.getContext(), splashAdBean.bootVideoScreenUrl,new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target,
boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target,
DataSource dataSource, boolean isFirstResource) {
SpUtils.setSplashCacheType(1);
SpUtils.saveSplashCache(GsonUtils.objectToJson(splashAdBean));
return true;
}
});
}
});
}
}
return true;
}
/**
* 异步预加载下次启动需要用到的图片
*
* @param splashAdBean
*/
private void prepareLaunchPageResource(SplashAdBean splashAdBean) {
ThreadPoolUtils.backgroundSubmit(new Runnable() {
@Override
public void run() {
dealLaunchInfo(splashAdBean, true);
}
});
}
/**
* 处理开屏页
*
* @param splashAdBean
* @param isPrepare true预加载,false加载
*/
private void dealLaunchInfo(SplashAdBean splashAdBean, boolean isPrepare) {
if(isPrepare){
SpUtils.saveSplashCache("");
SpUtils.setSplashCacheType(0);
}
//没有开机屏封面图/视频地址
if (splashAdBean == null || TextUtils.isEmpty(splashAdBean.bootScreenUrl)) {
if(!isPrepare){
appMainActivity.finishPage();
}
return;
}
launchType = 1;
//预加载
if (isPrepare) {
//图片
if ("1".equals(splashAdBean.showType)) {
// 2022/11/21 预加载所有(下次要使用的)图片,避免首次加载慢白屏问题
ThreadPoolUtils.backgroundSubmit(new Runnable() {
@Override
public void run() {
ImageUtils.getInstance().preloadImage(AppContext.getContext(), splashAdBean.bootScreenUrl,new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target,
boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target,
DataSource dataSource, boolean isFirstResource) {
SpUtils.setSplashCacheType(1);
SpUtils.saveSplashCache(GsonUtils.objectToJson(splashAdBean));
return true;
}
});
}
});
} else if ("2".equals(splashAdBean.showType)) {
//视频
downloadAd(false,splashAdBean);
}
} else {
mSplashAdBean = splashAdBean;
//图片
if (mSplashAdBean !=null && ("1".equals(mSplashAdBean.showType) || "2".equals(mSplashAdBean.showType))) {
//运营配置的启动页
initSplash();
} else {
appMainActivity.finishPage();
}
}
}
/**
* 加载闪屏页视频
* 使用网络url
*/
private void loadVideoAd(String url) {
initPlayer(url);
initTimer();
trackExposure(true);
}
/**
* 初始化闪屏页播放器
*/
private void initPlayer(String playUrl) {
aliyunRenderView = ViewUtils.findViewById(splashAdVideoStub.inflate(), R.id.splash_ad_video);
// 设置渲染View的类型,可选 SurfaceType.TEXTURE_VIEW 和 SurfaceType.SURFACE_VIEW
aliyunRenderView.setSurfaceType(AliyunRenderView.SurfaceType.SURFACE_VIEW);
UrlSource urlSource = new UrlSource();
urlSource.setUri(playUrl);
// 设置播放源,setDataSource为重载方法,还可以设置 sts,playAuth 等数据源
aliyunRenderView.setDataSource(urlSource);
aliyunRenderView.setLoop(true);
aliyunRenderView.setScaleModel(IPlayer.ScaleMode.SCALE_ASPECT_FILL);
aliyunRenderView.setMute(true);
// 播放相关
aliyunRenderView.prepare();
//优化起播黑屏,等播放第一帧后,在展示视频
aliyunRenderView.setOnRenderingStartListener(() -> {
visibleJumpAdAndAdTip();
ViewUtils.setVisible(aliyunRenderView, View.VISIBLE);
});
aliyunRenderView.setOnErrorListener(errorInfo -> {
visibleJumpAdAndAdTip();
});
aliyunRenderView.start();
//闪屏页视频标识
initJump();
appMainActivity.mainBottomBar.setVisibility(View.VISIBLE);
appMainActivity.bottomLine.setVisibility(View.VISIBLE);
appMainActivity.mainViewPager.setVisibility(View.VISIBLE);
}
/**
* 闪屏页图片加载完成\视频第一帧加载出来后,要展示的其他内容
* 启动页展示:跳过按钮
* 广告页展示:跳过按钮、广告、进入详情
*/
private void visibleJumpAdAndAdTip() {
//广告标签处理
if (splashAdTipTextView != null) {
splashAdTipTextView.setVisibility(View.VISIBLE);
}
if(launchType == 2){
//广告中心广告
//全屏/展示底部logo样式处理
if(launchAdInfoBean != null && launchAdInfoBean.getMatInfo()!=null){
CompAdvMatInfoBean compAdvMatInfoBean = launchAdInfoBean.getMatInfo();
String startStyle = compAdvMatInfoBean.getStartStyle();
if ("1".equals(startStyle)) {
//全屏展示
ViewUtils.setVisible(appMainActivity.welcomeIvLogo, View.GONE);
} else {
//默认非全屏,展示底部logo
ViewUtils.setVisible(appMainActivity.welcomeIvLogo, View.VISIBLE);
}
}
}else {
//全屏/展示底部logo样式处理
if (mSplashAdBean != null && "2".equals(mSplashAdBean.screenType)) {
//全屏展示
ViewUtils.setVisible(appMainActivity.welcomeIvLogo, View.GONE);
} else {
//默认非全屏,展示底部logo
ViewUtils.setVisible(appMainActivity.welcomeIvLogo, View.VISIBLE);
}
}
//跳转入口处理
if (splashRlJumpAd != null) {
splashRlJumpAd.setVisibility(View.VISIBLE);
}
//倒计时处理
splashAdImageVew.postDelayed(new Runnable() {
@Override
public void run() {
ViewUtils.setVisible(splashTimeView, View.VISIBLE);
//华为手机开机屏会闪动,先注释
/*appMainActivity.mainBottomBar.setVisibility(View.VISIBLE);
appMainActivity.bottomLine.setVisibility(View.VISIBLE);
appMainActivity.mainViewPager.setVisibility(View.VISIBLE);*/
}
}, 2);
}
/**
* 配置的是运营启动页,不显示广告的信息
*/
private void hideAdInfo() {
if (splashTimeView != null) {
splashTimeView.setVisibility(View.VISIBLE);
}
}
/**
* 显示闪屏页面广告
*/
private boolean showImageAd(String screenUrl) {
if (TextUtils.isEmpty(screenUrl)) {
return false;
}
File file = ImageUtils.getCache(appMainActivity,screenUrl);
//如果本地没有预加载出来图片,直接跳过
if(file == null){
return false;
}
ImageUtils.getInstance().loadImageHighLev(splashAdImageVew, file, adRequestListener);
initTimer();
// 处理广告跳转
initJump();
trackExposure(true);
return true;
}
/**
* 初始化闪屏页面广告倒计时计数器
*/
public void initTimer() {
splashTimeView.setVisibility(View.VISIBLE);
startCountdown();
}
/**
* 开屏页点击跳转
*/
private void initJump() {
if(launchType == 2){
if (launchAdInfoBean == null) {
return;
}
CompAdvMatInfoBean matInfoBean = launchAdInfoBean.getMatInfo();
if(matInfoBean == null){
return;
}
if (StringUtils.isNotBlank(matInfoBean.getOpenType())){
linkType = matInfoBean.getOpenType();
}else {
linkType = matInfoBean.getLinkType();
}
if(StringUtils.isEqual("0",linkType)){
return;
}
initTvJump();
splashRlJumpAd.setOnClickListener(v -> {
if (FastClickUtil.isFastClick()) {
return;
}
if(StringUtils.isEqual("0",linkType)){
// 0:无链接;
return;
}
String linkUrl = matInfoBean.getLinkUrl();
if(StringUtils.isEmpty(linkUrl)){
return;
}
if(StringUtils.isEqual("1",linkType)){
//内链
ProcessUtils.goToH5Page(new ContentBean(linkUrl));
}else if(StringUtils.isEqual("2",linkType)){
//外链
ProcessUtils.jumpBrowser(appMainActivity,linkUrl);
}
//开屏广告点击埋点
trackExposure(false);
appMainActivity.finishPage();
});
}else {
//展现中心
if (mSplashAdBean == null || TextUtils.isEmpty(mSplashAdBean.objectType) || "0".equals(mSplashAdBean.objectType)) {
return;
}
initTvJump();
splashRlJumpAd.setOnClickListener(v -> {
if (FastClickUtil.isFastClick()) {
return;
}
/*mHandle.removeMessages(0);
isDoCountDown = false;*/
//开机屏公共跳转
ContentBean contentBean = new ContentBean();
contentBean.setPageId(TextUtils.isEmpty(mSplashAdBean.pageId)? mSplashAdBean.objectId: mSplashAdBean.pageId);
contentBean.setObjectType(mSplashAdBean.objectType);
contentBean.setObjectId(mSplashAdBean.objectId);
contentBean.setObjectLevel(mSplashAdBean.objectLevel);
contentBean.setLinkUrl(mSplashAdBean.linkUrl);
contentBean.setBottomNavId(mSplashAdBean.bottomNavId);
contentBean.setRelId(mSplashAdBean.relId);
//专题模板 --->专题样式 1:常规, 2:作者, 3:时间线
//contentBean.setTopicTemplate(mSplashAdBean.topicTemplate);
ProcessUtils.processPage(contentBean);
//开屏广告点击埋点
trackExposure(false);
/*splashTimeView.postDelayed(new Runnable() {
@Override
public void run() {
splashTimeView.setVisibility(View.GONE);
appMainActivity.finishPage();
}
},500);*/
appMainActivity.finishPage();
});
}
}
private void initTvJump() {
splashRlJumpAd = new RelativeLayout(appMainActivity);
ConstraintLayout.LayoutParams splashRlparams = new ConstraintLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
if(launchType == 2){
//广告中心
if(launchAdInfoBean != null && launchAdInfoBean.getMatInfo()!= null){
CompAdvMatInfoBean matInfo = launchAdInfoBean.getMatInfo();
splashRlparams.setMargins(0, 0, 0,
(int) appMainActivity.getResources().
getDimension("1".equals(matInfo.getStartStyle()) ?
R.dimen.btmjump_dimensmall : R.dimen.btmjump_dimen));
}
}else if(mSplashAdBean !=null){
//展现中心
splashRlparams.setMargins(0, 0, 0,
(int) appMainActivity.getResources().
getDimension("2".equals(mSplashAdBean.screenType) ?
R.dimen.btmjump_dimensmall : R.dimen.btmjump_dimen));
}
splashRlparams.startToStart = ConstraintLayout.LayoutParams.PARENT_ID;
splashRlparams.endToEnd = ConstraintLayout.LayoutParams.PARENT_ID;
splashRlparams.topToTop = -1;
splashRlparams.bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID;
int screenWidth = ScreenUtils.getScreenSize(appMainActivity, true);
splashRlparams.width = 300*screenWidth/375;
splashRlparams.height = 58*screenWidth/375;
splashRlJumpAd.setLayoutParams(splashRlparams);
splashRlJumpAd.setBackground(FilletUtil.createRectangleDrawable(0x7f000000, 0x80FFFFFF, UiUtils.dp2px(1), UiUtils.dp2px(40)));
//动态添加布局
RelativeLayout.LayoutParams splashTvJumpAdParams = new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,ViewGroup.LayoutParams.WRAP_CONTENT);
splashTvJumpAdParams.addRule(RelativeLayout.CENTER_IN_PARENT);
splashTvJumpAd = new TextView(appMainActivity);
splashTvJumpAd.setLayoutParams(splashTvJumpAdParams);
splashRlJumpAd.addView(splashTvJumpAd);
splashRlJumpAd.setVisibility(View.INVISIBLE);
splashTvJumpAd.setCompoundDrawablePadding(UiUtils.dp2px(6));
splashTvJumpAd.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
splashTvJumpAd.setText( ResUtils.getString(launchType == 2 ?
R.string.res_splash_adv : R.string.res_splash));
splashTvJumpAd.setTextColor(0xFFFFFFFF);
Drawable drawable = ContextCompat.getDrawable(appMainActivity, R.drawable.ic_arrow_right_2);
drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
splashTvJumpAd.setCompoundDrawables(null, null, drawable, null);
appMainActivity.rootView.addView(splashRlJumpAd);
}
public void initAdTip(ViewGroup view) {
splashAdTipTextView = new RegularTextView(appMainActivity);
view.addView(splashAdTipTextView);
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) splashAdTipTextView.getLayoutParams();
params.startToStart = ConstraintLayout.LayoutParams.PARENT_ID;
params.endToEnd = -1;
params.topToTop = ConstraintLayout.LayoutParams.PARENT_ID;
params.bottomToBottom = -1;
params.leftMargin = (int) appMainActivity.getResources().getDimension(R.dimen.rmrb_dp10);
params.baselineToBaseline = R.id.tvdowntime;
splashAdTipTextView.setVisibility(View.INVISIBLE);
splashAdTipTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
splashAdTipTextView.setTextColor(0xffffffff);
splashAdTipTextView.setText(R.string.comp_adv);
splashAdTipTextView.setBackgroundResource(R.drawable.shape_corner_black_2);
int lr = (int) splashAdTipTextView.getResources().getDimension(R.dimen.rmrb_dp4);
int tb = (int) splashAdTipTextView.getResources().getDimension(R.dimen.rmrb_dp1);
splashAdTipTextView.setPadding(lr, tb, lr, tb);
}
/**
* 初始化闪屏广告页
*/
public void initSplash() {
View view = LayoutInflater.from(appMainActivity).inflate(R.layout.activity_splash, null);
splashAdVideoStub = ViewUtils.findViewById(view, R.id.ad_video_vstub);
splashTimeView = ViewUtils.findViewById(view, R.id.tvdowntime);
FilletUtil.setRoundBg(splashTimeView, "#80000000", appMainActivity.getResources().getDimension(R.dimen.rmrb_dp27));
splashAdImageVew = ViewUtils.findViewById(view, R.id.splash_ad_img);
splashTimeView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (FastClickUtil.isFastClick()) {
return;
}
isDoCountDown = false;
splashTimeView.setVisibility(View.GONE);
appMainActivity.finishPage();
// GeneralTrack.getInstance().skipClick();
}
});
appMainActivity.flsplashContainer.addView(view);
appMainActivity.flsplashContainer.setVisibility(View.VISIBLE);
boolean unfinish = true;
if(launchType == 2){
//广告中心
initAdTip((ViewGroup) view);
try {
if (launchAdInfoBean == null || launchAdInfoBean.getMatInfo() == null) {
unfinish = false;
} else {
CompAdvMatInfoBean matInfoBean = launchAdInfoBean.getMatInfo();
if (!TextUtils.isEmpty(launchAdInfoBean.getDisplayDuration())) {
totalTime = Integer.parseInt(launchAdInfoBean.getDisplayDuration()) * 1000;
}
if ("0".equals(matInfoBean.getMatType())) {
if(ArrayUtils.isEmpty(matInfoBean.getMatImageUrl())){
unfinish = false;
}else {
unfinish = showImageAd(matInfoBean.getMatImageUrl().get(0));
}
} else if ("1".equals(matInfoBean.getMatType())) {
// 视频 闪屏页面视频类型 闪屏页视频标识
unfinish = downloadLaunchAdInfoVideo(true,launchAdInfoBean);
} else {
unfinish = false;
}
}
} catch (Exception e) {
unfinish = false;
}
}else {
//展现中心广告
//动态处理广告标签
if (mSplashAdBean != null && "1".equals(mSplashAdBean.isAd)) {
initAdTip((ViewGroup) view);
} else {
hideAdInfo();
}
try {
if (mSplashAdBean == null) {
unfinish = false;
} else {
if (!TextUtils.isEmpty(mSplashAdBean.durations)) {
totalTime = Integer.parseInt(mSplashAdBean.durations) * 1000;
}
if ("1".equals(mSplashAdBean.showType)) {
unfinish = showImageAd(mSplashAdBean.bootScreenUrl);
} else if ("2".equals(mSplashAdBean.showType)) {
// 视频 闪屏页面视频类型 闪屏页视频标识
unfinish = downloadAd(true,mSplashAdBean);
} else {
unfinish = false;
}
}
} catch (Exception e) {
unfinish = false;
}
}
//页面未结束标识
if (unfinish) {
//设置跳过广告的顶部距离
setAdTipViewTop();
} else {
appMainActivity.finishPage();
}
}
/**
* 设置跳过广告的顶部距离
*/
private void setAdTipViewTop() {
ConstraintLayout.LayoutParams timeViewParams = (ConstraintLayout.LayoutParams) splashTimeView.getLayoutParams();
timeViewParams.topMargin = appMainActivity.topBarHeight + 10;
}
/**
* 展示本地广告数据
*/
private void showLocalSplash() {
//请求开机屏广告
loadSplashData();
//是否有符合要求的本地数据
int cacheType = SpUtils.getSplashCacheType();
if (cacheType == 1){
//展现中心广告
String json = SpUtils.getSplashCache();
if(!TextUtils.isEmpty(json)){
SplashAdBean launchPageBean = GsonUtils.fromJson(json, SplashAdBean.class);
if(launchPageBean == null){
appMainActivity.finishPage();
}else{
dealLaunchInfo(launchPageBean, false);
}
}else{
appMainActivity.finishPage();
}
}else if (cacheType == 2){
//广告中心广告
String json = SpUtils.getSplashCache();
if(!TextUtils.isEmpty(json)){
CompAdvBean compAdvBean = GsonUtils.fromJson(json, CompAdvBean.class);
if(compAdvBean == null){
appMainActivity.finishPage();
}else{
dealLaunchAdInfo(compAdvBean, false);
}
}else{
appMainActivity.finishPage();
}
}else {
//没有缓存
appMainActivity.finishPage();
}
}
/**
* 1 展示、2不展示、3只刷新数据库
* */
public void loadSplashData() {
new SplashDataFetcher(new ISplashListener() {
@Override
public void onGetAdlSuccess(LaunchPageBean launchPageBean, MetaBean metaBean) {
// 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);
if (null == launchPageBean) {
return;
}
//是否请求底部导航bottomNavGroup
BaseConstants.bottomNavGroupMd5 = launchPageBean.getBottomNavGroupMd5();
if (StringUtils.isBlank(launchPageBean.getNewsTabMd5())){
BaseConstants.newsTabMd5 = System.currentTimeMillis()+"";
}else {
BaseConstants.newsTabMd5 = launchPageBean.getNewsTabMd5();
}
//用户激励开关
TaskRuleSwitchBean taskRuleSwitchBean = launchPageBean.getPointOperate();
if (taskRuleSwitchBean != null) {
Constants.taskRuleSwitchBean = taskRuleSwitchBean;
}
if(appMainActivity != null){
appMainActivity.getLaunchPageFinish(launchPageBean);
//底部频道数据
appMainActivity.requestBottomGroup();
//请求新闻tab的groupDetail
appMainActivity.getNewsTabBottomNavGroupDetail();
}
//h5白名单
dealH5WhiteHost(launchPageBean);
if(metaBean != null){
String md5Str = metaBean.getMd5();
String localMd5 = SpUtils.getSplashCacheMd5();
if(StringUtils.isEmpty(localMd5) || !StringUtils.isEqual(md5Str,localMd5)){
//md5值变化,清除缓存数据
SpUtils.setSplashCacheType(0);
SpUtils.saveSplashCache("");
LaunchAdHelper.getInstance(appMainActivity).clear();
SpUtils.setSplashCacheMd5(md5Str);
}
}
//处理公共配置
if(launchPageBean.getCommons() != null){
dealCommons(launchPageBean.getCommons());
}
//处理国殇模式
if(launchPageBean.getMourns() != null){
appMainActivity.getMourningModeSuccess(launchPageBean.getMourns());
}
//处理融云APPKey
if(StringUtils.isNotBlank(launchPageBean.getRongyunKey())){
SpUtils.saveIMAppkey(launchPageBean.getRongyunKey());
}
//处理H5模板下载
if(launchPageBean.h5Template != null && launchPageBean.h5Template.size() > 0){
CompH5Bean compH5Bean = launchPageBean.h5Template.get(0);
if(compH5Bean != null )
{
downloadH5Template(compH5Bean.getH5TemplateUrl(),compH5Bean.getVersion(),
compH5Bean.getVersionRangeMin(),compH5Bean.getVersionRangeMax());
}
}
//隐私协议
LaunchPageBean.AgreementsBean agreementsBean = launchPageBean.getAgreements();
if (agreementsBean != null){
List<AppAgreementBean> agreementList = agreementsBean.getAgreementList();
appMainActivity.getUserAgreement(agreementList);
}
//地区文件
LaunchPageBean.AreasBean areasBean = launchPageBean.getAreas();
if (areasBean != null){
// 省份信息初始化
ProvinceDataManager.getInstance().init(areasBean);
}
if(launchPageBean.launchPageInfo != null){
//展现中心开机屏有数据,预加载数据
prepareLaunchPageResource(launchPageBean.launchPageInfo);
return;
}
if(ArrayUtils.isEmpty(launchPageBean.launchAdInfo)){
//无数据
return;
}
List<CompAdvBean> tempDatas = null;
try {
tempDatas = (List<CompAdvBean>) SerializationUtils.
clone((Serializable) launchPageBean.launchAdInfo);
} catch (Exception e) {
e.printStackTrace();
}
//缓存的展示过的开机屏广告数据
List<LaunchAdModel> launchAdModels = LaunchAdHelper.getInstance(appMainActivity).
getAll();
if(!ArrayUtils.isEmpty(launchAdModels) ){
//本地有缓存数据
int totalRounds = 0;
for (CompAdvBean compAdvBean:launchPageBean.launchAdInfo) {
for (LaunchAdModel launchAdModel:launchAdModels) {
if(launchAdModel.advId == compAdvBean.getId()){
compAdvBean.setDisplayRound(launchAdModel.displayRound);
}
}
totalRounds = totalRounds + compAdvBean.getDisplayRound();
}
if(totalRounds == 0){
//新一轮开始,清除缓存数据,使用接口返回的数据
LaunchAdHelper.getInstance(appMainActivity).clear();
CompAdvBean compAdvBean = AdvUtils.getLaunchAdInfoForRule(tempDatas);
if(compAdvBean != null){
//广告中心开机屏有数据,预加载数据
prepareLaunchAdInfoResource(compAdvBean);
return;
}
}
}
CompAdvBean compAdvBean = AdvUtils.getLaunchAdInfoForRule(launchPageBean.launchAdInfo);
if(compAdvBean != null){
//广告中心开机屏有数据,预加载数据
prepareLaunchAdInfoResource(compAdvBean);
}
}
@Override
public void onGetAdlFailed(String error) {
BaseConstants.newsTabMd5 = System.currentTimeMillis()+"";
if(appMainActivity != null){
appMainActivity.getLaunchPageFinish(null);
//底部频道数据,失败也调用
appMainActivity.requestBottomGroup();
//请求新闻tab的groupDetail
appMainActivity.getNewsTabBottomNavGroupDetail();
}
//接口报错,读取下文件添加到白名单
H5JsApiPermissionUtil.getInstance().addH5WhiteHostList();
}
}).getSplashAdInfo(ScreenUtils.getScreenSize(appMainActivity, true) + "", ScreenUtils.getScreenSize(appMainActivity, false) + "");
}
/**
* 公共配置
* @param commonConfigBean
*/
private void dealCommons(CommonConfigBean commonConfigBean){
if (commonConfigBean == null) {
return;
}
//移动生产开关
AppPublishConfigBean appPublishConfigBean = commonConfigBean.getAppPublish();
if (appPublishConfigBean != null) {
Constants.publishHideSwitch = appPublishConfigBean.isPublishHideSwitch();
}
//活动开关
AppAtvConfigBean appAtvConfigBean = commonConfigBean.getAppAtv();
if (appAtvConfigBean != null) {
Constants.atvHideSwitch = appAtvConfigBean.isAtvHideSwitch();
}
//定制化表情包
if (commonConfigBean !=null && commonConfigBean.getCommentPics() != null &&
ArrayUtils.isNotEmpty(commonConfigBean.getCommentPics().getCommentPicList())) {
MemStoreUtils.put("commentgif",commonConfigBean.getCommentPics().getCommentPicList());
}
}
/**
* 处理白名单
* @param launchPageBean
*/
private void dealH5WhiteHost(LaunchPageBean launchPageBean){
if (launchPageBean != null){
OperationUrlBean operationUrl = launchPageBean.getOperationUrl();
if (operationUrl != null){
// false--不校验白名单;ture校验
boolean enabled = operationUrl.isEnabled();
H5JsApiPermissionUtil.enabled = enabled;
//1、本地保存的md5和接口md5比较,不一致需要更新
String localMd5 = SpUtils.getH5WhiteHostDataMD5();
//更新下载文件md5
String md5 = operationUrl.getMd5();
//2、本地保存的文件不存在也更新
if (!localMd5.equals(md5) || H5JsApiPermissionUtil.getInstance().isH5WhiteHostFileNoExists()){
SpUtils.saveH5WhiteHostDataMD5(md5);
//更新下载文件地址
String linkUrl = operationUrl.getLinkUrl();
if (StringUtils.isNotBlank(linkUrl)){
//异步下载
H5JsApiPermissionUtil.getInstance().saveH5WhiteHostFile(linkUrl);
}
}else {
//不用保存,读取下文件添加到白名单
H5JsApiPermissionUtil.getInstance().addH5WhiteHostList();
}
}
}
}
/**
* 跳转启动页
*/
public void jumpSplash(boolean isfirst) {
Constants.easterEggsCanShow = "1";
//首次不展示
if(isfirst){
appMainActivity.finishPage();
//请求开机屏广告
loadSplashData();
return;
}
if (Constants.isPullup){
//拉起不展现广告
appMainActivity.finishPage();
//请求合并接口
loadSplashData();
}else {
//展示本地广告数据
showLocalSplash();
}
}
/**
* 倒计时控制标识
*/
private boolean isDoCountDown = false;
private Handler mHandle = new Handler(new Handler.Callback() {
@Override
public boolean handleMessage(@NonNull Message message) {
switch (message.what) {
case 0:
if (isDoCountDown) {
int value = (int) message.obj;
message = Message.obtain();
message.what = 0;
message.obj = value - 1000;
if (value > 0) {
splashTimeView.setText(String.valueOf(value / 1000) + downtimeWord);
mHandle.sendMessageDelayed(message, 1000);
} else {
isDoCountDown = false;
splashTimeView.setVisibility(View.GONE);
appMainActivity.finishPage();
}
}
break;
default:
break;
}
return false;
}
});
/**
* 开启倒计时+进度条
*/
private void startCountdown() {
//进度条开始读秒
splashTimeView.setText(totalTime / 1000 + downtimeWord);
Message message = Message.obtain();
message.what = 0;
message.obj = totalTime;
mHandle.sendMessage(message);
isDoCountDown = true;
}
public void releasePlayer() {
// if (aliyunRenderView != null) {
// aliyunRenderView.setVisibility(View.GONE);
// aliyunRenderView.stop();
// aliyunRenderView.release();
// aliyunRenderView = null;
// }
}
public void onPause() {
// if (aliyunRenderView != null) {
// aliyunRenderView.pause();
// }
}
public void onStop() {
// if (aliyunRenderView != null) {
// aliyunRenderView.stop();
// }
}
/**
* 释放资源
*/
public void releaseResources() {
//倒计时
if (splashTimeView != null) {
splashTimeView.setBackgroundResource(0);
}
//开屏图
if (splashAdImageVew != null) {
splashAdImageVew.setImageResource(0);
}
//跳到第三方入口
if (splashRlJumpAd != null) {
splashRlJumpAd.setBackgroundResource(0);
}
}
/**
* 开屏广告内容曝光埋点
* isExposure true曝光、false点击
* */
private void trackExposure(boolean isExposure) {
TrackContentBean trackContentBean = new TrackContentBean();
//页面名称 page_name
trackContentBean.setPage_name(PageNameConstants.OPEN_SCREEN_PAGE);
//页面ID page_id
trackContentBean.setPage_id(PageNameConstants.OPEN_SCREEN_PAGE);
//所属区域 region_name 0开屏
trackContentBean.setRegion_name(RegionNameConstants.OPEN_SCREEN);
trackContentBean.ad_type = RegionNameConstants.OPEN_SCREEN;
if(launchType == 1 && mSplashAdBean != null){
//展现中心广告
//内容ID content_id
trackContentBean.setContent_id(mSplashAdBean.id);
trackContentBean.setContent_type(mSplashAdBean.objectType);
//内容名称 content_name
trackContentBean.setContent_name(mSplashAdBean.screenName);
// trackContentBean.ad_type = mSplashAdBean.showType;
if(StringUtils.isEqual("1",mSplashAdBean.isAd)){
trackContentBean.setAdId(mSplashAdBean.id);
trackContentBean.setAdName(mSplashAdBean.screenName);
trackContentBean.setContent_name(mSplashAdBean.screenName);
trackContentBean.setAdType("0");
}
}else if(launchAdInfoBean != null ){
//广告中心广告
//内容ID content_id
trackContentBean.setContent_id(launchAdInfoBean.getId()+"");
//内容名称 content_name
// trackContentBean.setContent_name(launchAdInfoBean.get);
trackContentBean.setContent_type("4");
trackContentBean.setAdId(launchAdInfoBean.getId()+"");
trackContentBean.setAdType("0");
//开机屏广告没有标题,产品要求写死
trackContentBean.setContent_name("启动广告");
trackContentBean.setAdName("启动广告");
}else{
return;
}
// if(isExposure){
// //曝光
// trackContentBean.setAction(ActionConstants.SHOW);
// CommonTrack.getInstance().contentShowTrack(trackContentBean);
// }else{
// //点击
// trackContentBean.setAction(ActionConstants.DETAIL_PAGE_SHOW);
// CommonTrack.getInstance().contentClickTrack(trackContentBean);
// }
}
/**
* 异步预加载下次启动需要用到的图片
*
* @param compAdvBean
*/
private void prepareLaunchAdInfoResource(CompAdvBean compAdvBean) {
ThreadPoolUtils.backgroundSubmit(new Runnable() {
@Override
public void run() {
dealLaunchAdInfo(compAdvBean, true);
}
});
}
/**
* 处理开屏页
*
* @param compAdvBean
* @param isPrepare true预加载,false加载
*/
private void dealLaunchAdInfo(CompAdvBean compAdvBean, boolean isPrepare) {
if(compAdvBean == null || compAdvBean.getMatInfo() == null){
if(!isPrepare){
//不是预加载,要处理finishPage
appMainActivity.finishPage();
}
return;
}
CompAdvMatInfoBean compAdvMatInfoBean = compAdvBean.getMatInfo();
String matType = compAdvMatInfoBean.getMatType();
launchType = 2;
if (isPrepare) {
//预加载
if ("0".equals(matType)) {
//图片
if(ArrayUtils.isEmpty(compAdvMatInfoBean.getMatImageUrl())){
return;
}
String matImageUrl = compAdvMatInfoBean.getMatImageUrl().get(0);
if(StringUtils.isEmpty(matImageUrl)){
return;
}
ThreadPoolUtils.backgroundSubmit(new Runnable() {
@Override
public void run() {
ImageUtils.getInstance().preloadImage(AppContext.getContext(), matImageUrl,new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target,
boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target,
DataSource dataSource, boolean isFirstResource) {
SpUtils.setSplashCacheType(2);
SpUtils.saveSplashCache(GsonUtils.objectToJson(compAdvBean));
return true;
}
});
}
});
} else if ("1".equals(matType)) {
//视频
downloadLaunchAdInfoVideo(false,compAdvBean);
}
} else {
//非预加载
launchAdInfoBean = compAdvBean;
//先判断是否符合时间要求
long currentTimeLong = TimeUtil.millis();
long startLong = compAdvBean.getStartTime();
long endLong = compAdvBean.getEndTime();
if (currentTimeLong < startLong || currentTimeLong > endLong) {
//不符合开始时间和结束时间要求
appMainActivity.finishPage();
return;
}
if ("0".equals(matType) || "1".equals(matType)) {
//运营配置的启动页
initSplash();
//缓存展示的数据,将displayRound-1
LaunchAdModel launchAdModel = new LaunchAdModel();
launchAdModel.advId = compAdvBean.getId();
if(compAdvBean.getDisplayRound() < 1){
launchAdModel.displayRound = 0;
}else {
launchAdModel.displayRound = compAdvBean.getDisplayRound() - 1;
}
LaunchAdHelper.getInstance(appMainActivity).insert(launchAdModel);
} else {
appMainActivity.finishPage();
}
}
}
/**
* 视频使用本地缓存
*
* @param unPrepare 非预加载
*/
private boolean downloadLaunchAdInfoVideo(boolean unPrepare,CompAdvBean compAdvBean) {
if(compAdvBean == null || compAdvBean.getMatInfo() == null){
return false;
}
CompAdvMatInfoBean compAdvMatInfoBean = compAdvBean.getMatInfo();
if (TextUtils.isEmpty(compAdvMatInfoBean.getMatVideoUrl())) {
return false;
}
String finalPath = DownloadUtil.getDownloadCachePath(appMainActivity,
DownloadUtil.getNameFromUrl(compAdvMatInfoBean.getMatVideoUrl()));
if (MyFileUtils.isExist(finalPath)) {
//文件存在
if (unPrepare) {
loadVideoAd(finalPath);
}else{
SpUtils.setSplashCacheType(2);
SpUtils.saveSplashCache(GsonUtils.objectToJson(compAdvBean));
}
} else {
//文件不存在
// 同时下载
viewModel.downLoadAdData(appMainActivity, compAdvMatInfoBean.getMatVideoUrl(), new IDownloadListener() {
@Override
public void onStart() {
}
@Override
public void onProgress(int progress) {
}
@Override
public void onFailure() {
}
@Override
public void onDone() {
SpUtils.setSplashCacheType(2);
SpUtils.saveSplashCache(GsonUtils.objectToJson(compAdvBean));
}
});
if(!ArrayUtils.isEmpty(compAdvMatInfoBean.getMatImageUrl())){
if(!unPrepare){
File file = ImageUtils.getCache(appMainActivity,
compAdvMatInfoBean.getMatImageUrl().get(0));
//如果本地没有预加载该图片,进行预加载
if(file == null){
ThreadPoolUtils.backgroundSubmit(new Runnable() {
@Override
public void run() {
ImageUtils.getInstance().preloadImage(AppContext.getContext(),
compAdvMatInfoBean.getMatImageUrl().get(0),new RequestListener<Drawable>() {
@Override
public boolean onLoadFailed(@Nullable GlideException e, Object model, Target<Drawable> target,
boolean isFirstResource) {
return false;
}
@Override
public boolean onResourceReady(Drawable resource, Object model, Target<Drawable> target,
DataSource dataSource, boolean isFirstResource) {
SpUtils.setSplashCacheType(2);
SpUtils.saveSplashCache(GsonUtils.objectToJson(compAdvBean));
return true;
}
});
}
});
}
}
if(unPrepare){
//本地没有视频,直接跳过视频
return showImageAd(compAdvMatInfoBean.getMatImageUrl().get(0));
}
}
return false;
}
return true;
}
/**
* 下载H5模板文件
*/
private void downloadH5Template(String h5url,String serVersion,String minAPPV,String MaxAPPV) {
String localAppCode = DeviceUtil.getVersionCode() + "";
Logger.t("DownLoadH5").d("localAppCode=" + localAppCode + "&minAPPV=" + minAPPV + "&MaxAPPV=" + MaxAPPV );
//当前APP版本code,在服务器给的版本范围内才去下载更新模板
try {
if (Long.parseLong(localAppCode) < Long.parseLong(minAPPV) ||
Long.parseLong(localAppCode) > Long.parseLong(MaxAPPV)) {
return;
}
}catch (NumberFormatException e){
e.printStackTrace();
return;
}
//判断本地版本比服务器版本小才下载
String h5TempVersion = SpUtils.getH5Template();
if(!TextUtils.isEmpty(h5TempVersion)){
String lversion = h5TempVersion.substring(h5TempVersion.indexOf("_") + 1);
Logger.t("DownLoadH5").d("local_version=" + lversion + "&serVersion=" + serVersion );
try {
if( Long.parseLong(lversion) >= Long.parseLong(serVersion)){
return;
}
}catch (NumberFormatException e){
e.printStackTrace();
return;
}
}
DownloadUtil.get().download(AppContext.getContext(), h5url, new IDownloadListener() {
@Override
public void onStart() {
}
@Override
public void onProgress(int progress) {
}
@Override
public void onFailure() {
}
@Override
public void onDone() {
try {
Logger.t("DownLoadH5").d("success");
String filename = h5url.substring(h5url.lastIndexOf('/')+1);
File downLoadZip = new File(AppContext.getContext().getExternalCacheDir(), filename);
if (downLoadZip != null && downLoadZip.exists()) {
Logger.t("DownLoadH5").d(downLoadZip.getAbsolutePath());
String h5TempVersion = SpUtils.getH5Template();
File h5cacheDir = null;
String unUseTemp = "h5web1";
//缓存的模板在使用,不影响,使用另一个不用的模板覆盖
if(h5TempVersion.startsWith("h5web1")){
h5cacheDir = new File(AppContext.getContext().getCacheDir(), "h5web2");
unUseTemp = "h5web2";
}else if(h5TempVersion.startsWith("h5web2")){
h5cacheDir = new File(AppContext.getContext().getCacheDir(), "h5web1");
unUseTemp = "h5web1";
}else{
h5cacheDir = new File(AppContext.getContext().getCacheDir(), "h5web1");
unUseTemp = "h5web1";
}
//解压文件
boolean isUnpackZip = MyFileUtils.unpackZip(downLoadZip, h5cacheDir);
if (isUnpackZip) {
Logger.t("DownLoadH5").d("onSuccess:unUseTemp=" + unUseTemp + "_" + serVersion);
Logger.t("DownLoadH5").d("onSuccess:absolutePath=" + downLoadZip.getAbsolutePath());
SpUtils.saveH5Template(unUseTemp + "_" + serVersion);
} else {
Logger.t("DownLoadH5").d("onSuccess: 解压失败");
}
}
} catch (Exception e) {
Logger.t("DownLoadH5").d("fail:" + e.getMessage());
e.printStackTrace();
}
}
});
}
}
... ...
... ... @@ -5,11 +5,23 @@ import android.app.Activity;
import android.os.Environment;
import android.os.SystemClock;
import android.text.TextUtils;
import android.view.Gravity;
import androidx.core.content.FileProvider;
import androidx.fragment.app.FragmentActivity;
import com.people.location.LocationUtils;
import com.wd.common.listener.ResultCallback;
import com.wd.common.notify.CookieBar;
import com.wd.common.permissions.IInterCeptorCallBack;
import com.wd.common.permissions.IPmsCallBack;
import com.wd.common.permissions.PermissionsUtils;
import com.wd.common.permissions.PmsConstant;
import com.wd.common.utils.CommonNetUtils;
import com.wd.common.utils.CommonVarUtils;
import com.wd.foundation.bean.custom.comp.PageBean;
import com.wd.foundation.bean.custom.content.ContentBean;
import com.wd.foundation.bean.custom.content.ContentTypeConstant;
import com.wd.foundation.wdkit.base.BaseApplication;
import com.wd.foundation.wdinterface.config.INetConfig;
import com.wd.foundation.wdinterface.constant.InterfaceConstant;
... ... @@ -19,9 +31,12 @@ import com.wd.common.utils.ProcessUtils;
import com.wd.foundation.bean.custom.MenuBean;
import com.wd.foundation.bean.response.BottomNavBean;
import com.wd.foundation.bean.response.ChannelBean;
import com.wd.foundation.wdkit.system.DeviceUtil;
import com.wd.foundation.wdkit.utils.SpUtils;
import com.wd.foundation.wdkit.utils.ToastNightUtil;
import com.wd.foundation.wdkitcore.livedata.LiveDataBus;
import com.wd.foundation.wdkitcore.router.ArouterServiceManager;
import com.wd.foundation.wdkitcore.thread.ThreadPoolUtils;
import com.wd.foundation.wdkitcore.tools.JsonUtils;
import com.wd.foundation.wdkitcore.tools.StringUtils;
import com.wd.module_home.R;
... ... @@ -46,7 +61,7 @@ public class WelcomeUtils {
/**
* 定位工具
*/
// private static LocationUtils locationUtils;
private static LocationUtils locationUtils;
/**
* 定位弹窗,弹过了,可以弹升级了
... ... @@ -141,37 +156,37 @@ public class WelcomeUtils {
/**
* 桌面组件逻辑处理
*/
// public static void toWidgetActivity() {
// String widgetData = SpUtils.getWidgetData();
// if (!TextUtils.isEmpty(widgetData)) {
// // 跳转到电子报页面
// if ("1".equalsIgnoreCase(widgetData)) {
// ProcessUtils.goToPaperActivity();
// }else if ("2".equalsIgnoreCase(widgetData)){
// // 跳转到早晚报专题页面
// CommonNetUtils.getInstance().getDailyPaperId(new ResultCallback<PageBean>() {
// @Override
// public void onSuccess(PageBean pageBean) {
// if (pageBean != null) {
// ContentBean bean = new ContentBean();
// bean.setObjectLevel(String.valueOf(ContentTypeConstant.SUBJECT_TOPICTYPE_25));
// bean.setPageId(pageBean.getId());
// bean.setNewsTitle(pageBean.getName());
// ProcessUtils.goToCommonSubjectPage(bean);
//
// } else {
// ToastNightUtil.showShort("暂无数据");
// }
// }
//
// @Override
// public void onError(String errorCode) {
// }
// });
// }
// SpUtils.saveWidgetData("");
// }
// }
public static void toWidgetActivity() {
String widgetData = SpUtils.getWidgetData();
if (!TextUtils.isEmpty(widgetData)) {
// 跳转到电子报页面
if ("1".equalsIgnoreCase(widgetData)) {
ProcessUtils.goToPaperActivity();
}else if ("2".equalsIgnoreCase(widgetData)){
// 跳转到早晚报专题页面
CommonNetUtils.getInstance().getDailyPaperId(new ResultCallback<PageBean>() {
@Override
public void onSuccess(PageBean pageBean) {
if (pageBean != null) {
ContentBean bean = new ContentBean();
bean.setObjectLevel(String.valueOf(ContentTypeConstant.SUBJECT_TOPICTYPE_25));
bean.setPageId(pageBean.getId());
bean.setNewsTitle(pageBean.getName());
ProcessUtils.goToCommonSubjectPage(bean);
} else {
ToastNightUtil.showShort("暂无数据");
}
}
@Override
public void onError(String errorCode) {
}
});
}
SpUtils.saveWidgetData("");
}
}
/**
* 刷新彩蛋数据
... ... @@ -249,7 +264,7 @@ public class WelcomeUtils {
/**
* 同意了隐私政策,在线程里初始化
*/
// public static void delayInit(Activity context) {
public static void delayInit(Activity context) {
// //个推初始化
// GeTuiSdkHelper.initialize(context);
// //设备信息上传,随机延迟 1-10秒调用
... ... @@ -265,7 +280,7 @@ public class WelcomeUtils {
// TingYunSDKHelper.init(context);
// //TingYun 设置用户标识
// TingYunSDKHelper.setUserIdentifier(DeviceUtil.getDeviceId());
// }
}
/**
* 是否是正式环境
... ... @@ -344,84 +359,84 @@ public class WelcomeUtils {
* 首次申请定位权限
*/
public static void getLocation(FragmentActivity activity) {
//
// //拒绝过
// if (!SpUtils.getRefusedLocation()) {
// CommonVarUtils.isShowLocation = true;
// final CookieBar[] mCookieBar = new CookieBar[1];
// PermissionsUtils.getLocation(activity, null, new IInterCeptorCallBack() {
// @Override
// public void interceotor() {
// if (activity == null || activity.isFinishing() || activity.isDestroyed()) {
// return;
// }
// //需要请求权限拦截,此时弹出 定位权限消息提醒
// mCookieBar[0] = new CookieBar.Builder(activity)
// .setTitle("")
// .setMessage("")
// .setImgUrl("")
// .setPushScene(5)
// .setPlanStartTime(0)
// .setDuration(10000)
// .setLayoutGravity(Gravity.TOP)
// .setActionListener((type) -> {
// }).setDismissListener(type -> {
// }).show();
//
// }
// }, new IPmsCallBack() {
// @Override
// public void granted() {
// //关闭定位提醒
// if (mCookieBar[0] != null) {
// mCookieBar[0].dismiss();
// }
// CommonVarUtils.isShowLocation = false;
// requestLocation();
// // 检测弹窗
// locationIsShow = true;
// WelcomeUtils.upVersion(activity);
// }
//
// @Override
// public void notGranted() {
// //未授权
// //授权或未授权,获取到定位请求过不要设置,保留上一次的位置信息
// int firstLocation = SpUtils.getFirstLocation();
// if (-1 == firstLocation){
// SpUtils.saveFirstLocation(0);
// }
// if (mCookieBar[0] != null) {
// mCookieBar[0].dismiss();
// }
//
// CommonVarUtils.isShowLocation = false;
// // 检测弹窗
// locationIsShow = true;
// WelcomeUtils.upVersion(activity);
// SpUtils.saveRefusedLocation(true);
// }
// });
// } else {
// CommonVarUtils.isShowLocation = false;
// // 检测弹窗
// locationIsShow = true;
// WelcomeUtils.upVersion(activity);
// //检测下是否有可能用户自己在设置里面开启权限
// String[] permissions = new String[]{PmsConstant.ACCESS_FINE_LOCATION,
// PmsConstant.ACCESS_COARSE_LOCATION};
// boolean hPermission = PermissionsUtils.checkPermissionsGroup(activity, permissions);
// if (hPermission){
// //开启定位
// requestLocation();
// }else {
// int firstLocation = SpUtils.getFirstLocation();
// if (-1 == firstLocation){
// SpUtils.saveFirstLocation(0);
// }
// }
// }
//
//拒绝过
if (!SpUtils.getRefusedLocation()) {
CommonVarUtils.isShowLocation = true;
final CookieBar[] mCookieBar = new CookieBar[1];
PermissionsUtils.getLocation(activity, null, new IInterCeptorCallBack() {
@Override
public void interceotor() {
if (activity == null || activity.isFinishing() || activity.isDestroyed()) {
return;
}
//需要请求权限拦截,此时弹出 定位权限消息提醒
mCookieBar[0] = new CookieBar.Builder(activity)
.setTitle("")
.setMessage("")
.setImgUrl("")
.setPushScene(5)
.setPlanStartTime(0)
.setDuration(10000)
.setLayoutGravity(Gravity.TOP)
.setActionListener((type) -> {
}).setDismissListener(type -> {
}).show();
}
}, new IPmsCallBack() {
@Override
public void granted() {
//关闭定位提醒
if (mCookieBar[0] != null) {
mCookieBar[0].dismiss();
}
CommonVarUtils.isShowLocation = false;
requestLocation();
// 检测弹窗
locationIsShow = true;
WelcomeUtils.upVersion(activity);
}
@Override
public void notGranted() {
//未授权
//授权或未授权,获取到定位请求过不要设置,保留上一次的位置信息
int firstLocation = SpUtils.getFirstLocation();
if (-1 == firstLocation){
SpUtils.saveFirstLocation(0);
}
if (mCookieBar[0] != null) {
mCookieBar[0].dismiss();
}
CommonVarUtils.isShowLocation = false;
// 检测弹窗
locationIsShow = true;
WelcomeUtils.upVersion(activity);
SpUtils.saveRefusedLocation(true);
}
});
} else {
CommonVarUtils.isShowLocation = false;
// 检测弹窗
locationIsShow = true;
WelcomeUtils.upVersion(activity);
//检测下是否有可能用户自己在设置里面开启权限
String[] permissions = new String[]{PmsConstant.ACCESS_FINE_LOCATION,
PmsConstant.ACCESS_COARSE_LOCATION};
boolean hPermission = PermissionsUtils.checkPermissionsGroup(activity, permissions);
if (hPermission){
//开启定位
requestLocation();
}else {
int firstLocation = SpUtils.getFirstLocation();
if (-1 == firstLocation){
SpUtils.saveFirstLocation(0);
}
}
}
}
/**
... ... @@ -493,15 +508,15 @@ public class WelcomeUtils {
/**
* 获取定位信息
*/
// public static void requestLocation() {
// locationUtils = new LocationUtils();
// locationUtils.startLocation();
// }
public static void requestLocation() {
locationUtils = new LocationUtils();
locationUtils.startLocation();
}
public static void onDestory() {
// if (locationUtils != null) {
// locationUtils.destroyLocation();
// }
if (locationUtils != null) {
locationUtils.destroyLocation();
}
}
/**
... ...
package com.wd.module_home.vm;
import androidx.lifecycle.LifecycleOwner;
import com.wd.foundation.bean.launch.AppAgreementBean;
import com.wd.foundation.wdkit.mvvm.vm.UIViewModel;
import com.wd.module_home.model.AppAgreementFetcher;
import java.util.List;
/**
* 描述:获取隐私政策
*
* @author : lvjinhui
* @since: 2022/7/15
*/
public class AgreementViewModel extends UIViewModel {
private AppAgreementFetcher fetcher;
private IAgreementListener mAgreementListener;
/**
* 注册vm回调对象
*
* @param lifecycleOwner 生命周期对象
* @param listener 监听对象
*/
public void observeAgreementListener(LifecycleOwner lifecycleOwner, IAgreementListener listener) {
if (mAgreementListener == null) {
mAgreementListener = observe(lifecycleOwner, listener, IAgreementListener.class);
} else {
observeRepeat(lifecycleOwner, listener, mAgreementListener);
}
}
/**
* 获取隐私政策,单独接口请求的
*/
public void getAppAgreement() {
if (fetcher == null) {
fetcher = new AppAgreementFetcher(mAgreementListener);
}
fetcher.requestAppAgreementData();
}
/**
* 获取隐私政策,后来改成了合并接口里,避免重复使用
*/
public void getAppAgreementV2(List<AppAgreementBean> bean) {
if (fetcher == null) {
fetcher = new AppAgreementFetcher(mAgreementListener);
}
fetcher.getAppAgreementData(bean);
}
}
... ...
package com.wd.module_home.vm;
import com.wd.foundation.wdkit.mvvm.vm.IVMCallback;
/**
* @author baozhaoxin
* @version [V1.0.0, 2022/8/8]
* @description
* @since V1.0.0
*/
public interface IAgreementListener extends IVMCallback {
void result(int need,int serviceUserAgreeVersion,int servicePrivateAgreeVersion);
}
... ...
/*
* Copyright (c) Wondertek Technologies Co., Ltd. 2019-2022. All rights reserved.
*/
package com.wd.module_home.vm;
import com.wd.capability.network.bean.MetaBean;
import com.wd.foundation.bean.launch.LaunchPageBean;
import com.wd.foundation.wdkit.mvvm.vm.IVMCallback;
/**
* 描述:获取数据监听
*
* @author : lvjinhui
* @since: 2022/6/1
*/
public interface ISplashListener extends IVMCallback {
/**
* 获取到广告数据
* @param splashAdBean
* @param metaBean
*/
void onGetAdlSuccess(LaunchPageBean splashAdBean, MetaBean metaBean);
/**
* 获取广告数据失败返回
*
* @param error 错误信息
*/
void onGetAdlFailed(String error);
}
... ...
package com.wd.module_home.vm;
/*
* Copyright (c) Wondertek Technologies Co., Ltd. 2019-2022. All rights reserved.
*/
import android.content.Context;
import androidx.lifecycle.LifecycleOwner;
import com.wd.foundation.wdkit.mvvm.vm.UIViewModel;
import com.wd.foundation.wdkit.network.IDownloadListener;
import com.wd.module_home.model.SplashDataFetcher;
/**
* 描述:广告页
*
* @author : lvjinhui
* @since: 2022/6/1
*/
public class SplashViewModel extends UIViewModel {
private static final String TAG = "SplashViewModel";
private ISplashListener splashListener;
private SplashDataFetcher splashDataFetcher;
private IMainDataListener mainDataListener;
/**
* 注册vm回调对象
*
* @param lifecycleOwner 生命周期对象
* @param listener 监听对象
*/
public void observeSplashListener(LifecycleOwner lifecycleOwner, ISplashListener listener) {
if (splashListener == null) {
splashListener = observe(lifecycleOwner, listener, ISplashListener.class);
} else {
observeRepeat(lifecycleOwner, listener, splashListener);
}
}
public void observMainDataListener(LifecycleOwner lifecycleOwner, IMainDataListener listener){
if (mainDataListener == null) {
mainDataListener = observe(lifecycleOwner, listener, IMainDataListener.class);
} else {
observeRepeat(lifecycleOwner, listener, splashListener);
}
}
// /**
// * 获取广告数据
// */
// public void getSplashAdInfo(String provinceCode,String cityCode,String districtCode) {
// if (splashDataFetcher == null) {
// splashDataFetcher = new SplashDataFetcher(splashListener);
// }else {
// splashDataFetcher.setmListener(splashListener);
// }
// splashDataFetcher.getSplashAdInfo(ScreenUtils.getScreenSize(this, true) + "", ScreenUtils.getScreenSize(this, false) + "");
// }
/**
* 下载
*
* @param url
* @param callBack
*/
public void downLoadAdData(Context context, String url, IDownloadListener callBack) {
if (splashDataFetcher == null) {
splashDataFetcher = new SplashDataFetcher(splashListener);
}else {
splashDataFetcher.setmListener(splashListener);
}
splashDataFetcher.downloadAdData(context, url, callBack);
}
}
... ...
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clickable="true">
<!-- 引导页布局 -->
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewpager2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:overScrollMode="never"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
<!-- <androidx.recyclerview.widget.RecyclerView-->
<!-- android:id="@+id/rvindex"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="@dimen/rmrb_dp6"-->
<!-- android:orientation="horizontal"-->
<!-- android:scrollbars="none"-->
<!-- android:layout_marginBottom="@dimen/rmrb_dp82"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- tools:background="@color/red_theme_bg"-->
<!-- />-->
<!-- &lt;!&ndash; 引导页立即开启按钮 &ndash;&gt;-->
<!-- <ImageView-->
<!-- android:id="@+id/tvEnter"-->
<!-- android:layout_width="@dimen/rmrb_dp140"-->
<!-- android:layout_height="@dimen/rmrb_dp44"-->
<!-- android:src="@mipmap/guide_button"-->
<!-- android:scaleType="centerCrop"-->
<!-- android:visibility="gone"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- app:layout_constraintLeft_toLeftOf="parent"-->
<!-- app:layout_constraintRight_toRightOf="parent"-->
<!-- android:layout_marginBottom="@dimen/rmrb_dp67"-->
<!-- tools:visibility="visible"-->
<!-- />-->
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:clickable="true">
<ImageView android:id="@+id/splash_ad_img"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<ViewStub android:id="@+id/ad_video_vstub"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout="@layout/ad_video_viewstub_layout" />
<com.wd.foundation.wdkit.view.customtextview.RegularTextView
android:id="@+id/tvdowntime"
android:layout_width="@dimen/rmrb_dp79"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/rmrb_dp30"
android:layout_marginRight="@dimen/rmrb_dp15"
android:gravity="center_horizontal"
android:paddingVertical="@dimen/rmrb_dp5"
android:textSize="@dimen/rmrb_dp14"
android:textColor="#ffffff"
android:visibility="invisible"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
... ...
<?xml version="1.0" encoding="utf-8"?>
<com.wd.player.widget.AliyunRenderView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/splash_ad_video"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:visibility="invisible" />
... ...
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/ivstatic"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
<!-- #ED2800 #212228 -->
<RelativeLayout
android:id="@+id/rl_guide_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/res_color_C1"
android:visibility="gone"
tools:visibility="visible">
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@id/frag_first_start_img"
android:layout_marginBottom="@dimen/rmrb_dp140">
<ImageView
android:id="@+id/iv_act_first_content"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:src="@mipmap/bg_guide_img_5_text"
android:visibility="visible" />
</FrameLayout>
<FrameLayout
android:id="@+id/first_go_main_group"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<TextView
android:id="@+id/img_act_first_go_main"
android:layout_width="wrap_content"
android:layout_height="@dimen/rmrb_dp44"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="@dimen/rmrb_dp93"
android:background="@mipmap/bg_first_go_main_select"
android:gravity="center"
android:text="开启7.0全新体验"
android:textColor="@color/res_color_C1"
android:textSize="@dimen/rmrb_dp14" />
</FrameLayout>
<ImageView
android:id="@+id/frag_first_start_img"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/rmrb_dp30"
android:scaleType="fitCenter"
android:src="@mipmap/bg_guide_img_5" />
</RelativeLayout>
</RelativeLayout>
... ...
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<!-- 动态开始 -->
<!-- <ImageView-->
<!-- android:id="@+id/ivMessage"-->
<!-- android:layout_width="@dimen/rmrb_dp168"-->
<!-- android:layout_height="@dimen/btmlogo_dimen"-->
<!-- android:scaleType="center"-->
<!-- android:src="@drawable/startbg_3"-->
<!-- android:layout_gravity="center_horizontal|bottom"-->
<!-- app:layout_constraintStart_toStartOf="parent"-->
<!-- app:layout_constraintEnd_toEndOf="parent"-->
<!-- app:layout_constraintBottom_toBottomOf="parent"-->
<!-- />-->
<ImageView
android:id="@+id/ivstatic"
android:layout_width="@dimen/rmrb_dp168"
android:layout_height="@dimen/btmlogo_dimen"
android:scaleType="center"
android:src="@drawable/icon_splash_tra_bottom_logo"
android:layout_gravity="center_horizontal|bottom"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
... ...
package com.wd.foundation.wdkit.animator
import android.animation.Animator
import android.animation.ObjectAnimator
import android.app.Dialog
import android.os.Handler
import android.view.View
import android.view.animation.Animation
import android.view.animation.LinearInterpolator
import android.view.animation.RotateAnimation
import com.wd.kittools.density.DensityUtils
/**
* AnimatorUtil
... ... @@ -17,36 +20,36 @@ import android.view.animation.RotateAnimation
object AnimatorUtil {
fun startVerticalUp(view: View?) {
// view?.apply {
// val h = DensityUtils.getViewSize(this)[1].toFloat()
// val objectAnimator = ObjectAnimator.ofFloat(this, "y", h, 0f)
// objectAnimator.duration = 300
// objectAnimator.start()
// }
view?.apply {
val h = DensityUtils.getViewSize(this)[1].toFloat()
val objectAnimator = ObjectAnimator.ofFloat(this, "y", h, 0f)
objectAnimator.duration = 300
objectAnimator.start()
}
}
fun startVerticalDown(view: View?, dialog: Dialog?) {
// view?.apply {
// val h = DensityUtils.getViewSize(this)[1].toFloat()
// val objectAnimator = ObjectAnimator.ofFloat(this, "y", 0f, h)
// objectAnimator.duration = 300
// objectAnimator.start()
// objectAnimator.addListener(object : Animator.AnimatorListener {
// override fun onAnimationStart(animation: Animator?) {
// }
//
// override fun onAnimationEnd(animation: Animator?) {
// dialog?.dismiss()
// }
//
// override fun onAnimationCancel(animation: Animator?) {
// }
//
// override fun onAnimationRepeat(animation: Animator?) {
// }
//
// })
// }
view?.apply {
val h = DensityUtils.getViewSize(this)[1].toFloat()
val objectAnimator = ObjectAnimator.ofFloat(this, "y", 0f, h)
objectAnimator.duration = 300
objectAnimator.start()
objectAnimator.addListener(object : Animator.AnimatorListener {
override fun onAnimationStart(animation: Animator?) {
}
override fun onAnimationEnd(animation: Animator?) {
dialog?.dismiss()
}
override fun onAnimationCancel(animation: Animator?) {
}
override fun onAnimationRepeat(animation: Animator?) {
}
})
}
}
fun spinView(view: View?) {
... ...
/*
* Copyright (c) Wondertek Technologies Co., Ltd. 2019-2022. All rights reserved.
*/
package com.wd.foundation.wdkit.network;
import android.content.Context;
import android.text.TextUtils;
import androidx.annotation.NonNull;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import okhttp3.Call;
import okhttp3.Callback;
import okhttp3.OkHttpClient;
import okhttp3.Request;
import okhttp3.Response;
/**
* 描述:简单下载工具
*
* @author : lvjinhui
* @since: 2022/6/7
*/
public class DownloadUtil {
private static final String TAG = DownloadUtil.class.getName();
private static final String DOWNLOAD = "Download";
private static DownloadUtil downloadUtil;
private final OkHttpClient okHttpClient;
private DownloadUtil() {
okHttpClient = new OkHttpClient();
}
/**
* 获取实例
*
* @return 获取实例
*/
public static DownloadUtil get() {
if (downloadUtil == null) {
downloadUtil = new DownloadUtil();
}
return downloadUtil;
}
/**
* 下载
*
* @param url 下载连接
* @param listener 下载监听
*/
public void download(Context context, final String url, final IDownloadListener listener) {
Request request = new Request.Builder().url(url).build();
okHttpClient.newCall(request).enqueue(new Callback() {
@Override
public void onFailure(Call call, IOException e) {
// 下载失败
listener.onFailure();
}
@Override
public void onResponse(Call call, Response response) throws IOException {
//404等错误导致,视频下载失败,却保存了文件,导致视频播放不了
if(!response.isSuccessful()){
//isSuccessful为true,code200才行
listener.onFailure();
return;
}
InputStream is = null;
byte[] buf = new byte[2048];
int len = 0;
FileOutputStream fos = null;
try {
is = response.body().byteStream();
long total = response.body().contentLength();
String fileName = getDownloadCachePath(context,getNameFromUrl(url));
String tempFileName = "";
if(fileName.contains(".")){
tempFileName = fileName.substring(0,fileName.lastIndexOf("."))+".temp";
}
File file = new File(TextUtils.isEmpty(tempFileName)?fileName:tempFileName);
fos = new FileOutputStream(file);
long sum = 0;
while ((len = is.read(buf)) != -1) {
fos.write(buf, 0, len);
sum += len;
int progress = (int) (sum * 1.0f / total * 100);
// 下载中
listener.onProgress(progress);
}
fos.flush();
// 下载完成
listener.onDone();
if(!TextUtils.isEmpty(tempFileName)){
file.renameTo(new File(fileName));
}
} catch (Exception e) {
listener.onFailure();
} finally {
try {
if (is != null) {
is.close();
}
} catch (IOException e) {
}
try {
if (fos != null) {
fos.close();
}
} catch (IOException e) {
}
}
}
});
}
/**
* 从下载连接中解析出文件名
*
* @param url
* @return getNameFromUrl
*/
@NonNull
public static String getNameFromUrl(String url) {
return url.substring(url.lastIndexOf("/") + 1);
}
/**
* 下载到外置缓存目录
*/
public static String getDownloadCachePath(Context context, String fileName) {
return new File(context.getApplicationContext().getExternalCacheDir(), fileName).getAbsolutePath();
}
}
... ...
/*
* Copyright (c) Wondertek Technologies Co., Ltd. 2019-2022. All rights reserved.
*/
package com.wd.foundation.wdkit.network;
/**
* 描述:下载监听
*
* @author : lvjinhui
* @since: 2022/6/7
*/
public interface IDownloadListener {
/**
* 开始
*/
void onStart();
/**
* 下载进度
*
* @param progress
*/
void onProgress(int progress);
/**
* 下载失败
*/
void onFailure();
/**
* 下载完成
*/
void onDone();
}
... ...
... ... @@ -225,6 +225,21 @@ public class ScreenUtils {
}
/**
* 屏幕宽高比
* */
public static int[] getScreenWH() {
WindowManager wm = (WindowManager) AppContext.getContext().getApplicationContext().getSystemService(Context.WINDOW_SERVICE);
Point point = new Point();
wm.getDefaultDisplay().getRealSize(point);
int w = point.x;
int h = point.y;
if(w == 0 || h == 0){
return null;
}
return new int[]{w,h};
}
/**
* Return the density of screen.
*
* @return the density of screen
... ...