androidx版本首次提交
This commit is contained in:
113
app/build.gradle
Normal file
113
app/build.gradle
Normal file
@@ -0,0 +1,113 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'img-optimizer'
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
// 可根据需要选择性排除
|
||||
|
||||
android {
|
||||
dexOptions {
|
||||
jumboMode = true
|
||||
}
|
||||
compileSdkVersion rootProject.ext.android.compileSdkVersion
|
||||
buildToolsVersion rootProject.ext.android.buildToolsVersion
|
||||
packagingOptions {
|
||||
pickFirst "lib/armeabi/libyuvutils.so"
|
||||
pickFirst "lib/arm64-v8a/libyuvutils.so"
|
||||
pickFirst "lib/armeabi-v7a/libyuvutils.so"
|
||||
pickFirst "lib/armeabi/libyuvtools.so"
|
||||
pickFirst "lib/arm64-v8a/libyuvtools.so"
|
||||
pickFirst "lib/armeabi-v7a/libyuvtools.so"
|
||||
exclude "lib/arm64-v8a/libmmcv_api_handgesture.so"
|
||||
exclude "lib/arm64-v8a/libmmcv_api_express.so"
|
||||
exclude "lib/arm64-v8a/libMediaEncoder.so"
|
||||
exclude "lib/arm64-v8a/libarcore_sdk_c.so"
|
||||
exclude "lib/arm64-v8a/libmediadecoder.so"
|
||||
exclude "lib/arm64-v8a/libMediaMuxer.so"
|
||||
exclude "lib/arm64-v8a/libarcore_sdk_jni.so"
|
||||
exclude "lib/arm64-v8a/libMediaUtils.so"
|
||||
exclude "lib/arm64-v8a/libcosmosffmpeg.so"
|
||||
|
||||
}
|
||||
compileOptions {
|
||||
sourceCompatibility JavaVersion.VERSION_1_8
|
||||
targetCompatibility JavaVersion.VERSION_1_8
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
keyAlias 'phonelive'
|
||||
keyPassword 'phonelive'
|
||||
storeFile file('../hdl.jks')
|
||||
storePassword 'phonelive'
|
||||
}
|
||||
//陌陌本地配置需要
|
||||
config {//TODO BEAUTYSDK 这里需要配置keystore相关信息
|
||||
keyAlias 'phonelive'
|
||||
keyPassword 'phonelive'
|
||||
storeFile file('../hdl.jks')//keystore的存放路径
|
||||
storePassword 'phonelive'
|
||||
v2SigningEnabled true // android 5.0-8.0,必须用V2,否则会有安全问题
|
||||
v1SigningEnabled true
|
||||
}
|
||||
}
|
||||
aaptOptions {
|
||||
cruncherEnabled = false
|
||||
useNewCruncher = false
|
||||
}
|
||||
|
||||
packagingOptions {//加上这写代码 为了mob兼容性androidx
|
||||
pickFirst 'META-INF/*'
|
||||
}
|
||||
|
||||
|
||||
defaultConfig {
|
||||
// applicationId "myname.pdlive.shayu"
|
||||
applicationId "com.pdlive.shayu"
|
||||
minSdkVersion rootProject.ext.android.minSdkVersion
|
||||
//版本在这里修改
|
||||
targetSdkVersion rootProject.ext.android.targetSdkVersion
|
||||
versionCode rootProject.ext.android.versionCode
|
||||
versionName rootProject.ext.android.versionName
|
||||
manifestPlaceholders = rootProject.ext.manifestPlaceholders
|
||||
multiDexEnabled true
|
||||
ndk {
|
||||
// TODO: 谷歌商城需要兼容两个平台
|
||||
abiFilters "armeabi-v7a", "arm64-v8a"
|
||||
}
|
||||
javaCompileOptions {
|
||||
annotationProcessorOptions {
|
||||
arguments = [AROUTER_MODULE_NAME: project.getName()]
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
debug {
|
||||
signingConfig signingConfigs.release
|
||||
}
|
||||
}
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
abortOnError false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
repositories {
|
||||
flatDir {
|
||||
dirs 'libs', '../libs'
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
|
||||
//直播
|
||||
api project(':main')
|
||||
//短视频
|
||||
api project(':video')
|
||||
annotationProcessor rootProject.ext.dependencies["arouter-compiler"]
|
||||
}
|
||||
70
app/google-services.json
Normal file
70
app/google-services.json
Normal file
@@ -0,0 +1,70 @@
|
||||
{
|
||||
"project_info": {
|
||||
"project_number": "292494634914",
|
||||
"project_id": "pdlive-1631521064967",
|
||||
"storage_bucket": "pdlive-1631521064967.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:292494634914:android:d8db197d7e7a6c3a3a4cfb",
|
||||
"android_client_info": {
|
||||
"package_name": "com.pdlive.shayu"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "292494634914-8nuhhoeo061ki1jevbcsrl7dfdl6dlm0.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "com.pdlive.shayu",
|
||||
"certificate_hash": "38cc19306c9facee36a9224e9a4070bc0be15c7d"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "292494634914-ctr3fptp5mkv2qqr4gkgjo9uluq2joqb.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "com.pdlive.shayu",
|
||||
"certificate_hash": "15fc5e70cf238323bf7111c8c627803985478e87"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "292494634914-ejtqvaj86a2lldv0di2pr3d5gngprahd.apps.googleusercontent.com",
|
||||
"client_type": 1,
|
||||
"android_info": {
|
||||
"package_name": "com.pdlive.shayu",
|
||||
"certificate_hash": "b66dc8d21cfcf6c729577ddcf0c312b2a31ed872"
|
||||
}
|
||||
},
|
||||
{
|
||||
"client_id": "292494634914-ha2kbgtclkv20hl3a1l8r7861a1a0m5i.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyDVnuGnQzjI_vDrxh20Hv_S1OMUD7Vp3zU"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"appinvite_service": {
|
||||
"other_platform_oauth_client": [
|
||||
{
|
||||
"client_id": "292494634914-ha2kbgtclkv20hl3a1l8r7861a1a0m5i.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
},
|
||||
{
|
||||
"client_id": "292494634914-v9j4rei86q2pfh9as4seotb23vr2744a.apps.googleusercontent.com",
|
||||
"client_type": 2,
|
||||
"ios_info": {
|
||||
"bundle_id": "com.live.pd"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
||||
20
app/img_optimizer.log
Normal file
20
app/img_optimizer.log
Normal file
@@ -0,0 +1,20 @@
|
||||
2019-11-01 13:58:25 info: Task optimizeAppRelease begin:
|
||||
----------------------------------------
|
||||
2019-11-01 13:58:25 info: 6 images need to be optimized.
|
||||
----------------------------------------
|
||||
2019-11-01 13:58:25 info: Succeed! 21139B-->2066B, 90.22659% saved! /Users/yaling/Documents/bayue/denglong_release4/app/src/main/res/mipmap-mdpi/ic_launcher.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:58:25 info: Succeed! 22015B-->2465B, 88.803085% saved! /Users/yaling/Documents/bayue/denglong_release4/app/src/main/res/mipmap-hdpi/ic_launcher.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:58:25 info: Succeed! 115988B-->13798B, 88.10394% saved! /Users/yaling/Documents/bayue/denglong_release4/app/src/main/res/mipmap-xxxhdpi/screen.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:58:25 info: Succeed! 37339B-->8295B, 77.78462% saved! /Users/yaling/Documents/bayue/denglong_release4/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:58:25 info: Succeed! 26351B-->4102B, 84.43323% saved! /Users/yaling/Documents/bayue/denglong_release4/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:58:25 info: Succeed! 24070B-->3315B, 86.22767% saved! /Users/yaling/Documents/bayue/denglong_release4/app/src/main/res/mipmap-xhdpi/ic_launcher.png
|
||||
----------------------------------------
|
||||
2019-11-01 13:58:25 info: Total: 6, Succeed: 6, Skipped: 0, Failed: 0, Saved: 207.8720703125KB
|
||||
----------------------------------------
|
||||
2019-11-01 13:58:25 info: Task optimizeAppRelease executed successfully.
|
||||
----------------------------------------
|
||||
37
app/proguard-rules.pro
vendored
Normal file
37
app/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /Users/macpro/Library/Android/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
|
||||
# Uncomment this to preserve the groupLast number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the groupLast number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
-keep class com.adjust.sdk.**{ *; }
|
||||
-keep class com.google.android.gms.common.ConnectionResult {
|
||||
int SUCCESS;
|
||||
}
|
||||
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
|
||||
com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
|
||||
}
|
||||
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
|
||||
java.lang.String getId();
|
||||
boolean isLimitAdTrackingEnabled();
|
||||
}
|
||||
-keep public class com.android.installreferrer.**{ *; }
|
||||
173
app/src/main/AndroidManifest.xml
Normal file
173
app/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,173 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
package="myname.pdlive.shayu">
|
||||
|
||||
<uses-permission
|
||||
android:name="android.permission.CALL_PHONE"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.READ_LOGS"
|
||||
tools:ignore="ProtectedPermissions"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.READ_CALL_LOG"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_CALL_LOG"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.READ_SMS"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.SEND_SMS"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_SMS"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.RECEIVE_SMS"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.RECEIVE_WAP_PUSH"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.RECEIVE_MMS"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.SEND_MMS"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.MODIFY_PHONE_STATE"
|
||||
tools:ignore="ProtectedPermissions"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.PROCESS_OUTGOING_CALLS"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.MODIFY_AUDIO_SETTINGS"
|
||||
tools:node="remove" />
|
||||
<uses-permission
|
||||
android:name="android.permission.QUERY_ALL_PACKAGES"/>
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW" />
|
||||
<uses-permission android:name="android.permission.NETWORK_PROVIDER" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.VIBRATE" />
|
||||
<uses-permission android:name="android.permission.RECORD_AUDIO" />
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.FLASHLIGHT" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission
|
||||
android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
|
||||
<uses-permission android:name="android.permission.REORDER_TASKS" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" />
|
||||
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_SETTINGS"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
|
||||
<uses-permission android:name="com.android.vending.BILLING" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="com.google.android.gms.permission.AD_ID"/>
|
||||
<!-- Android11新增 -->
|
||||
<!-- <uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" />-->
|
||||
|
||||
<application
|
||||
android:name="com.shayu.phonelive.AppContext"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:preserveLegacyExternalStorage="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:theme="@style/AppTheme"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:replace="theme,label,icon,allowBackup">
|
||||
<activity
|
||||
android:name="com.shayu.phonelive.activity.LauncherActivity"
|
||||
android:screenOrientation="portrait"
|
||||
tools:ignore="LockedOrientationActivity">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<category android:name="android.intent.category.BROWSABLE" />
|
||||
|
||||
<data android:scheme="smvslm" />
|
||||
</intent-filter>
|
||||
</activity> <!-- keytool -exportcert -alias androiddebugkey -keystore feixiong.jks | openssl sha1 -binary | openssl base64 -->
|
||||
<meta-data
|
||||
android:name="TencentMapSDK"
|
||||
android:value="${txMapAppKey}" />
|
||||
<!-- <meta-data-->
|
||||
<!-- android:name="TencentMapAppSecret"-->
|
||||
<!-- android:value="${txMapAppSecret}" /> <!– 腾讯bugly –>-->
|
||||
<!-- <meta-data-->
|
||||
<!-- android:name="BUGLY_APPID"-->
|
||||
<!-- android:value="${buglyAppId}" />-->
|
||||
<!-- <meta-data-->
|
||||
<!-- android:name="BUGLY_APP_CHANNEL"-->
|
||||
<!-- android:value="com.chihu.phonelive" />-->
|
||||
<!-- <meta-data-->
|
||||
<!-- android:name="BUGLY_ENABLE_DEBUG"-->
|
||||
<!-- android:value="true" /> <!– 腾讯bugly end –>-->
|
||||
<!-- 百度语音识别 -->
|
||||
<meta-data
|
||||
android:name="com.baidu.speech.APP_ID"
|
||||
android:value="${baiduAppId}" />
|
||||
<meta-data
|
||||
android:name="com.baidu.speech.API_KEY"
|
||||
android:value="${baiduAppKey}" />
|
||||
<meta-data
|
||||
android:name="com.baidu.speech.SECRET_KEY"
|
||||
android:value="${baiduAppSecretKey}" />
|
||||
|
||||
<!-- <service-->
|
||||
<!-- android:name="com.baidu.speech.VoiceRecognitionService"-->
|
||||
<!-- android:exported="false" /> <!– 百度语音识别end –>-->
|
||||
<!-- 友盟统计 -->
|
||||
<!-- <meta-data-->
|
||||
<!-- android:name="UMENG_APPKEY"-->
|
||||
<!-- android:value="${umengAppKey}" />-->
|
||||
<!-- <meta-data-->
|
||||
<!-- android:name="UMENG_CHANNEL"-->
|
||||
<!-- android:value="com.chihu.phonelive" /> <!– 友盟统计 end –>-->
|
||||
<!-- 服务器地址 -->
|
||||
<meta-data
|
||||
android:name="SERVER_HOST"
|
||||
android:value="${serverHost}" />
|
||||
|
||||
<meta-data
|
||||
android:name="IS_GOOGLE_PLAY"
|
||||
android:value="${isGooglePlay}" />
|
||||
|
||||
<meta-data
|
||||
android:name="com.openinstall.APP_KEY"
|
||||
android:value="smvslm" />
|
||||
|
||||
|
||||
<meta-data
|
||||
android:name="com.facebook.sdk.ApplicationId"
|
||||
android:value="@string/facebook_app_id" />
|
||||
<meta-data
|
||||
android:name="com.facebook.sdk.ClientToken"
|
||||
android:value="@string/facebook_client_token" />
|
||||
<meta-data android:name="com.facebook.sdk.AutoLogAppEventsEnabled" android:value="false"/>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
269
app/src/main/java/com/shayu/phonelive/AppContext.java
Normal file
269
app/src/main/java/com/shayu/phonelive/AppContext.java
Normal file
@@ -0,0 +1,269 @@
|
||||
package com.shayu.phonelive;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManager;
|
||||
import android.content.Context;
|
||||
import android.net.http.HttpResponseCache;
|
||||
import android.os.Bundle;
|
||||
import android.os.Message;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.adjust.sdk.Adjust;
|
||||
import com.adjust.sdk.AdjustConfig;
|
||||
import com.adjust.sdk.AdjustEvent;
|
||||
import com.adjust.sdk.LogLevel;
|
||||
import com.alibaba.android.arouter.launcher.ARouter;
|
||||
import com.blankj.utilcode.util.Utils;
|
||||
import com.facebook.appevents.AppEventsLogger;
|
||||
import com.fm.openinstall.OpenInstall;
|
||||
import com.tencent.imsdk.v2.V2TIMGroupMemberInfo;
|
||||
import com.tencent.imsdk.v2.V2TIMManager;
|
||||
import com.tencent.imsdk.v2.V2TIMSimpleMsgListener;
|
||||
import com.tencent.imsdk.v2.V2TIMUserInfo;
|
||||
import com.yunbao.common.BuildConfig;
|
||||
import com.yunbao.common.CommonAppContext;
|
||||
import com.yunbao.common.Constants;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.live.socket.SocketRyClient;
|
||||
import com.yunbao.live.utils.LiveImDeletUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.message.TextMessage;
|
||||
|
||||
import static com.adjust.sdk.AdjustConfig.ENVIRONMENT_PRODUCTION;
|
||||
import static com.yunbao.live.socket.SocketClient.mSocketHandler;
|
||||
|
||||
//import cn.tillusory.sdk.TiSDK;
|
||||
|
||||
//import com.squareup.leakcanary.LeakCanary;
|
||||
|
||||
|
||||
/**
|
||||
* Created by cxf on 2017/8/3.
|
||||
*/
|
||||
|
||||
public class AppContext extends CommonAppContext {
|
||||
|
||||
public static AppContext sInstance;
|
||||
public LiveImDeletUtil liveImDeletUtil;
|
||||
|
||||
private static final class AdjustLifecycleCallbacks implements ActivityLifecycleCallbacks {
|
||||
@Override
|
||||
public void onActivityResumed(Activity activity) {
|
||||
Adjust.onResume();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityPaused(Activity activity) {
|
||||
Adjust.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStopped(@NonNull Activity activity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivitySaveInstanceState(@NonNull Activity activity, @NonNull Bundle outState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityDestroyed(@NonNull Activity activity) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(@NonNull Activity activity, @Nullable Bundle savedInstanceState) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivityStarted(@NonNull Activity activity) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
sInstance = this;
|
||||
L.setDeBug(BuildConfig.DEBUG);
|
||||
AppEventsLogger.activateApp(this);
|
||||
|
||||
File httpCacheDir = new File(getCacheDir(), "https");
|
||||
try {
|
||||
HttpResponseCache.install(httpCacheDir, 1024 * 1024 * 128);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
//初始化 ARouter
|
||||
if (BuildConfig.DEBUG) {
|
||||
ARouter.openLog();
|
||||
ARouter.openDebug();
|
||||
}
|
||||
ARouter.init(this);
|
||||
|
||||
//初始化 邀请码库
|
||||
if (isMainProcess()) {
|
||||
OpenInstall.init(this);
|
||||
}
|
||||
|
||||
String environment = AdjustConfig.ENVIRONMENT_PRODUCTION;
|
||||
AdjustConfig config = new AdjustConfig(this, "3om5fbglyqdc", environment);
|
||||
Adjust.onCreate(config);
|
||||
registerActivityLifecycleCallbacks(new AdjustLifecycleCallbacks());
|
||||
config.setLogLevel(LogLevel.WARN);
|
||||
//激活操作记录
|
||||
AdjustEvent adjustEvent = new AdjustEvent("m7wk0c");
|
||||
Adjust.trackEvent(adjustEvent);
|
||||
|
||||
//谷歌激活
|
||||
mFirebaseAnalytics.logEvent("FS_activation", null);
|
||||
|
||||
//FB激活
|
||||
logger.logEvent("FB_activation");
|
||||
|
||||
AdjustEvent adjustEvent2 = new AdjustEvent("p7igfz");
|
||||
Adjust.trackEvent(adjustEvent2);
|
||||
//谷歌激活
|
||||
mFirebaseAnalytics.logEvent("FS_complete_1st_loading", null);
|
||||
|
||||
//FB激活
|
||||
logger.logEvent("FB_complete_1st_loading");
|
||||
//初始化 AndroidUtilCode
|
||||
Utils.init(this);
|
||||
liveImDeletUtil = new LiveImDeletUtil();
|
||||
// 融云
|
||||
RongIMClient.getInstance().setOnReceiveMessageListener(new RongIMClient.OnReceiveMessageWrapperListener() {
|
||||
/**
|
||||
* 接收实时或者离线消息。
|
||||
* 注意:
|
||||
* 1. 针对接收离线消息时,服务端会将 200 条消息打成一个包发到客户端,客户端对这包数据进行解析。
|
||||
* 2. hasPackage 标识是否还有剩余的消息包,left 标识这包消息解析完逐条抛送给 App 层后,剩余多少条。
|
||||
* 如何判断离线消息收完:
|
||||
* 1. hasPackage 和 left 都为 0;
|
||||
* 2. hasPackage 为 0 标识当前正在接收最后一包(200条)消息,left 为 0 标识最后一包的最后一条消息也已接收完毕。
|
||||
*
|
||||
* @param message 接收到的消息对象
|
||||
* @param left 每个数据包数据逐条上抛后,还剩余的条数
|
||||
* @param hasPackage 是否在服务端还存在未下发的消息包
|
||||
* @param offline 消息是否离线消息
|
||||
* @return 是否处理消息。 如果 App 处理了此消息,返回 true; 否则返回 false 由 SDK 处理。
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean onReceived(io.rong.imlib.model.Message message, int left, boolean hasPackage, boolean offline) {
|
||||
Log.e("rytest", message.getContent() + "");
|
||||
if (message.getConversationType() == Conversation.ConversationType.CHATROOM) {
|
||||
//群聊
|
||||
Message msg = Message.obtain();
|
||||
msg.what = Constants.SOCKET_WHAT_BROADCAST;
|
||||
if (!"".equals(message.getContent()) && message.getContent() != null) {
|
||||
if (message.getObjectName().equals("RC:TxtMsg")) {
|
||||
TextMessage content = (TextMessage) message.getContent();
|
||||
msg.obj = content.getContent();
|
||||
if (SocketRyClient.mSocketHandler != null && Ingroup == 1) {
|
||||
SocketRyClient.mSocketHandler.sendMessage(msg);
|
||||
}
|
||||
TextMessage rongMsg = (TextMessage) message.getContent();
|
||||
String firstIndexRM = "";
|
||||
if (rongMsg.getContent().length() > 4) {
|
||||
firstIndexRM = rongMsg.getContent().substring(0, 5);
|
||||
}
|
||||
String firstIndexRM2 = "";
|
||||
if (rongMsg.getContent().length() > 9) {
|
||||
firstIndexRM2 = rongMsg.getContent().substring(0, 10);
|
||||
}
|
||||
if ("{\"msg".equals(firstIndexRM) || "{\"retcode\"".equals(firstIndexRM2)) {
|
||||
liveImDeletUtil.deleteMessages(message.getTargetId(), message.getMessageId());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
//私聊
|
||||
Message msg = Message.obtain();
|
||||
msg.what = Constants.SOCKET_WHAT_BROADCAST;
|
||||
if (!"".equals(message.getContent()) && message.getContent() != null) {
|
||||
if (message.getObjectName().equals("RC:TxtMsg")) {
|
||||
TextMessage content = (TextMessage) message.getContent();
|
||||
msg.obj = content.getContent();
|
||||
if (content.getContent().contains("_method_")) {
|
||||
if (SocketRyClient.mSocketHandler != null) {
|
||||
CommonAppContext.Ingroup = 1;
|
||||
SocketRyClient.mSocketHandler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
TextMessage rongMsg = (TextMessage) message.getContent();
|
||||
String firstIndexRM = "";
|
||||
if (rongMsg.getContent().length() > 4) {
|
||||
firstIndexRM = rongMsg.getContent().substring(0, 5);
|
||||
}
|
||||
String firstIndexRM2 = "";
|
||||
if (rongMsg.getContent().length() > 9) {
|
||||
firstIndexRM2 = rongMsg.getContent().substring(0, 10);
|
||||
}
|
||||
if ("{\"msg".equals(firstIndexRM) || "{\"retcode\"".equals(firstIndexRM2)) {
|
||||
liveImDeletUtil.deleteMessages(message.getTargetId(), message.getMessageId());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
//监听im消息
|
||||
V2TIMManager.getInstance().addSimpleMsgListener(new V2TIMSimpleMsgListener() {
|
||||
@Override
|
||||
public void onRecvGroupTextMessage(String msgID, String groupID, V2TIMGroupMemberInfo sender, String text) {
|
||||
super.onRecvGroupTextMessage(msgID, groupID, sender, text);
|
||||
Log.e("asasas", text);
|
||||
Message msg = Message.obtain();
|
||||
msg.what = Constants.SOCKET_WHAT_BROADCAST;
|
||||
msg.obj = text;
|
||||
if (mSocketHandler != null && Ingroup == 1) {
|
||||
mSocketHandler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecvC2CTextMessage(String msgID, V2TIMUserInfo sender, String text) {
|
||||
super.onRecvC2CTextMessage(msgID, sender, text);
|
||||
Message msg = Message.obtain();
|
||||
msg.what = Constants.SOCKET_WHAT_BROADCAST;
|
||||
msg.obj = text;
|
||||
if (mSocketHandler != null) {
|
||||
CommonAppContext.Ingroup = 1;
|
||||
mSocketHandler.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
public boolean isMainProcess() {
|
||||
int pid = android.os.Process.myPid();
|
||||
ActivityManager activityManager = (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
|
||||
for (ActivityManager.RunningAppProcessInfo appProcess : activityManager.getRunningAppProcesses()) {
|
||||
if (appProcess.pid == pid) {
|
||||
return getApplicationInfo().packageName.equals(appProcess.processName);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,524 @@
|
||||
package com.shayu.phonelive.activity;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import com.adjust.sdk.Adjust;
|
||||
import com.adjust.sdk.AdjustEvent;
|
||||
import com.alibaba.android.arouter.facade.annotation.Route;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.tencent.rtmp.ITXLivePlayListener;
|
||||
import com.tencent.rtmp.TXLiveBase;
|
||||
import com.tencent.rtmp.TXLiveConstants;
|
||||
import com.tencent.rtmp.TXLivePlayer;
|
||||
import com.tencent.rtmp.ui.TXCloudVideoView;
|
||||
import com.tencent.ugc.TXUGCBase;
|
||||
import com.yunbao.common.CommonAppConfig;
|
||||
import com.yunbao.common.bean.AdBean;
|
||||
import com.yunbao.common.bean.ConfigBean;
|
||||
import com.yunbao.common.bean.UserBean;
|
||||
import com.yunbao.common.custom.CircleProgress;
|
||||
import com.yunbao.common.glide.ImgLoader;
|
||||
import com.yunbao.common.http.CommonHttpConsts;
|
||||
import com.yunbao.common.http.CommonHttpUtil;
|
||||
import com.yunbao.common.interfaces.CommonCallback;
|
||||
import com.yunbao.common.utils.DownloadUtil;
|
||||
import com.yunbao.common.utils.L;
|
||||
import com.yunbao.common.utils.MD5Util;
|
||||
import com.yunbao.common.utils.RouteUtil;
|
||||
import com.yunbao.common.utils.SpUtil;
|
||||
import com.yunbao.common.utils.ToastUtil;
|
||||
import com.yunbao.common.utils.WordUtil;
|
||||
import com.yunbao.live.views.LauncherAdViewHolder;
|
||||
import com.yunbao.main.activity.EntryActivity;
|
||||
import com.yunbao.main.activity.MainActivity;
|
||||
import com.yunbao.main.http.MainHttpConsts;
|
||||
import com.yunbao.main.http.MainHttpUtil;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import myname.pdlive.shayu.R;
|
||||
|
||||
import static com.yunbao.common.CommonAppContext.logger;
|
||||
import static com.yunbao.common.CommonAppContext.mFirebaseAnalytics;
|
||||
|
||||
/**
|
||||
* Created by cxf on 2018/9/17.
|
||||
*/
|
||||
@Route(path = RouteUtil.PATH_LAUNCHER)
|
||||
public class LauncherActivity extends AppCompatActivity implements View.OnClickListener {
|
||||
|
||||
private static final String TAG = "LauncherActivity";
|
||||
private static final int WHAT_GET_CONFIG = 0;
|
||||
private static final int WHAT_COUNT_DOWN = 1;
|
||||
private Handler mHandler;
|
||||
protected Context mContext;
|
||||
private ViewGroup mRoot;
|
||||
private ImageView mCover;
|
||||
private ViewGroup mContainer;
|
||||
private CircleProgress mCircleProgress;
|
||||
private List<AdBean> mAdList;
|
||||
private List<ImageView> mImageViewList;
|
||||
private int mMaxProgressVal;
|
||||
private int mCurProgressVal;
|
||||
private int mAdIndex;
|
||||
private int mInterval = 2000;
|
||||
private View mBtnSkipImage;
|
||||
private View mBtnSkipVideo;
|
||||
private TXCloudVideoView mTXCloudVideoView;
|
||||
private TXLivePlayer mPlayer;
|
||||
private LauncherAdViewHolder mLauncherAdViewHolder;
|
||||
private boolean mPaused;
|
||||
private int mVideoLastProgress;
|
||||
private boolean mForward;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setStatusBar();
|
||||
// if ((getIntent().getFlags() & Intent.FLAG_ACTIVITY_BROUGHT_TO_FRONT) != 0) {
|
||||
// finish();
|
||||
// return;
|
||||
// }
|
||||
setContentView(R.layout.activity_launcher);
|
||||
//开屏
|
||||
AdjustEvent adjustEvent = new AdjustEvent("vjqk8g");
|
||||
Adjust.trackEvent(adjustEvent);
|
||||
|
||||
//谷歌激活
|
||||
mFirebaseAnalytics.logEvent("FS_screen", null);
|
||||
//FB激活
|
||||
logger.logEvent("FB_screen");
|
||||
mContext = this;
|
||||
mRoot = findViewById(R.id.root);
|
||||
mCover = findViewById(R.id.cover);
|
||||
mCircleProgress = findViewById(R.id.progress);
|
||||
mContainer = findViewById(R.id.container);
|
||||
mBtnSkipImage = findViewById(R.id.btn_skip_img);
|
||||
mBtnSkipVideo = findViewById(R.id.btn_skip_video);
|
||||
mBtnSkipImage.setOnClickListener(this);
|
||||
mBtnSkipVideo.setOnClickListener(this);
|
||||
ImgLoader.display(mContext, R.mipmap.screen, mCover);
|
||||
mHandler = new Handler() {
|
||||
@Override
|
||||
public void handleMessage(Message msg) {
|
||||
switch (msg.what) {
|
||||
case WHAT_GET_CONFIG:
|
||||
getConfig();
|
||||
break;
|
||||
case WHAT_COUNT_DOWN:
|
||||
updateCountDown();
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
mHandler.sendEmptyMessageDelayed(WHAT_GET_CONFIG, 1000);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 图片倒计时
|
||||
*/
|
||||
private void updateCountDown() {
|
||||
mCurProgressVal += 100;
|
||||
if (mCurProgressVal > mMaxProgressVal) {
|
||||
return;
|
||||
}
|
||||
if (mCircleProgress != null) {
|
||||
mCircleProgress.setCurProgress(mCurProgressVal);
|
||||
}
|
||||
int index = mCurProgressVal / mInterval;
|
||||
if (index < mAdList.size() && mAdIndex != index) {
|
||||
View v = mImageViewList.get(mAdIndex);
|
||||
if (v != null && v.getVisibility() == View.VISIBLE) {
|
||||
v.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
mAdIndex = mCurProgressVal / mInterval;
|
||||
}
|
||||
if (mCurProgressVal < mMaxProgressVal) {
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessageDelayed(WHAT_COUNT_DOWN, 100);
|
||||
}
|
||||
} else if (mCurProgressVal == mMaxProgressVal) {
|
||||
checkUidAndToken();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取Config信息
|
||||
*/
|
||||
private void getConfig() {
|
||||
CommonHttpUtil.getConfig(mContext, new CommonCallback<ConfigBean>() {
|
||||
@Override
|
||||
public void callback(ConfigBean bean) {
|
||||
if (bean != null) {
|
||||
L.e(TAG, "----------> getPaster360Url:" + bean.getBeautyKey() + " " + bean.getPaster360Url());
|
||||
CommonAppConfig.getInstance().setBeautySdkType(bean.getSproutType());
|
||||
//转盘开关
|
||||
CommonAppConfig.getInstance().setTurnTableEnable(bean.getTurntableEnable());
|
||||
CommonAppConfig.getInstance().setBeauty360TieZhiUrl(bean.getPaster360Url());
|
||||
CommonAppConfig.getInstance().setAnchorPkTime(bean.getPkTime());
|
||||
if (!TextUtils.isEmpty(bean.getTxVideoUgcLicenceUrl()) && !TextUtils.isEmpty(bean.getTxVideoUgcKey()))
|
||||
Log.i("tvv", bean.getTxVideoUgcLicenceUrl() + "是" + bean.getTxVideoUgcKey());
|
||||
TXLiveBase.getInstance().setLicence(LauncherActivity.this, bean.getTxVideoUgcLicenceUrl(), bean.getTxVideoUgcKey());
|
||||
TXUGCBase.getInstance().setLicence(LauncherActivity.this, bean.getTxPlayUgcLicenceUrl(), bean.getTxVideoUgcKey());
|
||||
|
||||
String adInfo = bean.getAdInfo();
|
||||
if (!TextUtils.isEmpty(adInfo)) {
|
||||
JSONObject obj = JSON.parseObject(adInfo);
|
||||
if (obj.getIntValue("switch") == 1) {
|
||||
List<AdBean> list = JSON.parseArray(obj.getString("list"), AdBean.class);
|
||||
if (list != null && list.size() > 0) {
|
||||
mAdList = list;
|
||||
mInterval = obj.getIntValue("time") * 1000;
|
||||
if (mContainer != null) {
|
||||
mContainer.setOnClickListener(LauncherActivity.this);
|
||||
}
|
||||
String[] uidAndToken = SpUtil.getInstance().getMultiStringValue(
|
||||
new String[]{SpUtil.UID, SpUtil.TOKEN});
|
||||
final String uid = uidAndToken[0];
|
||||
final String token = uidAndToken[1];
|
||||
if (!TextUtils.isEmpty(uid) && !TextUtils.isEmpty(token)) {
|
||||
playAD(obj.getIntValue("type") == 0);
|
||||
} else {
|
||||
releaseVideo();
|
||||
LauncherActivity.this.startActivity(new Intent(LauncherActivity.this, EntryActivity.class));
|
||||
LauncherActivity.this.finish();
|
||||
}
|
||||
} else {
|
||||
checkUidAndToken();
|
||||
}
|
||||
} else {
|
||||
checkUidAndToken();
|
||||
}
|
||||
} else {
|
||||
checkUidAndToken();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查uid和token是否存在
|
||||
*/
|
||||
private void checkUidAndToken() {
|
||||
if (mForward) {
|
||||
return;
|
||||
}
|
||||
mForward = true;
|
||||
if (mHandler != null) {
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
mHandler = null;
|
||||
}
|
||||
String[] uidAndToken = SpUtil.getInstance().getMultiStringValue(
|
||||
new String[]{SpUtil.UID, SpUtil.TOKEN});
|
||||
final String uid = uidAndToken[0];
|
||||
final String token = uidAndToken[1];
|
||||
if (!TextUtils.isEmpty(uid) && !TextUtils.isEmpty(token)) {
|
||||
MainHttpUtil.getBaseInfo(uid, token, new CommonCallback<UserBean>() {
|
||||
@Override
|
||||
public void callback(UserBean bean) {
|
||||
if (bean != null) {
|
||||
CommonAppConfig.getInstance().setLoginInfo(uid, token, false);
|
||||
forwardMainActivity();
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
releaseVideo();
|
||||
this.startActivity(new Intent(this, EntryActivity.class));
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 跳转到首页
|
||||
*/
|
||||
private void forwardMainActivity() {
|
||||
releaseVideo();
|
||||
MainActivity.forward(mContext);
|
||||
// this.startActivity(new Intent(this, TestActivity.class));
|
||||
finish();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
if (mHandler != null) {
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
mHandler = null;
|
||||
}
|
||||
MainHttpUtil.cancel(MainHttpConsts.GET_BASE_INFO);
|
||||
CommonHttpUtil.cancel(CommonHttpConsts.GET_CONFIG);
|
||||
releaseVideo();
|
||||
if (mLauncherAdViewHolder != null) {
|
||||
mLauncherAdViewHolder.release();
|
||||
}
|
||||
mLauncherAdViewHolder = null;
|
||||
super.onDestroy();
|
||||
L.e(TAG, "----------> onDestroy");
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置透明状态栏
|
||||
*/
|
||||
private void setStatusBar() {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
Window window = getWindow();
|
||||
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
|
||||
window.getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
|
||||
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
|
||||
window.setStatusBarColor(0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
int i = v.getId();
|
||||
if (i == R.id.btn_skip_img || i == R.id.btn_skip_video) {
|
||||
if (mBtnSkipImage != null) {
|
||||
mBtnSkipImage.setClickable(false);
|
||||
}
|
||||
if (mBtnSkipVideo != null) {
|
||||
mBtnSkipVideo.setClickable(false);
|
||||
}
|
||||
checkUidAndToken();
|
||||
} else if (i == R.id.container) {
|
||||
clickAD();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击广告
|
||||
*/
|
||||
private void clickAD() {
|
||||
if (mAdList != null && mAdList.size() > mAdIndex) {
|
||||
AdBean adBean = mAdList.get(mAdIndex);
|
||||
if (adBean != null) {
|
||||
String link = adBean.getLink();
|
||||
if (!TextUtils.isEmpty(link)) {
|
||||
if (mHandler != null) {
|
||||
mHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
if (mContainer != null) {
|
||||
mContainer.setClickable(false);
|
||||
}
|
||||
releaseVideo();
|
||||
if (mLauncherAdViewHolder == null) {
|
||||
mLauncherAdViewHolder = new LauncherAdViewHolder(mContext, mRoot, link + "?uid=" + CommonAppConfig.getInstance().getUid() + "&token=" + CommonAppConfig.getInstance().getToken());
|
||||
mLauncherAdViewHolder.addToParent();
|
||||
mLauncherAdViewHolder.loadData();
|
||||
mLauncherAdViewHolder.show();
|
||||
mLauncherAdViewHolder.setActionListener(new LauncherAdViewHolder.ActionListener() {
|
||||
@Override
|
||||
public void onHideClick() {
|
||||
checkUidAndToken();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void releaseVideo() {
|
||||
if (mPlayer != null) {
|
||||
mPlayer.stopPlay(false);
|
||||
mPlayer.setPlayListener(null);
|
||||
}
|
||||
mPlayer = null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 播放广告
|
||||
*/
|
||||
private void playAD(boolean isImage) {
|
||||
if (mContainer == null) {
|
||||
return;
|
||||
}
|
||||
if (isImage) {
|
||||
int imgSize = mAdList.size();
|
||||
if (imgSize > 0) {
|
||||
mImageViewList = new ArrayList<>();
|
||||
for (int i = 0; i < imgSize; i++) {
|
||||
ImageView imageView = new ImageView(mContext);
|
||||
imageView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
imageView.setBackgroundColor(0xffffffff);
|
||||
mImageViewList.add(imageView);
|
||||
ImgLoader.display(mContext, mAdList.get(i).getUrl(), imageView);
|
||||
}
|
||||
for (int i = imgSize - 1; i >= 0; i--) {
|
||||
mContainer.addView(mImageViewList.get(i));
|
||||
}
|
||||
if (mBtnSkipImage != null && mBtnSkipImage.getVisibility() != View.VISIBLE) {
|
||||
mBtnSkipImage.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mMaxProgressVal = imgSize * mInterval;
|
||||
if (mCircleProgress != null) {
|
||||
mCircleProgress.setMaxProgress(mMaxProgressVal);
|
||||
}
|
||||
if (mHandler != null) {
|
||||
mHandler.sendEmptyMessageDelayed(WHAT_COUNT_DOWN, 100);
|
||||
}
|
||||
if (mCover != null && mCover.getVisibility() == View.VISIBLE) {
|
||||
mCover.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
} else {
|
||||
checkUidAndToken();
|
||||
}
|
||||
} else {
|
||||
if (mAdList == null || mAdList.size() == 0) {
|
||||
checkUidAndToken();
|
||||
return;
|
||||
}
|
||||
String videoUrl = mAdList.get(0).getUrl();
|
||||
if (TextUtils.isEmpty(videoUrl)) {
|
||||
checkUidAndToken();
|
||||
return;
|
||||
}
|
||||
String videoFileName = MD5Util.getMD5(videoUrl);
|
||||
if (TextUtils.isEmpty(videoFileName)) {
|
||||
checkUidAndToken();
|
||||
return;
|
||||
}
|
||||
File file = new File(getCacheDir(), videoFileName);
|
||||
if (file.exists()) {
|
||||
playAdVideo(file);
|
||||
} else {
|
||||
downloadAdFile(videoUrl, videoFileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPause() {
|
||||
mPaused = true;
|
||||
if (mPlayer != null && mPlayer.isPlaying()) {
|
||||
mPlayer.setMute(true);
|
||||
}
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if (mPaused) {
|
||||
if (mPlayer != null && mPlayer.isPlaying()) {
|
||||
mPlayer.setMute(false);
|
||||
}
|
||||
}
|
||||
mPaused = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载视频
|
||||
*/
|
||||
private void downloadAdFile(String url, String fileName) {
|
||||
DownloadUtil downloadUtil = new DownloadUtil();
|
||||
downloadUtil.download("ad_video", getCacheDir(), fileName, url, new DownloadUtil.Callback() {
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
playAdVideo(file);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(int progress) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
checkUidAndToken();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 播放视频
|
||||
*/
|
||||
private void playAdVideo(File videoFile) {
|
||||
if (mBtnSkipVideo != null && mBtnSkipVideo.getVisibility() != View.VISIBLE) {
|
||||
mBtnSkipVideo.setVisibility(View.VISIBLE);
|
||||
}
|
||||
mTXCloudVideoView = new TXCloudVideoView(mContext);
|
||||
mTXCloudVideoView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
mTXCloudVideoView.setRenderMode(TXLiveConstants.RENDER_MODE_FULL_FILL_SCREEN);
|
||||
mContainer.addView(mTXCloudVideoView);
|
||||
mPlayer = new TXLivePlayer(mContext);
|
||||
mPlayer.setPlayerView(mTXCloudVideoView);
|
||||
mPlayer.setAutoPlay(true);
|
||||
mPlayer.setPlayListener(new ITXLivePlayListener() {
|
||||
@Override
|
||||
public void onPlayEvent(int e, Bundle bundle) {
|
||||
if (e == TXLiveConstants.PLAY_EVT_PLAY_END) {//获取到视频播放完毕的回调
|
||||
checkUidAndToken();
|
||||
L.e(TAG, "视频播放结束------>");
|
||||
} else if (e == TXLiveConstants.PLAY_EVT_CHANGE_RESOLUTION) {////获取到视频宽高回调
|
||||
float videoWidth = bundle.getInt("EVT_PARAM1", 0);
|
||||
float videoHeight = bundle.getInt("EVT_PARAM2", 0);
|
||||
if (mTXCloudVideoView != null && videoWidth > 0 && videoHeight > 0) {
|
||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) mTXCloudVideoView.getLayoutParams();
|
||||
int targetH = 0;
|
||||
if (videoWidth >= videoHeight) {//横屏
|
||||
params.gravity = Gravity.CENTER_VERTICAL;
|
||||
targetH = (int) (mTXCloudVideoView.getWidth() / videoWidth * videoHeight);
|
||||
} else {
|
||||
targetH = ViewGroup.LayoutParams.MATCH_PARENT;
|
||||
}
|
||||
if (targetH != params.height) {
|
||||
params.height = targetH;
|
||||
mTXCloudVideoView.requestLayout();
|
||||
}
|
||||
}
|
||||
} else if (e == TXLiveConstants.PLAY_EVT_RCV_FIRST_I_FRAME) {
|
||||
if (mCover != null && mCover.getVisibility() == View.VISIBLE) {
|
||||
mCover.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
} else if (e == TXLiveConstants.PLAY_ERR_NET_DISCONNECT ||
|
||||
e == TXLiveConstants.PLAY_ERR_FILE_NOT_FOUND) {
|
||||
ToastUtil.show(WordUtil.getString(R.string.live_play_error));
|
||||
checkUidAndToken();
|
||||
} else if (e == TXLiveConstants.PLAY_EVT_PLAY_PROGRESS) {
|
||||
int progress = bundle.getInt("EVT_PLAY_PROGRESS_MS");
|
||||
if (mVideoLastProgress == progress) {
|
||||
L.e(TAG, "视频播放结束------>");
|
||||
checkUidAndToken();
|
||||
} else {
|
||||
mVideoLastProgress = progress;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNetStatus(Bundle bundle) {
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
mPlayer.startPlay(videoFile.getAbsolutePath(), TXLivePlayer.PLAY_TYPE_LOCAL_VIDEO);
|
||||
}
|
||||
}
|
||||
4
app/src/main/res/drawable/bg_launcher_skip.xml
Normal file
4
app/src/main/res/drawable/bg_launcher_skip.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape android:shape="oval" xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<solid android:color="#80000000"/>
|
||||
</shape>
|
||||
6
app/src/main/res/drawable/bg_launcher_skip_2.xml
Normal file
6
app/src/main/res/drawable/bg_launcher_skip_2.xml
Normal file
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<shape xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<corners android:radius="12sp"/>
|
||||
<stroke android:color="@color/white" android:width="1dp"/>
|
||||
<solid android:color="#80000000"/>
|
||||
</shape>
|
||||
64
app/src/main/res/layout/activity_launcher.xml
Normal file
64
app/src/main/res/layout/activity_launcher.xml
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/root"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#000" />
|
||||
|
||||
<FrameLayout
|
||||
android:id="@+id/btn_skip_img"
|
||||
android:layout_width="40dp"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginTop="37dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:background="@drawable/bg_launcher_skip"
|
||||
android:visibility="invisible">
|
||||
|
||||
<com.yunbao.common.custom.CircleProgress
|
||||
android:id="@+id/progress"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
app:cp_bg_color="@color/white"
|
||||
app:cp_cur_progress="0"
|
||||
app:cp_fg_color="#ff7200"
|
||||
app:cp_stroke_width="2dp" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:gravity="center"
|
||||
android:text="@string/recommend_skip"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="11sp" />
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/btn_skip_video"
|
||||
android:layout_width="44dp"
|
||||
android:layout_height="26dp"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginTop="37dp"
|
||||
android:layout_marginRight="15dp"
|
||||
android:background="@drawable/bg_launcher_skip_2"
|
||||
android:gravity="center"
|
||||
android:text="@string/recommend_skip"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="11sp"
|
||||
android:visibility="invisible" />
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/cover"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:clickable="true"
|
||||
android:scaleType="centerCrop" />
|
||||
</FrameLayout>
|
||||
|
||||
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-hdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.8 KiB |
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-mdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.1 KiB |
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-xhdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.7 KiB |
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
BIN
app/src/main/res/mipmap-xxhdpi/ic_launcher.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.7 KiB |
BIN
app/src/main/res/mipmap-xxxhdpi/screen.png
Normal file
BIN
app/src/main/res/mipmap-xxxhdpi/screen.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 586 KiB |
4
app/src/main/res/values/strings.xml
Normal file
4
app/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">PDLIVE</string>
|
||||
</resources>
|
||||
Reference in New Issue
Block a user