基线备份:thirdparty 变体完成 + Android 4.2 兼容改造前
包含内容: - thirdparty flavor 独立 applicationId + Intent 入口(ThirdPartyEntryActivity) - 58 后端接口适配(单 /api 路径、code 0/200、camelCase 字段、UNBOUND 轮询) - MAC 硬件锚定校验(防一凭证多设备共用) - EPG mac 覆盖 SDK init(sMacOverride)+ ChannelManger 初始化对齐 - 提示文案优化(设备未注册/权益未绑定)
This commit is contained in:
1
app/.gitignore
vendored
Executable file
1
app/.gitignore
vendored
Executable file
@@ -0,0 +1 @@
|
||||
/build
|
||||
303
app/build.gradle
Executable file
303
app/build.gradle
Executable file
@@ -0,0 +1,303 @@
|
||||
import com.android.build.api.variant.BuildConfigField
|
||||
|
||||
plugins {
|
||||
id 'com.android.application'
|
||||
id 'org.jetbrains.kotlin.android'
|
||||
id 'com.google.devtools.ksp'
|
||||
}
|
||||
|
||||
android {
|
||||
namespace 'com.pukka.jiecheng'
|
||||
compileSdk app_android.compileSdkVersion
|
||||
buildFeatures {
|
||||
buildConfig = true
|
||||
}
|
||||
lintOptions {
|
||||
checkReleaseBuilds false
|
||||
abortOnError false
|
||||
}
|
||||
def versionSuffix = "0" // 定义版本后缀变量,必须小于或等于9大于0
|
||||
defaultConfig {
|
||||
applicationId "tv.huashi.jetsenx.jetsenfilx.jsttv"
|
||||
minSdk app_android.minSdkVersion
|
||||
targetSdk app_android.targetSdkVersion
|
||||
versionCode Integer.parseInt(new Date().format("yyMMddHH") + versionSuffix)
|
||||
versionName "v1.3.28"
|
||||
multiDexEnabled true
|
||||
//压缩语言种类,目前只支持中文语言
|
||||
resConfigs('zh-rCN')
|
||||
|
||||
// Define flavor dimensions
|
||||
flavorDimensions "channel", "control"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
//酒店 ANNING 安柠 AISHI 爱视(不要手柄)
|
||||
buildConfigField "String", "HOTEL_TYPE", "\"AISHI\""
|
||||
//首页是否包含我的页面 默认是包含 true,去掉 false 当前只有特殊爱视酒店版本不包含
|
||||
buildConfigField "boolean", "NEED_MY", "true"
|
||||
//是否需要激活码 扫码版下 as8Code 覆盖为 false
|
||||
buildConfigField "boolean", "NEED_ACTIVATION_CODE", "true"
|
||||
//是否为扫码变体(as8Scan 覆盖为 true;asAScan 同样覆盖为 true)
|
||||
buildConfigField "boolean", "SCAN_VARIANT", "false"
|
||||
buildConfigField "String", "BUGLY_APP_ID", "\"01f1b10fca\""
|
||||
//是否为第三方变体(thirdparty flavor 覆盖为 true)
|
||||
buildConfigField "boolean", "THIRDPARTY_VARIANT", "false"
|
||||
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a", "arm64-v8a"
|
||||
}
|
||||
}
|
||||
signingConfigs {
|
||||
release {
|
||||
storeFile file('key/jiecheng.jks')
|
||||
storePassword 'abc@123'
|
||||
keyAlias 'key0'
|
||||
keyPassword 'abc@123'
|
||||
}
|
||||
preview {
|
||||
storeFile file('key/jiecheng.jks')
|
||||
storePassword 'abc@123'
|
||||
keyAlias 'key0'
|
||||
keyPassword 'abc@123'
|
||||
}
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
// AS 域 baseUrl:release 走线上域名
|
||||
buildConfigField "String", "AS_BASE_URL", "\"https://jst.ainetv.cn/api/\""
|
||||
//是否开启混淆
|
||||
minifyEnabled false
|
||||
shrinkResources false
|
||||
zipAlignEnabled true // 是否开启zip压缩
|
||||
signingConfig signingConfigs.release
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
|
||||
// preview {
|
||||
// // AS 域 baseUrl:preview 走预发域名
|
||||
// buildConfigField "String", "AS_BASE_URL", "\"https://jst-test.ainetv.cn/api/\""
|
||||
// minifyEnabled false
|
||||
// shrinkResources false
|
||||
// zipAlignEnabled true // 是否开启zip压缩
|
||||
// signingConfig signingConfigs.release
|
||||
// proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
//// matchingFallbacks = ['release', 'debug']
|
||||
// }
|
||||
|
||||
debug {
|
||||
// AS 域 baseUrl:debug 走测试/内网域名
|
||||
buildConfigField "String", "AS_BASE_URL", "\"https://jst-test.ainetv.cn/api/\"" //http://as-partner-end.172.16.100.110.sslip.io/
|
||||
minifyEnabled false
|
||||
shrinkResources false
|
||||
zipAlignEnabled true // 是否开启zip压缩
|
||||
signingConfig signingConfigs.release
|
||||
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
|
||||
// Configure product flavors
|
||||
productFlavors {
|
||||
// --- Dimension: Control (Interaction Mode) ---
|
||||
touch {
|
||||
dimension "control"
|
||||
buildConfigField "boolean", "IS_TOUCH_MODE", "true"
|
||||
}
|
||||
|
||||
remote {
|
||||
dimension "control"
|
||||
buildConfigField "boolean", "IS_TOUCH_MODE", "false"
|
||||
}
|
||||
|
||||
// --- Dimension: Channel ---
|
||||
// Default base channel (Aishi)
|
||||
aishi {
|
||||
dimension "channel"
|
||||
manifestPlaceholders = [
|
||||
APP_CHANNEL_ID : "aishi",
|
||||
splash_theme : "@style/SplashTheme"]
|
||||
buildConfigField "String", "CHANNEL_ID", "\"AS\""
|
||||
}
|
||||
|
||||
ruigeer {
|
||||
dimension "channel"
|
||||
manifestPlaceholders = [
|
||||
APP_CHANNEL_ID : "ruigeer",
|
||||
splash_theme : "@style/SplashTheme"]
|
||||
//隐藏我的页面
|
||||
buildConfigField "boolean", "NEED_MY", "false"
|
||||
buildConfigField "String", "CHANNEL_ID", "\"RG\""
|
||||
}
|
||||
|
||||
ceshi {
|
||||
dimension "channel"
|
||||
manifestPlaceholders = [
|
||||
APP_CHANNEL_ID : "ceshi",
|
||||
splash_theme : "@style/SplashTheme"]
|
||||
//隐藏我的页面
|
||||
// buildConfigField "boolean", "NEED_MY", "false"
|
||||
buildConfigField "String", "CHANNEL_ID", "\"TS\""
|
||||
}
|
||||
|
||||
// --- aishi 子方向:扫码版(无激活码 默认 8888 的激活码) ---
|
||||
// 共享 aishi 渠道路由(X-Channel-Id="AS"),仅客户端激活流程差异
|
||||
as8Scan {
|
||||
dimension "channel"
|
||||
manifestPlaceholders = [
|
||||
APP_CHANNEL_ID : "aishi",
|
||||
splash_theme : "@style/SplashTheme"]
|
||||
buildConfigField "String", "CHANNEL_ID", "\"AS\""
|
||||
buildConfigField "boolean", "NEED_ACTIVATION_CODE", "false"
|
||||
buildConfigField "boolean", "SCAN_VARIANT", "true"
|
||||
}
|
||||
|
||||
// --- aishi 子方向:激活扫码版(有激活码) ---
|
||||
// 保留 NEED_ACTIVATION_CODE=true(年卡业务默认值),但额外打 SCAN_VARIANT=true:
|
||||
// /api/jst/check 在「已激活 无权益码」分支可能不返回 10900,而是其他 Activated 等价 code,
|
||||
// 此时 thirdCardNo 为空属于合法终态,不应弹"缺少设备码"。
|
||||
asAScan {
|
||||
dimension "channel"
|
||||
manifestPlaceholders = [
|
||||
APP_CHANNEL_ID : "aishi",
|
||||
splash_theme : "@style/SplashTheme"]
|
||||
buildConfigField "String", "CHANNEL_ID", "\"AS\""
|
||||
buildConfigField "boolean", "SCAN_VARIANT", "true"
|
||||
}
|
||||
|
||||
// --- 第三方渠道(thirdparty) ---
|
||||
thirdparty {
|
||||
dimension "channel"
|
||||
applicationIdSuffix ".thirdparty"
|
||||
manifestPlaceholders = [
|
||||
APP_CHANNEL_ID : "thirdparty",
|
||||
splash_theme : "@style/SplashTheme"]
|
||||
buildConfigField "String", "CHANNEL_ID", "\"TP\""
|
||||
buildConfigField "boolean", "THIRDPARTY_VARIANT", "true"
|
||||
// 注意:AS_BASE_URL 不能在此处覆盖,buildType 的 buildConfigField 优先级更高会将其覆盖。
|
||||
// 第三方域名通过下方 androidComponents.onVariants 设置(Variant API 优先级最高)。
|
||||
}
|
||||
|
||||
// Add more channels to this list as needed
|
||||
// def channelList = ["q1"]
|
||||
// channelList.each { name ->
|
||||
// create(name) {
|
||||
// dimension "channel"
|
||||
// manifestPlaceholders = [
|
||||
// APP_CHANNEL_ID : name,
|
||||
// splash_theme : "@style/SplashTheme"]
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
android.applicationVariants.all {
|
||||
variant ->
|
||||
variant.outputs.all {
|
||||
output ->
|
||||
if (outputFileName != null && outputFileName.contains('.apk')) {
|
||||
def datetime = String.valueOf(new Date().format("yyyyMMddHHmm"))
|
||||
// Naming format: Jetsenx_APK_<BuildType>_<Flavor>_<Date>.apk
|
||||
//outputFileName = "Jetsenx_APK_${variant.buildType.name}_${variant.name}_${datetime}.apk"
|
||||
outputFileName = "Jetsenx_${variant.versionName}_${variant.name}_${variant.versionCode}.apk"
|
||||
}
|
||||
}
|
||||
}
|
||||
compileOptions {
|
||||
encoding "UTF-8"
|
||||
sourceCompatibility JavaVersion.VERSION_17
|
||||
targetCompatibility JavaVersion.VERSION_17
|
||||
}
|
||||
kotlinOptions {
|
||||
jvmTarget = '17'
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
jniLibs.srcDirs = ['libs']
|
||||
}
|
||||
// Standard Gradle directory structure is used:
|
||||
// src/main/res -> Common resources
|
||||
// src/aishi/res -> Aishi channel resources
|
||||
// src/q1/res -> Q1 channel resources
|
||||
// src/touch/res -> Touch mode resources
|
||||
// src/remote/res -> Remote mode resources
|
||||
}
|
||||
}
|
||||
|
||||
// 第三方变体 AS_BASE_URL 覆盖:
|
||||
// buildType 的 buildConfigField 优先级高于 flavor,因此 thirdparty flavor 内直接设置会被
|
||||
// debug/release buildType 覆盖为 jst-test/jst.ainetv.cn。Variant API 的优先级最高,在此统一覆盖。
|
||||
androidComponents {
|
||||
onVariants(selector().withFlavor("channel", "thirdparty")) { variant ->
|
||||
variant.buildConfigFields.put(
|
||||
"AS_BASE_URL",
|
||||
new BuildConfigField("String", "\"http://58.220.83.58:8084/\"", null)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dependencies {
|
||||
|
||||
app_base_dependencies.each { k, v -> implementation v }
|
||||
app_app_dependencies.each { k, v -> implementation v }
|
||||
app_base_android_test_dependencies.each { k, v -> androidTestImplementation v }
|
||||
app_base_test_dependencies.each { k, v -> testImplementation v }
|
||||
implementation 'com.bytedance.boost_multidex:boost_multidex:1.0.1'
|
||||
implementation project(':libcore')
|
||||
implementation project(':libdata')
|
||||
implementation project(':mediaplayertv')
|
||||
implementation 'androidx.appcompat:appcompat:1.3.0'
|
||||
implementation 'com.google.android.material:material:1.11.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
|
||||
|
||||
implementation 'com.google.zxing:core:3.2.1'
|
||||
// debugImplementation files('libs/JetsenxSdk-external-release_v1.14.0.aar')
|
||||
// previewImplementation files('libs/JetsenxSdk-external-release_v1.14.0.aar')
|
||||
// releaseImplementation files('libs/JetsenxSdk-api-release_v1.14.0.aar')
|
||||
debugImplementation files('libs/JetsenxSdk-api-future-release-v1.23.aar')
|
||||
// previewImplementation files('libs/JetsenxSdk-api-future-release-v1.23.aar')
|
||||
releaseImplementation files('libs/JetsenxSdk-api-future-release-v1.23.aar')
|
||||
implementation files('libs/NewTVSDK-v4.0.3-app-lite.jar')
|
||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
||||
|
||||
implementation 'com.google.android.exoplayer:exoplayer:2.19.1'
|
||||
//implementation(name: 'exoplayer-ffmpeg-extension-2.19.1', ext: 'aar')
|
||||
|
||||
// implementation 'com.sensorsdata.analytics.android:SensorsAnalyticsSDK:6.8.3'
|
||||
implementation 'commons-codec:commons-codec:1.15'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.12.13'
|
||||
implementation 'com.google.code.gson:gson:2.8.9'
|
||||
implementation 'com.github.gzu-liyujiang:Android_CN_OAID:4.1.3'
|
||||
implementation('io.github.volcengine-tls:tls-android-producer:2.0.2-api16') {
|
||||
exclude group: 'com.google.guava', module: 'guava'
|
||||
exclude group: 'com.google.guava', module: 'guava-jdk5'
|
||||
exclude group: 'com.google.guava', module: 'guava-android'
|
||||
exclude group: 'com.google.guava', module: 'listenablefuture'
|
||||
}
|
||||
|
||||
// 强制使用统一的 Guava 版本
|
||||
implementation 'com.google.guava:guava:31.1-android'
|
||||
|
||||
// ===== 网络层(脚手架新引入,与既有 HttpUtils 双栈共存) =====
|
||||
// 为什么显式指定版本:app 模块此前未声明 retrofit/okhttp/moshi/coroutines,避免被根 config.gradle 隐式拉入不同版本。
|
||||
// Kotlin 1.9.22 -> KSP 1.9.22-1.0.17 已对齐。
|
||||
// 为什么用 `platform(enforcedPlatform)` 而非 `implementation`:okhttp-bom 是 Bill-of-Materials,本身仅提供版本对齐,
|
||||
// 不能被当作运行时产物拉到 runtime classpath(这正是上一个编译报错的根因)。
|
||||
implementation platform('com.squareup.okhttp3:okhttp-bom:4.12.0')
|
||||
implementation 'com.squareup.retrofit2:retrofit:2.11.0'
|
||||
implementation 'com.squareup.retrofit2:converter-moshi:2.11.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp'
|
||||
implementation 'com.squareup.okhttp3:logging-interceptor'
|
||||
implementation 'com.squareup.moshi:moshi:1.15.1'
|
||||
implementation 'com.squareup.moshi:moshi-kotlin:1.15.1'
|
||||
ksp 'com.squareup.moshi:moshi-kotlin-codegen:1.15.1'
|
||||
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.1'
|
||||
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2'
|
||||
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2'
|
||||
|
||||
implementation 'net.jpountz.lz4:lz4:1.3.0'
|
||||
implementation 'org.slf4j:slf4j-android:1.7.36'
|
||||
//腾讯buggly
|
||||
implementation 'com.tencent.bugly:crashreport:latest.release'
|
||||
//爱奇艺本地奔溃日志
|
||||
implementation 'com.iqiyi.xcrash:xcrash-android-lib:3.1.0'
|
||||
}
|
||||
BIN
app/key/jiecheng.jks
Executable file
BIN
app/key/jiecheng.jks
Executable file
Binary file not shown.
4
app/key/keystore.properties
Executable file
4
app/key/keystore.properties
Executable file
@@ -0,0 +1,4 @@
|
||||
storePassword=abc@123
|
||||
keyPassword=abc@123
|
||||
keyAlias=key0
|
||||
storeFile=../key/jiecheng.jks
|
||||
BIN
app/libs/JetsenxSdk-api-future-release-v1.23.aar
Executable file
BIN
app/libs/JetsenxSdk-api-future-release-v1.23.aar
Executable file
Binary file not shown.
BIN
app/libs/JetsenxSdk-api-release_v1.14.0.aar
Executable file
BIN
app/libs/JetsenxSdk-api-release_v1.14.0.aar
Executable file
Binary file not shown.
BIN
app/libs/JetsenxSdk-external-future-release-v1.23.aar
Executable file
BIN
app/libs/JetsenxSdk-external-future-release-v1.23.aar
Executable file
Binary file not shown.
BIN
app/libs/JetsenxSdk-external-release_v1.14.0.aar
Executable file
BIN
app/libs/JetsenxSdk-external-release_v1.14.0.aar
Executable file
Binary file not shown.
BIN
app/libs/NewTVSDK-v4.0.3-app-lite.jar
Executable file
BIN
app/libs/NewTVSDK-v4.0.3-app-lite.jar
Executable file
Binary file not shown.
BIN
app/libs/arm64-v8a/libnewtvsdk.so
Executable file
BIN
app/libs/arm64-v8a/libnewtvsdk.so
Executable file
Binary file not shown.
BIN
app/libs/armeabi-v7a/libnewtvsdk.so
Executable file
BIN
app/libs/armeabi-v7a/libnewtvsdk.so
Executable file
Binary file not shown.
BIN
app/libs/exoplayer-ffmpeg-extension-2.19.1.aar
Executable file
BIN
app/libs/exoplayer-ffmpeg-extension-2.19.1.aar
Executable file
Binary file not shown.
28
app/proguard-rules.pro
vendored
Executable file
28
app/proguard-rules.pro
vendored
Executable file
@@ -0,0 +1,28 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# You can control the set of applied configuration files using the
|
||||
# proguardFiles setting in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# 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 line number information for
|
||||
# debugging stack traces.
|
||||
#-keepattributes SourceFile,LineNumberTable
|
||||
|
||||
# If you keep the line number information, uncomment this to
|
||||
# hide the original source file name.
|
||||
#-renamesourcefileattribute SourceFile
|
||||
-dontwarn tv.newtv.ottsdk.**
|
||||
-keep class tv.newtv.ottsdk.**{*;}
|
||||
|
||||
|
||||
## 腾讯buggly
|
||||
-dontwarn com.tencent.bugly.**
|
||||
-keep class com.tencent.bugly.**{*;}
|
||||
4
app/src/aishiActivation/res/values/strings.xml
Executable file
4
app/src/aishiActivation/res/values/strings.xml
Executable file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">橘视厅扫码版</string>
|
||||
</resources>
|
||||
4
app/src/aishiScan/res/values/strings.xml
Executable file
4
app/src/aishiScan/res/values/strings.xml
Executable file
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string name="app_name">橘视厅扫码版</string>
|
||||
</resources>
|
||||
8
app/src/androidTest/androidmanifest.xml
Executable file
8
app/src/androidTest/androidmanifest.xml
Executable file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.migu.jiecheng">
|
||||
|
||||
<application>
|
||||
<activity android:name=".IndexNavType6TestActivity" />
|
||||
</application>
|
||||
</manifest>
|
||||
26
app/src/androidTest/java/com/migu/jiecheng/ExampleInstrumentedTest.java
Executable file
26
app/src/androidTest/java/com/migu/jiecheng/ExampleInstrumentedTest.java
Executable file
@@ -0,0 +1,26 @@
|
||||
package com.migu.jiecheng;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.test.platform.app.InstrumentationRegistry;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
|
||||
assertEquals("com.migu.jiecheng", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
199
app/src/androidTest/java/com/migu/jiecheng/IndexNavType6TestActivity.java
Executable file
199
app/src/androidTest/java/com/migu/jiecheng/IndexNavType6TestActivity.java
Executable file
@@ -0,0 +1,199 @@
|
||||
package com.migu.jiecheng;
|
||||
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.google.android.material.tabs.TabLayout;
|
||||
|
||||
public class IndexNavType6TestActivity extends AppCompatActivity {
|
||||
private RecyclerView recyclerView;
|
||||
private TabLayout tabLayout;
|
||||
private TestAdapter adapter;
|
||||
private boolean isProgrammaticSelection;
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
LinearLayout root = new LinearLayout(this);
|
||||
root.setOrientation(LinearLayout.VERTICAL);
|
||||
root.setLayoutParams(new ViewGroup.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.MATCH_PARENT
|
||||
));
|
||||
|
||||
Button externalButton = new Button(this);
|
||||
externalButton.setId(android.R.id.button1);
|
||||
externalButton.setText("切换 navtype=6");
|
||||
root.addView(externalButton, new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
|
||||
tabLayout = new TabLayout(this);
|
||||
tabLayout.setId(android.R.id.tabs);
|
||||
root.addView(tabLayout, new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
|
||||
recyclerView = new RecyclerView(this);
|
||||
recyclerView.setId(android.R.id.list);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
|
||||
adapter = new TestAdapter();
|
||||
recyclerView.setAdapter(adapter);
|
||||
root.addView(recyclerView, new LinearLayout.LayoutParams(
|
||||
ViewGroup.LayoutParams.MATCH_PARENT,
|
||||
ViewGroup.LayoutParams.WRAP_CONTENT
|
||||
));
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
tabLayout.addTab(tabLayout.newTab().setText("Tab " + i));
|
||||
}
|
||||
|
||||
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
|
||||
@Override
|
||||
public void onTabSelected(TabLayout.Tab tab) {
|
||||
if (tab != null) {
|
||||
IndexNavType6TestActivity.this.onTabSelected(tab.getPosition());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabUnselected(TabLayout.Tab tab) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTabReselected(TabLayout.Tab tab) {
|
||||
}
|
||||
});
|
||||
|
||||
externalButton.setOnClickListener(v -> onNavTypeChanged(6));
|
||||
setContentView(root);
|
||||
}
|
||||
|
||||
private void onNavTypeChanged(int navType) {
|
||||
if (isProgrammaticSelection) {
|
||||
return;
|
||||
}
|
||||
if (navType != 6) {
|
||||
return;
|
||||
}
|
||||
isProgrammaticSelection = true;
|
||||
try {
|
||||
syncSelection(6);
|
||||
} finally {
|
||||
isProgrammaticSelection = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void onTabSelected(int targetPosition) {
|
||||
if (isProgrammaticSelection) {
|
||||
return;
|
||||
}
|
||||
isProgrammaticSelection = true;
|
||||
try {
|
||||
syncSelection(targetPosition);
|
||||
} finally {
|
||||
isProgrammaticSelection = false;
|
||||
}
|
||||
}
|
||||
|
||||
private void syncSelection(int targetPosition) {
|
||||
recyclerView.scrollToPosition(targetPosition);
|
||||
adapter.setSelectedPosition(targetPosition);
|
||||
TabLayout.Tab tab = tabLayout.getTabAt(targetPosition);
|
||||
if (tab != null) {
|
||||
tab.select();
|
||||
}
|
||||
}
|
||||
|
||||
public int getSelectedPosition() {
|
||||
return adapter.getSelectedPosition();
|
||||
}
|
||||
|
||||
public int getSelectedTabPosition() {
|
||||
return tabLayout.getSelectedTabPosition();
|
||||
}
|
||||
|
||||
public int getNotifyItemChangedCount() {
|
||||
return adapter.getNotifyItemChangedCount();
|
||||
}
|
||||
|
||||
private static class TestAdapter extends RecyclerView.Adapter<TestAdapter.Holder> {
|
||||
private int selectedPosition = RecyclerView.NO_POSITION;
|
||||
private int notifyItemChangedCount = 0;
|
||||
|
||||
void setSelectedPosition(int position) {
|
||||
if (position < 0 || position >= getItemCount()) {
|
||||
return;
|
||||
}
|
||||
if (selectedPosition == position) {
|
||||
notifyItemChanged(position);
|
||||
notifyItemChangedCount++;
|
||||
return;
|
||||
}
|
||||
int oldPosition = selectedPosition;
|
||||
selectedPosition = position;
|
||||
if (oldPosition != RecyclerView.NO_POSITION) {
|
||||
notifyItemChanged(oldPosition);
|
||||
notifyItemChangedCount++;
|
||||
}
|
||||
notifyItemChanged(selectedPosition);
|
||||
notifyItemChangedCount++;
|
||||
}
|
||||
|
||||
int getSelectedPosition() {
|
||||
return selectedPosition;
|
||||
}
|
||||
|
||||
int getNotifyItemChangedCount() {
|
||||
return notifyItemChangedCount;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public Holder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
TextView textView = new TextView(parent.getContext());
|
||||
textView.setGravity(Gravity.CENTER);
|
||||
textView.setPadding(24, 24, 24, 24);
|
||||
return new Holder(textView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull Holder holder, int position) {
|
||||
holder.textView.setText(String.valueOf(position));
|
||||
boolean selected = position == selectedPosition;
|
||||
holder.textView.setBackgroundColor(selected ? Color.parseColor("#FF4CAF50") : Color.parseColor("#00000000"));
|
||||
holder.textView.setTextColor(selected ? Color.parseColor("#FFFFFFFF") : Color.parseColor("#FF999999"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
static class Holder extends RecyclerView.ViewHolder {
|
||||
private final TextView textView;
|
||||
|
||||
Holder(@NonNull TextView itemView) {
|
||||
super(itemView);
|
||||
this.textView = itemView;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
33
app/src/androidTest/java/com/migu/jiecheng/IndexNavType6UiTest.java
Executable file
33
app/src/androidTest/java/com/migu/jiecheng/IndexNavType6UiTest.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package com.migu.jiecheng;
|
||||
|
||||
import androidx.test.core.app.ActivityScenario;
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4;
|
||||
import androidx.test.filters.LargeTest;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static androidx.test.espresso.Espresso.onView;
|
||||
import static androidx.test.espresso.action.ViewActions.click;
|
||||
import static androidx.test.espresso.matcher.ViewMatchers.withId;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
@LargeTest
|
||||
public class IndexNavType6UiTest {
|
||||
|
||||
@Test
|
||||
public void 点击外部按钮切换到navtype6后列表与Tab应同步高亮() {
|
||||
try (ActivityScenario<IndexNavType6TestActivity> scenario =
|
||||
ActivityScenario.launch(IndexNavType6TestActivity.class)) {
|
||||
onView(withId(android.R.id.button1)).perform(click());
|
||||
|
||||
scenario.onActivity(activity -> {
|
||||
assertEquals(6, activity.getSelectedPosition());
|
||||
assertEquals(6, activity.getSelectedTabPosition());
|
||||
assertTrue(activity.getNotifyItemChangedCount() <= 2);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
157
app/src/main/AndroidManifest.xml
Executable file
157
app/src/main/AndroidManifest.xml
Executable file
@@ -0,0 +1,157 @@
|
||||
<?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="com.pukka.jiecheng"
|
||||
tools:ignore="MissingLeanbackLauncher">
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.telephony"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:name="android.software.leanback"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.touchscreen"
|
||||
android:required="false" />
|
||||
|
||||
<uses-permission android:name="android.permission.GET_TASKS" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE" tools:ignore="ScopedStorage" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
<uses-permission android:name="android.permission.INTERNET" /> <!-- MSA -->
|
||||
<uses-permission android:name="com.asus.msa.SupplementaryDID.ACCESS" />
|
||||
<uses-permission android:name="android.permission.WAKE_LOCK" />
|
||||
|
||||
<uses-permission-sdk-23 android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission-sdk-23 android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission-sdk-23 android:name="android.permission.READ_PHONE_STATE" />
|
||||
|
||||
<uses-permission android:name="android.permission.SEND_SMS" />
|
||||
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.REPLACE_EXISTING_PACKAGE" />
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<application
|
||||
android:name=".MyApplication"
|
||||
android:allowBackup="false"
|
||||
android:hardwareAccelerated="true"
|
||||
android:icon="@mipmap/ic_app"
|
||||
android:label="@string/app_name"
|
||||
android:largeHeap="true"
|
||||
android:networkSecurityConfig="@xml/network_permission_config"
|
||||
android:defaultToDeviceProtectedStorage="true"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:roundIcon="@mipmap/ic_app"
|
||||
android:supportsRtl="true"
|
||||
android:taskAffinity=""
|
||||
android:theme="@style/whiteTheme"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:node="merge"
|
||||
tools:replace="android:name,android:allowBackup,android:theme,android:icon,android:networkSecurityConfig,android:label,android:roundIcon"
|
||||
tools:targetApi="n">
|
||||
<activity
|
||||
android:name=".index.HotelMyActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="landscape" />
|
||||
<activity
|
||||
android:name=".aboutmy.AboutMyActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="landscape" />
|
||||
<activity
|
||||
android:name=".device.DeviceActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="landscape" />
|
||||
<activity
|
||||
android:name=".order.OrderActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@style/whiteTheme" />
|
||||
<activity
|
||||
android:name=".list.ListActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="landscape" />
|
||||
<activity
|
||||
android:name=".login.LoginActivity"
|
||||
android:exported="false"
|
||||
android:screenOrientation="landscape"
|
||||
android:windowSoftInputMode="stateHidden|adjustResize" />
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:exported="true"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="${splash_theme}">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ThirdPartyEntryActivity"
|
||||
android:exported="true"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@style/whiteTheme">
|
||||
<intent-filter>
|
||||
<action android:name="com.pukka.jiecheng.action.THIRD_PARTY_PLAY" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".TestActivity"
|
||||
android:exported="true"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@style/whiteTheme" />
|
||||
|
||||
<activity
|
||||
android:name=".video.VideoDetailActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@style/whiteTheme" />
|
||||
<activity
|
||||
android:name=".history.HistoryActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@style/whiteTheme" />
|
||||
<activity
|
||||
android:name=".index.IndexActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@style/whiteTheme" />
|
||||
<activity
|
||||
android:name=".search.SearchActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@style/whiteTheme" />
|
||||
<activity
|
||||
android:name=".web.SimpleWebActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@style/blackTheme" />
|
||||
<activity
|
||||
android:name=".filter.FilterActivity"
|
||||
android:screenOrientation="landscape"
|
||||
android:theme="@style/whiteTheme" />
|
||||
|
||||
<meta-data
|
||||
android:name="APP_CHANNEL_NAME"
|
||||
android:value="${APP_CHANNEL_ID}" />
|
||||
<!-- <meta-data
|
||||
android:name="APP_CHANNEL_TYPE"
|
||||
android:value="${APP_CHANNEL_TYPE}" /> -->
|
||||
|
||||
<provider
|
||||
android:name="androidx.core.content.FileProvider"
|
||||
android:authorities="${applicationId}.provider"
|
||||
android:exported="false"
|
||||
android:grantUriPermissions="true">
|
||||
<meta-data
|
||||
android:name="android.support.FILE_PROVIDER_PATHS"
|
||||
android:resource="@xml/file_paths" />
|
||||
</provider>
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
74
app/src/main/java/com/pukka/jiecheng/JcConfig.java
Executable file
74
app/src/main/java/com/pukka/jiecheng/JcConfig.java
Executable file
@@ -0,0 +1,74 @@
|
||||
package com.pukka.jiecheng;
|
||||
|
||||
import com.pukka.libcore.base.BaseConst;
|
||||
import com.pukka.libcore.base.BuildConfig;
|
||||
import com.pukka.libcore.base.DifferenceApi;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
public class JcConfig {
|
||||
//获取我的订购列表
|
||||
public static final String QUERAORDERLIST = getBaseUrl()+"bms_api/member/queryOrderList?";
|
||||
//卡密激活接口
|
||||
public static final String ACTIVATE = getBaseUrl()+"ccms_api/hswj/api/card/activate?";
|
||||
//轮询查询支付结果
|
||||
public static final String GETPAYRESULTCYCLE = getBaseUrl()+"bms_api/member/getPayResultCycle?";
|
||||
//用户退登
|
||||
public static final String LOGOUT =getBaseUrl()+"ums_api/member/tv/logout?";
|
||||
//获取会员到期时间
|
||||
public static final String QUERYVIPINFO =getBaseUrl()+"/ums_api/member/uid/queryVipInfo?";
|
||||
|
||||
public static final String header = "huashitv";
|
||||
public static final String key="hhDEHY1qC4r";
|
||||
//业务线参数
|
||||
public static final String businessLine = BaseConst.businessLine;
|
||||
//大屏轮询获取登录结果
|
||||
public static final String ISLOGIN=getBaseUrl()+"ums_api/member/tv/isLogin?";
|
||||
|
||||
//微信小程序地址
|
||||
public static final String weiXinURL = getWeiXinURL();
|
||||
//prefix 0代表测试环境,1代表正式环境
|
||||
public static final int prefix=getPrefix();
|
||||
|
||||
public static int getPrefix(){
|
||||
if (BuildConfig.BUILD_TYPE.contains("release")) {
|
||||
LogUtils.d("现网环境");
|
||||
return 1;
|
||||
}else{
|
||||
LogUtils.d("预发布环境");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取捷成正式环境或测试环境地址
|
||||
* */
|
||||
public static String getBaseUrl(){
|
||||
if (BuildConfig.BUILD_TYPE.contains("release")) {
|
||||
// LogUtils.d("现网环境=https://api.jetsenx.huashi.tv/");
|
||||
// return "https://api.jetsenx.huashi.tv/";
|
||||
//火山域名
|
||||
return "https://api.future.jetsentv.com/";
|
||||
}else{
|
||||
// LogUtils.d("测试环境=https://external.jetsenx.huashi.tv/");
|
||||
// return "https://external.jetsenx.huashi.tv/";
|
||||
return "https://external.future.jetsentv.com/";
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取捷成正式环境或测试环境地址
|
||||
* */
|
||||
public static String getWeiXinURL(){
|
||||
if (BuildConfig.BUILD_TYPE.contains("release")) {
|
||||
// LogUtils.d("微信小程序现网环境=https://api.jetsenx.huashi.tv");
|
||||
//阿里
|
||||
// return "https://api.jetsenx.huashi.tv";
|
||||
//火山域名
|
||||
return "https://api.future.jetsentv.com";
|
||||
}else{
|
||||
LogUtils.d("微信小程序测试环境");
|
||||
// return "https://external.jetsenx.huashi.tv";
|
||||
return "https://external.future.jetsentv.com";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
1127
app/src/main/java/com/pukka/jiecheng/MainActivity.java
Executable file
1127
app/src/main/java/com/pukka/jiecheng/MainActivity.java
Executable file
File diff suppressed because it is too large
Load Diff
134
app/src/main/java/com/pukka/jiecheng/MyApplication.java
Executable file
134
app/src/main/java/com/pukka/jiecheng/MyApplication.java
Executable file
@@ -0,0 +1,134 @@
|
||||
|
||||
package com.pukka.jiecheng;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.lifecycle.ProcessLifecycleOwner;
|
||||
|
||||
import com.bytedance.boost_multidex.BoostMultiDex;
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.migu.httputils.LowPlatformUtils;
|
||||
import com.pukka.jiecheng.config.AppConfiguration;
|
||||
import com.pukka.jiecheng.device.DeviceIdentityInitManager;
|
||||
import com.pukka.jiecheng.utils.ActivityMonitor;
|
||||
import com.pukka.jiecheng.utils.BuglyInitManager;
|
||||
import com.pukka.jiecheng.utils.CrashHandler;
|
||||
import com.pukka.libcore.fresco.Tls12SocketFactory;
|
||||
import com.pukka.libcore.fresco.TrustAllManager;
|
||||
import com.pukka.libcore.utils.AppLifecycleObserver;
|
||||
import com.pukka.libcore.utils.ContextUtils;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
import com.pukka.libcore.utils.ProcessUtil;
|
||||
|
||||
import javax.net.ssl.HttpsURLConnection;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
import javax.net.ssl.TrustManager;
|
||||
|
||||
/**
|
||||
* @author devel
|
||||
*/
|
||||
public class MyApplication extends Application {
|
||||
private static final String PROCESS_NAME_MAIN = "tv.huashi.jetsenx.jetsenfilx.jsttv";
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
LogUtils.d("onCreate: application.onCreate:");
|
||||
//ProcessLifecycleOwner.get().getLifecycle().addObserver(new AppLifecycleObserver());
|
||||
String currentProcessName = ProcessUtil.getCurrentProcessName(this);
|
||||
LogUtils.d("appStart --- application.onCreate:start " + currentProcessName);
|
||||
// 仅在主进程中进行初始化操作
|
||||
if (currentProcessName != null && currentProcessName.contains(PROCESS_NAME_MAIN) && !currentProcessName.contains(":")) {
|
||||
ContextUtils.init(this);
|
||||
LogUtils.d("onCreate: application.1:");
|
||||
DeviceIdentityInitManager.init(this);
|
||||
// 兼容4.0
|
||||
LowPlatformUtils.okhttp3InLowPlatform();
|
||||
// 修复 ExoPlayer 在低版本机顶盒上 HTTPS 证书校验失败导致无法播放(系统 CA 库过旧)
|
||||
installTrustAllSsl();
|
||||
//buggly异常统计
|
||||
BuglyInitManager.initIfPrivacyAgreed(this);
|
||||
// 全局捕获程序异常
|
||||
// CrashHandler crashHandler = CrashHandler.getInstance();
|
||||
// LogUtils.d("onCreate: application.4:");
|
||||
// crashHandler.init(this);
|
||||
LogUtils.d("onCreate: application.5:");
|
||||
ActivityMonitor.init(this);
|
||||
|
||||
// 网络层初始化(必须在 Fresco.initialize 之前,避免首签请求受 SSL 状态影响)
|
||||
initNetworkLayer();
|
||||
//preInitWebCore();
|
||||
//LogUtils.d("onCreate: channel_id : "+ AppConfiguration.getInstance().getChannelId()+ " isNeadMy : "+ AppConfiguration.getInstance().isNeedMy() + " control(Touch): "+AppConfiguration.getInstance().isTouchMode());
|
||||
}
|
||||
Fresco.initialize(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化脚手架新网络层(Retrofit + OkHttp + Moshi + Coroutines)。
|
||||
*
|
||||
* 时机:在 ActivityMonitor 之后、Fresco.initialize 之前。
|
||||
* 原因:Fresco 初始化会触发 SSL 状态锁定;网络层初始化越早越好,确保首签请求走正确的 SSL 栈。
|
||||
*
|
||||
* 为什么用 Java 静态方法调用 Kotlin object:MyApplication 暂不改为 Kotlin,避免牵动过大。
|
||||
*/
|
||||
private void initNetworkLayer() {
|
||||
try {
|
||||
com.pukka.jiecheng.network.infra.NetworkConfig config =
|
||||
new com.pukka.jiecheng.network.infra.NetworkConfig(
|
||||
com.pukka.jiecheng.network.infra.NetworkEnv.PROD,
|
||||
this,
|
||||
15_000L, // connectTimeoutMs
|
||||
20_000L, // readTimeoutMs
|
||||
30_000L, // callTimeoutMs
|
||||
BuildConfig.DEBUG // enableHttpLog:仅 DEBUG 启用日志,避免泄漏用户数据
|
||||
);
|
||||
com.pukka.jiecheng.network.auth.SpTokenStore tokenStore =
|
||||
new com.pukka.jiecheng.network.auth.SpTokenStore();
|
||||
com.pukka.jiecheng.network.infra.Network.INSTANCE.init(config, tokenStore);
|
||||
LogUtils.d("onCreate: network layer initialized");
|
||||
} catch (Throwable t) {
|
||||
// 网络层初始化失败不应阻塞应用启动;降级为旧 HttpUtils
|
||||
LogUtils.e("onCreate: network layer init failed: " + t.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 全局信任所有 HTTPS 证书,修复 ExoPlayer 播放 HTTPS 视频时
|
||||
* "Trust anchor for certification path not found" 握手失败。
|
||||
* DefaultHttpDataSource 基于 HttpsURLConnection,此处设置其全局默认 SSLSocketFactory,
|
||||
* 与 Fresco/OkHttp 网络栈保持一致的"信任所有证书"策略。
|
||||
*/
|
||||
private static void installTrustAllSsl() {
|
||||
try {
|
||||
TrustAllManager trustManager = new TrustAllManager();
|
||||
SSLContext sslContext = SSLContext.getInstance("TLS");
|
||||
sslContext.init(null, new TrustManager[]{trustManager}, new java.security.SecureRandom());
|
||||
// 套一层 Tls12SocketFactory,确保低版本系统启用 TLS1.2
|
||||
SSLSocketFactory sslSocketFactory = new Tls12SocketFactory(sslContext.getSocketFactory());
|
||||
HttpsURLConnection.setDefaultSSLSocketFactory(sslSocketFactory);
|
||||
HttpsURLConnection.setDefaultHostnameVerifier((hostname, session) -> true);
|
||||
} catch (Exception e) {
|
||||
LogUtils.d("installTrustAllSsl failed: " + e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 提前预初始化浏览器内核
|
||||
*/
|
||||
// private void preInitWebCore() {
|
||||
// Looper.myQueue().addIdleHandler(() -> {
|
||||
// LogUtils.d("preInitWebCore -- start");
|
||||
// new BrowserWebView(this).loadUrl("about:blank");
|
||||
// LogUtils.d("preInitWebCore -- end");
|
||||
// return false;
|
||||
// });
|
||||
// }
|
||||
|
||||
@Override
|
||||
protected void attachBaseContext(Context base) {
|
||||
super.attachBaseContext(base);
|
||||
BoostMultiDex.install(this);
|
||||
}
|
||||
}
|
||||
33
app/src/main/java/com/pukka/jiecheng/TestActivity.java
Executable file
33
app/src/main/java/com/pukka/jiecheng/TestActivity.java
Executable file
@@ -0,0 +1,33 @@
|
||||
package com.pukka.jiecheng;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
/**
|
||||
* @file TestActivity.java
|
||||
* @description 用于测试的 Activity,包含跳转到 MainActivity 的按钮,以实现简单的联调和入口测试
|
||||
* @author ainetv
|
||||
* @date 2026-03-20
|
||||
*/
|
||||
public class TestActivity extends AppCompatActivity {
|
||||
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_test);
|
||||
|
||||
Button btnGoToMain = findViewById(R.id.btn_go_to_main);
|
||||
btnGoToMain.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
Intent intent = new Intent(TestActivity.this, MainActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,500 @@
|
||||
package com.pukka.jiecheng;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
|
||||
import com.pukka.jiecheng.config.AppConfiguration;
|
||||
import com.pukka.jiecheng.index.IndexActivity;
|
||||
import com.pukka.jiecheng.request.AsApiRequester;
|
||||
import com.pukka.jiecheng.utils.BuildConfigUtils;
|
||||
import com.pukka.jiecheng.utils.ChannelManger;
|
||||
import com.pukka.jiecheng.utils.JetsenxSdkUtil;
|
||||
import com.pukka.jiecheng.video.VideoDetailActivity;
|
||||
import com.pukka.jiecheng.widget.DeviceUnregisteredView;
|
||||
import com.pukka.libcore.threading.DispatchQueue;
|
||||
import com.pukka.libcore.utils.AppManager;
|
||||
import com.pukka.libcore.utils.ContextUtils;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
import com.pukka.libcore.utils.StringUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.net.NetworkInterface;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* 第三方 EPG 调用入口 Activity。
|
||||
*
|
||||
* 仅在 thirdparty flavor 中使用,通过 Intent action
|
||||
* {@code com.pukka.jiecheng.action.THIRD_PARTY_PLAY} 启动。
|
||||
*
|
||||
* 流程:
|
||||
* 1. 解析 Intent extras(mac/wifiMac/deviceSn/deviceUid/programCode)
|
||||
* 2. 注入 ThirdPartyDeviceParams 到 AsApiRequester
|
||||
* 3. 执行 init -> checkBenefits 流程
|
||||
* 4. 权益通过:初始化 JetsenxSdk -> 路由到 VideoDetailActivity 或 IndexActivity
|
||||
* 5. 权益未通过:展示 DeviceUnregisteredView 阻断页
|
||||
*/
|
||||
public class ThirdPartyEntryActivity extends AppCompatActivity implements AsApiRequester.CheckStatusCallback {
|
||||
|
||||
private static final String TAG = "ThirdPartyEntryActivity";
|
||||
|
||||
private static final String EXTRA_MAC = "mac";
|
||||
private static final String EXTRA_WIFI_MAC = "wifiMac";
|
||||
private static final String EXTRA_DEVICE_SN = "deviceSn";
|
||||
private static final String EXTRA_DEVICE_UID = "deviceUid";
|
||||
private static final String EXTRA_PROGRAM_CODE = "programCode";
|
||||
|
||||
/** init 业务错误(第三方后端 code=400 设备未注册)提示文案 */
|
||||
private static final String MSG_DEVICE_NOT_REGISTERED = "设备未注册,请返回首页购买";
|
||||
/** checkBenefits 权益未生效(非 ACTIVE 终态/轮询超时)提示文案 */
|
||||
private static final String MSG_BENEFIT_NOT_BOUND = "设备未绑定权益,请返回首页购买";
|
||||
/** MAC 硬件锚定校验失败(EPG 传入的 mac 不属于本机网卡)提示文案 */
|
||||
private static final String MSG_DEVICE_MISMATCH = "设备校验失败,请返回首页重新进入";
|
||||
|
||||
/** 第三方后端 init 设备未注册业务错误码 */
|
||||
private static final int INIT_CODE_DEVICE_NOT_REGISTERED = 400;
|
||||
/** 权益轮询超时内部错误码(对齐 AsApiRequester POLLING_TIMEOUT 路径) */
|
||||
private static final int CHECK_CODE_POLLING_TIMEOUT = 1008;
|
||||
|
||||
private final AsApiRequester asApiRequester = AsApiRequester.INSTANCE;
|
||||
|
||||
private DeviceUnregisteredView deviceUnregisteredView;
|
||||
private View networkErrorContainer;
|
||||
private TextView networkErrorMessageView;
|
||||
private Button networkErrorRetryButton;
|
||||
private View loadingContainer;
|
||||
private TextView loadingMessageView;
|
||||
|
||||
private final Handler mainHandler = new Handler(Looper.getMainLooper());
|
||||
|
||||
private String programCode;
|
||||
|
||||
/** EPG 通过 Intent 传入的 mac(用于 MAC 硬件锚定校验) */
|
||||
private String passedMac;
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_thirdparty_entry);
|
||||
AppManager.getAppManager().addActivity(this);
|
||||
// 与原版 MainActivity 对齐的全局初始化:
|
||||
// 1. BuildConfigUtils:同步 FLAVOR/BUILD_TYPE/VERSION 到 libcore(JcConfig 域名选择依赖)
|
||||
// 2. ChannelManger.initChannel():覆盖 SDK 凭证为正式业务参数(ACCESSER/AGCODE/comboCode)。
|
||||
// 缺失会导致 SDK 以默认测试凭证(JSTPKTEST)初始化,后端天卡权益挂在正式凭证下,
|
||||
// playAuth 鉴权返回 -110 未订购。
|
||||
BuildConfigUtils.initBuildConfig(ContextUtils.getApplicationContext());
|
||||
ChannelManger.initChannel();
|
||||
parseIntentExtras();
|
||||
initView();
|
||||
// MAC 硬件锚定校验:EPG 传入的 mac 必须属于本机网卡,防止一个有效凭证多设备共用
|
||||
if (!verifyEpgMacAnchoring()) {
|
||||
showDeviceUnregistered(0, MSG_DEVICE_MISMATCH);
|
||||
return;
|
||||
}
|
||||
initCheckBenefitsFlow();
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析 Intent extras,组装 ThirdPartyDeviceParams 并注入 AsApiRequester。
|
||||
*/
|
||||
private void parseIntentExtras() {
|
||||
Intent intent = getIntent();
|
||||
if (intent == null) {
|
||||
return;
|
||||
}
|
||||
String mac = intent.getStringExtra(EXTRA_MAC);
|
||||
String wifiMac = intent.getStringExtra(EXTRA_WIFI_MAC);
|
||||
String deviceSn = intent.getStringExtra(EXTRA_DEVICE_SN);
|
||||
String deviceUid = intent.getStringExtra(EXTRA_DEVICE_UID);
|
||||
programCode = intent.getStringExtra(EXTRA_PROGRAM_CODE);
|
||||
passedMac = mac;
|
||||
|
||||
AsApiRequester.ThirdPartyDeviceParams params = new AsApiRequester.ThirdPartyDeviceParams(
|
||||
mac, wifiMac, deviceSn, deviceUid);
|
||||
AsApiRequester.setThirdPartyDeviceParams(params);
|
||||
|
||||
// EPG 传入的 mac 同步覆盖到 SDK init:后端权益以 EPG 注册的 MAC 绑定,
|
||||
// JetsenxSdkUtil.init 简化重载内部不再回退本机自采集 MAC(否则权益不生效)
|
||||
JetsenxSdkUtil.setMacOverride(mac);
|
||||
|
||||
LogUtils.d(TAG, "parseIntentExtras: mac=" + mac + ", deviceSn=" + deviceSn
|
||||
+ ", deviceUid=" + deviceUid + ", programCode=" + programCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* MAC 硬件锚定校验(防一个有效凭证多设备共用)。
|
||||
*
|
||||
* 背景:app 完全信任 EPG 传入的 mac 做设备识别与 SDK 鉴权,若恶意 EPG 把已注册设备的
|
||||
* mac 传给任意其他设备,即可用一个凭证给所有设备轮流播放。本校验把设备身份锚定到硬件:
|
||||
* EPG 传入的 mac 必须匹配本机任一网卡的真实硬件 MAC。
|
||||
*
|
||||
* 规则:
|
||||
* - 未传 mac:不校验(走自采集,由后端注册匹配兜底)
|
||||
* - 传入 mac 匹配本机任一网卡(eth0/wlan0 等):通过
|
||||
* - 传入 mac 不匹配任何本机网卡:阻断
|
||||
* - 本机网卡 MAC 全部读取失败:放行(fail-open,避免极端权限环境误伤正常设备)
|
||||
*
|
||||
* 兼容性:EPG 可能读取与本 app 不同的网卡(如 EPG 读 wlan0、app 默认自采集 eth0),
|
||||
* 因此校验集包含本机全部网卡的 MAC,而非仅 app 自采集那一个。
|
||||
*/
|
||||
private boolean verifyEpgMacAnchoring() {
|
||||
if (TextUtils.isEmpty(passedMac)) {
|
||||
LogUtils.d(TAG, "MAC anchoring skip: no mac passed");
|
||||
return true;
|
||||
}
|
||||
Set<String> deviceMacs = collectDeviceMacAddresses();
|
||||
if (deviceMacs.isEmpty()) {
|
||||
LogUtils.w(TAG, "MAC anchoring fail-open: no device mac readable");
|
||||
return true;
|
||||
}
|
||||
boolean matched = deviceMacs.contains(normalizeMac(passedMac));
|
||||
LogUtils.d(TAG, "MAC anchoring result=" + matched
|
||||
+ ", passedMac=" + passedMac + ", deviceMacCount=" + deviceMacs.size());
|
||||
return matched;
|
||||
}
|
||||
|
||||
/**
|
||||
* 收集本机所有网卡的硬件 MAC(归一化形式:小写、去冒号/横线)。
|
||||
* 双通道读取:NetworkInterface 遍历 + sysfs 网卡 address 文件兜底。
|
||||
* 过滤回环、全零、格式非法的地址。
|
||||
*/
|
||||
private Set<String> collectDeviceMacAddresses() {
|
||||
Set<String> macs = new HashSet<>();
|
||||
// 通道一:NetworkInterface 遍历(覆盖 eth0/wlan0/物理及虚拟网卡)
|
||||
try {
|
||||
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces();
|
||||
while (interfaces != null && interfaces.hasMoreElements()) {
|
||||
NetworkInterface ni = interfaces.nextElement();
|
||||
if (ni == null || ni.isLoopback() || ni.isPointToPoint()) {
|
||||
continue;
|
||||
}
|
||||
byte[] hw = ni.getHardwareAddress();
|
||||
addNormalizedMac(macs, bytesToMac(hw));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.e(TAG, "collectDeviceMacAddresses NetworkInterface error: " + e.getMessage());
|
||||
}
|
||||
// 通道二:/sys/class/net/*/address 文件(部分系统 NetworkInterface 拿不到硬件地址)
|
||||
try {
|
||||
File[] ifaces = new File("/sys/class/net").listFiles();
|
||||
if (ifaces != null) {
|
||||
for (File iface : ifaces) {
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
reader = new BufferedReader(new FileReader(new File(iface, "address")));
|
||||
String line = reader.readLine();
|
||||
addNormalizedMac(macs, line);
|
||||
} catch (Exception ignore) {
|
||||
// 单个接口读取失败不影响其他接口
|
||||
} finally {
|
||||
if (reader != null) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (Exception ignore) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.e(TAG, "collectDeviceMacAddresses sysfs error: " + e.getMessage());
|
||||
}
|
||||
return macs;
|
||||
}
|
||||
|
||||
/** 归一化并加入集合;过滤空值、全零、长度非 12 的非法地址 */
|
||||
private void addNormalizedMac(Set<String> out, String mac) {
|
||||
String normalized = normalizeMac(mac);
|
||||
if (normalized.length() == 12
|
||||
&& !"000000000000".equals(normalized)
|
||||
&& !normalized.matches("0+")) {
|
||||
out.add(normalized);
|
||||
}
|
||||
}
|
||||
|
||||
/** MAC 归一化:小写、去掉冒号/横线、去首尾空白 */
|
||||
private String normalizeMac(String mac) {
|
||||
if (mac == null) {
|
||||
return "";
|
||||
}
|
||||
return mac.trim().toLowerCase(Locale.ROOT).replace(":", "").replace("-", "");
|
||||
}
|
||||
|
||||
/** 字节数组转冒号分隔的 MAC 字符串 */
|
||||
private String bytesToMac(byte[] bytes) {
|
||||
if (bytes == null || bytes.length != 6) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder sb = new StringBuilder(17);
|
||||
for (int i = 0; i < bytes.length; i++) {
|
||||
if (i > 0) {
|
||||
sb.append(':');
|
||||
}
|
||||
sb.append(String.format("%02x", bytes[i]));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
deviceUnregisteredView = findViewById(R.id.device_unregistered_view);
|
||||
networkErrorContainer = findViewById(R.id.network_error_container);
|
||||
networkErrorMessageView = findViewById(R.id.network_error_message);
|
||||
networkErrorRetryButton = findViewById(R.id.network_error_retry_btn);
|
||||
loadingContainer = findViewById(R.id.loading_container);
|
||||
loadingMessageView = findViewById(R.id.loading_message);
|
||||
|
||||
networkErrorRetryButton.setFocusable(true);
|
||||
networkErrorRetryButton.setFocusableInTouchMode(true);
|
||||
networkErrorRetryButton.setClickable(true);
|
||||
networkErrorRetryButton.setEnabled(true);
|
||||
networkErrorRetryButton.setOnClickListener(v -> initCheckBenefitsFlow());
|
||||
|
||||
deviceUnregisteredView.setOnExitListener(this::exitApp);
|
||||
}
|
||||
|
||||
/**
|
||||
* init -> checkBenefits 流程。
|
||||
* 参考 MainActivity.checkUpgradeThenMembership,跳过升级检查。
|
||||
*/
|
||||
private void initCheckBenefitsFlow() {
|
||||
hideNetworkError();
|
||||
hideDeviceUnregistered();
|
||||
showLoading("正在初始化...");
|
||||
|
||||
asApiRequester.requestAsInitDeviceApi(this, new AsApiRequester.InitCallback() {
|
||||
@Override
|
||||
public void onSuccess(AsApiRequester.InitResult result) {
|
||||
asApiRequester.requestAsCheckBenefitsApi(
|
||||
ThirdPartyEntryActivity.this, ThirdPartyEntryActivity.this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int errorCode, String message) {
|
||||
if (errorCode == INIT_CODE_DEVICE_NOT_REGISTERED) {
|
||||
// 服务端业务错误:设备未在后端注册,展示阻断页(文案固定)
|
||||
showDeviceUnregistered(0, MSG_DEVICE_NOT_REGISTERED);
|
||||
} else {
|
||||
// 网络/内部错误:展示重试页
|
||||
showNetworkError(message);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ====== CheckStatusCallback ======
|
||||
|
||||
@Override
|
||||
public void onActivated(AsApiRequester.CheckBenefitsResult result) {
|
||||
hideLoading();
|
||||
hideNetworkError();
|
||||
routeAfterActivated(result);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPreset(AsApiRequester.CheckBenefitsResult result) {
|
||||
String msg = (result == null || StringUtils.isEmpty(result.msg))
|
||||
? "正在激活..." : result.msg;
|
||||
showLoading(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivating(AsApiRequester.CheckBenefitsResult result) {
|
||||
String msg = (result == null || StringUtils.isEmpty(result.msg))
|
||||
? "正在激活..." : result.msg;
|
||||
showLoading(msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onActivateFailed(AsApiRequester.CheckBenefitsResult result) {
|
||||
showDeviceUnregistered(0, MSG_BENEFIT_NOT_BOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnbound(AsApiRequester.CheckBenefitsResult result) {
|
||||
showDeviceUnregistered(0, MSG_BENEFIT_NOT_BOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExpired(AsApiRequester.CheckBenefitsResult result) {
|
||||
showDeviceUnregistered(0, MSG_BENEFIT_NOT_BOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onOccupied(AsApiRequester.CheckBenefitsResult result) {
|
||||
showDeviceUnregistered(0, MSG_BENEFIT_NOT_BOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnknown(AsApiRequester.CheckBenefitsResult result) {
|
||||
showDeviceUnregistered(0, MSG_BENEFIT_NOT_BOUND);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(int errorCode, String message) {
|
||||
if (errorCode == CHECK_CODE_POLLING_TIMEOUT) {
|
||||
// 权益轮询超时(设备已注册但卡一直未生效 ACTIVE):权益未绑定,展示阻断页
|
||||
showDeviceUnregistered(0, MSG_BENEFIT_NOT_BOUND);
|
||||
} else {
|
||||
// 网络错误(0)或内部错误(1001/1003/1004/1007):展示重试页
|
||||
showNetworkError(message);
|
||||
}
|
||||
}
|
||||
|
||||
// ====== 权益通过后的路由 ======
|
||||
|
||||
/**
|
||||
* 权益通过后:
|
||||
* 1. 清理 ThirdPartyDeviceParams
|
||||
* 2. 用 thirdCardNo 初始化 JetsenxSdk
|
||||
* 3. 有 programCode -> VideoDetailActivity 播放;无 programCode -> IndexActivity
|
||||
* 4. finish 当前 Activity
|
||||
*/
|
||||
private void routeAfterActivated(AsApiRequester.CheckBenefitsResult result) {
|
||||
AsApiRequester.clearThirdPartyDeviceParams();
|
||||
|
||||
String thirdCardNo = result != null ? result.thirdCardNo : "";
|
||||
if (TextUtils.isEmpty(thirdCardNo)) {
|
||||
showDeviceUnregistered(0, MSG_BENEFIT_NOT_BOUND);
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.expireTime != null) {
|
||||
AppConfiguration.getInstance().setExpireTime(result.expireTime);
|
||||
}
|
||||
JetsenxSdkUtil.cacheReusableUid(thirdCardNo);
|
||||
initJetsenxSdkWithRetry(thirdCardNo, 0);
|
||||
|
||||
if (!TextUtils.isEmpty(programCode)) {
|
||||
VideoDetailActivity.start(this, programCode, "",
|
||||
VideoDetailActivity.ModuleSourceType.HOME_PAGE, false);
|
||||
} else {
|
||||
Intent intent = new Intent(this, IndexActivity.class);
|
||||
startActivity(intent);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
/**
|
||||
* 用 thirdCardNo 初始化 JetsenxSdk,失败最多重试 3 次。
|
||||
* 参考 MainActivity.initJetsenxSdkWithRetry,在子线程执行避免 ANR。
|
||||
*/
|
||||
private void initJetsenxSdkWithRetry(String thirdCardNo, int retryCount) {
|
||||
DispatchQueue.global.async(() -> {
|
||||
try {
|
||||
JetsenxSdkUtil.init(
|
||||
ContextUtils.getApplicationContext(),
|
||||
thirdCardNo, new JetsenxSdkUtil.InitMemberCodeCallback() {
|
||||
@Override
|
||||
public void onSuccess(String memberCode) {
|
||||
JetsenxSdkUtil.cacheReusableUid(thirdCardNo);
|
||||
LogUtils.d(TAG, "Jetsenx SDK init success, cache thirdCardNo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String message) {
|
||||
LogUtils.e(TAG, "Jetsenx SDK init fail: " + message);
|
||||
if (retryCount < 3) {
|
||||
mainHandler.postDelayed(
|
||||
() -> initJetsenxSdkWithRetry(thirdCardNo, retryCount + 1), 1500);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
} catch (Exception e) {
|
||||
LogUtils.e(TAG, "Jetsenx SDK init exception: " + e.getMessage());
|
||||
if (retryCount < 3) {
|
||||
mainHandler.postDelayed(
|
||||
() -> initJetsenxSdkWithRetry(thirdCardNo, retryCount + 1), 1500);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// ====== UI 状态控制 ======
|
||||
|
||||
private void showLoading(String message) {
|
||||
runOnUiThread(() -> {
|
||||
hideNetworkError();
|
||||
hideDeviceUnregistered();
|
||||
loadingContainer.setVisibility(View.VISIBLE);
|
||||
if (!TextUtils.isEmpty(message)) {
|
||||
loadingMessageView.setText(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void hideLoading() {
|
||||
runOnUiThread(() -> loadingContainer.setVisibility(View.GONE));
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示设备未注册阻断页。
|
||||
*/
|
||||
private void showDeviceUnregistered(int errorCode, String message) {
|
||||
runOnUiThread(() -> {
|
||||
hideLoading();
|
||||
hideNetworkError();
|
||||
deviceUnregisteredView.setStatusInfo(errorCode, message);
|
||||
deviceUnregisteredView.setVisibility(View.VISIBLE);
|
||||
});
|
||||
}
|
||||
|
||||
private void hideDeviceUnregistered() {
|
||||
deviceUnregisteredView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 展示网络错误页,重试按钮重新执行 initCheckBenefitsFlow。
|
||||
*/
|
||||
private void showNetworkError(String message) {
|
||||
runOnUiThread(() -> {
|
||||
hideLoading();
|
||||
hideDeviceUnregistered();
|
||||
String displayMessage = StringUtils.isEmpty(message)
|
||||
? getString(R.string.str_network_error_fallback) : message;
|
||||
networkErrorMessageView.setText(displayMessage);
|
||||
networkErrorContainer.setVisibility(View.VISIBLE);
|
||||
networkErrorRetryButton.requestFocus();
|
||||
});
|
||||
}
|
||||
|
||||
private void hideNetworkError() {
|
||||
networkErrorContainer.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
// ====== 生命周期 ======
|
||||
|
||||
private void exitApp() {
|
||||
AppManager.getAppManager().setKeep(false);
|
||||
AppManager.getAppManager().appExit();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
super.onBackPressed();
|
||||
exitApp();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
AppManager.getAppManager().finishActivity(this);
|
||||
if (asApiRequester != null) {
|
||||
asApiRequester.onDestroy();
|
||||
}
|
||||
mainHandler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
}
|
||||
82
app/src/main/java/com/pukka/jiecheng/aboutmy/AboutMyActivity.java
Executable file
82
app/src/main/java/com/pukka/jiecheng/aboutmy/AboutMyActivity.java
Executable file
@@ -0,0 +1,82 @@
|
||||
package com.pukka.jiecheng.aboutmy;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.base.BaseActivity;
|
||||
import com.pukka.jiecheng.device.DeviceActivity;
|
||||
import com.pukka.jiecheng.index.HotelMyActivity;
|
||||
import com.pukka.jiecheng.utils.MgRoute;
|
||||
import com.pukka.libcore.base.BuildConfig;
|
||||
|
||||
public class AboutMyActivity extends BaseActivity {
|
||||
private int volumeUpPressCount = 0;
|
||||
private TextView mTvAboutTitle;
|
||||
ConstraintLayout mClYhxy,mClYsxy,mClSubmit;
|
||||
private String YHXY="https://servhub-ep01.future.jetsentv.com/h5/pages/user/index.html";
|
||||
private String YSXY="https://servhub-ep01.future.jetsentv.com/h5/pages/privacy/index.html";
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_about_my);
|
||||
initView();
|
||||
initListener();
|
||||
volumeUpPressCount = 0;
|
||||
}
|
||||
private void initView(){
|
||||
mTvAboutTitle = findViewById(R.id.id_tv_about_title);
|
||||
mClYhxy = findViewById(R.id.id_cl_yhxy);
|
||||
mClYsxy = findViewById(R.id.id_cl_ysxy);
|
||||
mClSubmit = findViewById(R.id.id_cl_submit);
|
||||
initGamePad();
|
||||
//enableBackButton();
|
||||
}
|
||||
private void initListener(){
|
||||
LongPressSpanHelper.setupLongPressOnWord(
|
||||
mTvAboutTitle,
|
||||
mTvAboutTitle.getText().toString(),
|
||||
"我",
|
||||
3000L,
|
||||
() -> {
|
||||
DeviceActivity.start(this);
|
||||
}
|
||||
);
|
||||
|
||||
mClYhxy.setOnClickListener(view->{
|
||||
MgRoute.go2UserAgree(mContext,YHXY);
|
||||
});
|
||||
|
||||
mClYsxy.setOnClickListener(view -> {
|
||||
MgRoute.go2UserAgree(mContext,YSXY);
|
||||
});
|
||||
|
||||
mClSubmit.setOnClickListener(view -> {
|
||||
finish();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
volumeUpPressCount = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
if (keyCode == KeyEvent.KEYCODE_DPAD_UP && mClYhxy.isFocused()) {
|
||||
volumeUpPressCount++;
|
||||
//ToastUtils.showShortToast("第 " + volumeUpPressCount + " 次上键");
|
||||
if(volumeUpPressCount == 3){
|
||||
volumeUpPressCount = 0;
|
||||
Intent intent = new Intent(this, HotelMyActivity.class);
|
||||
// 启动目标Activity
|
||||
startActivity(intent);
|
||||
}
|
||||
}
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
}
|
||||
105
app/src/main/java/com/pukka/jiecheng/aboutmy/LongPressSpanHelper.kt
Executable file
105
app/src/main/java/com/pukka/jiecheng/aboutmy/LongPressSpanHelper.kt
Executable file
@@ -0,0 +1,105 @@
|
||||
/**
|
||||
* @file LongPressSpanHelper.kt
|
||||
* @description 标题指定字符长按触发工具
|
||||
* @author ainetv
|
||||
* @date 2026-03-23
|
||||
*/
|
||||
package com.pukka.jiecheng.aboutmy
|
||||
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.MotionEvent
|
||||
import android.widget.TextView
|
||||
|
||||
object LongPressSpanHelper {
|
||||
|
||||
@JvmStatic
|
||||
fun setupLongPressOnWord(
|
||||
textView: TextView,
|
||||
fullText: String,
|
||||
targetWord: String,
|
||||
durationMs: Long = 3000L,
|
||||
onTrigger: Runnable
|
||||
) {
|
||||
textView.text = fullText
|
||||
if (targetWord.isEmpty()) {
|
||||
textView.setOnTouchListener(null)
|
||||
return
|
||||
}
|
||||
val targetStart = fullText.indexOf(targetWord)
|
||||
if (targetStart < 0) {
|
||||
textView.setOnTouchListener(null)
|
||||
return
|
||||
}
|
||||
val targetEnd = targetStart + targetWord.length
|
||||
val mainHandler = Handler(Looper.getMainLooper())
|
||||
var isPressTracking = false
|
||||
var hasTriggered = false
|
||||
|
||||
val triggerRunnable = Runnable {
|
||||
if (isPressTracking && !hasTriggered) {
|
||||
hasTriggered = true
|
||||
onTrigger.run()
|
||||
}
|
||||
}
|
||||
|
||||
fun cancelTracking() {
|
||||
isPressTracking = false
|
||||
mainHandler.removeCallbacks(triggerRunnable)
|
||||
}
|
||||
|
||||
textView.setOnTouchListener { v, event ->
|
||||
val tv = v as TextView
|
||||
when (event.actionMasked) {
|
||||
MotionEvent.ACTION_DOWN -> {
|
||||
hasTriggered = false
|
||||
val hitTarget = isTouchInsideWord(tv, event, targetStart, targetEnd)
|
||||
if (!hitTarget) {
|
||||
cancelTracking()
|
||||
return@setOnTouchListener false
|
||||
}
|
||||
isPressTracking = true
|
||||
mainHandler.removeCallbacks(triggerRunnable)
|
||||
mainHandler.postDelayed(triggerRunnable, durationMs)
|
||||
true
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_MOVE -> {
|
||||
if (!isPressTracking) return@setOnTouchListener false
|
||||
val stillInside = isTouchInsideWord(tv, event, targetStart, targetEnd)
|
||||
if (!stillInside) {
|
||||
cancelTracking()
|
||||
}
|
||||
true
|
||||
}
|
||||
|
||||
MotionEvent.ACTION_UP, MotionEvent.ACTION_CANCEL -> {
|
||||
val consumed = isPressTracking || hasTriggered
|
||||
cancelTracking()
|
||||
hasTriggered = false
|
||||
consumed
|
||||
}
|
||||
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun isTouchInsideWord(
|
||||
textView: TextView,
|
||||
event: MotionEvent,
|
||||
targetStart: Int,
|
||||
targetEnd: Int
|
||||
): Boolean {
|
||||
val layout = textView.layout ?: return false
|
||||
val x = event.x - textView.totalPaddingLeft + textView.scrollX
|
||||
val y = event.y - textView.totalPaddingTop + textView.scrollY
|
||||
if (x < 0f || y < 0f || y > layout.height) return false
|
||||
val line = layout.getLineForVertical(y.toInt())
|
||||
val lineLeft = layout.getLineLeft(line)
|
||||
val lineRight = layout.getLineRight(line)
|
||||
if (x < lineLeft || x > lineRight) return false
|
||||
val offset = layout.getOffsetForHorizontal(line, x)
|
||||
return offset in targetStart until targetEnd
|
||||
}
|
||||
}
|
||||
408
app/src/main/java/com/pukka/jiecheng/base/BaseActivity.java
Executable file
408
app/src/main/java/com/pukka/jiecheng/base/BaseActivity.java
Executable file
@@ -0,0 +1,408 @@
|
||||
/**
|
||||
* @file BaseActivity.java
|
||||
* @description Activity 基类,提供公共功能:按键节流、网络监听、返回按钮等
|
||||
* @author ainetv
|
||||
* @date 2026-04-16
|
||||
*/
|
||||
package com.pukka.jiecheng.base;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.Gravity;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.lifecycle.MutableLiveData;
|
||||
|
||||
import com.pukka.jiecheng.BuildConfig;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.config.AppConfiguration;
|
||||
import com.pukka.jiecheng.monitor.HomeMonitor;
|
||||
import com.pukka.jiecheng.monitor.NetworkMonitor;
|
||||
import com.pukka.jiecheng.newtv.NewTvListner;
|
||||
import com.pukka.jiecheng.newtv.NewTvManager;
|
||||
import com.pukka.jiecheng.newtv.NewTvUtils;
|
||||
import com.pukka.jiecheng.newtv.NewTvView;
|
||||
import com.pukka.jiecheng.utils.ChannelManger;
|
||||
import com.pukka.libcore.boxShared.BoxSharedParamsUtils;
|
||||
import com.pukka.libcore.utils.AppManager;
|
||||
import com.pukka.libcore.utils.AppUtils;
|
||||
import com.pukka.libcore.utils.GreyingManager;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
import com.pukka.libcore.utils.StringUtils;
|
||||
|
||||
|
||||
/**
|
||||
* Activity 基类
|
||||
*
|
||||
* 主要功能:
|
||||
* 1. 按键节流机制(防止快速连续按键)
|
||||
* 2. 网络状态监听
|
||||
* 3. 返回按钮管理(触摸模式)
|
||||
* 4. 未来认证页面显示
|
||||
* 5. 应用变灰功能
|
||||
*
|
||||
* 架构设计:
|
||||
* - 提供模板方法模式,子类可重写特定方法
|
||||
* - 使用策略模式实现按键节流
|
||||
* - 使用观察者模式监听网络状态
|
||||
*
|
||||
* @author ainetv
|
||||
*/
|
||||
public class BaseActivity extends AppCompatActivity implements NetworkMonitor.NetworkReceiver {
|
||||
private static final String TAG = "BaseActivity ";
|
||||
|
||||
protected long mLastKeyDownTime;
|
||||
|
||||
protected boolean goToOtherApp;
|
||||
|
||||
public static boolean isResumeVideo = false;
|
||||
protected Context mContext;
|
||||
|
||||
protected NetworkMonitor networkMonitor;
|
||||
private NewTvListner newTvListner;
|
||||
private boolean newtvState;
|
||||
|
||||
protected ImageView mIvGamePad;
|
||||
|
||||
private LinearLayout mBackButton;
|
||||
private boolean mBackButtonEnabled = false;
|
||||
private OnBackButtonClickListener mBackButtonClickListener;
|
||||
|
||||
public interface OnBackButtonClickListener {
|
||||
void onBackButtonClick();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mContext = this;
|
||||
goToOtherApp = false;
|
||||
AppManager.getAppManager().addActivity(this);
|
||||
themeGrey();
|
||||
registerBroadcastReceiver();
|
||||
HomeMonitor.registerReceiver(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
//可见但不在前台
|
||||
LogUtils.d("BaseActivity onStart()");
|
||||
AppManager.getAppManager().addCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
LogUtils.d("BaseActivity onResume()");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
//完全不可见
|
||||
LogUtils.d("BaseActivity onStop()");
|
||||
AppManager.getAppManager().reduceCount();
|
||||
}
|
||||
|
||||
|
||||
public void killApp() {
|
||||
NewTvUtils.getInstance().newTvLogAppExit();
|
||||
AppManager.getAppManager().appExit();
|
||||
}
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
AppManager.getAppManager().finishActivity(this);
|
||||
unregisterBroadcastReceiver();
|
||||
}
|
||||
|
||||
/**
|
||||
* 所有Activity变灰
|
||||
*/
|
||||
private void themeGrey() {
|
||||
int type = SystemConfigManager.getInstance().isGreying();
|
||||
if (type == 0) {
|
||||
GreyingManager.themeGrey(type, getWindow());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按键节流策略配置
|
||||
*
|
||||
* 设计意图:
|
||||
* - 防止用户快速连续按键导致的重复操作
|
||||
* - 子类可重写 shouldThrottleKey() 方法自定义节流策略
|
||||
* - 子类可重写 getThrottleInterval() 方法自定义节流间隔
|
||||
*
|
||||
* 默认策略:
|
||||
* - 所有按键节流间隔为 100ms
|
||||
* - 子类可通过重写 shouldThrottleKey() 排除特定按键
|
||||
*/
|
||||
@Override
|
||||
public boolean onKeyDown(int keyCode, KeyEvent event) {
|
||||
boolean dispatch = super.onKeyDown(keyCode, event);
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
// 检查是否需要节流该按键
|
||||
if (shouldThrottleKey(keyCode, event)) {
|
||||
long current = System.currentTimeMillis();
|
||||
long interval = getThrottleInterval(keyCode);
|
||||
if (current - mLastKeyDownTime < interval) {
|
||||
LogUtils.d(TAG, "按键被节流: keyCode=" + keyCode + ", interval=" + interval + "ms");
|
||||
return true;
|
||||
}
|
||||
mLastKeyDownTime = current;
|
||||
}
|
||||
} else if (keyCode == KeyEvent.KEYCODE_HOME) {
|
||||
// 处理Home键按下事件
|
||||
NewTvUtils.getInstance().newTvLogAppExit();
|
||||
AppManager.getAppManager().appExit();
|
||||
return dispatch;
|
||||
}
|
||||
return dispatch;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否需要节流该按键
|
||||
* 子类可重写此方法自定义节流策略
|
||||
*
|
||||
* @param keyCode 按键代码
|
||||
* @param event 按键事件
|
||||
* @return true 表示需要节流,false 表示不节流
|
||||
*/
|
||||
protected boolean shouldThrottleKey(int keyCode, KeyEvent event) {
|
||||
// 默认对所有按键进行节流
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取按键节流间隔(毫秒)
|
||||
* 子类可重写此方法自定义节流间隔
|
||||
*
|
||||
* @param keyCode 按键代码
|
||||
* @return 节流间隔(毫秒)
|
||||
*/
|
||||
protected long getThrottleInterval(int keyCode) {
|
||||
// 默认节流间隔为 100ms
|
||||
return 100;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onUserLeaveHint() {
|
||||
super.onUserLeaveHint();
|
||||
LogUtils.e(TAG + "onUserLeaveHint ---Activity : " + AppUtils.getTopActivity());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void currentNetType(String currentNetType) {
|
||||
LogUtils.d(TAG, "currentNetType:" + currentNetType);
|
||||
if ("unknown".equals(currentNetType)) {
|
||||
isResumeVideo = true;
|
||||
//NoNetworkActivity.start(this);
|
||||
} else {
|
||||
//AppManager.getAppManager().finishAppointActivity(NoNetworkActivity.class);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册网络广播、install广播
|
||||
*/
|
||||
public void registerBroadcastReceiver() {
|
||||
networkMonitor = new NetworkMonitor();
|
||||
networkMonitor.setNetworkNativeReceiver(this);
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction("android.net.conn.CONNECTIVITY_CHANGE");
|
||||
filter.addAction("android.net.wifi.WIFI_STATE_CHANGED");
|
||||
filter.addAction("android.net.wifi.STATE_CHANGE");
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
||||
mContext.registerReceiver(networkMonitor, filter, Context.RECEIVER_NOT_EXPORTED);
|
||||
} else {
|
||||
mContext.registerReceiver(networkMonitor, filter);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 反注册网络广播、install广播
|
||||
*/
|
||||
public void unregisterBroadcastReceiver() {
|
||||
mContext.unregisterReceiver(networkMonitor);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 未来认证页面显示
|
||||
*/
|
||||
public void activityShowNewTv() {
|
||||
String saveState = NewTvManager.getInstance().getNewtvState();
|
||||
if (!StringUtils.isEmpty(saveState)){
|
||||
return;
|
||||
}
|
||||
// 获取Activity的DecorView
|
||||
View decorView = getWindow().getDecorView();
|
||||
// 获取DecorView的ViewGroup
|
||||
ViewGroup decorViewGroup = (ViewGroup) decorView;
|
||||
|
||||
String state = NewTvManager.getInstance().getState();
|
||||
NewTvManager.getInstance().setNewtvState(state);
|
||||
boolean isFail = "fail".equals(state);
|
||||
newtvState = isFail;
|
||||
if (isFail) {
|
||||
removeDecorView(decorViewGroup);
|
||||
if (NewTvManager.getInstance().getNewTvView() != null) {
|
||||
NewTvManager.getInstance().getNewTvView().showError(isFail);
|
||||
decorViewGroup.addView(NewTvManager.getInstance().getNewTvView());
|
||||
}
|
||||
} else {
|
||||
MutableLiveData<String> goActivityData = new MutableLiveData<String>();
|
||||
goActivityData.observe(this, s -> {
|
||||
LogUtils.d("activityShowNewTv --observe : "+s);
|
||||
NewTvManager.getInstance().setNewtvState(s);
|
||||
removeDecorView(decorViewGroup);
|
||||
boolean fail = "fail".equals(s);
|
||||
newtvState = fail;
|
||||
if (fail) {
|
||||
if (NewTvManager.getInstance().getNewTvView() != null) {
|
||||
NewTvManager.getInstance().getNewTvView().showError(fail);
|
||||
decorViewGroup.addView(NewTvManager.getInstance().getNewTvView());
|
||||
}
|
||||
if (newTvListner != null) {
|
||||
newTvListner.playerPause();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
LogUtils.d("activityShowNewTv --state : "+state);
|
||||
|
||||
}
|
||||
|
||||
private void removeDecorView(ViewGroup decorViewGroup){
|
||||
try {
|
||||
int size = decorViewGroup.getChildCount();
|
||||
for (int i = 0; i < size; i++) {
|
||||
View view = decorViewGroup.getChildAt(i);
|
||||
if (view instanceof NewTvView) {
|
||||
decorViewGroup.removeView(view);
|
||||
LogUtils.d("activityShowNewTv: removeDecorView ");
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前未来认证的状态
|
||||
* @return
|
||||
*/
|
||||
public boolean getNewTvState(){
|
||||
LogUtils.d("getNewTvState -- :"+newtvState);
|
||||
return newtvState;
|
||||
}
|
||||
|
||||
public void setNewTvListner(NewTvListner listner){
|
||||
newTvListner = listner;
|
||||
}
|
||||
|
||||
protected void initGamePad(){
|
||||
if(BoxSharedParamsUtils.isJcCloud() || ChannelManger.isAnNingHotel()){
|
||||
//安柠游戏和安柠酒店版本显示手柄
|
||||
mIvGamePad = findViewById(R.id.id_iv_game_pad);
|
||||
if(null != mIvGamePad) {
|
||||
LogUtils.d("显示手柄");
|
||||
mIvGamePad.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void enableBackButton() {
|
||||
if(AppConfiguration.getInstance().isTouchMode()) {
|
||||
enableBackButton(null);
|
||||
}
|
||||
}
|
||||
|
||||
protected void enableBackButton(OnBackButtonClickListener listener) {
|
||||
if(AppConfiguration.getInstance().isTouchMode()) {
|
||||
mBackButtonClickListener = listener;
|
||||
mBackButtonEnabled = true;
|
||||
createAndShowBackButton();
|
||||
}
|
||||
}
|
||||
|
||||
protected void disableBackButton() {
|
||||
mBackButtonEnabled = false;
|
||||
removeBackButton();
|
||||
}
|
||||
|
||||
private void createAndShowBackButton() {
|
||||
if (mBackButton != null) {
|
||||
mBackButton.setVisibility(View.VISIBLE);
|
||||
return;
|
||||
}
|
||||
|
||||
FrameLayout contentLayout = findViewById(android.R.id.content);
|
||||
if (contentLayout == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mBackButton = new LinearLayout(this);
|
||||
mBackButton.setId(R.id.id_back_button_floating);
|
||||
mBackButton.setOrientation(LinearLayout.VERTICAL);
|
||||
mBackButton.setGravity(Gravity.CENTER);
|
||||
mBackButton.setFocusable(true);
|
||||
mBackButton.setClickable(true);
|
||||
mBackButton.setBackground(ContextCompat.getDrawable(this, R.drawable.bg_search_back_btn_selector));
|
||||
|
||||
int buttonSize = (int) getResources().getDimension(R.dimen.qb_px_80);
|
||||
int iconSize = (int) getResources().getDimension(R.dimen.qb_px_28);
|
||||
int marginEnd = (int) getResources().getDimension(R.dimen.qb_px_40);
|
||||
int marginBottom = (int) getResources().getDimension(R.dimen.qb_px_40);
|
||||
|
||||
FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(buttonSize, buttonSize);
|
||||
layoutParams.gravity = Gravity.BOTTOM | Gravity.END;
|
||||
layoutParams.setMargins(0, 0, marginEnd, marginBottom);
|
||||
mBackButton.setLayoutParams(layoutParams);
|
||||
|
||||
ImageView iconView = new ImageView(this);
|
||||
LinearLayout.LayoutParams iconParams = new LinearLayout.LayoutParams(iconSize, iconSize);
|
||||
iconView.setLayoutParams(iconParams);
|
||||
iconView.setImageResource(R.drawable.icon_detail_back_normal);
|
||||
mBackButton.addView(iconView);
|
||||
|
||||
mBackButton.setOnClickListener(v -> {
|
||||
if (mBackButtonClickListener != null) {
|
||||
mBackButtonClickListener.onBackButtonClick();
|
||||
} else {
|
||||
finish();
|
||||
}
|
||||
});
|
||||
|
||||
contentLayout.addView(mBackButton);
|
||||
}
|
||||
|
||||
private void removeBackButton() {
|
||||
if (mBackButton != null && mBackButton.getParent() != null) {
|
||||
ViewGroup parent = (ViewGroup) mBackButton.getParent();
|
||||
parent.removeView(mBackButton);
|
||||
mBackButton = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected LinearLayout getBackButton() {
|
||||
return mBackButton;
|
||||
}
|
||||
|
||||
protected boolean isBackButtonEnabled() {
|
||||
return mBackButtonEnabled;
|
||||
}
|
||||
|
||||
}
|
||||
20
app/src/main/java/com/pukka/jiecheng/base/BaseOnItemClickListener.java
Executable file
20
app/src/main/java/com/pukka/jiecheng/base/BaseOnItemClickListener.java
Executable file
@@ -0,0 +1,20 @@
|
||||
package com.pukka.jiecheng.base;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* 列表Item点击事件接口基类
|
||||
*
|
||||
* @author MajorLL
|
||||
*/
|
||||
public interface BaseOnItemClickListener<T> {
|
||||
|
||||
/**
|
||||
* item 点击事件
|
||||
*
|
||||
* @param view 点击view
|
||||
* @param position 点击位置
|
||||
* @param t item 泛型数据类
|
||||
*/
|
||||
public void onItemClick(View view, int position,T t);
|
||||
}
|
||||
22
app/src/main/java/com/pukka/jiecheng/base/BaseOnItemFocusChangeListener.java
Executable file
22
app/src/main/java/com/pukka/jiecheng/base/BaseOnItemFocusChangeListener.java
Executable file
@@ -0,0 +1,22 @@
|
||||
package com.pukka.jiecheng.base;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
/**
|
||||
* item 焦点变化事件
|
||||
*
|
||||
* @author MajorLL
|
||||
*/
|
||||
public interface BaseOnItemFocusChangeListener<T> {
|
||||
|
||||
/**
|
||||
* item 焦点变化
|
||||
*
|
||||
* @param v 当前view
|
||||
* @param hasFocus 是否获取焦点
|
||||
* @param position 获取位置
|
||||
* @param t 对应泛型数据
|
||||
*/
|
||||
public void onItemFocusChange(View v , boolean hasFocus, int position ,T t);
|
||||
|
||||
}
|
||||
118
app/src/main/java/com/pukka/jiecheng/base/BasePresenter.java
Executable file
118
app/src/main/java/com/pukka/jiecheng/base/BasePresenter.java
Executable file
@@ -0,0 +1,118 @@
|
||||
|
||||
package com.pukka.jiecheng.base;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.leanback.widget.Presenter;
|
||||
|
||||
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public abstract class BasePresenter<VH extends BasePresenterViewHolder, D> extends Presenter {
|
||||
|
||||
/**
|
||||
* item 点击事件
|
||||
*/
|
||||
protected OnItemClickListener<D> onItemClickListener = null;
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener<D> onItemClickListener) {
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewHolder onCreateViewHolder(ViewGroup viewGroup) {
|
||||
// long time = System.currentTimeMillis();
|
||||
View view;
|
||||
int layoutResId = getLayoutResId();
|
||||
if (layoutResId <= 0) {
|
||||
view = new View(viewGroup.getContext());
|
||||
} else {
|
||||
view = LayoutInflater.from(viewGroup.getContext()).inflate(getLayoutResId(), viewGroup, false);
|
||||
}
|
||||
ViewHolder viewHolder = createViewHolder(view);
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder viewHolder, Object o) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(ViewHolder viewHolder, Object item, List<Object> payloads) {
|
||||
try {
|
||||
((VH) viewHolder).bindViewHolderPayloads(item,payloads);
|
||||
if (onItemClickListener != null) {
|
||||
((VH) viewHolder).view.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onItemClickListener.onItemClick(viewHolder.view, (D) item);
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (ClassCastException e) {
|
||||
LogUtils.e(getLogTag() + "onBindViewHolder, cast param failed. " +e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewAttachedToWindow(ViewHolder viewHolder) {
|
||||
super.onViewAttachedToWindow(viewHolder);
|
||||
try {
|
||||
((VH) viewHolder).setAttachedToWindow(true);
|
||||
} catch (ClassCastException e) {
|
||||
LogUtils.e(getLogTag() + "onViewAttachedToWindow, cast param failed." + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewDetachedFromWindow(ViewHolder viewHolder) {
|
||||
super.onViewDetachedFromWindow(viewHolder);
|
||||
try {
|
||||
((VH) viewHolder).setAttachedToWindow(false);
|
||||
} catch (ClassCastException e) {
|
||||
LogUtils.e(getLogTag() + "onViewDetachedFromWindow, cast param failed." + e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUnbindViewHolder(ViewHolder viewHolder) {
|
||||
try {
|
||||
// long time = System.currentTimeMillis();
|
||||
((VH) viewHolder).unBindViewHolder();
|
||||
// Logger.d(getLogTag(), "onUnbindViewHolder. cost: " + (System.currentTimeMillis() - time));
|
||||
} catch (ClassCastException e) {
|
||||
LogUtils.e(getLogTag() + "onUnbindViewHolder, cast param failed." + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取布局的资源Id
|
||||
*
|
||||
* @return 布局的资源Id
|
||||
*/
|
||||
protected abstract int getLayoutResId();
|
||||
|
||||
/**
|
||||
* 创建一个ViewHolder的实例
|
||||
*
|
||||
* @param view view对象
|
||||
* @return viewHolder的实例
|
||||
*/
|
||||
protected abstract VH createViewHolder(View view);
|
||||
|
||||
/**
|
||||
* 获取日志的TAG
|
||||
*
|
||||
* @return 日志的TAG
|
||||
*/
|
||||
protected abstract String getLogTag();
|
||||
|
||||
public interface OnItemClickListener<D> {
|
||||
void onItemClick(View view, D d);
|
||||
}
|
||||
}
|
||||
75
app/src/main/java/com/pukka/jiecheng/base/BasePresenterViewHolder.java
Executable file
75
app/src/main/java/com/pukka/jiecheng/base/BasePresenterViewHolder.java
Executable file
@@ -0,0 +1,75 @@
|
||||
|
||||
package com.pukka.jiecheng.base;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.leanback.widget.Presenter;
|
||||
|
||||
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public abstract class BasePresenterViewHolder<D> extends Presenter.ViewHolder {
|
||||
/**
|
||||
* 布局是否绑定到窗口
|
||||
*/
|
||||
protected boolean mIsAttachedToWindow = false;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*
|
||||
* @param view 布局对象
|
||||
*/
|
||||
public BasePresenterViewHolder(View view) {
|
||||
super(view);
|
||||
initView(view);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化布局<BR>
|
||||
* 子类可以进行布局的findViewById等操作,提升bindData的性能
|
||||
*
|
||||
* @param itemView 布局
|
||||
*/
|
||||
protected abstract void initView(View itemView);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 绑定数据(刷新时调用)
|
||||
*
|
||||
* @param data 数据对象
|
||||
*/
|
||||
protected abstract void onBindDataPayloads(D data, List<Object> payloads);
|
||||
|
||||
/**
|
||||
* 接触绑定数据
|
||||
*/
|
||||
protected abstract void onUnbindData();
|
||||
|
||||
void bindViewHolderPayloads(Object item, List<Object> payloads) {
|
||||
try {
|
||||
onBindDataPayloads((D) item,payloads);
|
||||
} catch (ClassCastException e) {
|
||||
LogUtils.e("bindViewHolder, cast param failed." + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解绑视图ViewHolder
|
||||
*/
|
||||
void unBindViewHolder() {
|
||||
onUnbindData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否绑定到窗口
|
||||
*
|
||||
* @param isAttachedInWindow true表示绑定到窗口
|
||||
*/
|
||||
void setAttachedToWindow(boolean isAttachedInWindow) {
|
||||
mIsAttachedToWindow = isAttachedInWindow;
|
||||
}
|
||||
}
|
||||
144
app/src/main/java/com/pukka/jiecheng/base/BaseRecyclerAdapter.java
Executable file
144
app/src/main/java/com/pukka/jiecheng/base/BaseRecyclerAdapter.java
Executable file
@@ -0,0 +1,144 @@
|
||||
package com.pukka.jiecheng.base;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author MajorLL
|
||||
*/
|
||||
public abstract class BaseRecyclerAdapter<T> extends RecyclerView.Adapter<BaseRecyclerViewHolder<T>> {
|
||||
/**
|
||||
* 源数据
|
||||
*/
|
||||
protected List<T> mData;
|
||||
/**
|
||||
* item 点击事件
|
||||
*/
|
||||
protected BaseOnItemClickListener<T> onItemClickListener = null;
|
||||
|
||||
/**
|
||||
* item 焦点变化事件
|
||||
*/
|
||||
protected BaseOnItemFocusChangeListener<T> onItemFocusChangeListener = null;
|
||||
|
||||
|
||||
/**
|
||||
* 获取当前布局资源文件ID
|
||||
*
|
||||
* @param viewType viewType类型
|
||||
* @return 返回资源ID
|
||||
*/
|
||||
protected abstract int getLayoutId(int viewType);
|
||||
|
||||
/**
|
||||
* 获取对应ViewHolder
|
||||
*
|
||||
* @param view
|
||||
* @param viewType
|
||||
* @return
|
||||
*/
|
||||
public abstract BaseRecyclerViewHolder<T> getViewHolder(View view, int viewType);
|
||||
|
||||
public BaseRecyclerAdapter(@NonNull List<T> mData) {
|
||||
this.mData = mData;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对应位置泛型数据对象
|
||||
*
|
||||
* @param position 位置
|
||||
* @return 泛型数据
|
||||
*/
|
||||
protected T getIndexData(int position) {
|
||||
if (mData == null || mData.size() <= position) {
|
||||
return null;
|
||||
}
|
||||
return mData.get(position);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public BaseRecyclerViewHolder<T> onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(getLayoutId(viewType), parent, false);
|
||||
return getViewHolder(view, viewType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull BaseRecyclerViewHolder<T> holder, int position) {
|
||||
holder.setData(getIndexData(position));
|
||||
final int index = position;
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
holder.onItemClick(v, index, getIndexData(index));
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(v, index, getIndexData(index));
|
||||
}
|
||||
}
|
||||
});
|
||||
holder.itemView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
holder.onItemFocusChange(v, hasFocus);
|
||||
if (onItemFocusChangeListener != null) {
|
||||
onItemFocusChangeListener.onItemFocusChange(v, hasFocus, index, getIndexData(index));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (mData == null) {
|
||||
return 0;
|
||||
}
|
||||
return mData.size();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取空页面数量
|
||||
* @return 空页面数量
|
||||
*/
|
||||
public int getEmptyCount() {
|
||||
if (mData == null) {
|
||||
return 0;
|
||||
}
|
||||
int index = 0;
|
||||
for (T mDatum : mData) {
|
||||
if (mDatum == null) {
|
||||
index++;
|
||||
}
|
||||
}
|
||||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
return super.getItemViewType(position);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置对应得Item点击事件
|
||||
*
|
||||
* @param onItemClickListener item点击事件回调
|
||||
*/
|
||||
public void setOnItemClickListener(BaseOnItemClickListener<T> onItemClickListener) {
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置对应item焦点事件
|
||||
*
|
||||
* @param onItemFocusChangeListener item焦点事件回调
|
||||
*/
|
||||
public void setOnItemFocusChangeListener(BaseOnItemFocusChangeListener<T> onItemFocusChangeListener) {
|
||||
this.onItemFocusChangeListener = onItemFocusChangeListener;
|
||||
}
|
||||
}
|
||||
35
app/src/main/java/com/pukka/jiecheng/base/BaseRecyclerViewHolder.java
Executable file
35
app/src/main/java/com/pukka/jiecheng/base/BaseRecyclerViewHolder.java
Executable file
@@ -0,0 +1,35 @@
|
||||
package com.pukka.jiecheng.base;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
/**
|
||||
* RecyclerViewHolder基类
|
||||
*
|
||||
* @author MajorLL
|
||||
*/
|
||||
public abstract class BaseRecyclerViewHolder<T> extends RecyclerView.ViewHolder {
|
||||
public BaseRecyclerViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置数据
|
||||
*
|
||||
* @param t 泛型数据对象
|
||||
*/
|
||||
public abstract void setData(T t);
|
||||
|
||||
|
||||
/**
|
||||
* item焦点变化
|
||||
*
|
||||
* @param v 视图view
|
||||
* @param hasFocus 是否获取焦点
|
||||
*/
|
||||
public abstract void onItemFocusChange(View v, boolean hasFocus);
|
||||
|
||||
public abstract void onItemClick(View view, int position,T t);
|
||||
}
|
||||
75
app/src/main/java/com/pukka/jiecheng/base/BaseViewHolder.java
Executable file
75
app/src/main/java/com/pukka/jiecheng/base/BaseViewHolder.java
Executable file
@@ -0,0 +1,75 @@
|
||||
|
||||
package com.pukka.jiecheng.base;
|
||||
|
||||
import android.view.View;
|
||||
|
||||
import androidx.leanback.widget.Presenter;
|
||||
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
|
||||
public abstract class BaseViewHolder<D> extends Presenter.ViewHolder {
|
||||
/**
|
||||
* 布局是否绑定到窗口
|
||||
*/
|
||||
protected boolean mIsAttachedToWindow = false;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
*
|
||||
* @param view 布局对象
|
||||
*/
|
||||
public BaseViewHolder(View view) {
|
||||
super(view);
|
||||
initView(view);
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化布局<BR>
|
||||
* 子类可以进行布局的findViewById等操作,提升bindData的性能
|
||||
*
|
||||
* @param itemView 布局
|
||||
*/
|
||||
protected abstract void initView(View itemView);
|
||||
|
||||
/**
|
||||
* 绑定数据
|
||||
*
|
||||
* @param data 数据对象
|
||||
*/
|
||||
protected abstract void onBindData(D data);
|
||||
|
||||
/**
|
||||
* 接触绑定数据
|
||||
*/
|
||||
protected abstract void onUnbindData();
|
||||
|
||||
/**
|
||||
* 绑定视图ViewHolder
|
||||
*
|
||||
* @param data 数据对象
|
||||
*/
|
||||
void bindViewHolder(Object data) {
|
||||
try {
|
||||
onBindData((D) data);
|
||||
} catch (ClassCastException e) {
|
||||
LogUtils.e("bindViewHolder, cast param failed." + e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 解绑视图ViewHolder
|
||||
*/
|
||||
void unBindViewHolder() {
|
||||
onUnbindData();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置是否绑定到窗口
|
||||
*
|
||||
* @param isAttachedInWindow true表示绑定到窗口
|
||||
*/
|
||||
void setAttachedToWindow(boolean isAttachedInWindow) {
|
||||
mIsAttachedToWindow = isAttachedInWindow;
|
||||
}
|
||||
}
|
||||
537
app/src/main/java/com/pukka/jiecheng/base/SystemConfigManager.java
Executable file
537
app/src/main/java/com/pukka/jiecheng/base/SystemConfigManager.java
Executable file
@@ -0,0 +1,537 @@
|
||||
package com.pukka.jiecheng.base;
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.migu.bean.GetLayoutNavBean;
|
||||
import com.migu.bean.GetsystemBean;
|
||||
import com.migu.callback.AijiaCallback;
|
||||
import com.migu.httputils.HomeHttpUtils;
|
||||
import com.pukka.libcore.boxShared.BoxSharedParameters;
|
||||
import com.pukka.libcore.utils.ListUtils;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
import com.pukka.libcore.utils.SharedPreferenceUtils;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: wxf
|
||||
* Date: 2023/3/23 17:28
|
||||
* Description:全局配置管理
|
||||
*/
|
||||
public class SystemConfigManager {
|
||||
private static final SystemConfigManager M_INSTANCE = new SystemConfigManager();
|
||||
//一键变灰
|
||||
private static final int GREY_TYPE = 2;
|
||||
//是否驻留
|
||||
private static final int APP_KEEP_TYPE = 25;
|
||||
//是否隐藏VR
|
||||
private static final int HIDE_VR_TYPE = 13;
|
||||
//是否隐藏4K
|
||||
private static final int HIDE_4K_TYPE = 14;
|
||||
//VR测试流
|
||||
private static final int VRPLAYURL_TYPE = 21;
|
||||
//试看时长
|
||||
private static final int TRY_SEEING_TYPE = 3;
|
||||
//直播试看时长
|
||||
private static final int TRY_SEEING_LIVE_TYPE = 38;
|
||||
//首页垫片 shimCode
|
||||
private static final int INDEX_SHIM_CODE = 4;
|
||||
//广东iptv tid
|
||||
private static final int GUANGDONG_IPTV_TID = 62;
|
||||
//四川cdn信息
|
||||
private static final int SICHUAN_CDN = 42;
|
||||
private boolean isUserAgree;
|
||||
private String agreeDes;
|
||||
private String vrTestUrl;
|
||||
private int agreeLookDuration;
|
||||
private int tryLookDuration;
|
||||
private int tryLiveDuration;
|
||||
private String indexShimCode;
|
||||
|
||||
//退订周期 单位:天 默认365天
|
||||
private int cancelOrderPeriod = 365;
|
||||
//短视频息屏
|
||||
private int shortParseNum = 999;
|
||||
//登录页背景图
|
||||
private String loginBg = "";
|
||||
|
||||
public String getLoginBg() {
|
||||
return loginBg;
|
||||
}
|
||||
|
||||
public int getCancelOrderPeriod() {
|
||||
return cancelOrderPeriod;
|
||||
}
|
||||
|
||||
public int getShortParseNum(){
|
||||
return shortParseNum;
|
||||
}
|
||||
|
||||
|
||||
public static SystemConfigManager getInstance() {
|
||||
return M_INSTANCE;
|
||||
}
|
||||
|
||||
public GetsystemBean getsystemBean;
|
||||
|
||||
public void setGetsystemBean(GetsystemBean getsystemBean) {
|
||||
this.getsystemBean = getsystemBean;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过type值获取实体
|
||||
*
|
||||
* @param type type
|
||||
* @return 实体
|
||||
*/
|
||||
public GetsystemBean.ResultBean getResultBeanByType(int type) {
|
||||
if (null == getsystemBean) {
|
||||
return null;
|
||||
}
|
||||
|
||||
List<GetsystemBean.ResultBean> resultBeanList = getsystemBean.getResult();
|
||||
if (ListUtils.isEmpty(resultBeanList)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
int size = resultBeanList.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
if (type == resultBeanList.get(i).getType()) {
|
||||
return resultBeanList.get(i);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否一键变灰
|
||||
* 0:灰 1:正常
|
||||
*/
|
||||
public int isGreying() {
|
||||
int isGrey = 1;
|
||||
GetsystemBean.ResultBean resultBean = getResultBeanByType(GREY_TYPE);
|
||||
if (null != resultBean) {
|
||||
int status = resultBean.getStatus();
|
||||
if (status == 11) {
|
||||
// 变灰
|
||||
isGrey = 0;
|
||||
}
|
||||
}
|
||||
return isGrey;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否驻留
|
||||
*/
|
||||
public boolean isAppKeep() {
|
||||
GetsystemBean.ResultBean resultBean = getResultBeanByType(APP_KEEP_TYPE);
|
||||
return resultBean != null && 1 == resultBean.getStatus();
|
||||
}
|
||||
|
||||
/**
|
||||
* VR黑白名单
|
||||
* status 1支持 2不支持 3正常
|
||||
* 判断不支持隐藏首页vr tab (vr tab的判断在layoutnav接口里 type值为4的表示为vr tab)
|
||||
*/
|
||||
public int vrBlacklist() {
|
||||
GetsystemBean.ResultBean resultBean = getResultBeanByType(HIDE_VR_TYPE);
|
||||
if (null != resultBean) {
|
||||
return resultBean.getStatus();
|
||||
}
|
||||
return 3;
|
||||
}
|
||||
|
||||
/**
|
||||
* 4K黑白名单 == 是否隐藏4k
|
||||
* 取item里的status 1支持 2不支持 3正常
|
||||
* 判断不支持隐藏首页4k tab(4k tab的判断在layoutnav接口里 type值为3的表示为4k tab)
|
||||
*/
|
||||
public int isHide4K() {
|
||||
GetsystemBean.ResultBean resultBean = getResultBeanByType(HIDE_4K_TYPE);
|
||||
if (null != resultBean) {
|
||||
return resultBean.getStatus();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏4K导航tab
|
||||
*
|
||||
* @param response response
|
||||
*/
|
||||
public void hide4K(GetLayoutNavBean response) {
|
||||
boolean needHide4k = response != null && (isHide4K() == 2
|
||||
|| (isHide4K() != 1 && "0".equals(SharedPreferenceUtils.getString("epgToApk", "issupport4k", ""))));
|
||||
if (needHide4k) {
|
||||
for (GetLayoutNavBean.DataBean item : response.getData()) {
|
||||
if (ListUtils.isEmpty(item.getNavList())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<GetLayoutNavBean.DataBean.SubNavDataBean> iteratorSub = item.getNavList().iterator();
|
||||
while (iteratorSub.hasNext()) {
|
||||
GetLayoutNavBean.DataBean.SubNavDataBean itemSub = iteratorSub.next();
|
||||
if (3 == itemSub.getType()) {
|
||||
iteratorSub.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
removeEmptyData(response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 隐藏VR导航tab
|
||||
*
|
||||
* @param response response
|
||||
*/
|
||||
public void hideVr(GetLayoutNavBean response) {
|
||||
boolean needHideVr = response != null && (vrBlacklist() == 2
|
||||
|| (vrBlacklist() != 1 && "0".equals(SharedPreferenceUtils.getString("epgToApk", "issupportVr", ""))));
|
||||
if (needHideVr) {
|
||||
for (GetLayoutNavBean.DataBean item : response.getData()) {
|
||||
if (ListUtils.isEmpty(item.getNavList())) {
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<GetLayoutNavBean.DataBean.SubNavDataBean> iteratorSub = item.getNavList().iterator();
|
||||
while (iteratorSub.hasNext()) {
|
||||
GetLayoutNavBean.DataBean.SubNavDataBean itemSub = iteratorSub.next();
|
||||
if (4 == itemSub.getType()) {
|
||||
iteratorSub.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
removeEmptyData(response);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果VR或者4K配置在组nav中,在这个组为空时 要移除这组数据
|
||||
*
|
||||
* @param response response
|
||||
*/
|
||||
private void removeEmptyData(GetLayoutNavBean response) {
|
||||
Iterator<GetLayoutNavBean.DataBean> iterator = response.getData().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
GetLayoutNavBean.DataBean item = iterator.next();
|
||||
if (item.getNavList().size() == 0) {
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isUserAgree() {
|
||||
return isUserAgree;
|
||||
}
|
||||
|
||||
|
||||
public void getSystemResponse(OnPassData onPassData) {
|
||||
HomeHttpUtils.getsystemData(new AijiaCallback.GetsystemCallBack() {
|
||||
@Override
|
||||
public void onResponse(GetsystemBean response) {
|
||||
passResponse(response, onPassData);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void netFail() {
|
||||
onPassData.fail();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail() {
|
||||
onPassData.fail();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 配置信息
|
||||
*
|
||||
* @param getSystemBean getSystemBean
|
||||
* @param onPassData onPassData
|
||||
*/
|
||||
private void passResponse(GetsystemBean getSystemBean, OnPassData onPassData) {
|
||||
try {
|
||||
for (GetsystemBean.ResultBean resultBean : getSystemBean.getResult()) {
|
||||
int type = resultBean.getType();
|
||||
int status = resultBean.getStatus();
|
||||
String description = resultBean.getDescription();
|
||||
boolean descriptionIsNotEmpty = !TextUtils.isEmpty(description);
|
||||
LogUtils.d("resultBean -- type : " + type);
|
||||
switch (type) {
|
||||
case 1:
|
||||
//退出挽留弹窗
|
||||
break;
|
||||
case 2:
|
||||
//退订限制时长
|
||||
cancelOrderPeriod = resultBean.getLookDuration();
|
||||
LogUtils.d("cancelOrderPeriod:"+cancelOrderPeriod);
|
||||
break;
|
||||
case 3:
|
||||
shortParseNum = resultBean.getLookDuration();
|
||||
LogUtils.d("shortParseNum:"+shortParseNum);
|
||||
break;
|
||||
case 7:
|
||||
loginBg = resultBean.getCorner_url();
|
||||
LogUtils.d("loginBg:"+loginBg);
|
||||
break;
|
||||
// case 27:
|
||||
// // 设置登陆放通开关 status 0 关闭,1 打开
|
||||
// if (status == 1) {
|
||||
// BoxSharedParameters.getInstance().setToPass(true);
|
||||
// }
|
||||
// break;
|
||||
// case 40:
|
||||
// // 获取未来播控 id
|
||||
// if (descriptionIsNotEmpty) {
|
||||
// LogUtils.d("resultBean -- if 40:" + description);
|
||||
// String[] str = description.split("@@@");
|
||||
// if (str.length == 3) {
|
||||
//// if (!TextUtils.isEmpty(str[0]) && !TextUtils.isEmpty(str[1]) && !TextUtils.isEmpty(str[2])) {
|
||||
//// String channelCodePs = SpTimeUtils.getInstance(ContextUtils.getContext())
|
||||
//// .getString("NewtvSdk_channelCode", "");
|
||||
//// if (TextUtils.isEmpty(channelCodePs)) {
|
||||
//// SpTimeUtils.getInstance(ContextUtils.getContext())
|
||||
//// .setString("NewtvSdk_channelCode", str[0], 24 * SpTimeUtils.TIME_HOUR);
|
||||
//// SpTimeUtils.getInstance(ContextUtils.getContext())
|
||||
//// .setString("NewtvSdk_appKey", str[1], 24 * SpTimeUtils.TIME_HOUR);
|
||||
//// SpTimeUtils.getInstance(ContextUtils.getContext())
|
||||
//// .setString("NewtvSdk_appSecret", str[2], 24 * SpTimeUtils.TIME_HOUR);
|
||||
//// }
|
||||
//// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// break;
|
||||
// case 35:
|
||||
// LogUtils.d("resultBean -- if 35:" + status);
|
||||
// BoxSharedParameters.getInstance().setIsNetPass(status == 1);
|
||||
// break;
|
||||
// case 41:
|
||||
// LogUtils.d("resultBean -- if 41:" + status);
|
||||
// //未来认证放通
|
||||
// BoxSharedParameters.getInstance().setSwitchNewtvPassSwitch(status != 1);
|
||||
// break;
|
||||
// case 36:
|
||||
// // 设置省份id 和 code
|
||||
// String name = resultBean.getName();
|
||||
// if (!TextUtils.isEmpty(name)) {
|
||||
// LogUtils.d("resultBean -- if 36:" + name);
|
||||
// String[] str = name.split("@@@");
|
||||
// if (str.length == 2) {
|
||||
// if (str[0].length() == 2) {
|
||||
// BoxSharedParameters.getInstance().setProvinceId(str[0]);
|
||||
// BoxSharedParameters.getInstance().setProvinceCode(str[1]);
|
||||
// } else {
|
||||
// BoxSharedParameters.getInstance().setProvinceId(str[1]);
|
||||
// BoxSharedParameters.getInstance().setProvinceCode(str[0]);
|
||||
// }
|
||||
// }
|
||||
// // 全国走基地逻辑
|
||||
// if (!TextUtils.isEmpty(BoxSharedParameters.getInstance().getProvinceId())
|
||||
// && BoxSharedParameters.getInstance().getProvinceId().equals("90")) {
|
||||
// BoxSharedParameters.getInstance().setChannelType("jd");
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case 23:
|
||||
// // 设置网络Base api
|
||||
// if (descriptionIsNotEmpty) {
|
||||
// LogUtils.d("resultBean -- if 23:" + description);
|
||||
//// HttpRetrofitRequest.getInstances().setHttpBaseUrl(description);
|
||||
// }
|
||||
// break;
|
||||
// case 26:
|
||||
// LogUtils.d("resultBean -- if 26:" + description);
|
||||
// // 取description 字段,0:vr-mediaplayer 1:vr-mediacodec 2:vr-软解
|
||||
// BoxSharedParameters.getInstance().setVrType(description);
|
||||
// break;
|
||||
// case 31:
|
||||
// if (descriptionIsNotEmpty) {
|
||||
// LogUtils.d("resultBean -- if 31:" + description);
|
||||
// BoxSharedParameters.getInstance().setHotSearchId(description);
|
||||
// }
|
||||
// break;
|
||||
// case 34:
|
||||
// LogUtils.d("resultBean -- if 34:" + status);
|
||||
// BoxSharedParameters.getInstance().setShowSearchHot(status != 1);
|
||||
// break;
|
||||
// case 43:
|
||||
// // 取description 字段,0:系统播放器 1:杭研播放器
|
||||
// if (descriptionIsNotEmpty) {
|
||||
// LogUtils.d("resultBean -- if 43:" + description);
|
||||
// if (description.equals("0")) {
|
||||
// BoxSharedParameters.getInstance().setVideoPlayType(0);
|
||||
// } else if (description.equals("1")) {
|
||||
// BoxSharedParameters.getInstance().setVideoPlayType(1);
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case 44:
|
||||
// // 取description 字段,0:系统键盘 1:tsg自研键盘
|
||||
// if (descriptionIsNotEmpty) {
|
||||
// LogUtils.d("resultBean -- if 44:" + description);
|
||||
//// if (description.equals("0")) {
|
||||
//// ShowLogon.keybordStatus = 0;
|
||||
//// } else {
|
||||
//// ShowLogon.keybordStatus = 1;
|
||||
//// }
|
||||
// }
|
||||
// break;
|
||||
// case 47:
|
||||
// // 取description EPG地址
|
||||
// if (descriptionIsNotEmpty) {
|
||||
// LogUtils.d("resultBean -- if 47:" + description);
|
||||
// // BoxSharedParameters.getInstance().setEpgUrl(description);
|
||||
// // BaseUrl.getSingleton().setHomeUrl(description);
|
||||
// }
|
||||
// break;
|
||||
// case 53:
|
||||
// // 取description 域名白名单
|
||||
// if (descriptionIsNotEmpty) {
|
||||
// LogUtils.d("resultBean -- if 53:" + description);
|
||||
//// BaseWay.getSingleton().setcmdUrl(description);
|
||||
//// BaseWay.getSingleton().setPassUrl(description);
|
||||
// }
|
||||
// break;
|
||||
// case 56:
|
||||
// // 取description 省测鉴权主接口
|
||||
// if (descriptionIsNotEmpty) {
|
||||
// LogUtils.d("resultBean -- if 56:" + description);
|
||||
// BoxSharedParameters.getInstance().setProvInteface(description);
|
||||
// }
|
||||
// break;
|
||||
// case 64:
|
||||
// // 取status 1 :NATIVE 模式 2 :H5 模式
|
||||
// LogUtils.d("resultBean -- if 64:" + status);
|
||||
// BoxSharedParameters.getInstance().setLoadType(status);
|
||||
//
|
||||
// break;
|
||||
// case 37:
|
||||
// // 用户协议
|
||||
// if (status == 1) {
|
||||
// // 开
|
||||
// isUserAgree = true;
|
||||
// agreeDes = description;
|
||||
// agreeLookDuration = resultBean.getLookDuration();
|
||||
// LogUtils.d("resultBean -- if 37:" + description);
|
||||
// LogUtils.d("resultBean -- if 37:" + agreeLookDuration);
|
||||
// } else {
|
||||
// isUserAgree = false;
|
||||
// }
|
||||
//
|
||||
// break;
|
||||
// case 61:
|
||||
// //免杀白名单
|
||||
// LogUtils.d("resultBean -- if 61:" + resultBean.getDescription());
|
||||
//// if(!TextUtils.isEmpty(resultBean.getDescription())){
|
||||
//// DifferenceData.UserLeaveHintDF.addNoKillPackage(Arrays.asList(resultBean.getDescription().split("@@@")));
|
||||
//// }
|
||||
//
|
||||
// break;
|
||||
// case VRPLAYURL_TYPE:
|
||||
// // VR测试流
|
||||
// vrTestUrl = resultBean.getCornerurl();
|
||||
// LogUtils.d("resultBean -- if 21:" + vrTestUrl);
|
||||
// break;
|
||||
// case TRY_SEEING_TYPE:
|
||||
// // 试看时长
|
||||
// tryLookDuration = resultBean.getLookDuration();
|
||||
// break;
|
||||
// case TRY_SEEING_LIVE_TYPE:
|
||||
// // 直播试看时长
|
||||
// tryLiveDuration = resultBean.getLookDuration();
|
||||
// break;
|
||||
// case INDEX_SHIM_CODE:
|
||||
// // 首页垫片 shimCode
|
||||
// indexShimCode = resultBean.getShimCode();
|
||||
// break;
|
||||
// case GUANGDONG_IPTV_TID:
|
||||
// // 广东iptv tid
|
||||
// if (descriptionIsNotEmpty) {
|
||||
// String tid = description.split("@@@")[0];
|
||||
// String cpid = description.split("@@@")[1];
|
||||
// SharedPreferenceUtils.put("guangdong","iptvTid",tid);
|
||||
// SharedPreferenceUtils.put("guangdong","iptvCpid",cpid);
|
||||
// LogUtils.d("resultBean --tid : "+tid);
|
||||
// LogUtils.d("resultBean --cpid : "+cpid);
|
||||
// }
|
||||
// break;
|
||||
// case SICHUAN_CDN:
|
||||
// if (descriptionIsNotEmpty) {
|
||||
// LogUtils.d("resultBean -- if 42:" + description);
|
||||
// BoxSharedParameters.getInstance().setCdnInfo(description);
|
||||
// }
|
||||
// break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
//setData();
|
||||
LogUtils.d("resultBean -- over ");
|
||||
LogUtils.e("resultBean -- resultBean :执行over 前");
|
||||
onPassData.onResponse(getSystemBean);
|
||||
LogUtils.e("resultBean -- resultBean :执行over ");
|
||||
} catch (Exception e) {
|
||||
LogUtils.d("resultBean -- Exception " + e);
|
||||
onPassData.onResponse(getSystemBean);
|
||||
}
|
||||
}
|
||||
|
||||
// private void setData() {
|
||||
// String channelCodePs = SpTimeUtils.getInstance(ContextUtils.getContext()).getString("NewtvSdk_channelCode", "");
|
||||
// String appKeyPs = SpTimeUtils.getInstance(ContextUtils.getContext()).getString("NewtvSdk_appKey", "");
|
||||
// String appSecretPs = SpTimeUtils.getInstance(ContextUtils.getContext()).getString("NewtvSdk_appSecret", "");
|
||||
// if (!TextUtils.isEmpty(channelCodePs) && !TextUtils.isEmpty(appKeyPs) && !TextUtils.isEmpty(appSecretPs)) {
|
||||
// DifferenceData.NewtvSdk.channelCodePs = channelCodePs;
|
||||
// DifferenceData.NewtvSdk.appKeyPs = appKeyPs;
|
||||
// DifferenceData.NewtvSdk.appSecretPs = appSecretPs;
|
||||
// }
|
||||
// LogUtils.d("resultBean -- channelCodePs:" + DifferenceData.NewtvSdk.channelCodePs);
|
||||
// }
|
||||
|
||||
public String getAgreeDes() {
|
||||
return agreeDes;
|
||||
}
|
||||
|
||||
public String getVrTestUrl() {
|
||||
return vrTestUrl;
|
||||
}
|
||||
|
||||
public int getAgreeLookDuration() {
|
||||
return agreeLookDuration;
|
||||
}
|
||||
|
||||
public int getTryLookDuration() {
|
||||
if (tryLookDuration <= 0) {
|
||||
tryLookDuration = 6;
|
||||
}
|
||||
return tryLookDuration;
|
||||
}
|
||||
|
||||
public int getTryLiveDuration() {
|
||||
if (tryLiveDuration <= 0) {
|
||||
tryLiveDuration = 6;
|
||||
}
|
||||
return tryLiveDuration;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取首页垫片 shimCode
|
||||
*
|
||||
* @return 首页垫片 shimCode
|
||||
*/
|
||||
public String getIndexShimCode() {
|
||||
return indexShimCode;
|
||||
}
|
||||
|
||||
public interface OnPassData {
|
||||
void onResponse(GetsystemBean getsystemBean);
|
||||
|
||||
void fail();
|
||||
}
|
||||
}
|
||||
141
app/src/main/java/com/pukka/jiecheng/config/AppConfiguration.java
Executable file
141
app/src/main/java/com/pukka/jiecheng/config/AppConfiguration.java
Executable file
@@ -0,0 +1,141 @@
|
||||
package com.pukka.jiecheng.config;
|
||||
|
||||
import com.pukka.jiecheng.BuildConfig;
|
||||
|
||||
/**
|
||||
* AppConfiguration
|
||||
* 统一的应用配置管理类,封装所有构建配置访问。
|
||||
*
|
||||
* 功能:
|
||||
* 1. 提供渠道 ID 获取 (getChannelId)
|
||||
* 2. 提供交互模式判断 (isTouchMode)
|
||||
* 3. 提供构建类型判断 (isRelease)
|
||||
* 4. 提供酒店类型获取 (getHotelType)
|
||||
* 5. 提供是否显示我的页面配置 (isNeedMy)
|
||||
*
|
||||
* - 屏蔽底层 BuildConfig 细节,解耦业务逻辑。
|
||||
* - 统一入口,便于未来修改配置源。
|
||||
* - 类型安全,避免直接操作字符串。
|
||||
*/
|
||||
public class AppConfiguration {
|
||||
|
||||
private static volatile AppConfiguration instance;
|
||||
private static final String AS_RELEASE_BASE_URL = "https://jst.ainetv.cn/api";
|
||||
private static final String AS_PREVIEW_BASE_URL = "https://jst.ainetv.cn/api";
|
||||
private static final String AS_DEBUG_BASE_URL = "https://jst.ainetv.cn/api"; //https://vip.ainetv.cn/api http://172.16.100.67:3002
|
||||
|
||||
// 心跳请求间隔周期,默认 5 分钟 (300,000 毫秒)
|
||||
private static final long HEART_BEAT_INTERVAL = 300000L;
|
||||
|
||||
private String expireTime = "";
|
||||
private String mDeviceUid = "";
|
||||
|
||||
private AppConfiguration() {
|
||||
// 私有构造函数,防止外部实例化
|
||||
}
|
||||
|
||||
public void setExpireTime(String expireTime) {
|
||||
if (expireTime != null) {
|
||||
this.expireTime = expireTime;
|
||||
} else {
|
||||
this.expireTime = "";
|
||||
}
|
||||
}
|
||||
|
||||
public String getExpireTime() {
|
||||
return expireTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取单例实例 (线程安全,懒加载)
|
||||
*/
|
||||
public static AppConfiguration getInstance() {
|
||||
if (instance == null) {
|
||||
synchronized (AppConfiguration.class) {
|
||||
if (instance == null) {
|
||||
instance = new AppConfiguration();
|
||||
}
|
||||
}
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前渠道 ID (即 Flavor Name)
|
||||
* 例如: "aishi", "q1"
|
||||
* @return 渠道名称字符串
|
||||
*/
|
||||
public String getChannelId() {
|
||||
return BuildConfig.CHANNEL_ID;
|
||||
}
|
||||
|
||||
public String getAsBaseUrl() {
|
||||
if (isRelease()) {
|
||||
return AS_RELEASE_BASE_URL;
|
||||
} else if(isPreview()){
|
||||
return AS_PREVIEW_BASE_URL;
|
||||
}
|
||||
return AS_DEBUG_BASE_URL;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前交互模式
|
||||
* @return true: 触摸模式; false: 遥控模式
|
||||
*/
|
||||
public boolean isTouchMode() {
|
||||
return BuildConfig.IS_TOUCH_MODE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为 Release 构建
|
||||
* @return true: Release; false: Debug/Preview
|
||||
*/
|
||||
public boolean isRelease() {
|
||||
return "release".equals(BuildConfig.BUILD_TYPE);
|
||||
}
|
||||
|
||||
public boolean isPreview(){
|
||||
return "preview".equals(BuildConfig.BUILD_TYPE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取酒店类型
|
||||
* 例如: "AISHI"
|
||||
* @return 酒店类型字符串
|
||||
*/
|
||||
public String getHotelType() {
|
||||
return BuildConfig.HOTEL_TYPE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否需要显示"我的"页面
|
||||
* @return true: 显示; false: 隐藏
|
||||
*/
|
||||
public boolean isNeedMy() {
|
||||
return BuildConfig.NEED_MY;
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为第三方变体
|
||||
* @return true: thirdparty flavor; false: 其他渠道
|
||||
*/
|
||||
public boolean isThirdPartyVariant() {
|
||||
return BuildConfig.THIRDPARTY_VARIANT;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取心跳请求间隔时间
|
||||
* @return 心跳请求间隔周期 (毫秒)
|
||||
*/
|
||||
public long getHeartBeatInterval() {
|
||||
return HEART_BEAT_INTERVAL;
|
||||
}
|
||||
|
||||
public void setDeviceUid(String deviceUid) {
|
||||
mDeviceUid = deviceUid;
|
||||
}
|
||||
|
||||
public String getmDeviceUid() {
|
||||
return mDeviceUid;
|
||||
}
|
||||
}
|
||||
87
app/src/main/java/com/pukka/jiecheng/device/DeviceActivity.kt
Executable file
87
app/src/main/java/com/pukka/jiecheng/device/DeviceActivity.kt
Executable file
@@ -0,0 +1,87 @@
|
||||
package com.pukka.jiecheng.device
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.constraintlayout.widget.ConstraintLayout
|
||||
import com.pukka.jiecheng.R
|
||||
import com.pukka.jiecheng.base.BaseActivity
|
||||
import com.pukka.jiecheng.config.AppConfiguration
|
||||
import com.pukka.jiecheng.utils.ToastUtils
|
||||
import com.pukka.libcore.base.BaseConst
|
||||
import com.pukka.libcore.boxShared.BoxSharedParamsUtils
|
||||
import com.pukka.libcore.utils.AppUtils
|
||||
import com.pukka.libcore.utils.PackageUtils
|
||||
|
||||
|
||||
class DeviceActivity : BaseActivity() {
|
||||
companion object {
|
||||
@JvmStatic
|
||||
fun start(context: Context) {
|
||||
val intent = Intent(context, DeviceActivity::class.java)
|
||||
if (context !is Activity) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
var mTvDeviceName: TextView? = null
|
||||
var mTvVersionName: TextView? = null
|
||||
var mTvChannelMark: TextView? = null
|
||||
var mTvChannelId: TextView? = null
|
||||
var mTvAppId: TextView? = null
|
||||
var mTvMac: TextView? = null
|
||||
var mTvSn: TextView? = null
|
||||
var mTvExpireTime: TextView? = null
|
||||
var mClCheckUpdate: ConstraintLayout? = null
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_device)
|
||||
initView()
|
||||
initListener()
|
||||
}
|
||||
|
||||
private fun initView() {
|
||||
mTvDeviceName = findViewById<TextView>(R.id.id_tv_device_name)
|
||||
mTvDeviceName!!.setText(BoxSharedParamsUtils.getInstance().getModel())
|
||||
mTvVersionName = findViewById<TextView>(R.id.id_tv_version_name)
|
||||
mTvVersionName!!.setText(PackageUtils.getVersionName(this@DeviceActivity))
|
||||
mTvChannelMark = findViewById<TextView>(R.id.id_tv_channel_mark)
|
||||
mTvChannelMark!!.setText(AppConfiguration.getInstance().getChannelId())
|
||||
mTvChannelId = findViewById<TextView>(R.id.id_tv_channelId)
|
||||
mTvChannelId!!.setText(BaseConst.serviceComboCode)
|
||||
mTvAppId = findViewById<TextView>(R.id.id_tv_appId)
|
||||
mTvAppId!!.setText(AppUtils.getPackageName())
|
||||
mTvMac = findViewById<TextView>(R.id.id_tv_mac)
|
||||
mTvMac!!.setText(BoxSharedParamsUtils.getInstance().getMac())
|
||||
mTvSn = findViewById<TextView>(R.id.id_tv_sn)
|
||||
mTvSn!!.setText(AppConfiguration.getInstance().getmDeviceUid())
|
||||
mTvExpireTime = findViewById<TextView>(R.id.id_tv_expire_time)
|
||||
val expireTime = AppConfiguration.getInstance().expireTime
|
||||
if (!expireTime.isNullOrEmpty()) {
|
||||
mTvExpireTime!!.text = expireTime
|
||||
} else {
|
||||
mTvExpireTime!!.text = "暂无数据"
|
||||
}
|
||||
|
||||
mClCheckUpdate = findViewById<ConstraintLayout>(R.id.id_cl_check_update)
|
||||
initGamePad()
|
||||
enableBackButton()
|
||||
}
|
||||
|
||||
private fun initListener() {
|
||||
// mClCheckUpdate!!.setOnClickListener(View.OnClickListener { v: View? ->
|
||||
// // TODO: 2025/6/10 APK更新
|
||||
//// DownApkDialog(this).initDown2()
|
||||
//
|
||||
// //检测更新
|
||||
// // TODO: 2025/6/10 APK更新
|
||||
//// new DownApkDialog(getActivity()).initDown2();
|
||||
// ToastUtils.showLongBottomToast("暂无新版本")
|
||||
// })
|
||||
}
|
||||
}
|
||||
56
app/src/main/java/com/pukka/jiecheng/device/DeviceIdentityInitManager.java
Executable file
56
app/src/main/java/com/pukka/jiecheng/device/DeviceIdentityInitManager.java
Executable file
@@ -0,0 +1,56 @@
|
||||
package com.pukka.jiecheng.device;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.pukka.jiecheng.config.AppConfiguration;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
public final class DeviceIdentityInitManager {
|
||||
private static final String TAG = "DeviceIdentityInitManager";
|
||||
private static final DeviceIdentityProvider DEVICE_IDENTITY_PROVIDER = new DeviceIdentityProvider();
|
||||
private static final Object LOCK = new Object();
|
||||
private static String sCachedDeviceSn = "";
|
||||
|
||||
private DeviceIdentityInitManager() {
|
||||
}
|
||||
|
||||
public static Result init(Context context) {
|
||||
synchronized (LOCK) {
|
||||
String deviceSn = normalize(DEVICE_IDENTITY_PROVIDER.getDeviceSn(context));
|
||||
String deviceUid = normalize(DEVICE_IDENTITY_PROVIDER.getDeviceUid(context, deviceSn));
|
||||
sCachedDeviceSn = deviceSn;
|
||||
AppConfiguration.getInstance().setDeviceUid(deviceUid);
|
||||
if (TextUtils.isEmpty(deviceUid)) {
|
||||
LogUtils.w(TAG, "init finish with empty deviceUid");
|
||||
} else {
|
||||
LogUtils.i(TAG, "init finish with deviceUid");
|
||||
}
|
||||
return new Result(deviceSn, deviceUid);
|
||||
}
|
||||
}
|
||||
|
||||
public static Result getCachedOrInit(Context context) {
|
||||
synchronized (LOCK) {
|
||||
String cachedDeviceUid = normalize(AppConfiguration.getInstance().getmDeviceUid());
|
||||
if (!TextUtils.isEmpty(cachedDeviceUid) && !TextUtils.isEmpty(sCachedDeviceSn)) {
|
||||
return new Result(sCachedDeviceSn, cachedDeviceUid);
|
||||
}
|
||||
}
|
||||
return init(context);
|
||||
}
|
||||
|
||||
private static String normalize(String value) {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
|
||||
public static final class Result {
|
||||
public final String deviceSn;
|
||||
public final String deviceUid;
|
||||
|
||||
private Result(String deviceSn, String deviceUid) {
|
||||
this.deviceSn = deviceSn;
|
||||
this.deviceUid = deviceUid;
|
||||
}
|
||||
}
|
||||
}
|
||||
141
app/src/main/java/com/pukka/jiecheng/device/DeviceIdentityProvider.java
Executable file
141
app/src/main/java/com/pukka/jiecheng/device/DeviceIdentityProvider.java
Executable file
@@ -0,0 +1,141 @@
|
||||
package com.pukka.jiecheng.device;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.provider.Settings;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.pukka.jiecheng.config.AppConfiguration;
|
||||
import com.pukka.libcore.boxShared.BoxSharedParamsUtils;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Locale;
|
||||
|
||||
public class DeviceIdentityProvider {
|
||||
private static final String TAG = "DeviceIdentityProvider";
|
||||
// OAID 生成的设备标识前缀
|
||||
private static final String OAID_UID_PREFIX = "O_";
|
||||
// deviceSn 非空时的设备标识前缀(硬件序列号可用)
|
||||
private static final String HARDWARE_SN_UID_PREFIX = "H_";
|
||||
// deviceSn 为空时的设备标识前缀(软标识兜底)
|
||||
private static final String SOFT_SN_UID_PREFIX = "S_";
|
||||
private static final char[] BASE_36_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
|
||||
private static final int MD5_TRUNCATED_BYTES = 10;
|
||||
private static final int GENERATED_UID_LENGTH = 20;
|
||||
private final DeviceIdentityStore identityStore = new DeviceIdentityStore();
|
||||
private final OaidProvider oaidProvider = new OaidProvider();
|
||||
|
||||
public String getDeviceSn(Context context) {
|
||||
String serial = safe(BoxSharedParamsUtils.getInstance().getSn());
|
||||
if (!TextUtils.isEmpty(serial)) {
|
||||
return serial;
|
||||
}
|
||||
return getAndroidId(context);
|
||||
}
|
||||
|
||||
public String getDeviceUid(Context context, String deviceSn) {
|
||||
String storedValue = identityStore.readDeviceUid(context);
|
||||
if (!TextUtils.isEmpty(storedValue)) {
|
||||
LogUtils.i(TAG, "device_uid source=store value=" + storedValue);
|
||||
return storedValue;
|
||||
}
|
||||
String oaidValue = oaidProvider.getOaid(context);
|
||||
if (!TextUtils.isEmpty(oaidValue)) {
|
||||
String oaidUidValue = generateStableDeviceUid("OAID|" + oaidValue, OAID_UID_PREFIX);
|
||||
if (!TextUtils.isEmpty(oaidUidValue)) {
|
||||
identityStore.saveDeviceUid(context, oaidUidValue);
|
||||
LogUtils.i(TAG, "device_uid source=oaid_generated value=" + oaidUidValue);
|
||||
return oaidUidValue;
|
||||
}
|
||||
}
|
||||
String generatedValue = generateDeviceUid(deviceSn);
|
||||
if (!TextUtils.isEmpty(generatedValue)) {
|
||||
identityStore.saveDeviceUid(context, generatedValue);
|
||||
// LogUtils.i(TAG, "device_uid source=generated value=" + generatedValue);
|
||||
} else {
|
||||
LogUtils.w(TAG, "device_uid source=generated value=empty");
|
||||
}
|
||||
return safe(generatedValue);
|
||||
}
|
||||
|
||||
String generateDeviceUid(String deviceSn) {
|
||||
String channelId = safe(AppConfiguration.getInstance().getChannelId());
|
||||
String model = safe(Build.MODEL);
|
||||
String normalizedSn = safe(deviceSn);
|
||||
String uidPrefix = resolveGeneratedUidPrefix(normalizedSn);
|
||||
String source = (channelId + model + normalizedSn + System.currentTimeMillis()).trim().toUpperCase(Locale.ROOT);
|
||||
String mappedUid = generateMd5Base36Uid(source, GENERATED_UID_LENGTH);
|
||||
if (TextUtils.isEmpty(mappedUid)) {
|
||||
return "";
|
||||
}
|
||||
return uidPrefix + mappedUid;
|
||||
}
|
||||
|
||||
private String resolveGeneratedUidPrefix(String normalizedSn) {
|
||||
if (!TextUtils.isEmpty(normalizedSn)) {
|
||||
return HARDWARE_SN_UID_PREFIX;
|
||||
}
|
||||
return SOFT_SN_UID_PREFIX;
|
||||
}
|
||||
|
||||
private String generateMd5Base36Uid(String sourceValue, int targetLength) {
|
||||
try {
|
||||
String source = safe(sourceValue).toUpperCase(Locale.ROOT);
|
||||
if (TextUtils.isEmpty(source) || targetLength <= 0) {
|
||||
return "";
|
||||
}
|
||||
MessageDigest digest = MessageDigest.getInstance("MD5");
|
||||
byte[] hashBytes = digest.digest(source.getBytes(StandardCharsets.UTF_8));
|
||||
int usedBytes = Math.min(MD5_TRUNCATED_BYTES, hashBytes.length);
|
||||
if (usedBytes <= 0) {
|
||||
return "";
|
||||
}
|
||||
StringBuilder builder = new StringBuilder(targetLength);
|
||||
for (int i = 0; i < targetLength; i++) {
|
||||
int current = hashBytes[i % usedBytes] & 0xFF;
|
||||
int next = hashBytes[(i + 1) % usedBytes] & 0xFF;
|
||||
int index = (current + next + i) % BASE_36_CHARS.length;
|
||||
builder.append(BASE_36_CHARS[index]);
|
||||
}
|
||||
return builder.toString();
|
||||
} catch (Exception ignore) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
String generateStableDeviceUid(String sourceValue, String uidPrefix) {
|
||||
try {
|
||||
String source = safe(sourceValue).toUpperCase(Locale.ROOT);
|
||||
if (TextUtils.isEmpty(source)) {
|
||||
return "";
|
||||
}
|
||||
MessageDigest digest = MessageDigest.getInstance("SHA-256");
|
||||
byte[] hashBytes = digest.digest(source.getBytes(StandardCharsets.UTF_8));
|
||||
StringBuilder hexBuilder = new StringBuilder(hashBytes.length * 2);
|
||||
for (byte hashByte : hashBytes) {
|
||||
hexBuilder.append(String.format(Locale.ROOT, "%02X", hashByte));
|
||||
}
|
||||
return safe(uidPrefix) + hexBuilder;
|
||||
} catch (Exception ignore) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String getAndroidId(Context context) {
|
||||
if (context == null) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
String androidId = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||
return safe(androidId);
|
||||
} catch (Exception ignore) {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String safe(String value) {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
}
|
||||
207
app/src/main/java/com/pukka/jiecheng/device/DeviceIdentityStore.java
Executable file
207
app/src/main/java/com/pukka/jiecheng/device/DeviceIdentityStore.java
Executable file
@@ -0,0 +1,207 @@
|
||||
package com.pukka.jiecheng.device;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Environment;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
import com.pukka.libcore.utils.SharedPreferenceUtils;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
public class DeviceIdentityStore {
|
||||
private static final String TAG = "DeviceIdentityStore1";
|
||||
private static final String LOG_KEYWORD_WRITE = "device_uid_write";
|
||||
private static final String DEVICE_UID_KEY = "as_device_uid";
|
||||
private static final String SHARED_RELATIVE_PATH = "./";
|
||||
private static final String SHARED_FILE_NAME = ".jc_dev_ice_uid";
|
||||
private static final String EXTERNAL_STATE_MOUNTED = Environment.MEDIA_MOUNTED;
|
||||
private static final Charset UTF8 = Charset.forName("UTF-8");
|
||||
|
||||
public String readDeviceUid(Context context) {
|
||||
LogUtils.i(TAG, "device_uid read start relativePath=" + SHARED_RELATIVE_PATH + " fileName=" + SHARED_FILE_NAME);
|
||||
String sharedValue = readFromSharedExternalStorage(context);
|
||||
if (!TextUtils.isEmpty(sharedValue)) {
|
||||
LogUtils.i(TAG, "device_uid source=shared_external value=" + sharedValue);
|
||||
SharedPreferenceUtils.put(DEVICE_UID_KEY, sharedValue);
|
||||
LogUtils.i(TAG, "device_uid read end source=shared_external");
|
||||
return sharedValue;
|
||||
}
|
||||
String localValue = normalize(SharedPreferenceUtils.getString(DEVICE_UID_KEY, ""));
|
||||
if (!TextUtils.isEmpty(localValue)) {
|
||||
LogUtils.i(TAG, "device_uid source=shared_pref value=" + localValue);
|
||||
writeToSharedExternalStorage(context, localValue);
|
||||
LogUtils.i(TAG, "device_uid read end source=shared_pref");
|
||||
} else {
|
||||
LogUtils.w(TAG, "device_uid source=shared_pref value=empty");
|
||||
LogUtils.w(TAG, "device_uid read end source=empty");
|
||||
}
|
||||
return TextUtils.isEmpty(localValue) ? "" : localValue;
|
||||
}
|
||||
|
||||
public void saveDeviceUid(Context context, String deviceUid) {
|
||||
String value = normalize(deviceUid);
|
||||
if (TextUtils.isEmpty(value)) {
|
||||
LogUtils.w(TAG, "saveDeviceUid skipped: empty uid");
|
||||
return;
|
||||
}
|
||||
LogUtils.i(TAG, "device_uid source=save_request value=" + value);
|
||||
SharedPreferenceUtils.put(DEVICE_UID_KEY, value);
|
||||
writeToSharedExternalStorage(context, value);
|
||||
// LogUtils.i(TAG, "device_uid save end value=" + value);
|
||||
}
|
||||
|
||||
private String readFromSharedExternalStorage(Context context) {
|
||||
if (context == null) {
|
||||
LogUtils.w(TAG, "shared_external read skipped context=null");
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
File sharedFile = getSharedFile();
|
||||
if (!sharedFile.exists()) {
|
||||
LogUtils.w(TAG, "shared_external read miss path=" + sharedFile.getAbsolutePath());
|
||||
return "";
|
||||
}
|
||||
String value = readContent(sharedFile);
|
||||
if (TextUtils.isEmpty(value)) {
|
||||
LogUtils.w(TAG, "shared_external read empty path=" + sharedFile.getAbsolutePath());
|
||||
return "";
|
||||
}
|
||||
LogUtils.i(TAG, "shared_external read success path=" + sharedFile.getAbsolutePath() + " value=" + value);
|
||||
return value;
|
||||
} catch (Exception ignore) {
|
||||
LogUtils.e(TAG, "shared_external read failed: " + ignore.getClass().getSimpleName() + "|" + ignore.getMessage());
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private void writeToSharedExternalStorage(Context context, String deviceUid) {
|
||||
if (context == null) {
|
||||
LogUtils.w(TAG, LOG_KEYWORD_WRITE + " event=skip reason=context_null");
|
||||
return;
|
||||
}
|
||||
String normalizedUid = normalize(deviceUid);
|
||||
if (TextUtils.isEmpty(normalizedUid)) {
|
||||
LogUtils.w(TAG, LOG_KEYWORD_WRITE + " event=skip reason=uid_empty");
|
||||
return;
|
||||
}
|
||||
ExternalWriteAvailability writeAvailability = checkExternalWriteAvailability();
|
||||
if (!writeAvailability.available) {
|
||||
LogUtils.w(TAG, LOG_KEYWORD_WRITE + " event=skip reason=" + writeAvailability.reason);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
File sharedDir = getSharedDirectory();
|
||||
if (!sharedDir.exists() && !sharedDir.mkdirs()) {
|
||||
dispatchExternalWriteFailure("mkdir_failed", null, sharedDir);
|
||||
return;
|
||||
}
|
||||
File sharedFile = getSharedFile();
|
||||
String existingValue = readContent(sharedFile);
|
||||
if (normalizedUid.equals(existingValue)) {
|
||||
LogUtils.i(TAG, LOG_KEYWORD_WRITE + " event=idempotent path=" + sharedFile.getAbsolutePath() + " value=" + normalizedUid);
|
||||
} else {
|
||||
writeContent(sharedFile, normalizedUid);
|
||||
// LogUtils.i(TAG, LOG_KEYWORD_WRITE + " event=success path=" + sharedFile.getAbsolutePath() + " value=" + normalizedUid);
|
||||
}
|
||||
} catch (Exception ignore) {
|
||||
dispatchExternalWriteFailure("write_failed", ignore, null);
|
||||
}
|
||||
}
|
||||
|
||||
private ExternalWriteAvailability checkExternalWriteAvailability() {
|
||||
String state = Environment.getExternalStorageState();
|
||||
if (!EXTERNAL_STATE_MOUNTED.equals(state)) {
|
||||
return ExternalWriteAvailability.unavailable("storage_state_" + state);
|
||||
}
|
||||
File externalRoot = Environment.getExternalStorageDirectory();
|
||||
if (externalRoot == null) {
|
||||
return ExternalWriteAvailability.unavailable("storage_dir_null");
|
||||
}
|
||||
if (!externalRoot.exists()) {
|
||||
return ExternalWriteAvailability.unavailable("storage_dir_missing");
|
||||
}
|
||||
if (!externalRoot.canWrite()) {
|
||||
return ExternalWriteAvailability.unavailable("storage_not_writable");
|
||||
}
|
||||
return ExternalWriteAvailability.available();
|
||||
}
|
||||
|
||||
private void dispatchExternalWriteFailure(String stage, Exception exception, File target) {
|
||||
if (exception == null) {
|
||||
LogUtils.e(TAG, LOG_KEYWORD_WRITE + " event=failed stage=" + stage + " path=" + (target == null ? "unknown" : target.getAbsolutePath()));
|
||||
return;
|
||||
}
|
||||
LogUtils.e(TAG, LOG_KEYWORD_WRITE + " event=failed stage=" + stage + " type="
|
||||
+ exception.getClass().getSimpleName() + " msg=" + exception.getMessage()
|
||||
+ " path=" + (target == null ? "unknown" : target.getAbsolutePath()));
|
||||
}
|
||||
|
||||
private File getSharedDirectory() {
|
||||
File sharedDir = new File(Environment.getExternalStorageDirectory(), SHARED_RELATIVE_PATH);
|
||||
if (!sharedDir.exists() && !sharedDir.mkdirs()) {
|
||||
LogUtils.w(TAG, "shared_external dir create failed path=" + sharedDir.getAbsolutePath());
|
||||
}
|
||||
return sharedDir;
|
||||
}
|
||||
|
||||
private File getSharedFile() {
|
||||
return new File(getSharedDirectory(), SHARED_FILE_NAME);
|
||||
}
|
||||
|
||||
private String readContent(File file) {
|
||||
if (file == null || !file.exists()) {
|
||||
return "";
|
||||
}
|
||||
try (FileInputStream inputStream = new FileInputStream(file);
|
||||
InputStreamReader reader = new InputStreamReader(inputStream, UTF8);
|
||||
BufferedReader bufferedReader = new BufferedReader(reader)) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
String line;
|
||||
while ((line = bufferedReader.readLine()) != null) {
|
||||
builder.append(line);
|
||||
}
|
||||
return normalize(builder.toString());
|
||||
} catch (Exception ignore) {
|
||||
LogUtils.e(TAG, "shared_external read content failed: " + ignore.getClass().getSimpleName() + "|" + ignore.getMessage() + " path=" + file.getAbsolutePath());
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private void writeContent(File file, String value) {
|
||||
try (FileOutputStream outputStream = new FileOutputStream(file, false)) {
|
||||
outputStream.write(value.getBytes(UTF8));
|
||||
outputStream.flush();
|
||||
} catch (Exception ignore) {
|
||||
LogUtils.e(TAG, "shared_external write content failed: " + ignore.getClass().getSimpleName() + "|" + ignore.getMessage() + " path=" + file.getAbsolutePath());
|
||||
throw new RuntimeException(ignore);
|
||||
}
|
||||
}
|
||||
|
||||
private String normalize(String value) {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
|
||||
private static final class ExternalWriteAvailability {
|
||||
private final boolean available;
|
||||
private final String reason;
|
||||
|
||||
private ExternalWriteAvailability(boolean available, String reason) {
|
||||
this.available = available;
|
||||
this.reason = reason;
|
||||
}
|
||||
|
||||
private static ExternalWriteAvailability available() {
|
||||
return new ExternalWriteAvailability(true, "ok");
|
||||
}
|
||||
|
||||
private static ExternalWriteAvailability unavailable(String reason) {
|
||||
return new ExternalWriteAvailability(false, reason);
|
||||
}
|
||||
}
|
||||
}
|
||||
42
app/src/main/java/com/pukka/jiecheng/device/OaidProvider.java
Executable file
42
app/src/main/java/com/pukka/jiecheng/device/OaidProvider.java
Executable file
@@ -0,0 +1,42 @@
|
||||
package com.pukka.jiecheng.device;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.github.gzuliyujiang.oaid.DeviceID;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
public class OaidProvider {
|
||||
private static final String TAG = "OaidProvider";
|
||||
|
||||
public String getOaid(Context context) {
|
||||
if (context == null) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
Context applicationContext = context.getApplicationContext();
|
||||
if (applicationContext instanceof Application) {
|
||||
DeviceID.register((Application) applicationContext);
|
||||
}
|
||||
if (!DeviceID.supportedOAID(context)) {
|
||||
LogUtils.w(TAG, "oaid unsupported");
|
||||
return "";
|
||||
}
|
||||
String oaid = normalize(DeviceID.getOAID());
|
||||
if (TextUtils.isEmpty(oaid)) {
|
||||
LogUtils.w(TAG, "oaid empty");
|
||||
return "";
|
||||
}
|
||||
LogUtils.i(TAG, "oaid success value=" + oaid);
|
||||
return oaid;
|
||||
} catch (Throwable throwable) {
|
||||
LogUtils.e(TAG, "oaid error " + throwable.getClass().getSimpleName() + "|" + throwable.getMessage());
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
private String normalize(String value) {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
}
|
||||
213
app/src/main/java/com/pukka/jiecheng/downapk/DownApkDialog.java
Executable file
213
app/src/main/java/com/pukka/jiecheng/downapk/DownApkDialog.java
Executable file
@@ -0,0 +1,213 @@
|
||||
package com.pukka.jiecheng.downapk;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Build;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.downapk.amber.DownApkAmberManager;
|
||||
import com.pukka.jiecheng.newtv.NewTvUtils;
|
||||
import com.pukka.jiecheng.utils.ToastUtils;
|
||||
import com.pukka.jiecheng.utils.VideoContainerHelper;
|
||||
import com.pukka.libcore.utils.AppManager;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class DownApkDialog extends Dialog {
|
||||
private static final int PERMISSION_REQUEST_CODE = 996;
|
||||
private Activity activity;
|
||||
private DownloadApkManager downloadApkManager;
|
||||
private boolean isDowning;
|
||||
private boolean isQz;
|
||||
|
||||
private TextView left, title, right;
|
||||
private ProgressBar progressBar;
|
||||
private LinearLayout llbt;
|
||||
private OnSkipUpgradeListener onSkipUpgradeListener;
|
||||
|
||||
public interface OnSkipUpgradeListener {
|
||||
void onSkipUpgrade();
|
||||
}
|
||||
|
||||
public DownApkDialog(@NonNull Activity activity) {
|
||||
super(activity);
|
||||
this.activity = activity;
|
||||
downloadApkManager = new DownloadApkManager(activity);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
View view = View.inflate(activity, R.layout.layout_dialog_downapk, null);
|
||||
title = view.findViewById(R.id.title);
|
||||
llbt = view.findViewById(R.id.llbt);
|
||||
left = view.findViewById(R.id.left);
|
||||
right = view.findViewById(R.id.right);
|
||||
progressBar = view.findViewById(R.id.progress);
|
||||
addContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
setCancelable(false);
|
||||
setCanceledOnTouchOutside(false);
|
||||
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
left.setOnClickListener(v -> {
|
||||
if (isDowning) {
|
||||
return;
|
||||
}
|
||||
DownApkAmberManager.apkUpdate(isQz, downloadApkManager.getCurVersionName(), downloadApkManager.getUpdateVersionName(), "下次再说");
|
||||
if (onSkipUpgradeListener != null) {
|
||||
onSkipUpgradeListener.onSkipUpgrade();
|
||||
}
|
||||
dismiss();
|
||||
});
|
||||
right.setOnClickListener(v -> {
|
||||
if (isDowning) {
|
||||
return;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||
if (activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
|
||||
activity.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, PERMISSION_REQUEST_CODE);
|
||||
} else {
|
||||
handleDownloadClick();
|
||||
}
|
||||
} else {
|
||||
handleDownloadClick();
|
||||
}
|
||||
});
|
||||
initListener();
|
||||
}
|
||||
|
||||
private void handleDownloadClick() {
|
||||
if (right.getText().toString().contains("立即重启")) {
|
||||
dismiss();
|
||||
VideoContainerHelper.getInstance().release();
|
||||
NewTvUtils.getInstance().newTvLogAppExit();
|
||||
AppManager.getAppManager().appExit();
|
||||
} else {
|
||||
initDialog(true);
|
||||
startDownApk();
|
||||
DownApkAmberManager.apkUpdate(isQz, downloadApkManager.getCurVersionName(), downloadApkManager.getUpdateVersionName(), "下载安装");
|
||||
}
|
||||
}
|
||||
|
||||
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
|
||||
if (requestCode == PERMISSION_REQUEST_CODE) {
|
||||
if (grantResults.length > 0 && grantResults[0] == PackageManager.PERMISSION_GRANTED) {
|
||||
handleDownloadClick();
|
||||
} else {
|
||||
ToastUtils.showLongToast("需要存储权限才能下载更新");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void initListener() {
|
||||
downloadApkManager.setOnDownloadApkManagerCallBack(new DownloadApkManager.OnDownloadApkManagerCallBack() {
|
||||
@Override
|
||||
public void onSuccess(File file) {
|
||||
activity.runOnUiThread(() -> {
|
||||
downloadApkManager.installApk(file);
|
||||
isDowning = false;
|
||||
DownApkAmberManager.apkUpdateResult(isQz, downloadApkManager.getCurVersionName(), downloadApkManager.getUpdateVersionName(), true);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onProgress(int progress) {
|
||||
activity.runOnUiThread(() -> progressBar.setProgress(progress));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
activity.runOnUiThread(() -> {
|
||||
initDialog(false);
|
||||
title.setText("系统出小差了~ \n请重启应用再次尝试升级");
|
||||
right.setText("立即重启");
|
||||
left.setVisibility(View.GONE);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startShowDown(boolean isQzb) {
|
||||
isQz = isQzb;
|
||||
if (isQz) {
|
||||
title.setText("需要安装新版本才可使用");
|
||||
left.setVisibility(View.GONE);
|
||||
} else {
|
||||
title.setText("您有新版本可下载,是否安装使用?");
|
||||
left.setVisibility(View.VISIBLE);
|
||||
}
|
||||
show();
|
||||
right.requestFocus();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void over() {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initDialog(boolean isShowProgress) {
|
||||
if (isQz) {
|
||||
title.setText("需要安装新版本才可使用");
|
||||
left.setVisibility(View.GONE);
|
||||
} else {
|
||||
title.setText("您有新版本可下载,是否安装使用?");
|
||||
left.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (isShowProgress) {
|
||||
llbt.setVisibility(View.GONE);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
llbt.setVisibility(View.VISIBLE);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
isDowning = false;
|
||||
progressBar.setProgress(0);
|
||||
right.requestFocus();
|
||||
}
|
||||
|
||||
public void initDown() {
|
||||
downloadApkManager.judgeIsDownApk(false);
|
||||
}
|
||||
|
||||
public void initDown2() {
|
||||
downloadApkManager.judgeIsDownApk(true);
|
||||
}
|
||||
|
||||
public void setUpgradeInfo(String versionCode, String versionName, String downloadUrl, boolean isForce) {
|
||||
downloadApkManager.setUpgradeInfo(versionCode, versionName, downloadUrl, isForce);
|
||||
}
|
||||
|
||||
public void setOnSkipUpgradeListener(OnSkipUpgradeListener onSkipUpgradeListener) {
|
||||
this.onSkipUpgradeListener = onSkipUpgradeListener;
|
||||
}
|
||||
|
||||
public void showUpgradeDialog() {
|
||||
isQz = downloadApkManager.isForceUpgrade();
|
||||
if (isQz) {
|
||||
title.setText("需要安装新版本才可使用");
|
||||
left.setVisibility(View.GONE);
|
||||
} else {
|
||||
title.setText("您有新版本可下载,是否安装使用?");
|
||||
left.setVisibility(View.VISIBLE);
|
||||
}
|
||||
show();
|
||||
right.requestFocus();
|
||||
}
|
||||
|
||||
private void startDownApk() {
|
||||
isDowning = true;
|
||||
title.setText("新版本安装中…");
|
||||
progressBar.setProgress(0);
|
||||
downloadApkManager.downloadApk();
|
||||
}
|
||||
}
|
||||
250
app/src/main/java/com/pukka/jiecheng/downapk/DownloadApkManager.java
Executable file
250
app/src/main/java/com/pukka/jiecheng/downapk/DownloadApkManager.java
Executable file
@@ -0,0 +1,250 @@
|
||||
package com.pukka.jiecheng.downapk;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.core.content.FileProvider;
|
||||
|
||||
import com.migu.bean.UpApkRequestBean;
|
||||
import com.migu.callback.AijiaCallback;
|
||||
import com.migu.httputils.HomeHttpUtils;
|
||||
import com.migu.libnetwork.HttpRequestFileCallback;
|
||||
import com.migu.libnetwork.HttpUtils;
|
||||
import com.pukka.jiecheng.JcConfig;
|
||||
import com.pukka.jiecheng.utils.ToastUtils;
|
||||
import com.pukka.libcore.utils.AppUtils;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
import com.pukka.libcore.utils.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class DownloadApkManager {
|
||||
private final static String TAG = "DownloadApkManager";
|
||||
private Activity activity;
|
||||
private UpApkRequestBean downResponse;
|
||||
private String curVersionName = "";
|
||||
private String updateVersionName = "";
|
||||
private String downloadUrl;
|
||||
private boolean isForceUpgrade = false;
|
||||
|
||||
public String getCurVersionName() {
|
||||
return curVersionName;
|
||||
}
|
||||
|
||||
public String getUpdateVersionName() {
|
||||
return updateVersionName;
|
||||
}
|
||||
|
||||
public DownloadApkManager(Activity activity) {
|
||||
this.activity = activity;
|
||||
}
|
||||
|
||||
public void setDownloadUrl(String url) {
|
||||
this.downloadUrl = url;
|
||||
}
|
||||
|
||||
public void setForceUpgrade(boolean force) {
|
||||
this.isForceUpgrade = force;
|
||||
}
|
||||
|
||||
public boolean isForceUpgrade() {
|
||||
return isForceUpgrade;
|
||||
}
|
||||
|
||||
public void setUpgradeInfo(String versionCode, String versionName, String url, boolean isForce) {
|
||||
this.updateVersionName = versionCode;
|
||||
this.downloadUrl = url;
|
||||
this.isForceUpgrade = isForce;
|
||||
if (downResponse == null) {
|
||||
downResponse = new UpApkRequestBean();
|
||||
}
|
||||
downResponse.setVersionCode(versionCode);
|
||||
downResponse.setPackageLocation(url);
|
||||
downResponse.setUrgentStatus(isForce ? 1 : 0);
|
||||
}
|
||||
|
||||
public boolean compareVersion(String currentVersion, String newVersion) {
|
||||
if (TextUtils.isEmpty(currentVersion) || TextUtils.isEmpty(newVersion)) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
return Integer.parseInt(currentVersion) < Integer.parseInt(newVersion);
|
||||
} catch (NumberFormatException e) {
|
||||
LogUtils.e(TAG, "Version compare error: " + e.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void judgeIsDownApk(boolean isShowTip) {
|
||||
String baseUrl = JcConfig.getBaseUrl();
|
||||
HomeHttpUtils.getApkVersion(baseUrl,new AijiaCallback.OnUpApkCallBack() {
|
||||
@Override
|
||||
public void onResponse(UpApkRequestBean response) {
|
||||
curVersionName = AppUtils.getVersionCode();
|
||||
LogUtils.d("versionCode cur: " + curVersionName + " update:" + response.getVersionCode());
|
||||
if (TextUtils.isEmpty(response.getVersionCode())) {
|
||||
return;
|
||||
}
|
||||
updateVersionName = response.getVersionCode();
|
||||
if (compareVersion(curVersionName, updateVersionName)) {
|
||||
downResponse = response;
|
||||
isUpdate();
|
||||
}else{
|
||||
if(isShowTip){
|
||||
ToastUtils.showLongToast("暂无新版本");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail() {
|
||||
if(isShowTip){
|
||||
ToastUtils.showLongToast("暂无新版本");
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void installApk(File file) {
|
||||
onDownloadApkManagerCallBack.over();
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
try {
|
||||
if (activity == null) {
|
||||
return;
|
||||
}
|
||||
Intent install = new Intent();
|
||||
install.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
install.setAction(Intent.ACTION_VIEW);
|
||||
LogUtils.d(TAG, "setDataAndType --- SDK_INT : " + Build.VERSION.SDK_INT);
|
||||
/*
|
||||
* 判读版本是否在7.0以上
|
||||
*/
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
String authority = activity.getPackageName() + ".provider";
|
||||
LogUtils.d(TAG, "authority: " + authority);
|
||||
/*
|
||||
* 在AndroidManifest中的android:authorities值
|
||||
*/
|
||||
Uri apkUri = FileProvider.getUriForFile(activity, authority, file);
|
||||
|
||||
install.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
install.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
|
||||
LogUtils.d(TAG, "setDataAndType --- uri : " + apkUri);
|
||||
install.setDataAndType(apkUri, "application/vnd.android.package-archive");
|
||||
activity.startActivity(install);
|
||||
} else {
|
||||
install.setDataAndType(Uri.fromFile(file), "application/vnd.android.package-archive");
|
||||
activity.startActivity(install);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.e(Log.getStackTraceString(e));
|
||||
Toast.makeText(activity, e.toString(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private OnDownloadApkManagerCallBack onDownloadApkManagerCallBack;
|
||||
|
||||
public void setOnDownloadApkManagerCallBack(OnDownloadApkManagerCallBack onDownloadApkManagerCallBack) {
|
||||
this.onDownloadApkManagerCallBack = onDownloadApkManagerCallBack;
|
||||
}
|
||||
|
||||
public interface OnDownloadApkManagerCallBack {
|
||||
void onSuccess(File file);
|
||||
|
||||
void onProgress(int progress);
|
||||
|
||||
void onFailure();
|
||||
|
||||
void startShowDown(boolean isQz);
|
||||
|
||||
void over();
|
||||
}
|
||||
|
||||
|
||||
private void isUpdate() {
|
||||
if (downResponse == null) {
|
||||
return;
|
||||
}
|
||||
final String url = downResponse.getPackageLocation();
|
||||
if (StringUtils.isEmpty(url)) {
|
||||
LogUtils.d(TAG, "isUpdate url is null");
|
||||
return;
|
||||
}
|
||||
LogUtils.d(TAG, "update url ===" + url);
|
||||
try {
|
||||
if (downResponse.getUrgentStatus() == 1) {
|
||||
//强制升级
|
||||
LogUtils.d(TAG, "isUpdate else");
|
||||
onDownloadApkManagerCallBack.startShowDown(true);
|
||||
} else {
|
||||
LogUtils.d(TAG, "isUpdate1");
|
||||
onDownloadApkManagerCallBack.startShowDown(false);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(TAG, "isUpdate catch");
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载apk
|
||||
*/
|
||||
public void downloadApk() {
|
||||
LogUtils.d(TAG, "DownloadApk");
|
||||
if (downResponse == null) {
|
||||
return;
|
||||
}
|
||||
String url = downResponse.getPackageLocation();
|
||||
if (StringUtils.isEmpty(url)) {
|
||||
LogUtils.d(TAG, "update url is null");
|
||||
return;
|
||||
}
|
||||
LogUtils.d(TAG, "update url ===" + url);
|
||||
HttpUtils.getInstance().executeDownFile(url, 0, new HttpRequestFileCallback() {
|
||||
@Override
|
||||
public void onRequestNetFail(int type) {
|
||||
onDownloadApkManagerCallBack.onFailure();
|
||||
LogUtils.d(TAG, "downloadFile onRequestNetFail");
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onProgress(int progress) {
|
||||
LogUtils.d(TAG, "downloadFile onProgress" + progress);
|
||||
onDownloadApkManagerCallBack.onProgress(progress);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(File file) {
|
||||
onDownloadApkManagerCallBack.onSuccess(file);
|
||||
// onDownloadApkManagerCallBack.onFailure();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
LogUtils.d(TAG, "downloadFile onStart");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downFail() {
|
||||
onDownloadApkManagerCallBack.onFailure();
|
||||
LogUtils.d(TAG, "downloadFile downFail");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestFail(String value, String failCode, int type) {
|
||||
onDownloadApkManagerCallBack.onFailure();
|
||||
LogUtils.d(TAG, "downloadFile onRequestFail");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
39
app/src/main/java/com/pukka/jiecheng/downapk/UpgradeHelper.java
Executable file
39
app/src/main/java/com/pukka/jiecheng/downapk/UpgradeHelper.java
Executable file
@@ -0,0 +1,39 @@
|
||||
package com.pukka.jiecheng.downapk;
|
||||
|
||||
import android.app.Activity;
|
||||
|
||||
public class UpgradeHelper {
|
||||
private static final String TAG = "UpgradeHelper";
|
||||
|
||||
private UpgradeHelper() {
|
||||
}
|
||||
|
||||
public static void upgrade(Activity activity, String versionCode, String versionName, String downloadUrl, boolean isForce) {
|
||||
upgrade(activity, versionCode, versionName, downloadUrl, isForce, null);
|
||||
}
|
||||
|
||||
public static void upgrade(Activity activity, String versionCode, String versionName, String downloadUrl, boolean isForce, DownApkDialog.OnSkipUpgradeListener onSkipUpgradeListener) {
|
||||
if (activity == null || activity.isFinishing()) {
|
||||
return;
|
||||
}
|
||||
if (downloadUrl == null || downloadUrl.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
DownApkDialog dialog = new DownApkDialog(activity);
|
||||
dialog.setUpgradeInfo(versionCode, versionName, downloadUrl, isForce);
|
||||
dialog.setOnSkipUpgradeListener(onSkipUpgradeListener);
|
||||
dialog.showUpgradeDialog();
|
||||
}
|
||||
|
||||
public static void upgrade(Activity activity, String versionCode, String downloadUrl, boolean isForce) {
|
||||
upgrade(activity, versionCode, "", downloadUrl, isForce);
|
||||
}
|
||||
|
||||
public static void upgradeForce(Activity activity, String versionCode, String versionName, String downloadUrl) {
|
||||
upgrade(activity, versionCode, versionName, downloadUrl, true);
|
||||
}
|
||||
|
||||
public static void upgradeOptional(Activity activity, String versionCode, String versionName, String downloadUrl) {
|
||||
upgrade(activity, versionCode, versionName, downloadUrl, false);
|
||||
}
|
||||
}
|
||||
38
app/src/main/java/com/pukka/jiecheng/downapk/amber/DownApkAmberManager.java
Executable file
38
app/src/main/java/com/pukka/jiecheng/downapk/amber/DownApkAmberManager.java
Executable file
@@ -0,0 +1,38 @@
|
||||
package com.pukka.jiecheng.downapk.amber;
|
||||
|
||||
import com.migu.amber.AmberUtil;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
public class DownApkAmberManager {
|
||||
private static final String TAG = "DownApkAmberManager";
|
||||
|
||||
/**
|
||||
* APK升级
|
||||
*/
|
||||
public static void apkUpdate(boolean is_force, String current_version, String update_version, String button_click) {
|
||||
String eventType = "apk_update";
|
||||
HashMap<String, Object> maps = new HashMap<>();
|
||||
maps.put("is_force", is_force);
|
||||
maps.put("current_version", current_version);
|
||||
maps.put("update_version", update_version);
|
||||
maps.put("button_click", button_click);
|
||||
LogUtils.d(TAG, eventType+":" + maps.toString());
|
||||
AmberUtil.send(eventType, maps);
|
||||
}
|
||||
|
||||
/**
|
||||
* APK升级结果
|
||||
*/
|
||||
public static void apkUpdateResult(boolean is_force,String current_version, String update_version, boolean is_successful) {
|
||||
String eventType = "apk_update_result";
|
||||
HashMap<String, Object> maps = new HashMap<>();
|
||||
maps.put("is_force", is_force);
|
||||
maps.put("current_version", current_version);
|
||||
maps.put("update_version", update_version);
|
||||
maps.put("is_successful", is_successful);
|
||||
LogUtils.d(TAG, eventType+":" + maps.toString());
|
||||
AmberUtil.send(eventType, maps);
|
||||
}
|
||||
}
|
||||
42
app/src/main/java/com/pukka/jiecheng/filter/FilterActivity.java
Executable file
42
app/src/main/java/com/pukka/jiecheng/filter/FilterActivity.java
Executable file
@@ -0,0 +1,42 @@
|
||||
package com.pukka.jiecheng.filter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.base.BaseActivity;
|
||||
|
||||
/**
|
||||
* 筛选页面
|
||||
*/
|
||||
public class FilterActivity extends BaseActivity {
|
||||
private FilterFragment filterFragment;
|
||||
public static void start(Context context) {
|
||||
Intent starter = new Intent(context, FilterActivity.class);
|
||||
context.startActivity(starter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_filtermain);
|
||||
initGamePad();
|
||||
filterFragment = FilterFragment.newInstance(false);
|
||||
try {
|
||||
getSupportFragmentManager().beginTransaction()
|
||||
.replace(R.id.id_fragment_filter_container,filterFragment)
|
||||
.commit();
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (filterFragment.onBackPressed()){
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
}
|
||||
555
app/src/main/java/com/pukka/jiecheng/filter/FilterFragment.java
Executable file
555
app/src/main/java/com/pukka/jiecheng/filter/FilterFragment.java
Executable file
@@ -0,0 +1,555 @@
|
||||
package com.pukka.jiecheng.filter;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.ConcatAdapter;
|
||||
import androidx.recyclerview.widget.GridLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.migu.bean.SearchResultBean;
|
||||
import com.migu.callback.AijiaCallback;
|
||||
import com.migu.httputils.HomeHttpUtils;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.filter.adapter.ContentAdapter;
|
||||
import com.pukka.jiecheng.filter.adapter.HeaderAdapter;
|
||||
import com.pukka.jiecheng.filter.bean.TopBean;
|
||||
import com.pukka.jiecheng.index.IndexActivity;
|
||||
import com.pukka.jiecheng.search.UnFocusListener;
|
||||
import com.pukka.jiecheng.utils.NextPageManger;
|
||||
import com.pukka.jiecheng.widget.FocusRecyclerView;
|
||||
import com.pukka.jiecheng.widget.MgRecyclerView;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
/**
|
||||
* 筛选页面
|
||||
*/
|
||||
public class FilterFragment extends Fragment {
|
||||
private static final int FILTER_PAGE_SIZE = 12;
|
||||
private static final int TOUCH_PRELOAD_THRESHOLD = 6;
|
||||
private FocusRecyclerView contentInfoRv;
|
||||
private ContentAdapter contentAdapter;
|
||||
private TextView num, tvBack, tvFilterTotal,tvFilterTotal2;
|
||||
private int Pagetotal,Sizetotal;
|
||||
private NextPageManger<SearchResultBean.ResultBean, ContentAdapter> nextPageManger;
|
||||
private Context context;
|
||||
private ConstraintLayout rltop,rltop2;
|
||||
private boolean isHome;
|
||||
|
||||
private boolean series1IsFocus;
|
||||
|
||||
private ConcatAdapter concatAdapter;
|
||||
private HeaderAdapter headerAdapter;
|
||||
private View focusView;
|
||||
private boolean isPagingLoading;
|
||||
|
||||
|
||||
public static FilterFragment newInstance(boolean isHome) {
|
||||
FilterFragment fragment = new FilterFragment();
|
||||
Bundle args = new Bundle();
|
||||
args.putBoolean("isHome", isHome);
|
||||
fragment.setArguments(args);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.activity_filter, container, false);
|
||||
context = getActivity();
|
||||
initView(view);
|
||||
initAdapter();
|
||||
contentInfoRv.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
initListener();
|
||||
updateTop();
|
||||
initPos();
|
||||
}
|
||||
});
|
||||
return view;
|
||||
}
|
||||
|
||||
private void initView(View view) {
|
||||
focusView = view.findViewById(R.id.focusView);
|
||||
rltop = view.findViewById(R.id.rltop);
|
||||
rltop2 = view.findViewById(R.id.rltop2);
|
||||
tvFilterTotal = view.findViewById(R.id.tvFilterTotal);
|
||||
tvFilterTotal2 = view.findViewById(R.id.tvFilterTotal2);
|
||||
tvBack = view.findViewById(R.id.tvBack);
|
||||
num = view.findViewById(R.id.num);
|
||||
|
||||
if (getArguments() != null) {
|
||||
isHome = getArguments().getBoolean("isHome");
|
||||
}
|
||||
if (isHome){
|
||||
rltop.setVisibility(View.GONE);
|
||||
}else {
|
||||
rltop.setVisibility(View.VISIBLE);
|
||||
}
|
||||
nextPageManger = new NextPageManger<>();
|
||||
contentAdapter = new ContentAdapter(context,contentInfoRv, nextPageManger.getList());
|
||||
nextPageManger.setAdapter(contentAdapter);
|
||||
contentInfoRv = view.findViewById(R.id.contentInfoRv);
|
||||
contentInfoRv.setStopLongClick(true);
|
||||
contentInfoRv.setInterceptLeft(true);
|
||||
contentInfoRv.setInterceptDown(true);
|
||||
contentInfoRv.setInterceptRight(true);
|
||||
contentInfoRv.setInterceptUp(true);
|
||||
contentInfoRv.setmCanFocusOutHorizontal(false);
|
||||
contentInfoRv.setmCanFocusOutVertical(false);
|
||||
contentInfoRv.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE && !recyclerView.isInTouchMode()) {
|
||||
View focusedChild = recyclerView.getFocusedChild();
|
||||
if (focusedChild != null) {
|
||||
int position = recyclerView.getChildAdapterPosition(focusedChild);
|
||||
if (position>0&&position != RecyclerView.NO_POSITION) {
|
||||
smoothCenterItem(contentInfoRv,position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
if (!recyclerView.isInTouchMode() || dy <= 0 || isPagingLoading || nextPageManger == null || !nextPageManger.isNextPage()) {
|
||||
return;
|
||||
}
|
||||
RecyclerView.LayoutManager layoutManager = recyclerView.getLayoutManager();
|
||||
if (!(layoutManager instanceof GridLayoutManager)) {
|
||||
return;
|
||||
}
|
||||
int lastVisibleItem = ((GridLayoutManager) layoutManager).findLastVisibleItemPosition();
|
||||
int totalItemCount = concatAdapter == null ? 0 : concatAdapter.getItemCount();
|
||||
if (lastVisibleItem == RecyclerView.NO_POSITION || totalItemCount <= 0) {
|
||||
return;
|
||||
}
|
||||
if (lastVisibleItem >= totalItemCount - TOUCH_PRELOAD_THRESHOLD) {
|
||||
triggerNextPage();
|
||||
}
|
||||
}
|
||||
});
|
||||
contentAdapter.setOnFocusChangeListener(new ContentAdapter.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(int position) {
|
||||
headerAdapter.getHolder().id_rv_series_5.setVisibility(View.VISIBLE);
|
||||
LogUtils.d("onFocusChange:"+position);
|
||||
int bsStr = position / FILTER_PAGE_SIZE + 1;
|
||||
String fullText = "共" + Sizetotal + "部 当前" + bsStr + "/" + Pagetotal;
|
||||
if (Pagetotal == 0) {
|
||||
fullText = "共0部";
|
||||
}
|
||||
changeNumTextColor("共" + Sizetotal + "部 当前",bsStr+"","/" + Pagetotal,fullText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void needUpData() {
|
||||
LogUtils.d("needUpData:");
|
||||
triggerNextPage();
|
||||
}
|
||||
});
|
||||
contentInfoRv.setUnFocusListener(new UnFocusListener() {
|
||||
@Override
|
||||
public void unFocus(View view, int keycode) {
|
||||
LogUtils.d("unFocus:" + keycode);
|
||||
if (keycode==19){
|
||||
if (isHome && headerAdapter.getHolder().id_rv_series_1.hasFocus()){
|
||||
((IndexActivity)(getActivity())).backNavFocus();
|
||||
}
|
||||
// contentInfoRv.getLayoutManager().getChildAt(0).requestFocus();
|
||||
// concatAdapter.scrollTo(0, 0);
|
||||
// id_rv_series_4.getLayoutManager().getChildAt(id_rv_series_4.getmLastFocusPosition()).requestFocus();
|
||||
}else if (keycode==20){
|
||||
// nsv.smoothScrollBy(0, context.getResources().getDimensionPixelSize(R.dimen.qb_px_140));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initAdapter(){
|
||||
// 创建适配器
|
||||
headerAdapter = new HeaderAdapter();
|
||||
headerAdapter.setOnItemCallBack(new HeaderAdapter.OnItemCallBack() {
|
||||
@Override
|
||||
public void onItem() {
|
||||
nextPageManger.setPageIndex(1);
|
||||
updateContent(true);
|
||||
initFilterTotal();
|
||||
}
|
||||
});
|
||||
GridLayoutManager layoutManager = new GridLayoutManager(context, 6);
|
||||
concatAdapter = new ConcatAdapter( headerAdapter, contentAdapter);
|
||||
// 设置 SpanSizeLookup
|
||||
layoutManager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
|
||||
@Override
|
||||
public int getSpanSize(int position) {
|
||||
if (position == 0) { // 头部位置
|
||||
return 6; // 头部占据所有列
|
||||
} else {
|
||||
return 1; // 网格项占据 1 列
|
||||
}
|
||||
}
|
||||
});
|
||||
contentInfoRv.setLayoutManager(layoutManager);
|
||||
contentInfoRv.setAdapter(concatAdapter);
|
||||
HeaderVisibilityHelper visibilityHelper = new HeaderVisibilityHelper(concatAdapter, headerAdapter, new HeaderVisibilityHelper.OnHeaderCallBack() {
|
||||
@Override
|
||||
public void onHeaderIsVisible(boolean isVisible) {
|
||||
LogUtils.d("onHeaderIsVisible:" + isVisible);
|
||||
if (isVisible){
|
||||
// 子视图可见
|
||||
tvBack.setVisibility(View.GONE);
|
||||
tvFilterTotal.setVisibility(View.GONE);
|
||||
if (isHome) {
|
||||
rltop2.setVisibility(View.GONE);
|
||||
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) contentInfoRv.getLayoutParams();
|
||||
params.topMargin = 0;
|
||||
contentInfoRv.setLayoutParams(params);
|
||||
}
|
||||
}else {
|
||||
// 子视图不可见
|
||||
tvFilterTotal.setVisibility(View.VISIBLE);
|
||||
tvBack.setVisibility(View.VISIBLE);
|
||||
if (isHome) {
|
||||
rltop2.setVisibility(View.VISIBLE);
|
||||
ViewGroup.MarginLayoutParams params = (ViewGroup.MarginLayoutParams) contentInfoRv.getLayoutParams();
|
||||
params.topMargin = (int) context.getResources().getDimension(R.dimen.qb_px_50);
|
||||
contentInfoRv.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
visibilityHelper.setupScrollListener(contentInfoRv);
|
||||
}
|
||||
|
||||
private void smoothCenterItem(RecyclerView recyclerView,int position) {
|
||||
LogUtils.d("smoothCenterItem:"+position);
|
||||
GridLayoutManager layoutManager = (GridLayoutManager) recyclerView.getLayoutManager();
|
||||
int viewHeight = recyclerView.getHeight();
|
||||
View itemView = layoutManager.findViewByPosition(position);
|
||||
|
||||
if (itemView != null) {
|
||||
int itemTop = itemView.getTop();
|
||||
int itemBottom = itemView.getBottom();
|
||||
int itemHeight = itemBottom - itemTop;
|
||||
int centerOffset = (viewHeight - itemHeight) / 2;
|
||||
|
||||
// 平滑滚动到居中位置
|
||||
recyclerView.smoothScrollBy(0, itemTop - centerOffset);
|
||||
}
|
||||
}
|
||||
|
||||
private void initHeaderListener(){
|
||||
headerAdapter.getHolder().id_rv_series_1.setOnLayoutFocusChangeListener(new MgRecyclerView.OnLayoutFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(boolean hasFocus) {
|
||||
LogUtils.d("onFocusChange id_rv_series_1:"+hasFocus);
|
||||
}
|
||||
});
|
||||
headerAdapter.getHolder().id_rv_series_2.setOnLayoutFocusChangeListener(new MgRecyclerView.OnLayoutFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(boolean hasFocus) {
|
||||
LogUtils.d("onFocusChange id_rv_series_2:"+hasFocus);
|
||||
}
|
||||
});
|
||||
headerAdapter.getHolder().id_rv_series_3.setOnLayoutFocusChangeListener(new MgRecyclerView.OnLayoutFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(boolean hasFocus) {
|
||||
LogUtils.d("onFocusChange id_rv_series_3:"+hasFocus);
|
||||
}
|
||||
});
|
||||
headerAdapter.getHolder().id_rv_series_4.setOnLayoutFocusChangeListener(new MgRecyclerView.OnLayoutFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(boolean hasFocus) {
|
||||
LogUtils.d("onFocusChange id_rv_series_4:"+hasFocus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initListener() {
|
||||
// initHeaderListener();
|
||||
nextPageManger.setOnUpdateCallBack(new NextPageManger.OnUpdateCallBack() {
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
updateContent(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNoMoreDate() {
|
||||
isPagingLoading = false;
|
||||
LogUtils.d("needUpData到底了");
|
||||
// contentInfoRv.postDelayed(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// nsv.smoothScrollBy(0, context.getResources().getDimensionPixelSize(R.dimen.qb_px_140));
|
||||
// }
|
||||
// }, 200);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNoDate() {
|
||||
isPagingLoading = false;
|
||||
headerAdapter.getHolder().tvNoData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
private void updateTop() {
|
||||
initFilterTotal();
|
||||
if(headerAdapter != null && headerAdapter.getHolder() != null) {
|
||||
if (!isHome) {
|
||||
headerAdapter.getHolder().id_rv_series_1.requestFocus();
|
||||
} else {
|
||||
headerAdapter.getHolder().id_rv_series_1.setFocusUpView(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void requestFocusFirst(){
|
||||
LogUtils.d("requestFocusFirst");
|
||||
if (headerAdapter.getHolder().id_rv_series_1==null){
|
||||
return;
|
||||
}
|
||||
headerAdapter.getHolder().id_rv_series_1.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
headerAdapter.getHolder().id_rv_series_1.requestFocus();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void initPos(){
|
||||
if (headerAdapter==null || headerAdapter.getHolder() == null){
|
||||
return;
|
||||
}
|
||||
if (headerAdapter.getHolder().id_rv_series_1==null){
|
||||
return;
|
||||
}
|
||||
headerAdapter.getHolder().id_rv_series_1.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
headerAdapter.getHolder().id_rv_series_1.setLastFocusPosition(0);
|
||||
headerAdapter.getHolder().id_rv_series_2.setLastFocusPosition(0);
|
||||
headerAdapter.getHolder().id_rv_series_2.scrollToPosition(0);
|
||||
headerAdapter.getHolder().id_rv_series_3.setLastFocusPosition(0);
|
||||
headerAdapter.getHolder().id_rv_series_3.scrollToPosition(0);
|
||||
headerAdapter.getHolder().id_rv_series_4.setLastFocusPosition(0);
|
||||
headerAdapter.getHolder().id_rv_series_4.scrollToPosition(0);
|
||||
nextPageManger.setPageIndex(1);
|
||||
for (TopBean b:headerAdapter.getHolder().topAdapter_1.getList()
|
||||
) {
|
||||
b.setSelect(false);
|
||||
if (b.getName().equals("全部")){
|
||||
b.setSelect(true);
|
||||
}
|
||||
}
|
||||
for (TopBean b:headerAdapter.getHolder().topAdapter_2.getList()
|
||||
) {
|
||||
b.setSelect(false);
|
||||
if (b.getName().equals("全部")){
|
||||
b.setSelect(true);
|
||||
}
|
||||
}
|
||||
for (TopBean b:headerAdapter.getHolder().topAdapter_3.getList()
|
||||
) {
|
||||
b.setSelect(false);
|
||||
if (b.getName().equals("全部")){
|
||||
b.setSelect(true);
|
||||
}
|
||||
}
|
||||
for (TopBean b:headerAdapter.getHolder().topAdapter_4.getList()
|
||||
) {
|
||||
b.setSelect(false);
|
||||
if (b.getName().equals("全部")){
|
||||
b.setSelect(true);
|
||||
}
|
||||
}
|
||||
headerAdapter.getHolder().topAdapter_1.notifyDataSetChanged();
|
||||
headerAdapter.getHolder().topAdapter_2.notifyDataSetChanged();
|
||||
headerAdapter.getHolder().topAdapter_3.notifyDataSetChanged();
|
||||
headerAdapter.getHolder().topAdapter_4.notifyDataSetChanged();
|
||||
headerAdapter.setFocusRv(null);
|
||||
updateContent(!isHome);
|
||||
initFilterTotal();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateContent(boolean isFocus) {
|
||||
headerAdapter.getHolder().tvNoData.setVisibility(View.GONE);
|
||||
LogUtils.d("updateContent");
|
||||
HomeHttpUtils.getShaixuan(headerAdapter.getHolder().topAdapter_1.getSelectValue(),
|
||||
headerAdapter.getHolder().topAdapter_2.getSelectValue(),
|
||||
headerAdapter.getHolder().topAdapter_3.getSelectValue(),
|
||||
headerAdapter.getHolder().topAdapter_4.getSelectValue(), nextPageManger.getPageIndex(), new AijiaCallback.VideoResultCallback() {
|
||||
@Override
|
||||
public void onResponse(SearchResultBean response) {
|
||||
Pagetotal = response.getPagetotal();
|
||||
Sizetotal = response.getSizetotal();
|
||||
if (nextPageManger.getPageIndex()==1) {
|
||||
String fullText = "共" + Sizetotal + "部 当前" + 1 + "/" + Pagetotal;
|
||||
if (Pagetotal == 0) {
|
||||
fullText = "共0部";
|
||||
}
|
||||
changeNumTextColor("共" + Sizetotal + "部 当前","1","/" + Pagetotal,fullText);
|
||||
}else {
|
||||
// contentInfoRv.postDelayed(new Runnable() {
|
||||
// @Override
|
||||
// public void run() {
|
||||
// contentInfoRv.smoothScrollBy(0, 200);
|
||||
// }
|
||||
// }, 50);
|
||||
}
|
||||
if (nextPageManger.getPageIndex()==1&&isFocus) {
|
||||
focusView.setFocusable(true);
|
||||
focusView.requestFocus();
|
||||
nextPageManger.notifyData(contentInfoRv,response.getPagetotal(), response.getResult());
|
||||
contentInfoRv.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (headerAdapter.getFocusRv()!=null) {
|
||||
headerAdapter.getFocusRv().requestFocus();
|
||||
}else {
|
||||
headerAdapter.getHolder().id_rv_series_1.requestFocus();
|
||||
}
|
||||
focusView.setFocusable(false);
|
||||
}
|
||||
});
|
||||
}else {
|
||||
focusView.setFocusable(false);
|
||||
nextPageManger.notifyData(contentInfoRv,response.getPagetotal(), response.getResult());
|
||||
}
|
||||
isPagingLoading = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String value) {
|
||||
isPagingLoading = false;
|
||||
nextPageManger.notifyDataFail();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
public boolean onBackPressed() {
|
||||
if (isHome){
|
||||
if (rltop2.getVisibility()==View.GONE){
|
||||
return true;
|
||||
}
|
||||
contentInfoRv.scrollToPosition(0);
|
||||
headerAdapter.getHolder().id_rv_series_1.requestFocus();
|
||||
contentInfoRv.smoothScrollBy(0,-1);
|
||||
LogUtils.d("筛选页,按返回键");
|
||||
return false;
|
||||
}else {
|
||||
if (tvBack!=null&&tvBack.getVisibility() == View.VISIBLE) {
|
||||
contentInfoRv.scrollToPosition(0);
|
||||
headerAdapter.getHolder().id_rv_series_1.requestFocus();
|
||||
contentInfoRv.smoothScrollBy(0,-1);
|
||||
String fullText = "共" + Sizetotal + "部 当前" + 1 + "/" + Pagetotal;
|
||||
if (Pagetotal == 0) {
|
||||
fullText = "共0部";
|
||||
}
|
||||
changeNumTextColor("共" + Sizetotal + "部 当前","1","/" + Pagetotal,fullText);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private void changeNumTextColor(String starStr,String midStr,String endStr,String fullTextStr){
|
||||
if (fullTextStr.equals("共0部")){
|
||||
num.setText(fullTextStr);
|
||||
return;
|
||||
}
|
||||
String text = starStr + "<font color=\"#FF7417\">" + midStr + "</font>" + endStr;
|
||||
|
||||
// 使用兼容的方式处理 HTML
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
num.setText(Html.fromHtml(text, Html.FROM_HTML_MODE_LEGACY));
|
||||
} else {
|
||||
// 低版本也可以显示颜色,只是方式不同
|
||||
num.setText(Html.fromHtml(text));
|
||||
}
|
||||
}
|
||||
|
||||
private void initFilterTotal() {
|
||||
if (headerAdapter.getHolder()==null){
|
||||
return;
|
||||
}
|
||||
StringBuffer stringBuffer = new StringBuffer();
|
||||
for (TopBean bean : headerAdapter.getHolder().topAdapter_1.getList()
|
||||
) {
|
||||
if (bean.isSelect()) {
|
||||
if (bean.getName().equals("全部")){
|
||||
stringBuffer.append("全部栏目");
|
||||
}else {
|
||||
stringBuffer.append(bean.getName());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (TopBean bean : headerAdapter.getHolder().topAdapter_2.getList()
|
||||
) {
|
||||
if (bean.isSelect()) {
|
||||
stringBuffer.append(" > ");
|
||||
if (bean.getName().equals("全部")){
|
||||
stringBuffer.append("全部类型");
|
||||
}else {
|
||||
stringBuffer.append(bean.getName());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (TopBean bean : headerAdapter.getHolder().topAdapter_3.getList()
|
||||
) {
|
||||
if (bean.isSelect()) {
|
||||
stringBuffer.append(" > ");
|
||||
if (bean.getName().equals("全部")){
|
||||
stringBuffer.append("全部地区");
|
||||
}else {
|
||||
stringBuffer.append(bean.getName());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
for (TopBean bean : headerAdapter.getHolder().topAdapter_4.getList()
|
||||
) {
|
||||
if (bean.isSelect()) {
|
||||
stringBuffer.append(" > ");
|
||||
if (bean.getName().equals("全部")){
|
||||
stringBuffer.append("全部年代");
|
||||
}else {
|
||||
stringBuffer.append(bean.getName());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
LogUtils.d("tvFilterTotal222:"+stringBuffer.toString());
|
||||
tvFilterTotal.setText(stringBuffer.toString());
|
||||
tvFilterTotal2.setText(stringBuffer.toString());
|
||||
}
|
||||
|
||||
private void triggerNextPage() {
|
||||
if (isPagingLoading || nextPageManger == null || !nextPageManger.isNextPage()) {
|
||||
return;
|
||||
}
|
||||
isPagingLoading = true;
|
||||
nextPageManger.nextPage();
|
||||
}
|
||||
}
|
||||
86
app/src/main/java/com/pukka/jiecheng/filter/HeaderVisibilityHelper.java
Executable file
86
app/src/main/java/com/pukka/jiecheng/filter/HeaderVisibilityHelper.java
Executable file
@@ -0,0 +1,86 @@
|
||||
package com.pukka.jiecheng.filter;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.ConcatAdapter;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
public class HeaderVisibilityHelper {
|
||||
private ConcatAdapter concatAdapter;
|
||||
private RecyclerView.Adapter<?> headerAdapter;
|
||||
private int headerStartPosition = -1;
|
||||
private int headerEndPosition = -1;
|
||||
|
||||
private OnHeaderCallBack onHeaderCallBack;
|
||||
|
||||
public HeaderVisibilityHelper(ConcatAdapter concatAdapter, RecyclerView.Adapter<?> headerAdapter,OnHeaderCallBack onHeaderCallBack) {
|
||||
this.concatAdapter = concatAdapter;
|
||||
this.headerAdapter = headerAdapter;
|
||||
this.onHeaderCallBack = onHeaderCallBack;
|
||||
calculateHeaderPosition();
|
||||
}
|
||||
|
||||
private void calculateHeaderPosition() {
|
||||
// 查找header adapter在concat adapter中的位置
|
||||
int position = 0;
|
||||
for (int i = 0; i < concatAdapter.getAdapters().size(); i++) {
|
||||
RecyclerView.Adapter<?> adapter = concatAdapter.getAdapters().get(i);
|
||||
if (adapter == headerAdapter) {
|
||||
headerStartPosition = position;
|
||||
headerEndPosition = position + adapter.getItemCount() - 1;
|
||||
break;
|
||||
}
|
||||
position += adapter.getItemCount();
|
||||
}
|
||||
}
|
||||
|
||||
public void setupScrollListener(RecyclerView recyclerView) {
|
||||
recyclerView.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
checkHeaderVisibility(recyclerView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onScrollStateChanged(@NonNull RecyclerView recyclerView, int newState) {
|
||||
super.onScrollStateChanged(recyclerView, newState);
|
||||
if (newState == RecyclerView.SCROLL_STATE_IDLE) {
|
||||
checkHeaderVisibility(recyclerView);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void checkHeaderVisibility(RecyclerView recyclerView) {
|
||||
if (headerStartPosition == -1) return;
|
||||
|
||||
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||
if (layoutManager == null) return;
|
||||
|
||||
int firstVisible = layoutManager.findFirstVisibleItemPosition();
|
||||
int lastVisible = layoutManager.findLastVisibleItemPosition();
|
||||
|
||||
boolean isHeaderVisible = !(headerEndPosition < firstVisible || headerStartPosition > lastVisible);
|
||||
|
||||
if (isHeaderVisible) {
|
||||
onHeaderVisible();
|
||||
} else {
|
||||
onHeaderInvisible();
|
||||
}
|
||||
}
|
||||
|
||||
private void onHeaderVisible() {
|
||||
// 头部可见时的业务逻辑
|
||||
onHeaderCallBack.onHeaderIsVisible(true);
|
||||
}
|
||||
|
||||
private void onHeaderInvisible() {
|
||||
// 头部不可见时的业务逻辑
|
||||
onHeaderCallBack.onHeaderIsVisible(false);
|
||||
}
|
||||
|
||||
public interface OnHeaderCallBack{
|
||||
void onHeaderIsVisible(boolean isVisible);
|
||||
}
|
||||
}
|
||||
202
app/src/main/java/com/pukka/jiecheng/filter/adapter/ContentAdapter.java
Executable file
202
app/src/main/java/com/pukka/jiecheng/filter/adapter/ContentAdapter.java
Executable file
@@ -0,0 +1,202 @@
|
||||
package com.pukka.jiecheng.filter.adapter;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.migu.bean.SearchResultBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.utils.TopStyleUtils;
|
||||
import com.pukka.jiecheng.video.VideoDetailActivity;
|
||||
import com.pukka.jiecheng.video.utils.ContentDetailUtils;
|
||||
import com.pukka.jiecheng.widget.FocusRecyclerView;
|
||||
import com.pukka.libcore.boxShared.BoxSharedParamsUtils;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class ContentAdapter extends RecyclerView.Adapter<ContentAdapter.ItemHolder> {
|
||||
private final Context mContext;
|
||||
private List<SearchResultBean.ResultBean> contentInfoChooseList;
|
||||
private OnFocusChangeListener onFocusChangeListener;
|
||||
private OnItemClickListener onItemClickListener;
|
||||
private FocusRecyclerView contentInfoRv;
|
||||
|
||||
public ContentAdapter(Context mContext, FocusRecyclerView contentInfoRv,List<SearchResultBean.ResultBean> contentInfoChooseList) {
|
||||
this.mContext = mContext;
|
||||
this.contentInfoRv = contentInfoRv;
|
||||
this.contentInfoChooseList = contentInfoChooseList;
|
||||
}
|
||||
|
||||
public void setList(List<SearchResultBean.ResultBean> contentInfoChooseList) {
|
||||
this.contentInfoChooseList = contentInfoChooseList;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public List<SearchResultBean.ResultBean> getContentInfoChooseList() {
|
||||
return contentInfoChooseList;
|
||||
}
|
||||
|
||||
public void addList(List<SearchResultBean.ResultBean> contentInfoChooseList) {
|
||||
int positionStart = this.contentInfoChooseList.size() > 0 ?
|
||||
this.contentInfoChooseList.size() - 1 : 0;
|
||||
this.contentInfoChooseList.addAll(contentInfoChooseList);
|
||||
notifyItemRangeChanged(positionStart, this.contentInfoChooseList.size() - 1);
|
||||
}
|
||||
|
||||
public void setOnFocusChangeListener(OnFocusChangeListener onFocusChangeListener) {
|
||||
this.onFocusChangeListener = onFocusChangeListener;
|
||||
}
|
||||
|
||||
public void setItemOnClickListener(OnItemClickListener onItemClickListener) {
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||
View view = inflater.inflate(R.layout.item_hot_hcontent, parent, false);
|
||||
return new ItemHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ItemHolder itemHolder, int position) {
|
||||
// LogUtils.d("onBindViewHolder: " + position + " " + contentInfoChooseList.size());
|
||||
if (position>=contentInfoChooseList.size()){
|
||||
itemHolder.clear();
|
||||
return;
|
||||
}
|
||||
itemHolder.show();
|
||||
setView(itemHolder, position);
|
||||
if (null != contentInfoChooseList.get(position)) {
|
||||
|
||||
// if ((contentInfoChooseList.get(position)).getContenttype() == 2) {
|
||||
// int inx = (contentInfoChooseList.get(position)).getEpisodeindex();
|
||||
// itemHolder.id_tv_playtime.setText("更新至" + inx + ((contentInfoChooseList.get(position)).getCategoryname().equals("综艺") ? " 期" : " 集"));
|
||||
// }else {
|
||||
// itemHolder.id_tv_playtime.setText("");
|
||||
// }
|
||||
String info = ContentDetailUtils.getProgramInformation(contentInfoChooseList.get(position).getContenttype(),
|
||||
contentInfoChooseList.get(position).getEpisodecount());
|
||||
itemHolder.mask.setVisibility(TextUtils.isEmpty(info) ? View.GONE : View.VISIBLE);
|
||||
itemHolder.id_tv_playtime.setText(info);
|
||||
|
||||
itemHolder.hotContentItemCl.setOnFocusChangeListener((v, b) -> {
|
||||
if (b) {
|
||||
onFocusChangeListener.onFocusChange(position);
|
||||
itemHolder.resultTv.setSelected(true);
|
||||
itemHolder.resultTv.setEllipsize(TextUtils.TruncateAt.MARQUEE);
|
||||
itemHolder.resultTv.setTextColor(ContextCompat.getColor(v.getContext(),
|
||||
R.color.focuswhite95));
|
||||
LogUtils.d("needUpData position: " + position + " contentInfoChooseListSize:" + contentInfoChooseList.size());
|
||||
|
||||
if (position >= contentInfoChooseList.size() - 6 && position >=6 ) {
|
||||
LogUtils.d("needUpData222 position: " + position);
|
||||
onFocusChangeListener.needUpData();
|
||||
}
|
||||
} else {
|
||||
itemHolder.resultTv.setSelected(false);
|
||||
itemHolder.resultTv.setEllipsize(TextUtils.TruncateAt.END);
|
||||
itemHolder.resultTv.setTextColor(ContextCompat.getColor(v.getContext(),
|
||||
R.color.white30));
|
||||
}
|
||||
TopStyleUtils.topImageChangeFilter(v, b);
|
||||
});
|
||||
|
||||
itemHolder.hotContentItemCl.setOnClickListener(v -> {
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.OnItemClick(contentInfoChooseList.get(position), position);
|
||||
}
|
||||
|
||||
VideoDetailActivity.start(mContext, contentInfoChooseList.get(position).getContentcode(), String.valueOf(contentInfoChooseList.get(position).getContenttype())
|
||||
, VideoDetailActivity.ModuleSourceType.SEARCH_PAGE);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isViewFullyVisible(RecyclerView parent, View child) {
|
||||
Rect childRect = new Rect();
|
||||
child.getGlobalVisibleRect(childRect);
|
||||
|
||||
Rect parentRect = new Rect();
|
||||
parent.getGlobalVisibleRect(parentRect);
|
||||
|
||||
// 考虑RecyclerView的padding
|
||||
parentRect.left += parent.getPaddingLeft();
|
||||
parentRect.right -= parent.getPaddingRight();
|
||||
parentRect.top += parent.getPaddingTop();
|
||||
parentRect.bottom -= parent.getPaddingBottom();
|
||||
|
||||
return parentRect.contains(childRect);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void setView(ItemHolder itemHolder, int position) {
|
||||
if (contentInfoChooseList.get(position) != null) {
|
||||
if (!TextUtils.isEmpty(contentInfoChooseList.get(position).getPosterimg())) {
|
||||
itemHolder.posterIv.setImageURI(contentInfoChooseList.get(position).getPosterimg());
|
||||
}
|
||||
if (!TextUtils.isEmpty(contentInfoChooseList.get(position).getName())) {
|
||||
itemHolder.resultTv.setText(contentInfoChooseList.get(position).getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return null != contentInfoChooseList ? contentInfoChooseList.size() : 0;
|
||||
}
|
||||
|
||||
public static class ItemHolder extends RecyclerView.ViewHolder {
|
||||
public LinearLayout hotContentItemCl;
|
||||
public PkSimpleDraweeView posterIv;
|
||||
public TextView resultTv, id_tv_playtime, mask;
|
||||
|
||||
|
||||
ItemHolder(View itemView) {
|
||||
super(itemView);
|
||||
mask = itemView.findViewById(R.id.mask);
|
||||
posterIv = itemView.findViewById(R.id.posterIv);
|
||||
hotContentItemCl = itemView.findViewById(R.id.hotContentItemCl);
|
||||
resultTv = itemView.findViewById(R.id.resultTv);
|
||||
id_tv_playtime = itemView.findViewById(R.id.id_tv_playtime);
|
||||
if (BoxSharedParamsUtils.isJcCloud()||BoxSharedParamsUtils.isJcHotel()){
|
||||
ViewGroup.LayoutParams params = hotContentItemCl.getLayoutParams();
|
||||
params.width = (int) hotContentItemCl.getContext().getResources().getDimension(R.dimen.qb_px_173);
|
||||
hotContentItemCl.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
|
||||
void clear(){
|
||||
hotContentItemCl.setVisibility(View.GONE);
|
||||
}
|
||||
void show(){
|
||||
hotContentItemCl.setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public interface OnFocusChangeListener {
|
||||
void onFocusChange(int position);
|
||||
|
||||
void needUpData();
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void OnItemClick(SearchResultBean.ResultBean resultBean, int position);
|
||||
}
|
||||
|
||||
}
|
||||
378
app/src/main/java/com/pukka/jiecheng/filter/adapter/HeaderAdapter.java
Executable file
378
app/src/main/java/com/pukka/jiecheng/filter/adapter/HeaderAdapter.java
Executable file
@@ -0,0 +1,378 @@
|
||||
package com.pukka.jiecheng.filter.adapter;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.filter.bean.TopBean;
|
||||
import com.pukka.jiecheng.filter.bean.TopListBean;
|
||||
import com.pukka.jiecheng.widget.MgRecyclerView;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
// 头部适配器
|
||||
public class HeaderAdapter extends RecyclerView.Adapter<HeaderAdapter.HeaderViewHolder> implements TopAdapter.OnItemClickListener {
|
||||
private HeaderViewHolder holder;
|
||||
private MgRecyclerView focusRv;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public HeaderViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.inflate(R.layout.filter_header_layout, parent, false);
|
||||
if (holder == null) {
|
||||
holder = new HeaderViewHolder(view);
|
||||
}
|
||||
return holder;
|
||||
}
|
||||
|
||||
public void setFocusRv(MgRecyclerView focusRv) {
|
||||
this.focusRv = focusRv;
|
||||
}
|
||||
|
||||
public MgRecyclerView getFocusRv() {
|
||||
return focusRv;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull HeaderViewHolder holder, int position) {
|
||||
// 绑定头部数据
|
||||
holder.id_rv_series_2.setOnLayoutFocusChangeListener(new MgRecyclerView.OnLayoutFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(boolean hasFocus) {
|
||||
LogUtils.d("id_rv_series_2 onFocusChange:" + hasFocus);
|
||||
if (!hasFocus && holder.id_rv_series_2.getmLastFocusPosition() >= 0) {
|
||||
holder.id_rv_series_2.scrollToPosition(holder.id_rv_series_2.getmLastFocusPosition());
|
||||
}
|
||||
}
|
||||
});
|
||||
holder.id_rv_series_3.setOnLayoutFocusChangeListener(new MgRecyclerView.OnLayoutFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(boolean hasFocus) {
|
||||
LogUtils.d("id_rv_series_3 onFocusChange:" + hasFocus);
|
||||
if (!hasFocus && holder.id_rv_series_3.getmLastFocusPosition() >= 0) {
|
||||
holder.id_rv_series_3.scrollToPosition(holder.id_rv_series_3.getmLastFocusPosition());
|
||||
}
|
||||
}
|
||||
});
|
||||
holder.id_rv_series_4.setOnLayoutFocusChangeListener(new MgRecyclerView.OnLayoutFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(boolean hasFocus) {
|
||||
LogUtils.d("id_rv_series_4 onFocusChange:" + hasFocus);
|
||||
if (!hasFocus && holder.id_rv_series_4.getmLastFocusPosition() >= 0) {
|
||||
holder.id_rv_series_4.scrollToPosition(holder.id_rv_series_4.getmLastFocusPosition());
|
||||
}
|
||||
}
|
||||
});
|
||||
holder.topAdapter_1.setOnItemClickListener(this);
|
||||
holder.topAdapter_2.setOnItemClickListener(this);
|
||||
holder.topAdapter_3.setOnItemClickListener(this);
|
||||
holder.topAdapter_4.setOnItemClickListener(this);
|
||||
|
||||
updateTop(holder);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return 1; // 只有一个头部
|
||||
}
|
||||
|
||||
private void updateTop(HeaderViewHolder holder) {
|
||||
|
||||
// initFilterTotal();
|
||||
// if (!isHome) {
|
||||
// id_rv_series_1.requestFocus();
|
||||
// }else {
|
||||
// id_rv_series_1.setFocusUpView(false);
|
||||
// }
|
||||
}
|
||||
|
||||
public HeaderViewHolder getHolder() {
|
||||
return holder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onItemClick(int type, String name, int pos) {
|
||||
switch (type) {
|
||||
case 1:
|
||||
focusRv = holder.id_rv_series_1;
|
||||
holder.id_rv_series_1.setLastFocusPosition(pos);
|
||||
for (TopBean b:holder.topAdapter_2.getList()
|
||||
) {
|
||||
b.setSelect(false);
|
||||
if (b.getName().equals("全部")){
|
||||
b.setSelect(true);
|
||||
}
|
||||
}
|
||||
for (TopBean b:holder.topAdapter_3.getList()
|
||||
) {
|
||||
b.setSelect(false);
|
||||
if (b.getName().equals("全部")){
|
||||
b.setSelect(true);
|
||||
}
|
||||
}
|
||||
holder.topAdapter_2.setList(holder.topListMap.get(name).getList2());
|
||||
holder.id_rv_series_2.setLastFocusPosition(0);
|
||||
holder.id_rv_series_2.scrollToPosition(0);
|
||||
holder.topAdapter_3.setList(holder.topListMap.get(name).getList3());
|
||||
holder.id_rv_series_3.setLastFocusPosition(0);
|
||||
holder.id_rv_series_3.scrollToPosition(0);
|
||||
break;
|
||||
case 2:
|
||||
focusRv = holder.id_rv_series_2;
|
||||
holder.id_rv_series_2.setLastFocusPosition(pos);
|
||||
break;
|
||||
case 3:
|
||||
focusRv = holder.id_rv_series_3;
|
||||
holder.id_rv_series_3.setLastFocusPosition(pos);
|
||||
break;
|
||||
case 4:
|
||||
focusRv = holder.id_rv_series_4;
|
||||
holder.id_rv_series_4.setLastFocusPosition(pos);
|
||||
break;
|
||||
}
|
||||
onItemCallBack.onItem();
|
||||
}
|
||||
|
||||
OnItemCallBack onItemCallBack;
|
||||
|
||||
public void setOnItemCallBack(OnItemCallBack onItemCallBack) {
|
||||
this.onItemCallBack = onItemCallBack;
|
||||
}
|
||||
|
||||
public interface OnItemCallBack {
|
||||
void onItem();
|
||||
}
|
||||
|
||||
public class HeaderViewHolder extends RecyclerView.ViewHolder {
|
||||
public MgRecyclerView id_rv_series_1, id_rv_series_2, id_rv_series_3, id_rv_series_4, id_rv_series_5;
|
||||
public TopAdapter topAdapter_1, topAdapter_2, topAdapter_3, topAdapter_4;
|
||||
public TopAdapter2 topAdapter_5;
|
||||
public TextView tvNoData;
|
||||
public HashMap<String, TopListBean> topListMap = new HashMap<>();
|
||||
|
||||
public HeaderViewHolder(@NonNull View view) {
|
||||
super(view);
|
||||
id_rv_series_1 = view.findViewById(R.id.id_rv_series_1);
|
||||
id_rv_series_2 = view.findViewById(R.id.id_rv_series_2);
|
||||
id_rv_series_3 = view.findViewById(R.id.id_rv_series_3);
|
||||
id_rv_series_4 = view.findViewById(R.id.id_rv_series_4);
|
||||
id_rv_series_5 = view.findViewById(R.id.id_rv_series_5);
|
||||
id_rv_series_1.setRecord(false);
|
||||
id_rv_series_2.setRecord(false);
|
||||
id_rv_series_3.setRecord(false);
|
||||
id_rv_series_4.setRecord(false);
|
||||
id_rv_series_5.setRecord(false);
|
||||
tvNoData = view.findViewById(R.id.tvNoData);
|
||||
topAdapter_1 = new TopAdapter(1);
|
||||
topAdapter_2 = new TopAdapter(2);
|
||||
topAdapter_2.setMgRecyclerView(id_rv_series_2);
|
||||
topAdapter_3 = new TopAdapter(3);
|
||||
topAdapter_3.setMgRecyclerView(id_rv_series_3);
|
||||
topAdapter_4 = new TopAdapter(4);
|
||||
topAdapter_4.setMgRecyclerView(id_rv_series_4);
|
||||
topAdapter_4.setRv5(id_rv_series_5);
|
||||
topAdapter_5 = new TopAdapter2(5);
|
||||
topAdapter_5.setMgRecyclerView(id_rv_series_4);
|
||||
//全部 电影 电视剧 少儿 动漫 综艺 短剧 纪实 生活
|
||||
topAdapter_1.getList().add(new TopBean("全部", true));
|
||||
topAdapter_1.getList().add(new TopBean("电影", false));
|
||||
topAdapter_1.getList().add(new TopBean("电视剧", false));
|
||||
topAdapter_1.getList().add(new TopBean("少儿", false));
|
||||
topAdapter_1.getList().add(new TopBean("动漫", false));
|
||||
topAdapter_1.updateList();
|
||||
|
||||
for (TopBean bean : topAdapter_1.getList()
|
||||
) {
|
||||
initTopListMap(bean.getName());
|
||||
}
|
||||
|
||||
topAdapter_2.setList(topListMap.get("全部").getList2());
|
||||
topAdapter_3.setList(topListMap.get("全部").getList3());
|
||||
|
||||
int curYear = Calendar.getInstance().get(Calendar.YEAR);
|
||||
//全部 2025-2024 2023-2020 2019-2010 更早
|
||||
// topAdapter_4.getList().add(new TopBean("全部", true));
|
||||
// topAdapter_4.getList().add(new TopBean(curYear + "-" + (curYear - 1), false));
|
||||
// topAdapter_4.getList().add(new TopBean((curYear - 2) + "-" + (curYear - 5), false));
|
||||
// topAdapter_4.getList().add(new TopBean((curYear - 6) + "-" + (curYear - 15), false));
|
||||
// topAdapter_4.getList().add(new TopBean("更早", false));
|
||||
|
||||
topAdapter_4.getList().add(new TopBean("全部", true));
|
||||
// for (int i = 0; i < 10; i++) {
|
||||
// topAdapter_4.getList().add(new TopBean(curYear - i + "", false));
|
||||
// }
|
||||
topAdapter_4.getList().add(new TopBean((curYear) + "-" + (curYear - 1), false));
|
||||
topAdapter_4.getList().add(new TopBean((curYear - 2) + "-" + (curYear - 6), false));
|
||||
topAdapter_4.getList().add(new TopBean((curYear-6)+"之前", false));
|
||||
|
||||
topAdapter_4.updateList();
|
||||
|
||||
for (int i = 0; i < 13; i++) {
|
||||
topAdapter_5.getList().add(new TopBean("全不", false));
|
||||
}
|
||||
topAdapter_5.updateList();
|
||||
|
||||
id_rv_series_5.setAdapter(topAdapter_5);
|
||||
id_rv_series_4.setAdapter(topAdapter_4);
|
||||
id_rv_series_3.setAdapter(topAdapter_3);
|
||||
id_rv_series_2.setAdapter(topAdapter_2);
|
||||
id_rv_series_1.setAdapter(topAdapter_1);
|
||||
}
|
||||
|
||||
private void initTopListMap(String name) {
|
||||
List<TopBean> topList2qb = new ArrayList<>();
|
||||
List<TopBean> topList3qb = new ArrayList<>();
|
||||
if (name.equals("电视剧")) {
|
||||
topList2qb.add(new TopBean("全部", true));
|
||||
topList2qb.add(new TopBean("剧情", false));
|
||||
topList2qb.add(new TopBean("爱情", false));
|
||||
topList2qb.add(new TopBean("悬疑", false));
|
||||
topList2qb.add(new TopBean("古装", false));
|
||||
topList2qb.add(new TopBean("都市", false));
|
||||
topList2qb.add(new TopBean("家庭", false));
|
||||
topList2qb.add(new TopBean("喜剧", false));
|
||||
topList2qb.add(new TopBean("犯罪", false));
|
||||
topList2qb.add(new TopBean("战争", false));
|
||||
topList2qb.add(new TopBean("历史", false));
|
||||
topList2qb.add(new TopBean("动作", false));
|
||||
topList2qb.add(new TopBean("青春", false));
|
||||
topList2qb.add(new TopBean("农村", false));
|
||||
topList2qb.add(new TopBean("励志", false));
|
||||
topList2qb.add(new TopBean("奇幻", false));
|
||||
topList2qb.add(new TopBean("惊悚", false));
|
||||
topList2qb.add(new TopBean("传记", false));
|
||||
topList2qb.add(new TopBean("短片", false));
|
||||
topList2qb.add(new TopBean("纪录", false));
|
||||
topList2qb.add(new TopBean("传奇", false));
|
||||
topList2qb.add(new TopBean("当代", false));
|
||||
topList2qb.add(new TopBean("年代", false));
|
||||
topList2qb.add(new TopBean("偶像", false));
|
||||
topList2qb.add(new TopBean("情感", false));
|
||||
topList2qb.add(new TopBean("现代", false));
|
||||
topList2qb.add(new TopBean("警匪", false));
|
||||
|
||||
topList3qb.add(new TopBean("全部", true));
|
||||
topList3qb.add(new TopBean("中国大陆", false));
|
||||
topList3qb.add(new TopBean("中国台湾", false));
|
||||
topList3qb.add(new TopBean("中国香港", false));
|
||||
topList3qb.add(new TopBean("日本", false));
|
||||
topList3qb.add(new TopBean("泰国", false));
|
||||
topList3qb.add(new TopBean("新加坡", false));
|
||||
topList3qb.add(new TopBean("其他", false));
|
||||
}else if (name.equals("全部") || name.equals("电影")){
|
||||
topList2qb.add(new TopBean("全部", true));
|
||||
topList2qb.add(new TopBean("剧情", false));
|
||||
topList2qb.add(new TopBean("爱情", false));
|
||||
topList2qb.add(new TopBean("喜剧", false));
|
||||
topList2qb.add(new TopBean("动作", false));
|
||||
topList2qb.add(new TopBean("悬疑", false));
|
||||
topList2qb.add(new TopBean("犯罪", false));
|
||||
topList2qb.add(new TopBean("奇幻", false));
|
||||
topList2qb.add(new TopBean("科幻", false));
|
||||
topList2qb.add(new TopBean("惊悚", false));
|
||||
topList2qb.add(new TopBean("动画", false));
|
||||
topList2qb.add(new TopBean("家庭", false));
|
||||
topList2qb.add(new TopBean("古装", false));
|
||||
topList2qb.add(new TopBean("都市", false));
|
||||
topList2qb.add(new TopBean("战争", false));
|
||||
topList2qb.add(new TopBean("冒险", false));
|
||||
topList2qb.add(new TopBean("传记", false));
|
||||
topList2qb.add(new TopBean("历史", false));
|
||||
topList2qb.add(new TopBean("歌舞", false));
|
||||
topList2qb.add(new TopBean("运动", false));
|
||||
topList2qb.add(new TopBean("灾难", false));
|
||||
topList2qb.add(new TopBean("励志", false));
|
||||
topList2qb.add(new TopBean("文艺", false));
|
||||
topList2qb.add(new TopBean("纪录", false));
|
||||
topList2qb.add(new TopBean("短片", false));
|
||||
|
||||
topList3qb.add(new TopBean("全部", true));
|
||||
topList3qb.add(new TopBean("中国大陆", false));
|
||||
topList3qb.add(new TopBean("中国台湾", false));
|
||||
topList3qb.add(new TopBean("中国香港", false));
|
||||
topList3qb.add(new TopBean("日本", false));
|
||||
topList3qb.add(new TopBean("泰国", false));
|
||||
topList3qb.add(new TopBean("新加坡", false));
|
||||
topList3qb.add(new TopBean("英国", false));
|
||||
topList3qb.add(new TopBean("意大利", false));
|
||||
topList3qb.add(new TopBean("美国", false));
|
||||
topList3qb.add(new TopBean("法国", false));
|
||||
topList3qb.add(new TopBean("德国", false));
|
||||
topList3qb.add(new TopBean("韩国", false));
|
||||
topList3qb.add(new TopBean("其他", false));
|
||||
}else if (name.equals("少儿")){
|
||||
topList2qb.add(new TopBean("全部", true));
|
||||
topList2qb.add(new TopBean("动画", false));
|
||||
topList2qb.add(new TopBean("益智", false));
|
||||
topList2qb.add(new TopBean("成长", false));
|
||||
topList2qb.add(new TopBean("亲子", false));
|
||||
topList2qb.add(new TopBean("欢乐", false));
|
||||
topList2qb.add(new TopBean("冒险", false));
|
||||
topList2qb.add(new TopBean("奇幻", false));
|
||||
topList2qb.add(new TopBean("科幻", false));
|
||||
topList2qb.add(new TopBean("武侠", false));
|
||||
topList2qb.add(new TopBean("艺术", false));
|
||||
topList2qb.add(new TopBean("国学", false));
|
||||
topList2qb.add(new TopBean("友情", false));
|
||||
topList2qb.add(new TopBean("寓教于乐", false));
|
||||
topList2qb.add(new TopBean("纯娱乐类", false));
|
||||
topList2qb.add(new TopBean("科普", false));
|
||||
|
||||
topList3qb.add(new TopBean("全部", true));
|
||||
topList3qb.add(new TopBean("中国大陆", false));
|
||||
topList3qb.add(new TopBean("日本", false));
|
||||
topList3qb.add(new TopBean("英国", false));
|
||||
topList3qb.add(new TopBean("意大利", false));
|
||||
topList3qb.add(new TopBean("美国", false));
|
||||
topList3qb.add(new TopBean("法国", false));
|
||||
topList3qb.add(new TopBean("韩国", false));
|
||||
topList3qb.add(new TopBean("加拿大", false));
|
||||
topList3qb.add(new TopBean("澳大利亚", false));
|
||||
topList3qb.add(new TopBean("俄罗斯", false));
|
||||
topList3qb.add(new TopBean("其他", false));
|
||||
}else if (name.equals("动漫")){
|
||||
topList2qb.add(new TopBean("全部", true));
|
||||
topList2qb.add(new TopBean("冒险", false));
|
||||
topList2qb.add(new TopBean("奇幻", false));
|
||||
topList2qb.add(new TopBean("喜剧", false));
|
||||
topList2qb.add(new TopBean("科幻", false));
|
||||
topList2qb.add(new TopBean("动作", false));
|
||||
topList2qb.add(new TopBean("家庭", false));
|
||||
topList2qb.add(new TopBean("儿童", false));
|
||||
topList2qb.add(new TopBean("剧情", false));
|
||||
topList2qb.add(new TopBean("音乐", false));
|
||||
topList2qb.add(new TopBean("爱情", false));
|
||||
topList2qb.add(new TopBean("战争", false));
|
||||
topList2qb.add(new TopBean("运动", false));
|
||||
topList2qb.add(new TopBean("悬疑", false));
|
||||
topList2qb.add(new TopBean("传记", false));
|
||||
topList2qb.add(new TopBean("历史", false));
|
||||
topList2qb.add(new TopBean("亲子", false));
|
||||
topList2qb.add(new TopBean("少儿", false));
|
||||
topList2qb.add(new TopBean("歌舞", false));
|
||||
|
||||
topList3qb.add(new TopBean("全部", true));
|
||||
topList3qb.add(new TopBean("中国大陆", false));
|
||||
topList3qb.add(new TopBean("中国香港", false));
|
||||
topList3qb.add(new TopBean("日本", false));
|
||||
topList3qb.add(new TopBean("英国", false));
|
||||
topList3qb.add(new TopBean("美国", false));
|
||||
topList3qb.add(new TopBean("德国", false));
|
||||
topList3qb.add(new TopBean("法国", false));
|
||||
topList3qb.add(new TopBean("泰国", false));
|
||||
topList3qb.add(new TopBean("其他", false));
|
||||
}
|
||||
topListMap.put(name, new TopListBean(topList2qb, topList3qb));
|
||||
}
|
||||
}
|
||||
}
|
||||
192
app/src/main/java/com/pukka/jiecheng/filter/adapter/TopAdapter.java
Executable file
192
app/src/main/java/com/pukka/jiecheng/filter/adapter/TopAdapter.java
Executable file
@@ -0,0 +1,192 @@
|
||||
package com.pukka.jiecheng.filter.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.filter.bean.TopBean;
|
||||
import com.pukka.jiecheng.widget.MgRecyclerView;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TopAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
private List<TopBean> list = new ArrayList<>();
|
||||
private int type = 1;
|
||||
|
||||
private MgRecyclerView mgRecyclerView;
|
||||
private MgRecyclerView rv5;
|
||||
|
||||
public void setMgRecyclerView(MgRecyclerView mgRecyclerView) {
|
||||
this.mgRecyclerView = mgRecyclerView;
|
||||
}
|
||||
|
||||
public void setRv5(MgRecyclerView rv5) {
|
||||
this.rv5 = rv5;
|
||||
}
|
||||
|
||||
public TopAdapter(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<TopBean> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public String getSelectValue() {
|
||||
for (TopBean b : list
|
||||
) {
|
||||
if (b.isSelect()) {
|
||||
if (b.getName().equals("全部")){
|
||||
return "";
|
||||
}
|
||||
return b.getName();
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setList(List<TopBean> list) {
|
||||
this.list = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void updateList() {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||
View view = inflater.inflate(R.layout.item_filter, parent, false);
|
||||
return new TopHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
|
||||
TopBean topBean = list.get(position);
|
||||
TopHolder topHolder = (TopHolder) holder;
|
||||
|
||||
topHolder.id_tv_nav_name.setText(topBean.getName());
|
||||
updateTextColor(topHolder, topBean.isSelect(), false);
|
||||
|
||||
topHolder.nav_all.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
int action = event.getAction();
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
topHolder.id_tv_nav_name.setTextColor(0xFFFFFFFF);
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
updateTextColor(topHolder, topBean.isSelect(), false);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
topHolder.nav_all.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (hasFocus && mgRecyclerView != null && (type == 2 || type == 3 || type == 4)) {
|
||||
int[] amount = getScrollAmount(mgRecyclerView, v);
|
||||
LogUtils.d("smoothScrollBy:" + amount[0]);
|
||||
if (amount[0] < 200) {
|
||||
mgRecyclerView.smoothScrollBy(amount[0], 0);
|
||||
}
|
||||
}
|
||||
if (hasFocus && rv5 != null) {
|
||||
rv5.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
updateTextColor(topHolder, topBean.isSelect(), hasFocus);
|
||||
}
|
||||
});
|
||||
|
||||
topHolder.nav_all.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
boolean isUpdate = true;
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (list.get(i).isSelect()) {
|
||||
if (i == position) {
|
||||
isUpdate = false;
|
||||
break;
|
||||
}
|
||||
list.get(i).setSelect(false);
|
||||
notifyItemChanged(i);
|
||||
}
|
||||
}
|
||||
if (isUpdate) {
|
||||
list.get(position).setSelect(true);
|
||||
notifyItemChanged(position);
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.onItemClick(type, list.get(position).getName(), position);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateTextColor(TopHolder holder, boolean isSelect, boolean hasFocus) {
|
||||
if (hasFocus) {
|
||||
holder.id_tv_nav_name.setTextColor(0xFFFFFFFF);
|
||||
} else {
|
||||
holder.id_tv_nav_name.setTextColor(isSelect ? 0xFFFF7417 : 0xB3FFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
private int[] getScrollAmount(RecyclerView recyclerView, View view) {
|
||||
int[] out = new int[2];
|
||||
final int parentLeft = recyclerView.getPaddingLeft();
|
||||
final int parentTop = recyclerView.getPaddingTop();
|
||||
final int parentRight = recyclerView.getWidth() - recyclerView.getPaddingRight();
|
||||
final int childLeft = view.getLeft() - view.getScrollX();
|
||||
final int childTop = view.getTop() - view.getScrollY();
|
||||
|
||||
final int dx = childLeft - parentLeft - ((parentRight - view.getWidth()) / 2);
|
||||
|
||||
final int dy = childTop - parentTop - (parentTop - view.getHeight()) / 2;
|
||||
out[0] = dx;
|
||||
out[1] = dy;
|
||||
return out;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
private OnItemClickListener onItemClickListener;
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(int type, String name,int pos);
|
||||
}
|
||||
|
||||
static class TopHolder extends RecyclerView.ViewHolder {
|
||||
private TextView id_tv_nav_name;
|
||||
private ConstraintLayout nav_all;
|
||||
|
||||
public TopHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
nav_all = itemView.findViewById(R.id.nav_all);
|
||||
id_tv_nav_name = itemView.findViewById(R.id.id_tv_nav_name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
118
app/src/main/java/com/pukka/jiecheng/filter/adapter/TopAdapter2.java
Executable file
118
app/src/main/java/com/pukka/jiecheng/filter/adapter/TopAdapter2.java
Executable file
@@ -0,0 +1,118 @@
|
||||
package com.pukka.jiecheng.filter.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.filter.bean.TopBean;
|
||||
import com.pukka.jiecheng.widget.MgRecyclerView;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TopAdapter2 extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
private List<TopBean> list = new ArrayList<>();
|
||||
private int type = 1;
|
||||
|
||||
private MgRecyclerView rv4;
|
||||
|
||||
public void setMgRecyclerView(MgRecyclerView rv4) {
|
||||
this.rv4 = rv4;
|
||||
}
|
||||
|
||||
public TopAdapter2(int type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public List<TopBean> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
public void setList(List<TopBean> list) {
|
||||
this.list = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void updateList() {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||
View view = inflater.inflate(R.layout.item_filter, parent, false);
|
||||
return new TopHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
|
||||
TopBean topBean = list.get(position);
|
||||
TopHolder topHolder = (TopHolder) holder;
|
||||
|
||||
topHolder.id_tv_nav_name.setText(topBean.getName());
|
||||
updateTextColor(topHolder, topBean.isSelect(), false);
|
||||
|
||||
topHolder.nav_all.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
public boolean onTouch(View v, MotionEvent event) {
|
||||
int action = event.getAction();
|
||||
switch (action) {
|
||||
case MotionEvent.ACTION_DOWN:
|
||||
topHolder.id_tv_nav_name.setTextColor(0xFFFFFFFF);
|
||||
break;
|
||||
case MotionEvent.ACTION_UP:
|
||||
case MotionEvent.ACTION_CANCEL:
|
||||
updateTextColor(topHolder, topBean.isSelect(), false);
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
topHolder.nav_all.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (hasFocus) {
|
||||
rv4.requestFocus();
|
||||
}
|
||||
updateTextColor(topHolder, topBean.isSelect(), hasFocus);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void updateTextColor(TopHolder holder, boolean isSelect, boolean hasFocus) {
|
||||
if (hasFocus) {
|
||||
holder.id_tv_nav_name.setTextColor(0xFFFFFFFF);
|
||||
} else {
|
||||
holder.id_tv_nav_name.setTextColor(isSelect ? 0xFFFF7417 : 0xB3FFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list.size();
|
||||
}
|
||||
|
||||
static class TopHolder extends RecyclerView.ViewHolder {
|
||||
private TextView id_tv_nav_name;
|
||||
private ConstraintLayout nav_all;
|
||||
|
||||
public TopHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
nav_all = itemView.findViewById(R.id.nav_all);
|
||||
id_tv_nav_name = itemView.findViewById(R.id.id_tv_nav_name);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
35
app/src/main/java/com/pukka/jiecheng/filter/bean/TopBean.java
Executable file
35
app/src/main/java/com/pukka/jiecheng/filter/bean/TopBean.java
Executable file
@@ -0,0 +1,35 @@
|
||||
package com.pukka.jiecheng.filter.bean;
|
||||
|
||||
public class TopBean {
|
||||
private String name;
|
||||
private boolean isSelect;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "TopBean{" +
|
||||
"name='" + name + '\'' +
|
||||
", isSelect=" + isSelect +
|
||||
'}';
|
||||
}
|
||||
|
||||
public TopBean(String name, boolean isSelect) {
|
||||
this.name = name;
|
||||
this.isSelect = isSelect;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean isSelect() {
|
||||
return isSelect;
|
||||
}
|
||||
|
||||
public void setSelect(boolean select) {
|
||||
isSelect = select;
|
||||
}
|
||||
}
|
||||
30
app/src/main/java/com/pukka/jiecheng/filter/bean/TopListBean.java
Executable file
30
app/src/main/java/com/pukka/jiecheng/filter/bean/TopListBean.java
Executable file
@@ -0,0 +1,30 @@
|
||||
package com.pukka.jiecheng.filter.bean;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class TopListBean {
|
||||
private List<TopBean>list2 = new ArrayList<>();
|
||||
private List<TopBean>list3 = new ArrayList<>();
|
||||
|
||||
public TopListBean(List<TopBean> list2, List<TopBean> list3) {
|
||||
this.list2 = list2;
|
||||
this.list3 = list3;
|
||||
}
|
||||
|
||||
public List<TopBean> getList2() {
|
||||
return list2;
|
||||
}
|
||||
|
||||
public void setList2(List<TopBean> list2) {
|
||||
this.list2 = list2;
|
||||
}
|
||||
|
||||
public List<TopBean> getList3() {
|
||||
return list3;
|
||||
}
|
||||
|
||||
public void setList3(List<TopBean> list3) {
|
||||
this.list3 = list3;
|
||||
}
|
||||
}
|
||||
41
app/src/main/java/com/pukka/jiecheng/history/CenterLinearLayoutManager.java
Executable file
41
app/src/main/java/com/pukka/jiecheng/history/CenterLinearLayoutManager.java
Executable file
@@ -0,0 +1,41 @@
|
||||
|
||||
package com.pukka.jiecheng.history;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Rect;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.libcore.widget.HorizontalRecyclerViewTv;
|
||||
|
||||
/**
|
||||
* [首页模板内容的布局Manager]<BR>
|
||||
*
|
||||
* @author wxf
|
||||
* @version [V0.1.0.1, 2023/2/3 0011]
|
||||
* @since V0.1.0.1
|
||||
*/
|
||||
public class CenterLinearLayoutManager extends LinearLayoutManager {
|
||||
private static final String TAG = CenterLinearLayoutManager.class.getSimpleName();
|
||||
|
||||
public static Integer NAV_INDEX = -1;
|
||||
|
||||
public CenterLinearLayoutManager(Context context, int orientation, boolean reverseLayout) {
|
||||
super(context, orientation, reverseLayout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requestChildRectangleOnScreen(@NonNull RecyclerView parent, @NonNull View child, @NonNull Rect rect,
|
||||
boolean immediate, boolean focusedChildVisible) {
|
||||
if (parent instanceof HorizontalRecyclerViewTv) {
|
||||
parent.requestChildRectangleOnScreen(child, rect, immediate);
|
||||
}
|
||||
return super.requestChildRectangleOnScreen(parent, child, rect, immediate, focusedChildVisible);
|
||||
}
|
||||
|
||||
}
|
||||
662
app/src/main/java/com/pukka/jiecheng/history/HistoryActivity.java
Executable file
662
app/src/main/java/com/pukka/jiecheng/history/HistoryActivity.java
Executable file
@@ -0,0 +1,662 @@
|
||||
package com.pukka.jiecheng.history;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewTreeObserver;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.leanback.widget.ArrayObjectAdapter;
|
||||
import androidx.leanback.widget.ItemBridgeAdapter;
|
||||
import androidx.leanback.widget.OnChildViewHolderSelectedListener;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.gson.Gson;
|
||||
import com.migu.amber.AmberUtil;
|
||||
import com.migu.bean.CollectBean;
|
||||
import com.migu.bean.GetCollectBean;
|
||||
import com.migu.bean.GetcontentlistBean;
|
||||
import com.migu.bean.PlayHistoryBean;
|
||||
import com.migu.callback.AijiaCallback;
|
||||
import com.migu.httputils.ContentHttpUtils;
|
||||
import com.migu.httputils.HomeHttpUtils;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.base.BaseActivity;
|
||||
import com.pukka.jiecheng.list.ListAmberManager;
|
||||
import com.pukka.jiecheng.login.LoginActivity;
|
||||
import com.pukka.jiecheng.utils.ResUtil;
|
||||
import com.pukka.jiecheng.video.VideoDetailActivity;
|
||||
import com.pukka.jiecheng.video.other.SpacesItemDecoration;
|
||||
import com.pukka.jiecheng.widget.HorizontalGridViewPk;
|
||||
import com.pukka.libcore.boxShared.BoxSharedParameters;
|
||||
import com.pukka.libcore.boxShared.BoxSharedParamsUtils;
|
||||
import com.pukka.libcore.threading.DispatchQueue;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
import com.pukka.libcore.utils.StringUtils;
|
||||
import com.pukka.libcore.widget.HorizontalRecyclerViewTv;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class HistoryActivity extends BaseActivity {
|
||||
List<PlayHistoryBean.DataDTO> historyList = new ArrayList<>();
|
||||
List<GetCollectBean.ResultDTO> collectList = new ArrayList<>();
|
||||
Context context;
|
||||
private PlayHistoryBean playHistoryBean;
|
||||
private GetCollectBean getCollectBean;
|
||||
private int delStatus = 0;
|
||||
//0 播放,1收藏
|
||||
private int curShowStatus = 0;
|
||||
private HistoryItemAdapter historyItemAdapter;
|
||||
private HistoryItemAdapter likeItemAdapter;
|
||||
private HistoryTextPresenter textPresenter;
|
||||
private ArrayObjectAdapter navAdapter;
|
||||
private ArrayObjectAdapter hisAdapter;
|
||||
private List<HistoryTextBean> textBeanList = new ArrayList<>();
|
||||
private List<GetcontentlistBean.ResultEntity> likeList;
|
||||
private TextView tvKeyCode;
|
||||
private HorizontalRecyclerViewTv historyRecycle;
|
||||
private HorizontalRecyclerViewTv likeRecycle;
|
||||
private HorizontalGridViewPk textGrid;
|
||||
private ConstraintLayout noDataLayout;
|
||||
private TextView tvlike;
|
||||
|
||||
private int delPos = -1;
|
||||
private int textGridSelectedPosition = 0;
|
||||
|
||||
public static void start(Context context) {
|
||||
start(context,0);
|
||||
}
|
||||
public static void start(Context context,int selectedPosition) {
|
||||
// if (!BoxSharedParameters.getInstance().isLogin()){
|
||||
// LoginActivity.start(context);
|
||||
// return;
|
||||
// }
|
||||
Intent starter = new Intent(context, HistoryActivity.class);
|
||||
starter.putExtra("selectedPosition",selectedPosition);
|
||||
context.startActivity(starter);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_history);
|
||||
initView();
|
||||
getIntentParam();
|
||||
loadTopTextData();
|
||||
setFocusChangeLis();
|
||||
initListener();
|
||||
setLikeListener();
|
||||
}
|
||||
private void getIntentParam(){
|
||||
Intent intent = getIntent();
|
||||
if (intent != null) {
|
||||
textGridSelectedPosition = intent.getIntExtra("selectedPosition",0);
|
||||
LogUtils.d("textGridSelectedPosition="+textGridSelectedPosition);
|
||||
}
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
context = this;
|
||||
// tvHistory = findViewById(R.id.tv_history);
|
||||
// tvBook = findViewById(R.id.tv_book);
|
||||
tvlike = findViewById(R.id.tv_like);
|
||||
tvKeyCode = findViewById(R.id.tv_delete);
|
||||
historyRecycle = findViewById(R.id.history_recycle);
|
||||
likeRecycle = findViewById(R.id.like_recycle);
|
||||
textGrid = findViewById(R.id.id_text_nav);
|
||||
historyItemAdapter = new HistoryItemAdapter();
|
||||
noDataLayout = findViewById(R.id.nodata);
|
||||
int itemSpacesH = (int) context.getResources().getDimension(R.dimen.qb_px_36);
|
||||
SpacesItemDecoration spacesItemDecoration = new SpacesItemDecoration(0, 0, itemSpacesH, 0);
|
||||
historyRecycle.addItemDecoration(spacesItemDecoration);
|
||||
historyRecycle.setRightIntercept();
|
||||
historyRecycle.setLeftIntercept();
|
||||
historyRecycle.setHorizontalCenter();
|
||||
initGamePad();
|
||||
enableBackButton();
|
||||
|
||||
String right = ResUtil.getString(R.string.history_menu_key);
|
||||
tvKeyCode.setText(Html.fromHtml(right));
|
||||
pageEnter();
|
||||
}
|
||||
|
||||
|
||||
private void initListener() {
|
||||
historyItemAdapter.setOnItemClickListener(new HistoryItemAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void OnItemClick(Object obj, int state, int pos) {
|
||||
String id = "";
|
||||
delPos = pos;
|
||||
if (obj instanceof PlayHistoryBean.DataDTO) {
|
||||
id = ((PlayHistoryBean.DataDTO) obj).getContentcode();
|
||||
if (!StringUtils.isEmpty(id)) {
|
||||
if (state == 0) {
|
||||
//跳转到详细页
|
||||
id = ((PlayHistoryBean.DataDTO) obj).getParentcode();
|
||||
String type = ((PlayHistoryBean.DataDTO) obj).getContenttype().toString();
|
||||
String name = ((PlayHistoryBean.DataDTO) obj).getContentname();
|
||||
gotoVodDetail(id, type, VideoDetailActivity.ModuleSourceType.HISTORY_PAGE);
|
||||
contentClick("1", name, id);
|
||||
} else if (state == 1) {
|
||||
//删除
|
||||
delHistoryData(((PlayHistoryBean.DataDTO) obj).getParentcode());
|
||||
}
|
||||
}
|
||||
} else if (obj instanceof GetCollectBean.ResultDTO) {
|
||||
id = ((GetCollectBean.ResultDTO) obj).getContentcode();
|
||||
if (!StringUtils.isEmpty(id)) {
|
||||
if (state == 0) {
|
||||
//跳转到详细页
|
||||
try {
|
||||
String type = ((GetCollectBean.ResultDTO) obj).getContenttype().toString();
|
||||
String name = ((GetCollectBean.ResultDTO) obj).getContentname();
|
||||
gotoVodDetail(id, type, VideoDetailActivity.ModuleSourceType.COLL_PAGE);
|
||||
contentClick("3", name, id);
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
} else if (state == 1) {
|
||||
//删除
|
||||
delCollectData(((GetCollectBean.ResultDTO) obj).getContentcode());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到详情页
|
||||
*
|
||||
* @param countId
|
||||
* @param contentType
|
||||
*/
|
||||
private void gotoVodDetail(String countId, String contentType, VideoDetailActivity.ModuleSourceType moduleSourceType) {
|
||||
VideoDetailActivity.start(mContext, countId, contentType, moduleSourceType);
|
||||
}
|
||||
|
||||
private void loadTopTextData() {
|
||||
textBeanList.clear();
|
||||
textBeanList.add(new HistoryTextBean("播放记录", ""));
|
||||
if (!BoxSharedParamsUtils.isJcHotel()) {
|
||||
textBeanList.add(new HistoryTextBean("收藏记录", ""));
|
||||
}
|
||||
textPresenter = new HistoryTextPresenter();
|
||||
navAdapter = new ArrayObjectAdapter(textPresenter);
|
||||
//textGrid.setHorizontalSpacing((int) getResources().getDimension(R.dimen.qb_px_4));
|
||||
int itemSpacesH = context.getResources().getDimensionPixelSize(R.dimen.qb_px_10);
|
||||
SpacesItemDecoration spacesItemDecoration = new SpacesItemDecoration(0, 0, itemSpacesH, 0);
|
||||
textGrid.addItemDecoration(spacesItemDecoration);
|
||||
textGrid.setOnChildViewHolderSelectedListener(new OnChildViewHolderSelectedListener() {
|
||||
@Override
|
||||
public void onChildViewHolderSelected(RecyclerView parent, RecyclerView.ViewHolder child, int position, int subposition) {
|
||||
super.onChildViewHolderSelected(parent, child, position, subposition);
|
||||
String name = textBeanList.get(position).getName();
|
||||
LogUtils.e("loadTopTextData -- :" + name);
|
||||
textPresenter.setSelect(name);
|
||||
if (name.equals("播放记录")) {
|
||||
curShowStatus = 0;
|
||||
getLikeData();
|
||||
getHistoryData(false);
|
||||
} else if (name.equals("收藏记录")) {
|
||||
curShowStatus = 1;
|
||||
getLikeData();
|
||||
getCollectData(false);
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
navAdapter.clear();
|
||||
navAdapter.addAll(0, textBeanList);
|
||||
textGrid.setAdapter(new ItemBridgeAdapter(navAdapter));
|
||||
textGrid.setSelectedPosition(textGridSelectedPosition);
|
||||
textPresenter.setmOnHideLineCallBack(new HistoryTextPresenter.OnHideLineCallBack() {
|
||||
@Override
|
||||
public void hideLine() {
|
||||
if (tvKeyCode.getVisibility() == View.VISIBLE) {
|
||||
historyItemAdapter.setStatus(1);
|
||||
delStatus = 1;
|
||||
showKeyCodeData();
|
||||
String right = ResUtil.getString(R.string.history_back_key);
|
||||
tvKeyCode.setText(Html.fromHtml(right));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取播放历史记录
|
||||
*/
|
||||
private void getHistoryData(boolean isDelete) {
|
||||
ContentHttpUtils.getPlayHistory("1", "20", new AijiaCallback.StringResponseCallBack() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
if (!StringUtils.isEmpty(response)) {
|
||||
playHistoryBean = new Gson().fromJson(response, PlayHistoryBean.class);
|
||||
loadHistoryData(playHistoryBean, isDelete);
|
||||
} else {
|
||||
noDataLayout.setVisibility(View.VISIBLE);
|
||||
}
|
||||
if (noDataLayout.getVisibility() == View.VISIBLE) {
|
||||
tvKeyCode.setVisibility(View.GONE);
|
||||
} else {
|
||||
tvKeyCode.setVisibility(View.VISIBLE);
|
||||
}
|
||||
LogUtils.d("onResponse:" + response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取收藏记录
|
||||
*/
|
||||
private void getCollectData(boolean isDelete) {
|
||||
ContentHttpUtils.getCollect("1", "10", new AijiaCallback.StringResponseCallBack() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
if (!StringUtils.isEmpty(response)) {
|
||||
getCollectBean = new Gson().fromJson(response, GetCollectBean.class);
|
||||
loadCollectData(getCollectBean,isDelete);
|
||||
}
|
||||
LogUtils.d("onResponse:" + response);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取猜你喜欢数据
|
||||
*/
|
||||
private void getLikeData() {
|
||||
String id = "483";
|
||||
if (curShowStatus == 0) {
|
||||
//播放
|
||||
id = "482";
|
||||
} else {
|
||||
id = "483";
|
||||
}
|
||||
//推荐数据
|
||||
HomeHttpUtils.getcontentlist("12", id, new AijiaCallback.GetcontentlistCallback() {
|
||||
@Override
|
||||
public void onResponse(GetcontentlistBean response) {
|
||||
loadLikeData(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail(String value) {
|
||||
loadLikeData(null);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 删除播放记录
|
||||
*/
|
||||
private void delHistoryData(String code) {
|
||||
ContentHttpUtils.delPlayHistory(code, new AijiaCallback.StringResponseCallBack() {
|
||||
@Override
|
||||
public void onResponse(String response) {
|
||||
LogUtils.d("onResponse:" + response);
|
||||
if (!StringUtils.isEmpty(response)) {
|
||||
String code = JSON.parseObject(response).getString("result");
|
||||
if (code.equals("1")) {
|
||||
getHistoryData(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除收藏记录
|
||||
*/
|
||||
private void delCollectData(String code) {
|
||||
ContentHttpUtils.delCollect(code, new AijiaCallback.CollectResponseCallBack() {
|
||||
@Override
|
||||
public void onResponse(CollectBean response) {
|
||||
if (response != null && StringUtils.equals("1", response.getResultcode())) {
|
||||
getCollectData(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private void loadHistoryData(PlayHistoryBean bean, boolean isDelete) {
|
||||
historyRecycle.removeAllViews();
|
||||
historyList.clear();
|
||||
if (bean != null && bean.getData() != null && !bean.getData().isEmpty()) {
|
||||
noDataLayout.setVisibility(View.GONE);
|
||||
historyList.addAll(bean.getData());
|
||||
if (delStatus == 1 && !bean.getData().isEmpty()) {
|
||||
PlayHistoryBean.DataDTO dataDTO = new PlayHistoryBean.DataDTO();
|
||||
dataDTO.setContentname("全部清空");
|
||||
dataDTO.setContentcode("$$remove_all$$");
|
||||
historyList.add(0, dataDTO);
|
||||
}
|
||||
historyItemAdapter.setList(historyList);
|
||||
CenterLinearLayoutManager linearLayoutManager =
|
||||
new CenterLinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false);
|
||||
linearLayoutManager.setItemPrefetchEnabled(true);
|
||||
historyRecycle.setLayoutManager(linearLayoutManager);
|
||||
historyRecycle.setAdapter(historyItemAdapter);
|
||||
setDelOneFocus();
|
||||
} else {
|
||||
delPos = -1;
|
||||
noDataLayout.setVisibility(View.VISIBLE);
|
||||
historyItemAdapter.clear();
|
||||
setLikeFocus(isDelete && historyList.size() == 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private void loadCollectData(GetCollectBean bean, boolean isDelete) {
|
||||
historyRecycle.removeAllViews();
|
||||
collectList.clear();
|
||||
if (bean != null && bean.getResult() != null && !bean.getResult().isEmpty()) {
|
||||
noDataLayout.setVisibility(View.GONE);
|
||||
collectList.addAll(0, bean.getResult());
|
||||
if (delStatus == 1 && !bean.getResult().isEmpty()) {
|
||||
GetCollectBean.ResultDTO dataDTO = new GetCollectBean.ResultDTO();
|
||||
dataDTO.setContentname("全部清空");
|
||||
dataDTO.setMidimg("");
|
||||
dataDTO.setContentcode("$$remove_all$$");
|
||||
collectList.add(0, dataDTO);
|
||||
}
|
||||
historyItemAdapter.setList(collectList);
|
||||
CenterLinearLayoutManager linearLayoutManager =
|
||||
new CenterLinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false);
|
||||
linearLayoutManager.setItemPrefetchEnabled(true);
|
||||
historyRecycle.setLayoutManager(linearLayoutManager);
|
||||
historyRecycle.setAdapter(historyItemAdapter);
|
||||
setDelOneFocus();
|
||||
} else {
|
||||
delPos = -1;
|
||||
noDataLayout.setVisibility(View.VISIBLE);
|
||||
historyItemAdapter.clear();
|
||||
setLikeFocus(isDelete && collectList.size() == 0);
|
||||
}
|
||||
if (noDataLayout.getVisibility() == View.VISIBLE) {
|
||||
tvKeyCode.setVisibility(View.GONE);
|
||||
} else {
|
||||
tvKeyCode.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 记录无数据的时候,落焦到猜你喜欢上
|
||||
*/
|
||||
private void setLikeFocus(boolean isDelete) {
|
||||
LogUtils.d("setLikeFocus");
|
||||
if (isDelete) {
|
||||
likeRecycle.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (likeRecycle.getLayoutManager() != null) {
|
||||
int count = likeRecycle.getLayoutManager().getItemCount();
|
||||
if (count > 0) {
|
||||
View view = likeRecycle.getLayoutManager().findViewByPosition(0);
|
||||
if (view != null) {
|
||||
view.requestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
delPos = -1;
|
||||
}
|
||||
}, 100);
|
||||
} else {
|
||||
if (delPos != -1) {
|
||||
likeRecycle.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (likeRecycle.getLayoutManager() != null) {
|
||||
int count = likeRecycle.getLayoutManager().getItemCount();
|
||||
if (count > 0) {
|
||||
View view = likeRecycle.getLayoutManager().findViewByPosition(0);
|
||||
if (view != null) {
|
||||
view.requestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
delPos = -1;
|
||||
}
|
||||
}, 100);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setLikeFocus() {
|
||||
setLikeFocus(false);
|
||||
}
|
||||
|
||||
private void setDelOneFocus() {
|
||||
if (delPos != -1) {
|
||||
historyRecycle.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (historyRecycle.getLayoutManager() != null) {
|
||||
int count = historyRecycle.getLayoutManager().getItemCount();
|
||||
LogUtils.d("getItemCount:" + count + " -- pos:" + delPos);
|
||||
|
||||
if (delPos > count - 1) {
|
||||
delPos = count - 1;
|
||||
}
|
||||
if (delPos >= 3) {
|
||||
historyRecycle.scrollToPosition(delPos);
|
||||
}
|
||||
toSetFocus();
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void toSetFocus() {
|
||||
DispatchQueue.main.after(100, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (historyRecycle.getLayoutManager() != null) {
|
||||
View view = historyRecycle.getLayoutManager().findViewByPosition(delPos);
|
||||
if (view == null) {
|
||||
view = historyRecycle.getLayoutManager().findViewByPosition(delPos - 1);
|
||||
}
|
||||
if (view != null) {
|
||||
view.requestFocus();
|
||||
}
|
||||
}
|
||||
delPos = -1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setLikeListener() {
|
||||
likeList = new ArrayList<>();
|
||||
int itemSpacesH = context.getResources().getDimensionPixelSize(R.dimen.qb_px_36);
|
||||
SpacesItemDecoration spacesItemDecoration = new SpacesItemDecoration(0, 0, itemSpacesH, 0);
|
||||
likeRecycle.addItemDecoration(spacesItemDecoration);
|
||||
likeRecycle.setRightIntercept();
|
||||
likeRecycle.setLeftIntercept();
|
||||
likeItemAdapter = new HistoryItemAdapter();
|
||||
likeItemAdapter.setOnItemClickListener(new HistoryItemAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void OnItemClick(Object obj, int state, int pos) {
|
||||
if (obj instanceof GetcontentlistBean.ResultEntity) {
|
||||
String id = ((GetcontentlistBean.ResultEntity) obj).getCode();
|
||||
//跳转到详细页
|
||||
int type = ((GetcontentlistBean.ResultEntity) obj).getContenttype();
|
||||
gotoVodDetail(id, String.valueOf(type), VideoDetailActivity.ModuleSourceType.HISTORY_PAGE);
|
||||
String name = ((GetcontentlistBean.ResultEntity) obj).getName();
|
||||
if (curShowStatus == 0) {
|
||||
contentClick("2", name, id);
|
||||
} else {
|
||||
contentClick("4", name, id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载猜你喜欢的数据
|
||||
*/
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
private void loadLikeData(GetcontentlistBean data) {
|
||||
likeRecycle.removeAllViews();
|
||||
likeList.clear();
|
||||
if (data != null && data.getResult() != null && !data.getResult().isEmpty()) {
|
||||
for (int i = 0; i < data.getResult().size(); i++) {
|
||||
if (likeList.size() < 6) {
|
||||
likeList.add(data.getResult().get(i));
|
||||
}
|
||||
}
|
||||
tvlike.setVisibility(View.VISIBLE);
|
||||
|
||||
likeItemAdapter.setList(likeList);
|
||||
LinearLayoutManager linearLayoutManager =
|
||||
new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false);
|
||||
likeRecycle.setLayoutManager(linearLayoutManager);
|
||||
likeRecycle.setAdapter(likeItemAdapter);
|
||||
} else {
|
||||
tvlike.setVisibility(View.GONE);
|
||||
likeItemAdapter.clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void setFocusChangeLis() {
|
||||
View rootView = getWindow().getDecorView().getRootView();
|
||||
ViewTreeObserver viewTreeObserver = rootView.getViewTreeObserver();
|
||||
viewTreeObserver.addOnGlobalFocusChangeListener(new ViewTreeObserver.OnGlobalFocusChangeListener() {
|
||||
@Override
|
||||
public void onGlobalFocusChanged(View oldFocus, View newFocus) {
|
||||
// 处理焦点变化事件
|
||||
if (newFocus != null) {
|
||||
LogUtils.d("FocusChange", "New focused view: " + newFocus);
|
||||
}
|
||||
if (oldFocus != null) {
|
||||
LogUtils.d("FocusChange", "Old focused view: " + oldFocus);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
@Override
|
||||
public boolean dispatchKeyEvent(KeyEvent event) {
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||
if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
|
||||
if (tvKeyCode.getText().toString().contains("返回键") && tvKeyCode.getVisibility() == View.VISIBLE) {
|
||||
String right = ResUtil.getString(R.string.history_menu_key);
|
||||
tvKeyCode.setText(Html.fromHtml(right));
|
||||
historyItemAdapter.setStatus(0);
|
||||
delStatus = 0;
|
||||
showKeyCodeData();
|
||||
setFocusModel();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.dispatchKeyEvent(event);
|
||||
}
|
||||
|
||||
private void showKeyCodeData() {
|
||||
if (curShowStatus == 0) {
|
||||
loadHistoryData(playHistoryBean,false);
|
||||
} else if (curShowStatus == 1) {
|
||||
loadCollectData(getCollectBean,false);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestart() {
|
||||
delStatus = 0;
|
||||
historyItemAdapter.setStatus(0);
|
||||
String right = ResUtil.getString(R.string.history_menu_key);
|
||||
tvKeyCode.setText(Html.fromHtml(right));
|
||||
if (curShowStatus == 0) {
|
||||
getHistoryData(false);
|
||||
} else if (curShowStatus == 1) {
|
||||
getCollectData(false);
|
||||
}
|
||||
super.onRestart();
|
||||
}
|
||||
|
||||
/**
|
||||
* 落焦点规则
|
||||
*/
|
||||
private void setFocusModel() {
|
||||
if (historyRecycle.getLayoutManager() != null) {
|
||||
historyRecycle.postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
int count = historyRecycle.getLayoutManager().getItemCount();
|
||||
if (count > 0) {
|
||||
historyRecycle.scrollToPosition(0);
|
||||
historyRecycle.requestFocus();
|
||||
} else {
|
||||
if (!likeList.isEmpty()) {
|
||||
likeRecycle.requestFocus();
|
||||
}
|
||||
}
|
||||
LogUtils.d("setFocusModel count: " + count);
|
||||
}
|
||||
}, 200);
|
||||
} else {
|
||||
if (!likeList.isEmpty()) {
|
||||
likeRecycle.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 进入页面
|
||||
*/
|
||||
private void pageEnter() {
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("module_source", "顶部按钮");
|
||||
AmberUtil.send("history_enter", map);
|
||||
}
|
||||
|
||||
private void contentClick(String type, String name, String id) {
|
||||
|
||||
String eventType = "";
|
||||
if ("1".equals(type)) {
|
||||
eventType = "history_page_click";
|
||||
} else if ("2".equals(type)) {
|
||||
eventType = "history_page_preference";
|
||||
} else if ("3".equals(type)) {
|
||||
eventType = "favorite_page_click";
|
||||
} else if ("4".equals(type)) {
|
||||
eventType = "favorite_page_preference";
|
||||
}
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("content_name", name);
|
||||
map.put("content_id", id);
|
||||
AmberUtil.send(eventType, map);
|
||||
}
|
||||
}
|
||||
235
app/src/main/java/com/pukka/jiecheng/history/HistoryItemAdapter.java
Executable file
235
app/src/main/java/com/pukka/jiecheng/history/HistoryItemAdapter.java
Executable file
@@ -0,0 +1,235 @@
|
||||
package com.pukka.jiecheng.history;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Color;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.migu.bean.GetCollectBean;
|
||||
import com.migu.bean.GetcontentlistBean;
|
||||
import com.migu.bean.PlayHistoryBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.utils.TopStyleUtils;
|
||||
import com.pukka.jiecheng.utils.UiUtils;
|
||||
import com.pukka.libcore.boxShared.BoxSharedParamsUtils;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
import com.pukka.libcore.utils.DateUtils;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 足球阵容item
|
||||
*/
|
||||
|
||||
public class HistoryItemAdapter extends RecyclerView.Adapter<HistoryItemAdapter.HistroyViewHolder> {
|
||||
private List<?> list = new ArrayList<>();
|
||||
|
||||
private OnItemClickListener onItemClickListener;
|
||||
private OnFocusChangeListener onFocusChangeListener;
|
||||
private LinearLayoutManager linearLayoutManager;
|
||||
//赛事状态
|
||||
private int status = 0;
|
||||
|
||||
public HistoryItemAdapter() {
|
||||
|
||||
}
|
||||
|
||||
public void setStatus(int status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void setList(List<?> list) {
|
||||
this.list = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void clear() {
|
||||
this.list.clear();
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public List<?> getList() {
|
||||
return list;
|
||||
}
|
||||
|
||||
public void setOnFocusChangeListener(OnFocusChangeListener onFocusChangeListener) {
|
||||
this.onFocusChangeListener = onFocusChangeListener;
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public HistroyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_player_history, parent, false);
|
||||
return new HistroyViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull HistroyViewHolder holder, @SuppressLint("RecyclerView") int position) {
|
||||
try {
|
||||
if (list.get(position) instanceof PlayHistoryBean.DataDTO) {
|
||||
String name = ((PlayHistoryBean.DataDTO) list.get(position)).getContentname();
|
||||
if ("全部清空".equals(name)) {
|
||||
holder.mTvInfo.setText(name);
|
||||
holder.mIvImage.setImageURI("");
|
||||
holder.mTvName.setText("");
|
||||
} else {
|
||||
holder.mTvInfo.setText("");
|
||||
holder.mIvImage.setImageURI(((PlayHistoryBean.DataDTO) list.get(position)).getMidimg());
|
||||
holder.mTvName.setText(((PlayHistoryBean.DataDTO) list.get(position)).getContentname());
|
||||
|
||||
//episodeindex
|
||||
int contentType = ((PlayHistoryBean.DataDTO) list.get(position)).getContenttype();
|
||||
//内容类型1:单集.2:剧集(子集)(EpisodeProgram)(可能包含综艺多少期那样的节目)type:3连续剧4:直播频道5:专题6:片花
|
||||
if (contentType == 2||contentType == 3) {
|
||||
int inx = ((PlayHistoryBean.DataDTO) list.get(position)).getEpisodeindex();
|
||||
holder.mTvPlayTime.setText("播放至第" + inx + (((PlayHistoryBean.DataDTO) list.get(position)).getCategoryname().equals("综艺") ? " 期" : " 集"));
|
||||
} else {
|
||||
int time = ((PlayHistoryBean.DataDTO) list.get(position)).getPlaylong();
|
||||
String tip = "观看至" + DateUtils.secToTime(time / 1000);
|
||||
if (time == 0) {
|
||||
tip = "已观看完毕";
|
||||
}
|
||||
holder.mTvPlayTime.setText(tip);
|
||||
}
|
||||
if (BoxSharedParamsUtils.isJcHotel()){
|
||||
holder.mTvPlayTime.setText("");
|
||||
}
|
||||
}
|
||||
|
||||
if (status == 1) {
|
||||
holder.ivDelete.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.ivDelete.setVisibility(View.GONE);
|
||||
}
|
||||
} else if (list.get(position) instanceof GetCollectBean.ResultDTO) {
|
||||
String name = ((GetCollectBean.ResultDTO) list.get(position)).getContentname();
|
||||
|
||||
if ("全部清空".equals(name)) {
|
||||
holder.mTvInfo.setText(name);
|
||||
holder.mIvImage.setImageURI("");
|
||||
holder.mTvName.setText("");
|
||||
} else {
|
||||
holder.mTvInfo.setText("");
|
||||
holder.mIvImage.setImageURI(((GetCollectBean.ResultDTO) list.get(position)).getMidimg());
|
||||
holder.mTvName.setText(((GetCollectBean.ResultDTO) list.get(position)).getContentname());
|
||||
}
|
||||
if (status == 1) {
|
||||
holder.ivDelete.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
holder.ivDelete.setVisibility(View.GONE);
|
||||
}
|
||||
} else if (list.get(position) instanceof GetcontentlistBean.ResultEntity) {
|
||||
holder.mIvImage.setImageURI(((GetcontentlistBean.ResultEntity) list.get(position)).getPosterimg());
|
||||
holder.mTvName.setText(((GetcontentlistBean.ResultEntity) list.get(position)).getName());
|
||||
}
|
||||
|
||||
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (onItemClickListener != null) {
|
||||
onItemClickListener.OnItemClick(list.get(position), status, position);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
holder.itemView.setOnFocusChangeListener((view, focus) -> {
|
||||
if (focus) {
|
||||
if (status == 1) {
|
||||
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) holder.ivDelete.getLayoutParams();
|
||||
params.height = (int) holder.itemView.getContext().getResources().getDimension(R.dimen.qb_px_255);
|
||||
|
||||
holder.ivDelete.setLayoutParams(params);
|
||||
holder.ivDelete.setBackground(AppCompatResources.getDrawable(holder.itemView.getContext(), R.drawable.history_del_focus));
|
||||
}
|
||||
holder.mTvName.setTextColor(ContextCompat.getColor(view.getContext(), R.color.black));
|
||||
holder.mTvName.setSelected(true);
|
||||
holder.mTvName.setEllipsize(TextUtils.TruncateAt.MARQUEE);
|
||||
} else {
|
||||
if (status == 1) {
|
||||
ConstraintLayout.LayoutParams params = (ConstraintLayout.LayoutParams) holder.ivDelete.getLayoutParams();
|
||||
params.height = (int) holder.itemView.getContext().getResources().getDimension(R.dimen.qb_px_220);
|
||||
|
||||
holder.ivDelete.setLayoutParams(params);
|
||||
holder.ivDelete.setBackground(AppCompatResources.getDrawable(holder.itemView.getContext(), R.drawable.history_delete));
|
||||
}
|
||||
holder.mTvName.setTextColor(ContextCompat.getColor(view.getContext(), R.color.white7));
|
||||
holder.mTvName.setSelected(false);
|
||||
holder.mTvName.setEllipsize(TextUtils.TruncateAt.END);
|
||||
}
|
||||
TopStyleUtils.topImageChange(view, focus);
|
||||
});
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
LogUtils.d(e.getMessage());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return list != null ? list.size() : 0;
|
||||
}
|
||||
|
||||
|
||||
public interface OnItemClickListener {
|
||||
/**
|
||||
* 点击事件
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
void OnItemClick(Object obj, int state, int pos);
|
||||
}
|
||||
|
||||
|
||||
public interface OnFocusChangeListener {
|
||||
/**
|
||||
* 点击事件
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
void OnFocusChange(boolean b);
|
||||
}
|
||||
|
||||
|
||||
public static class HistroyViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView mTvName;
|
||||
TextView mTvInfo;
|
||||
TextView mTvPlayTime;
|
||||
PkSimpleDraweeView mIvImage;
|
||||
PkSimpleDraweeView ivDelete;
|
||||
|
||||
public HistroyViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
mTvName = itemView.findViewById(R.id.id_tv_name);
|
||||
mIvImage = itemView.findViewById(R.id.id_msd_image);
|
||||
ivDelete = itemView.findViewById(R.id.ivDelete);
|
||||
mTvInfo = itemView.findViewById(R.id.id_tv_info);
|
||||
mTvPlayTime = itemView.findViewById(R.id.id_tv_playtime);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
39
app/src/main/java/com/pukka/jiecheng/history/HistoryTextBean.java
Executable file
39
app/src/main/java/com/pukka/jiecheng/history/HistoryTextBean.java
Executable file
@@ -0,0 +1,39 @@
|
||||
package com.pukka.jiecheng.history;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @Auther: sunmm
|
||||
* @datetime: 2025/6/3 10:31
|
||||
* @desc:
|
||||
*/
|
||||
public class HistoryTextBean implements Serializable {
|
||||
|
||||
@SerializedName("name")
|
||||
private String name;
|
||||
@SerializedName("seleact")
|
||||
private String seleact;
|
||||
|
||||
public HistoryTextBean(String name,String sele){
|
||||
this.name = name;
|
||||
this.seleact = sele;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getSeleact() {
|
||||
return seleact;
|
||||
}
|
||||
|
||||
public void setSeleact(String seleact) {
|
||||
this.seleact = seleact;
|
||||
}
|
||||
}
|
||||
113
app/src/main/java/com/pukka/jiecheng/history/HistoryTextPresenter.java
Executable file
113
app/src/main/java/com/pukka/jiecheng/history/HistoryTextPresenter.java
Executable file
@@ -0,0 +1,113 @@
|
||||
package com.pukka.jiecheng.history;
|
||||
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.core.content.ContextCompat;
|
||||
|
||||
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.base.BasePresenter;
|
||||
import com.pukka.jiecheng.base.BasePresenterViewHolder;
|
||||
import com.pukka.libcore.utils.StringUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 历史记录头部导航
|
||||
*
|
||||
*/
|
||||
public class HistoryTextPresenter extends BasePresenter<HistoryTextPresenter.ItemViewHolder, HistoryTextBean> {
|
||||
|
||||
private OnHideLineCallBack mOnHideLineCallBack;
|
||||
private String curSelect;
|
||||
|
||||
public void setmOnHideLineCallBack(OnHideLineCallBack callBack){
|
||||
this.mOnHideLineCallBack = callBack;
|
||||
}
|
||||
public void setSelect(String select){
|
||||
curSelect = select;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getLayoutResId() {
|
||||
return R.layout.item_history_text_nav;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ItemViewHolder createViewHolder(View view) {
|
||||
return new ItemViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getLogTag() {
|
||||
return HistoryTextPresenter.class.getSimpleName();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public class ItemViewHolder extends BasePresenterViewHolder<HistoryTextBean> {
|
||||
LinearLayout llNavAll;
|
||||
TextView tvNavName;
|
||||
View line;
|
||||
|
||||
public ItemViewHolder(View view) {
|
||||
super(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void initView(View itemView) {
|
||||
tvNavName = itemView.findViewById(R.id.tv_history);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBindDataPayloads(HistoryTextBean contentEntity, List<Object> payloads) {
|
||||
if (contentEntity == null) {
|
||||
return;
|
||||
}
|
||||
tvNavName.setText(StringUtils.getStringValue(contentEntity.getName()));
|
||||
tvNavName.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
if (hasFocus){
|
||||
tvNavName.setTextColor(ContextCompat.getColor(tvNavName.getContext(), R.color.white));
|
||||
tvNavName.setBackground(AppCompatResources.getDrawable(tvNavName.getContext(), R.drawable.login_codebtn_bg_selector));
|
||||
}else {
|
||||
if (contentEntity.getName().equals(curSelect)){
|
||||
tvNavName.setTextColor(ContextCompat.getColor(tvNavName.getContext(), R.color.btn_selector_textColor));
|
||||
}else {
|
||||
tvNavName.setTextColor(ContextCompat.getColor(tvNavName.getContext(), R.color.white6));
|
||||
}
|
||||
tvNavName.setBackground(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
tvNavName.setOnKeyListener(new View.OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN){
|
||||
if (keyCode == KeyEvent.KEYCODE_DPAD_UP){
|
||||
if (mOnHideLineCallBack != null) {
|
||||
mOnHideLineCallBack.hideLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onUnbindData() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public interface OnHideLineCallBack {
|
||||
void hideLine();
|
||||
}
|
||||
}
|
||||
36
app/src/main/java/com/pukka/jiecheng/index/HotelMyActivity.java
Executable file
36
app/src/main/java/com/pukka/jiecheng/index/HotelMyActivity.java
Executable file
@@ -0,0 +1,36 @@
|
||||
package com.pukka.jiecheng.index;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.base.BaseActivity;
|
||||
import com.pukka.jiecheng.index.fragment.HotelMyFragment;
|
||||
|
||||
/**
|
||||
* Author: wxf
|
||||
* Date: 2025/12/31
|
||||
* Description:爱视酒店我的页面
|
||||
*/
|
||||
public class HotelMyActivity extends BaseActivity {
|
||||
|
||||
private HotelMyFragment mHotelMyFragment;
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_hotel_my);
|
||||
initView();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
FragmentManager fm = this.getSupportFragmentManager();
|
||||
FragmentTransaction ft = fm.beginTransaction();
|
||||
mHotelMyFragment = HotelMyFragment.newInstance();
|
||||
ft.replace(R.id.contentFragment, mHotelMyFragment);
|
||||
ft.commit();
|
||||
}
|
||||
|
||||
}
|
||||
1402
app/src/main/java/com/pukka/jiecheng/index/IndexActivity.java
Executable file
1402
app/src/main/java/com/pukka/jiecheng/index/IndexActivity.java
Executable file
File diff suppressed because it is too large
Load Diff
118
app/src/main/java/com/pukka/jiecheng/index/IndexAmberManager.java
Executable file
118
app/src/main/java/com/pukka/jiecheng/index/IndexAmberManager.java
Executable file
@@ -0,0 +1,118 @@
|
||||
package com.pukka.jiecheng.index;
|
||||
|
||||
import com.migu.amber.AmberUtil;
|
||||
import com.migu.bean.GetLayoutBean;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
import com.pukka.libcore.utils.StringUtils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class IndexAmberManager {
|
||||
public static String navName="";
|
||||
public static String recommend_type1 = "图文";
|
||||
public static String recommend_type2 = "视频窗";
|
||||
public static String recommentType = recommend_type1;
|
||||
public static int floorPosition;
|
||||
/**
|
||||
* 首页跳转动作列表
|
||||
*/
|
||||
private static final Map<String, String> ActionPageNameList = initActionPageName();
|
||||
/**
|
||||
* 顶部按钮 top_button_click
|
||||
* */
|
||||
public static void topButtonClick(String page_button){
|
||||
String eventType = "top_button_click";
|
||||
HashMap<String, Object> maps = new HashMap<>();
|
||||
maps.put("page_button", page_button);
|
||||
maps.put("page_name", navName);
|
||||
LogUtils.d(eventType+":" + maps.toString());
|
||||
AmberUtil.send(eventType, maps);
|
||||
}
|
||||
/**
|
||||
* 底部按钮 bottom_button_click
|
||||
* */
|
||||
public static void bottomButtonClick(String page_button,String page_name){
|
||||
String eventType = "bottom_button_click";
|
||||
HashMap<String, Object> maps = new HashMap<>();
|
||||
maps.put("page_button", page_button);
|
||||
maps.put("page_name", navName);
|
||||
LogUtils.d(eventType+":" + maps.toString());
|
||||
AmberUtil.send(eventType, maps);
|
||||
}
|
||||
/**
|
||||
* 首页导航页 bottom_button_click 页面曝光
|
||||
* */
|
||||
public static void pageExposure(String top_tab_name){
|
||||
String eventType = "page_exposure";
|
||||
HashMap<String, Object> maps = new HashMap<>();
|
||||
maps.put("top_tab_name", top_tab_name);
|
||||
LogUtils.d(eventType+":" + maps.toString());
|
||||
AmberUtil.send(eventType, maps);
|
||||
}
|
||||
/**
|
||||
* 首页推荐位 recommend_click 推荐位点击
|
||||
* */
|
||||
public static void recommendClick(String top_tab_name,String recommend_id,String recommend_type,String recommend_location,String contact_type,String content_name,String content_id){
|
||||
String eventType = "recommend_click";
|
||||
HashMap<String, Object> maps = new HashMap<>();
|
||||
maps.put("top_tab_name", top_tab_name);
|
||||
maps.put("recommend_id", recommend_id);
|
||||
maps.put("recommend_type", recommend_type);
|
||||
maps.put("recommend_location", recommend_location);
|
||||
maps.put("contact_type", contact_type);
|
||||
maps.put("content_name", content_name);
|
||||
maps.put("content_id", content_id);
|
||||
LogUtils.d(eventType+":" + maps.toString());
|
||||
AmberUtil.send(eventType, maps);
|
||||
recommentType = recommend_type1;
|
||||
}
|
||||
/**
|
||||
* 回到顶部
|
||||
* */
|
||||
public static void bottomButtonClick(String page_button){
|
||||
String eventType = "bottom_button_click";
|
||||
if(!StringUtils.isEmpty(navName)) {
|
||||
HashMap<String, Object> maps = new HashMap<>();
|
||||
maps.put("page_button", page_button);
|
||||
maps.put("page_name", navName);
|
||||
LogUtils.d(eventType + ":" + maps.toString());
|
||||
AmberUtil.send(eventType, maps);
|
||||
}
|
||||
}
|
||||
|
||||
public static void recommendClick(GetLayoutBean.DataBean.ExtraDataBean mItemData,String floorIndex){
|
||||
if(mItemData != null){
|
||||
String recommend_id = mItemData.getPositionid();
|
||||
String content_id = mItemData.getContentcode();
|
||||
String contact_type = ActionPageNameList.get(mItemData.getType());
|
||||
String content_name = mItemData.getName();
|
||||
String recommend_type =recommentType;
|
||||
String top_tab_name = navName;
|
||||
String recommend_location = "";
|
||||
if(floorPosition>=10){
|
||||
recommend_location="0"+floorPosition;
|
||||
}else if(floorPosition <10){
|
||||
recommend_location="00"+floorPosition;
|
||||
}else {
|
||||
recommend_location=floorPosition+"";
|
||||
}
|
||||
recommend_location=recommend_location+"00"+floorIndex;
|
||||
|
||||
if(!StringUtils.isEmpty(recommend_location)) {
|
||||
recommendClick(top_tab_name, recommend_id, recommend_type, recommend_location, contact_type, content_name, content_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
private static Map<String, String> initActionPageName() {
|
||||
Map<String, String> matchStatus = new HashMap<>(16);
|
||||
matchStatus.put("1", "点播详情页");
|
||||
matchStatus.put("2", "点播播放页");
|
||||
matchStatus.put("3", "栏目");
|
||||
matchStatus.put("4", "搜索页");
|
||||
matchStatus.put("5", "外链");
|
||||
matchStatus.put("6", "跳转apk");
|
||||
matchStatus.put("7", "无动作");
|
||||
return matchStatus;
|
||||
}
|
||||
}
|
||||
367
app/src/main/java/com/pukka/jiecheng/index/IndexConstant.java
Executable file
367
app/src/main/java/com/pukka/jiecheng/index/IndexConstant.java
Executable file
@@ -0,0 +1,367 @@
|
||||
package com.pukka.jiecheng.index;
|
||||
|
||||
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.migu.bean.GetGameSeasonInfoListBean;
|
||||
import com.migu.bean.GetGameSeasonInfoRecommendBean;
|
||||
import com.pukka.jiecheng.index.bean.ItemTypeBean;
|
||||
import com.pukka.libcore.utils.DateUtils;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class IndexConstant {
|
||||
|
||||
public static final int FIRST_FOCUS = 1000;
|
||||
|
||||
public static final int GO_CHOSEN = 2000;
|
||||
|
||||
/**
|
||||
* ContentFragment 延迟加载内容
|
||||
* */
|
||||
public static final int DELAY_CONTENT_LOAD = 3000;
|
||||
public static final int DELAY_SHORTVIDEO_LAOD = 4000;
|
||||
|
||||
public static final String NAVID_PARAM1 = "media_id";
|
||||
|
||||
|
||||
private IndexConstant() {
|
||||
}
|
||||
|
||||
public static String playId;
|
||||
|
||||
/**
|
||||
* 生成楼层接口对照表
|
||||
*/
|
||||
public static final List<ItemTypeBean> floorMapList = getFloorMap();
|
||||
|
||||
|
||||
/**
|
||||
* 比赛状态
|
||||
*/
|
||||
private static final Map<String, String> MATCH_STATUS = initMatchStatus();
|
||||
|
||||
private static List<ItemTypeBean> getFloorMap() {
|
||||
List<ItemTypeBean> list = new ArrayList<>(60);
|
||||
list.add(new ItemTypeBean(1, "imgHFloorR1C6", "B1"));
|
||||
list.add(new ItemTypeBean(2, "imgHFloorR1C4s", "B2"));
|
||||
list.add(new ItemTypeBean(5, "imgSFloorR1C6s", "B3"));
|
||||
list.add(new ItemTypeBean(7, "imgHFloorR1C3", "B5"));//B5没在第一版中,但不影响
|
||||
list.add(new ItemTypeBean(8, "imgHFloorR1C3s", "B5-2"));
|
||||
list.add(new ItemTypeBean(12, "imgHFloorR1C2", "B9"));
|
||||
list.add(new ItemTypeBean(14, "imgHFloorR1C4A11", "B11"));
|
||||
list.add(new ItemTypeBean(16, "imgHFloorR1C3A14", "B13"));
|
||||
list.add(new ItemTypeBean(21, "imgHFloorR2C5A4", "C3"));
|
||||
list.add(new ItemTypeBean(26, "imgHFloorR2C5", "C7=D5"));
|
||||
list.add(new ItemTypeBean(55, "imgHFloorR1C1A49", "A49"));
|
||||
list.add(new ItemTypeBean(58, "imgHFloorR1C4_notitlte", "JC1"));
|
||||
list.add(new ItemTypeBean(29, "newsAndfirsts", "D1"));
|
||||
list.add(new ItemTypeBean(59, "newsAndcommend", "JC32"));
|
||||
list.add(new ItemTypeBean(31, "hotMovie", "D4"));
|
||||
// 回到顶部
|
||||
list.add(new ItemTypeBean(57, "toTop", "toTop"));
|
||||
|
||||
//list.add(new ItemTypeBean(3, "imgHFloorR1C4", "B2-2"));
|
||||
//list.add(new ItemTypeBean(4, "imgHFloorR1C4T", "B2-3"));
|
||||
|
||||
//list.add(new ItemTypeBean(6, "imgHSFloorR1C5s", "B4"));
|
||||
|
||||
//list.add(new ItemTypeBean(9, "imgHFloorR1C3A5", "B6"));
|
||||
//list.add(new ItemTypeBean(10, "imgHFloorR1C5", "B7"));
|
||||
//list.add(new ItemTypeBean(11, "imgCFloorR1C6", "B8"));
|
||||
//list.add(new ItemTypeBean(13, "imgHFloorR1C2A10", "B10"));
|
||||
|
||||
//list.add(new ItemTypeBean(15, "imgHFloorR1C4A12", "B12"));
|
||||
|
||||
//list.add(new ItemTypeBean(17, "imgHFloorR1C23A15", "B14"));
|
||||
//list.add(new ItemTypeBean(18, "imgHFloorR1C2A16", "B15"));
|
||||
//list.add(new ItemTypeBean(19, "imgHFloorR2C6", "C1"));
|
||||
//list.add(new ItemTypeBean(20, "imgHFloorR2C7s", "C2"));
|
||||
|
||||
//list.add(new ItemTypeBean(22, "imgHFloorR2C5A14", "C4"));
|
||||
//list.add(new ItemTypeBean(23, "imgHFloorR2C3", "C5"));
|
||||
// 中间不是轮播
|
||||
//list.add(new ItemTypeBean(24, "imgHFloorR1C3A19", "C6=F6"));
|
||||
// 中间是轮播
|
||||
//list.add(new ItemTypeBean(25, "midCarouslePoster", "C6_1"));
|
||||
|
||||
//list.add(new ItemTypeBean(27, "historyIndex", "D2"));
|
||||
//list.add(new ItemTypeBean(54, "historyCarouslePoster", "D2_1"));
|
||||
//list.add(new ItemTypeBean(30, "hotProjectVod", "D3"));
|
||||
//list.add(new ItemTypeBean(31, "hotMovie", "D4"));
|
||||
//list.add(new ItemTypeBean(53, "hotproject", "D5"));
|
||||
//list.add(new ItemTypeBean(32, "summerAndGold", "E1"));
|
||||
//list.add(new ItemTypeBean(33, "summerAndNotGold", "E2"));
|
||||
//list.add(new ItemTypeBean(34, "imgHFloorR1C4Call", "E3"));
|
||||
//list.add(new ItemTypeBean(35, "chinaGold", "E4"));
|
||||
//list.add(new ItemTypeBean(36, "hotMatch", "E5"));
|
||||
//list.add(new ItemTypeBean(37, "chinaNews", "E6"));
|
||||
//list.add(new ItemTypeBean(38, "vodSlide", "F6"));
|
||||
// list.add(new ItemTypeBean(39, "winterAndCountDown", "F1"));
|
||||
// list.add(new ItemTypeBean(40, "winterAndGold", "F2"));
|
||||
// list.add(new ItemTypeBean(41, "allMatchlistandSum", "F3"));
|
||||
// list.add(new ItemTypeBean(42, "allMatchlist", "B2-4"));
|
||||
// list.add(new ItemTypeBean(43, "chinaGold", "F4"));
|
||||
// list.add(new ItemTypeBean(44, "chinaGoldAndCall", "chinaGoldAndCall"));
|
||||
// list.add(new ItemTypeBean(45, "support", "support"));
|
||||
// list.add(new ItemTypeBean(46, "chinanewsAndImg", "F8"));
|
||||
// list.add(new ItemTypeBean(47, "chinanewsAndGold", "F9"));
|
||||
// list.add(new ItemTypeBean(48, "center4", "center4"));
|
||||
// list.add(new ItemTypeBean(49, "setting", "setting"));
|
||||
// list.add(new ItemTypeBean(50, "historyAndCollection", "historyAndCollection"));
|
||||
|
||||
//list.add(new ItemTypeBean(56, "imgHFloorR1C1", "A50"));
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化比赛状态数据
|
||||
*
|
||||
* @return 比赛状态map
|
||||
*/
|
||||
private static Map<String, String> initMatchStatus() {
|
||||
Map<String, String> matchStatus = new HashMap<>(16);
|
||||
matchStatus.put("0", "未开始");
|
||||
matchStatus.put("1", "直播中");
|
||||
// 结束的都是回看 最新设计
|
||||
matchStatus.put("2", "回看");
|
||||
// 为直播回看
|
||||
matchStatus.put("3", "回看");
|
||||
// 为点播回看
|
||||
matchStatus.put("4", "回看");
|
||||
matchStatus.put("5", "时间待定");
|
||||
matchStatus.put("6", "延期");
|
||||
matchStatus.put("7", "延迟");
|
||||
matchStatus.put("8", "取消");
|
||||
matchStatus.put("9", "待定");
|
||||
return matchStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 播放器错误字典
|
||||
**/
|
||||
public static final Map<String, String> PLAY_ERROR = getPlayError();
|
||||
|
||||
private static Map<String, String> getPlayError() {
|
||||
Map<String, String> playError = new HashMap<>(16);
|
||||
// 播放地址不存在
|
||||
playError.put("MG3-000000", "请稍后重试或观看其他节目");
|
||||
|
||||
playError.put("1111", "WL_播放鉴权失败");
|
||||
// playError.put(IMediaPlayer.MEDIA_ERROR_UNKNOWN,"未知错误");
|
||||
playError.put("MG2-1", "请稍后重试或观看其他节目");
|
||||
playError.put("MG2-100", "播放地址,服务端异常");
|
||||
playError.put("MG2--1004", "请求流,IO异常");
|
||||
playError.put("MG2--110", "请求流,超时");
|
||||
playError.put("MG2--1007", "播放器不支持");
|
||||
playError.put("MG2--1010", "播放器不支持");
|
||||
playError.put("MG3-60001", "请稍后重试或观看其他节目");
|
||||
playError.put("100002", "尊敬的用户您好!VR节目播放依赖于机顶盒芯片能力,经检测您的机顶盒不支持观看VR节目,烦请选择其它分类继续观看!");
|
||||
playError.put("100003", "抱歉,页面迷路了~");
|
||||
// 终端不支持组播,但单播地址不存在的场景
|
||||
playError.put("MG3-10006", "请稍后重试或观看其他节目");
|
||||
// 终端支持组播,组播与单播地址都不存在场景
|
||||
playError.put("MG3-10007", "请稍后重试或观看其他节目");
|
||||
// 终端支持组播,但组播播放报指定错误码需切换单播但单播地址不存在的场景
|
||||
playError.put("MG3-10008", "请稍后重试或观看其他节目");
|
||||
|
||||
return playError;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取比赛状态
|
||||
*
|
||||
* @param status 状态码
|
||||
* @return 状态
|
||||
*/
|
||||
public static String getMatchStatus(String status) {
|
||||
String matchStatus = MATCH_STATUS.get(status);
|
||||
return TextUtils.isEmpty(matchStatus) ? status : matchStatus;
|
||||
}
|
||||
|
||||
public static String matchStatus(GetGameSeasonInfoRecommendBean.ResultEntity matchInfo, String linuxTime,
|
||||
long time) {
|
||||
long starttime = 0, gameduration = 0, beforetime = 0, linuxtimeStemp = 0;
|
||||
String backurl = "", demandurl = "";
|
||||
int matchSta = matchInfo.getMatchstatus();
|
||||
|
||||
try {
|
||||
String sTimeStr = matchInfo.getStarttimeString();
|
||||
if (!TextUtils.isEmpty(sTimeStr)) {
|
||||
starttime = DateUtils.stringDateToStamp(sTimeStr, DateUtils.FORMAT_STYLE_1);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(linuxTime)) {
|
||||
linuxtimeStemp = DateUtils.stringDateToStamp(linuxTime, DateUtils.FORMAT_STYLE_1);
|
||||
linuxtimeStemp = linuxtimeStemp + time;
|
||||
}
|
||||
if (matchInfo.getGameduration() != 0) {
|
||||
gameduration = (long) matchInfo.getGameduration() * 60 * 1000;
|
||||
}
|
||||
if (TextUtils.isEmpty(matchInfo.getBeforetime())) {
|
||||
beforetime = (long) Integer.parseInt(matchInfo.getBeforetime()) * 60 * 1000;
|
||||
}
|
||||
|
||||
backurl =
|
||||
null != matchInfo.getBackchannelurl() ? matchInfo.getBackchannelurl() : matchInfo.getBackchannellist();
|
||||
demandurl = matchInfo.getContentid();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// matchStatus为3或者以上为特殊状态,需要直接显示该状态3一下为未开始 直播中,已结束,在这些状态里页面划分为5个状态
|
||||
if (matchSta >= 3) {
|
||||
return String.valueOf(matchSta + 2);
|
||||
}
|
||||
|
||||
if (starttime - beforetime > linuxtimeStemp) {
|
||||
return "0";
|
||||
} else if (starttime - beforetime < linuxtimeStemp && starttime + gameduration > linuxtimeStemp) {
|
||||
return "1";
|
||||
} else if (starttime + gameduration < linuxtimeStemp) {
|
||||
if (TextUtils.isEmpty(backurl) && TextUtils.isEmpty(demandurl)) {
|
||||
return "2";
|
||||
} else if (!TextUtils.isEmpty(backurl) && TextUtils.isEmpty(demandurl)) {
|
||||
return "3";
|
||||
} else if (!TextUtils.isEmpty(demandurl)) {
|
||||
return "4";
|
||||
}
|
||||
}
|
||||
|
||||
return "0";
|
||||
}
|
||||
|
||||
public static String matchStatus(GetGameSeasonInfoRecommendBean.ResultEntity matchInfo, String linuxTime) {
|
||||
long starttime = 0, gameduration = 0, beforetime = 0, linuxtimeStemp = 0;
|
||||
String backurl = "", demandurl = "";
|
||||
int matchSta = matchInfo.getMatchstatus();
|
||||
|
||||
try {
|
||||
String sTimeStr = matchInfo.getStarttimeString();
|
||||
if (!TextUtils.isEmpty(sTimeStr)) {
|
||||
starttime = DateUtils.stringDateToStamp(sTimeStr, DateUtils.FORMAT_STYLE_1);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(linuxTime)) {
|
||||
linuxtimeStemp = DateUtils.stringDateToStamp(linuxTime, DateUtils.FORMAT_STYLE_1);
|
||||
}
|
||||
if (matchInfo.getGameduration() != 0) {
|
||||
gameduration = (long) matchInfo.getGameduration() * 60 * 1000;
|
||||
}
|
||||
if (TextUtils.isEmpty(matchInfo.getBeforetime())) {
|
||||
beforetime = (long) Integer.parseInt(matchInfo.getBeforetime()) * 60 * 1000;
|
||||
}
|
||||
|
||||
backurl =
|
||||
null != matchInfo.getBackchannelurl() ? matchInfo.getBackchannelurl() : matchInfo.getBackchannellist();
|
||||
demandurl = matchInfo.getContentid();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// matchStatus为3或者以上为特殊状态,需要直接显示该状态3一下为未开始 直播中,已结束,在这些状态里页面划分为5个状态
|
||||
if (matchSta >= 3) {
|
||||
return String.valueOf(matchSta + 2);
|
||||
}
|
||||
|
||||
if (starttime - beforetime > linuxtimeStemp) {
|
||||
return "0";
|
||||
} else if (starttime - beforetime < linuxtimeStemp && starttime + gameduration > linuxtimeStemp) {
|
||||
return "1";
|
||||
} else if (starttime + gameduration < linuxtimeStemp) {
|
||||
if (TextUtils.isEmpty(backurl) && TextUtils.isEmpty(demandurl)) {
|
||||
return "2";
|
||||
} else if (!TextUtils.isEmpty(backurl) && TextUtils.isEmpty(demandurl)) {
|
||||
return "3";
|
||||
} else if (!TextUtils.isEmpty(demandurl)) {
|
||||
return "4";
|
||||
}
|
||||
}
|
||||
|
||||
return "0";
|
||||
}
|
||||
|
||||
private static String getStringAt(int count) {
|
||||
StringBuilder stringAt = new StringBuilder();
|
||||
String alpha_String = "123456789abcdef";
|
||||
for (int i = 0; i < count; i++) {
|
||||
int x = (int) (Math.random() * (alpha_String.length() - 1));
|
||||
stringAt.append(alpha_String.charAt(x));
|
||||
}
|
||||
return stringAt.toString();
|
||||
}
|
||||
|
||||
public static String getPlayId(int type) {
|
||||
StringBuilder sessionId = new StringBuilder();
|
||||
sessionId.append(getStringAt(8));
|
||||
for (int i = 0; i < 3; i++) {
|
||||
sessionId.append(getStringAt(4));
|
||||
}
|
||||
long time = System.currentTimeMillis();
|
||||
sessionId.append("0000000");
|
||||
String sTime = Long.toHexString(time);
|
||||
LogUtils.d("sTime:" + sTime);
|
||||
if (sTime.length() > 3) {
|
||||
sessionId.append(sTime.substring(0, 3));
|
||||
} else {
|
||||
sessionId.append(getStringAt(3));
|
||||
}
|
||||
sessionId.append(getStringAt(4));
|
||||
// 重新设置
|
||||
if (type == 1) {
|
||||
playId = sessionId.toString();
|
||||
}
|
||||
return playId;
|
||||
}
|
||||
|
||||
public static String matchStatus(GetGameSeasonInfoListBean.ResultEntity matchInfo, String linuxTime) {
|
||||
long starttime = 0, gameduration = 0, beforetime = 0, linuxtimeStemp = 0;
|
||||
String backurl = "", demandurl = "";
|
||||
int matchSta = matchInfo.getMatchstatus();
|
||||
|
||||
try {
|
||||
String sTimeStr = matchInfo.getStarttimeString();
|
||||
if (!TextUtils.isEmpty(sTimeStr)) {
|
||||
starttime = DateUtils.stringDateToStamp(sTimeStr, DateUtils.FORMAT_STYLE_1);
|
||||
}
|
||||
|
||||
if (!TextUtils.isEmpty(linuxTime)) {
|
||||
linuxtimeStemp = DateUtils.stringDateToStamp(linuxTime, DateUtils.FORMAT_STYLE_1);
|
||||
}
|
||||
gameduration = (long) matchInfo.getGameduration() * 60 * 1000;
|
||||
beforetime = (long) Integer.parseInt(matchInfo.getBeforetime()) * 60 * 1000;
|
||||
backurl =
|
||||
null != matchInfo.getBackchannelurl() ? matchInfo.getBackchannelurl() : matchInfo.getBackchannellist();
|
||||
demandurl = matchInfo.getContentid();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// matchStatus为3或者以上为特殊状态,需要直接显示该状态3一下为未开始 直播中,已结束,在这些状态里页面划分为5个状态
|
||||
if (matchSta >= 3) {
|
||||
return String.valueOf(matchSta + 2);
|
||||
}
|
||||
|
||||
if (starttime - beforetime > linuxtimeStemp) {
|
||||
return "0";
|
||||
} else if (starttime - beforetime < linuxtimeStemp && starttime + gameduration > linuxtimeStemp) {
|
||||
return "1";
|
||||
} else if (starttime + gameduration < linuxtimeStemp) {
|
||||
if (TextUtils.isEmpty(backurl) && TextUtils.isEmpty(demandurl)) {
|
||||
return "2";
|
||||
} else if (!TextUtils.isEmpty(backurl) && TextUtils.isEmpty(demandurl)) {
|
||||
return "3";
|
||||
} else if (!TextUtils.isEmpty(demandurl)) {
|
||||
return "4";
|
||||
}
|
||||
}
|
||||
|
||||
return "0";
|
||||
}
|
||||
|
||||
}
|
||||
255
app/src/main/java/com/pukka/jiecheng/index/adapter/D1ContentAdapter.java
Executable file
255
app/src/main/java/com/pukka/jiecheng/index/adapter/D1ContentAdapter.java
Executable file
@@ -0,0 +1,255 @@
|
||||
|
||||
package com.pukka.jiecheng.index.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.migu.bean.GetLayoutBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.index.bean.D1TypeBean;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:wuxf
|
||||
* @Date:2025-11-7
|
||||
* @Description:D1楼层 轮播台列表
|
||||
*/
|
||||
public class D1ContentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
public final static String TAG = "D1ContentAdapter";
|
||||
private List<GetLayoutBean.DataBean.ExtraDataBean> extraDataBeanList = new ArrayList<>();
|
||||
|
||||
private String imgUrl =
|
||||
"data:image/gif;base64,R0lGODlhHgAeAJEDAB8fHyEhISAgIAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/wtYTVAgRGF0YVhNUDw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ4IDc5LjE2NDAzNiwgMjAxOS8wOC8xMy0wMTowNjo1NyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIxLjAgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6NjZERTExRjI1ODM4MTFFQkJENEE5NDI3RUFGMEI0NUYiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6NjZERTExRjM1ODM4MTFFQkJENEE5NDI3RUFGMEI0NUYiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo2NkRFMTFGMDU4MzgxMUVCQkQ0QTk0MjdFQUYwQjQ1RiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo2NkRFMTFGMTU4MzgxMUVCQkQ0QTk0MjdFQUYwQjQ1RiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PgH//v38+/r5+Pf29fTz8vHw7+7t7Ovq6ejn5uXk4+Lh4N/e3dzb2tnY19bV1NPS0dDPzs3My8rJyMfGxcTDwsHAv769vLu6ubi3trW0s7KxsK+urayrqqmop6alpKOioaCfnp2cm5qZmJeWlZSTkpGQj46NjIuKiYiHhoWEg4KBgH9+fXx7enl4d3Z1dHNycXBvbm1sa2ppaGdmZWRjYmFgX15dXFtaWVhXVlVUU1JRUE9OTUxLSklIR0ZFRENCQUA/Pj08Ozo5ODc2NTQzMjEwLy4tLCsqKSgnJiUkIyIhIB8eHRwbGhkYFxYVFBMSERAPDg0MCwoJCAcGBQQDAgEAACH5BAkEAAMALAAAAAAeAB4AAAJUnI+py+0Po5y0TmGd2Jlt3ClfKHIkMkqAADRp9JYgbC7xc6M1lB9vbwAOfruEkDiTuWrHom7WhLJ8TCdVir0us8Fq0ujVdr9P8TDsQZ+5p7b73S4AACH5BAkEAAMALAAAAAAeAB4AAAJSnI+py+0Po5y0TmGd2Jlt3ClfKHIkMl6aGaWLC8GJvIIvG+MzSx+94foNhEEdyujjIYE421Dp3NmK0+Wzik1Gj1lm9/alNsRe7RhqLp/W7Da7AAAh+QQJBAADACwAAAAAHgAeAAACVJyPqcvtD6OctNrLBGZAgK0IIpiIGnmY1JmNktqyELzQs1vjdomHes+TBVNAxM74EyJZogCRWXxKDbTjdFBNNrLQ7lZLBee8YfL4yv2a06i2+70pAAAh+QQJBAADACwAAAAAHgAeAAACT5yPqcvtD6OctNqLrchLeJ54G3iIZPlJJrNGrfIGzhumA43g6HjbsO0B7IYsoJGnM7SWxwYT2SxCp8ROtEeVVp/OK1er9PpqWWz1hE6rJwUAIfkECQQAAwAsAAAAAB4AHgAAAk+cj6nL7Q+jnLTai7PevIrfGZ8QDuNxMqkJACgowstKy6tSk7FuyrgN5N0SuZfQRwwalyrljjlz9o68HxU6RBSf3Oi1m8VKw+AxsoROqxMFACH5BAkEAAMALAAAAAAeAB4AAAJOnI+py+0Po5y02ouz3kpwJISfEXpMOaGHSYqSOsBw58a1XNMsvucJv7r5QMKesQFsHU/F4HKRtD11zqoS2bxqoVmplfuMUrfikfmMdhQAACH5BAkEAAMALAAAAAAeAB4AAAJQnI+py+0Po5y02oufECCrLXgJKCIkc0bpt03r2EqvGat1Oh/4zYdorwP+fIMdMWcwBo81FvO5bCiTwsW0WHVGqdDhFtu1Vq9a7hdZSqvXkgIAIfkECQQAAwAsAAAAAB4AHgAAAlecj6nL7Q+jnLTai58QIKvdecgmiOPWkJPKsJH7oRKc0Elwlodu2Ls8cAmBMd7QSKwBjz9esQntJXPR4HJaZUqdSqS3+txmseKy9du6os8p9ZhrisvnlQIAIfkECQQAAwAsAAAAAB4AHgAAAk6cj6nL7Q+jnLTai6HIS3ieeBt4iI0pod2XsusYqYocujRyl/YO54YK5J2EP+JL1zPOjEHYMglFDqNF6rEqxTKa2YHPy1TWrFyS+YzOFAAAIfkECQQAAwAsAAAAAB4AHgAAAlGcj6nL7Q+jnLTai3MWWonfIR/XkNJYggxqsIvrqQOc0KJsH3mLy7H50/VMu9lQSPTVjrwkcOlESldMY5R6tU5fVVfR21XesuDneFsOqddsTQEAIfkECQQAAwAsAAAAAB4AHgAAAlOcj6nL7Q+jnLTai7PePIl/fEImhmAzoudQMoAAqCm7Ku1y33btrXo/281+CKJpyCsmj0xDbun0SZFBYJNGlV2fVWU2+sVNt1AsOSw8XzvstntSAAAh+QQJBAADACwAAAAAHgAeAAACWJyPqcvtD6OctNqLExAgKwF6CSiICGkeqOqtg6sEQtC48Bgydr7cJ+9T8T7AIa6kKyJ7xt8yaIC+lLWm8MnbdKJWLvZ7rYK94eR4eiaed0t1Gf1Oyef0SQEAIfkECQQAAwAsAAAAAB4AHgAAAlKcj6nL7Q+jnLQeYZ3YmW3cKV8ociQynpepDmn7viW4xOzc2DTusXLyQ/luQKKQFlztikijMjdcHqHNHWDaqz4NSW5063J6tWMwL0xGt9bstqUAACH5BAkEAAMALAAAAAAeAB4AAAJVnI+py+0Po5y02iluE1wvnnkJKI5deZAT4KhG0J6f7Cq1GQ43sqe0bAPifLlgcWjoJYW837H5JEoZSp1zw5xac65q97qMhrVf8ZYMnnHTVZT7DY8UAAAh+QQJBAADACwAAAAAHgAeAAACVZyPqcvtD6OctNqLs9aib9QJEyAATTihjDqwipuwMOitdXu/eXzPh2+Q7WgiWxF31CV5RyDy1Bv+pMFo0wq9aqdLIvdb7YKf4bFyLBSX1+T25w2PXwoAIfkECQQAAwAsAAAAAB4AHgAAAlOcj6nL7Q+jnLTai7PeVXh+eEITCMEkNqmxLq3SvomMxB9Dh/eQszu86/F+syCxdtSNfMthU2h7GptAqVWpmmKZ2Sv369KCoWLnNuw1g0HstntSAAAh+QQJBAADACwAAAAAHgAeAAACVZyPqcvtD6OctNqL8xFaAQF0iECKWzmFDclJX7uwDjzIjB2jta7gve5LBEdAntBIhOGWyJOy+KQdo87qDWrdSZNZ5raLNQzBVHHTXNZmf2mv6Q2PWwoAIfkECQQAAwAsAAAAAB4AHgAAAlecj6nL7Q+jnLTaG4XGCwjAKZoQJmOJnJIWNGr2uds6Ly90m7Wd7uSR6/0GLw/IEATWXsydbtiEOoVKqVV2RS6n1a42a9uCk18vUYw1R9Pl9nmIisvnlwIAIfkECQQAAwAsAAAAAB4AHgAAAlCcj6nL7Q+jnLTaI24TXC+eeQkojl2JnREAhJ8KccAGPyRzR/leO7ybi6l+NODw6FIQDcuX8ZlKmqBMZDGKrUoRzabSqs06xd4pGYxKq9eaAgAh+QQJBAADACwAAAAAHgAeAAACUZyPqcvtD6OctNorAWaib9UJXxKOSGkaqCSep8fCw7pCtFw/dzvLC9/j7RpDFc5HOgqVRKZxCUxCD8WfM0hFvqbPbHTrDXc51yqofE2p1+xJAQAh+QQJBAADACwAAAAAHgAeAAACUZyPqcvtD6OctNqLs35iJyAA3iGUWdkZ6Gmq7bW6aVSKMvku8xDzb6/oCX+5xHB2bCRvTB0R+VRGm0Dj1AfdWbM4LmOJ7Uq94WbwCh6p1+xJAQAh+QQJBAADACwAAAAAHgAeAAACTpyPqcvtD6OctNqLs95PeH54AjJmYvhhp7FebasAAtC86QIndonfO8pT/Fi+m7DIG/aSSGCtSWQGddCB8ih1Rp/ZrXeptVax4SvojE5LCgAh+QQFBAADACwAAAAAHgAeAAACUpyPqcvtD6OctNqLq9hZAQF0ySaICGke6FQ2a/QqbzxyzGwv9Jnvai7rAWstnbAYLOKUQx7z+UMSo1SDz3qsDq7bLBZ683bBRvLSJT6n1ux2pQAAOw==";
|
||||
|
||||
private String imgFocus =
|
||||
"data:image/gif;base64,R0lGODlhHgAeALMIAFzA/1vB/1rA/1u//1rB/1y//1zB/1vA/wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH/C05FVFNDQVBFMi4wAwEAAAAh/wtYTVAgRGF0YVhNUDw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuNi1jMTQ4IDc5LjE2NDAzNiwgMjAxOS8wOC8xMy0wMTowNjo1NyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIDIxLjAgKE1hY2ludG9zaCkiIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6RUQ3RDQzQUQ1ODVBMTFFQkJENEE5NDI3RUFGMEI0NUYiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6RUQ3RDQzQUU1ODVBMTFFQkJENEE5NDI3RUFGMEI0NUYiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDo2NkRFMTFGNDU4MzgxMUVCQkQ0QTk0MjdFQUYwQjQ1RiIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDpFRDdENDNBQzU4NUExMUVCQkQ0QTk0MjdFQUYwQjQ1RiIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PgH//v38+/r5+Pf29fTz8vHw7+7t7Ovq6ejn5uXk4+Lh4N/e3dzb2tnY19bV1NPS0dDPzs3My8rJyMfGxcTDwsHAv769vLu6ubi3trW0s7KxsK+urayrqqmop6alpKOioaCfnp2cm5qZmJeWlZSTkpGQj46NjIuKiYiHhoWEg4KBgH9+fXx7enl4d3Z1dHNycXBvbm1sa2ppaGdmZWRjYmFgX15dXFtaWVhXVlVUU1JRUE9OTUxLSklIR0ZFRENCQUA/Pj08Ozo5ODc2NTQzMjEwLy4tLCsqKSgnJiUkIyIhIB8eHRwbGhkYFxYVFBMSERAPDg0MCwoJCAcGBQQDAgEAACH5BAkEAAgALAAAAAAeAB4AAARYEMlJq7046827/2D4AaJ2nCV2Hum1ttYLU3JHHERWc3vVmyhVsPObFIUspHEYY/qGR0S0NnXSoNZl0oXdNrfUrk4sCXufYLI0W1abx+m4Fj5vy2f4vD4fAQAh+QQJBAAIACwAAAAAHgAeAAAEVRDJSau9OOvNu/9g+Amidpwldh7ptbbWC1Oyx2Y1l1e7iaq/Tm8yBN5cwSJCWWMGY8knT0qLHqHXrBW3lTSpxO5SjA0fv9fpWexcu83ct5c8q9vvsAgAIfkECQQACAAsAAAAAB4AHgAABFYQyUmrvTjrzbv/YCiO2EGWh3lWqbpO7UvFH6DRHW7pGz+nHx8MKAkcAhmhBKdENJnEyzM6dUGt0R11i3Vpu0MwSuzkJs1LtFR9PZPb47A87ZXZ73hRBAAh+QQJBAAIACwAAAAAHgAeAAAEXRDJSau9OOvNu/9gKI6kWJSXcAhodbwt9R7xNH9Ant0ef/kIggbogkmIMuNPibQpASsn7ai0+K7ManGKwHKb1G9WzLWOpWiMN93VJslscBseZpvpc/s2fq75/4AhEQAh+QQJBAAIACwAAAAAHgAeAAAEUxDJSau9OOvNu/9gKI5kaZ5oeKyptB4t8k7BEWSzy+owj+8yYC7YuwyPQqAFWWT+mklocRmdODFXolVZyWap0m0YW/WZjWXtGSxur7vpb2xOr1siACH5BAkEAAgALAAAAAAeAB4AAARWEMlJq7046827/2AojmRpnpaAUke7Su2RxR89Bazr2QjPWz5dT/irBGUwohCoRA6dxRy0OYlWqcmpk6m9djFHrxiMfY4v4eyZe06jy262em5+2e/4TgQAIfkECQQACAAsAAAAAB4AHgAABFUQyUmrvTjrzbv/YCiO5HYcQmmdh1qxLgVjc1ev53e/ubfLPVuw9psQh8gWLWlkLpWII7QokTanQRx2e81Yq87LNxrWdsHc55mcFofHZvSaGqvb754IACH5BAkEAAgALAAAAAAeAB4AAARZEMlJq7046827/2AojuR2nKV1Hmm1ttSLyR2top7t4jV/s5lBzAeU6IZFmtK3S/KWxd8EOmUiq85shmp8WrHgrnbmHSOO4XM5LRWn0e642tyev7+wvH7/iQAAIfkECQQACAAsAAAAAB4AHgAABFMQyUmrvTjrzbv/YCiOJHeU16GilXqyk5vJHp2uNX6/nW35LR2QMowJj7yixMZEzpxL6M6YlP6kTd61yqU+u1HwNOwlY7JlhFKNtQbFaJh8Ti9FAAAh+QQJBAAIACwAAAAAHgAeAAAEWhDJSau9OOvNu/9gKI5kWR6mdawptaIZAL4ZjQVHMNkXr7ISX0XoAiKIO+MPdlQOnUUmbwpNSo1U5tLKDVa913C3hy2LMdkxEqw219zsOPncpG/l6ZZ+zy9FAAAh+QQJBAAIACwAAAAAHgAeAAAEWRDJSau9OOvNu/9gKI5kaZ5odawTcADlekyyNme1lF+7tfcqFuYn5BV9RSBFSUsegzdjlKl7Lp1TLE5bzUaR3mZ4yEUQv1Cxursdm8vg9dsdZ9vnqbx+L4oAACH5BAkEAAgALAAAAAAeAB4AAARbEMlJq7046827/2AojmR1nKV1HqmJttMKx680pLKUXwNwY7udqjZk6Ygu4yWIpAiTNGUxw5RCgbWnsxntYq1b5U5wEHiX2bSYe1y7z9P2WTtXw6+I6n3G7/s7EQAh+QQJBAAIACwAAAAAHgAeAAAEWBDJSau9OOvNu/9gOAGidpwldh7ptbbWC1PyLNU2Ptc6jao/RG8yvAWLwmDsqKwgeU0fCzhNVpdXJzMrzUC5xGi4ihN0qeO0EbxWW91Y99e7lYtt+Lz+EwEAIfkECQQACAAsAAAAAB4AHgAABFkQyUmrvTjrzbv/YCh+xZgdqHmhh2qxbgXH0+y1ZzoFmv3qCJ8M+MMFiUNjsYakCJ3AJ1OZnOaoUKNUsj1qm1aMrUuOmr/YsFddRrPB3PM7HXfX1bS8fj+KAAAh+QQJBAAIACwAAAAAHgAeAAAEWRDJSau9OOvNu/9gKI5kaZpHelLp8R2Ai7WvOtuIgFv0LSO9S5CHG1aMrOLuuEz+kBOoJCgFNqPKH1HLfF6nX6t3jOU6y2iwOS1mV6lZ9tYd99HJq7x+X4oAACH5BAkEAAgALAAAAAAeAB4AAARaEMlJq7046827/2AojmRpnuGhopN6ZMERfG5WS/eVW/le+ZTeCgNsDRFF3JF3TCKXvyY0ODW+lFdEwDDD2qRZYZYZBlu/5fSZaPa6de2nmj2Xr+F1MWvP74siACH5BAkEAAgALAAAAAAeAB4AAARUEMlJq7046827/2AojmQ5HaZ1rCm1oq30gjA2e/eV6y5r+zrgrjLs1YonoEqoJDaNySOztpRao5mcdprlyrzB61ccxo7N5bMagVxvyVX0O0av20URACH5BAkEAAgALAAAAAAeAB4AAARaEMlJq7046827/2Aojh1wAOR1rKm1Hm31xtTsDceQ2R3vsh6fDNgj/mAZQc1YWCJVRJ7UOHxOrVTn5LrNdrHg7y5KDmO4EjTUjFAfxenymO2uwttymn7PT0UAACH5BAkEAAgALAAAAAAeAB4AAARaEMlJq7046827/2AoTsCYHah5oYdqsW4Fx9PcCUdwpp798h2fDMixGYmbY0si1ChrSMqTCWxCl4hpNnrtUrHWr3cL5orP5PGvzFYP2+hwOl41z+9amn7PH0UAACH5BAkEAAgALAAAAAAeAB4AAARbEMlJq7046827/2Aojt5BYkd6Wqm5Uu0Lq7IUf+4UzDl3I4ADYPLz0RC/4iZ5VFYGPGLzyJrmmL0KVnqlaq3cMApsI1+25W42mhYjvey32l2dt+9nM7rG7/tBEQAh+QQJBAAIACwAAAAAHgAeAAAEUxDJSau9OOvNu/9gKI5kaW7AWR2sOrFHCb8tOUv3mOdcUCO73yVACcZwwtXPSDtemEgnTyldWp0WKPCa0Wqz3GizG95WsdSxeP0sf9Pst2tOr3ciACH5BAkEAAgALAAAAAAeAB4AAARWEMlJq7046827/2AojmRpntuhopN6UIDptis5S/eY55ZwCJld7cKrCF+YIw2JKFKUuKFzSY0yp9ZqUzq0QLfXrpEbLgfJWiw4jU6211m3OQ5n2e94UAQAIfkEBQQACAAsAAAAAB4AHgAABFIQyUmrvTjrzbv/YCiOZHicpXUeabW21AtLsjdoNZe7KN1fu9gvOCH6WMeMEVFbOoc/FRTJnCqtySwQW6U+vdxvMRzlgc9jqhStFbe5s7h8/okAADs=";
|
||||
|
||||
|
||||
public D1ContentAdapter(List<GetLayoutBean.DataBean.ExtraDataBean> extraDataBeans) {
|
||||
extraDataBeanList = extraDataBeans;
|
||||
initBtnStatus();
|
||||
}
|
||||
|
||||
private int playingItemPosition = 0;
|
||||
//是否需要还原
|
||||
private boolean isNeedRestore;
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||
View view = inflater.inflate(R.layout.item_d1_list_content, parent, false);
|
||||
return new D1ContentViewHolder(view);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
|
||||
D1ContentViewHolder viewHolder = (D1ContentViewHolder) holder;
|
||||
bindFloorData(position, viewHolder);
|
||||
setFocusChangeListener(viewHolder, position);
|
||||
setClickListener(position, viewHolder);
|
||||
// 设置唯一tag,防止复用
|
||||
holder.itemView.setTag("item_" + position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewRecycled(@NonNull RecyclerView.ViewHolder holder) {
|
||||
// 空实现,不进行回收处理
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
// 为每个item返回不同的viewType,强制创建新的ViewHolder
|
||||
return position;
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private String bindFloorData(int position, D1ContentViewHolder viewHolder) {
|
||||
try {
|
||||
LogUtils.d("绑定数据 position=" + position);
|
||||
viewHolder.mTvTitleName.setText(extraDataBeanList.get(position).getName());
|
||||
viewHolder.mTvSubTitle.setText(extraDataBeanList.get(position).getTitle());
|
||||
if (isNeedRestore) {
|
||||
LogUtils.d("还原样式 position=" + position);
|
||||
changeStyle(viewHolder, position);
|
||||
}
|
||||
if (position == playingItemPosition) {
|
||||
LogUtils.d("默认播放节目,显示播放节目样式:" + playingItemPosition);
|
||||
extraDataBeanList.get(position).setBtnStatus(D1TypeBean.PLAYING);
|
||||
changeStyle(viewHolder, position);
|
||||
playingItemPosition = -1;
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("wcg, D1 e: " + e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void setFocusChangeListener(D1ContentViewHolder viewHolder, int position) {
|
||||
viewHolder.itemView.setOnFocusChangeListener((view, hasFocus) -> {
|
||||
isNeedRestore = false;
|
||||
if (hasFocus) {
|
||||
//副标题跑马灯
|
||||
viewHolder.mTvSubTitle.setSelected(true);
|
||||
viewHolder.mTvSubTitle.setEllipsize(TextUtils.TruncateAt.MARQUEE);
|
||||
LogUtils.d("d1 contentItem 获取焦点 position=" + position);
|
||||
if (extraDataBeanList.get(position).getBtnStatus() == D1TypeBean.NORMAL) {
|
||||
extraDataBeanList.get(position).setBtnStatus(D1TypeBean.FOCUSED);
|
||||
} else if (extraDataBeanList.get(position).getBtnStatus() == D1TypeBean.PLAYING) {
|
||||
extraDataBeanList.get(position).setBtnStatus(D1TypeBean.PLAYINGANDFOCUSED);
|
||||
}
|
||||
} else {
|
||||
LogUtils.d("d1 contentItem 失去焦点 position=" + position);
|
||||
viewHolder.mTvSubTitle.setSelected(false);
|
||||
viewHolder.mTvSubTitle.setEllipsize(TextUtils.TruncateAt.END);
|
||||
if (extraDataBeanList.get(position).getBtnStatus() == D1TypeBean.PLAYINGANDFOCUSED) {
|
||||
extraDataBeanList.get(position).setBtnStatus(D1TypeBean.PLAYING);
|
||||
} else {
|
||||
extraDataBeanList.get(position).setBtnStatus(D1TypeBean.NORMAL);
|
||||
}
|
||||
}
|
||||
changeStyle(viewHolder, position);
|
||||
});
|
||||
}
|
||||
|
||||
public void changeStyle(D1ContentViewHolder viewHolder, int i) {
|
||||
TextView textView1 = viewHolder.mTvTitleName;
|
||||
TextView textView2 = viewHolder.mTvSubTitle;
|
||||
PkSimpleDraweeView imageView = viewHolder.mIvPlayIc;
|
||||
if (extraDataBeanList.get(i).getBtnStatus() == D1TypeBean.NORMAL) {
|
||||
LogUtils.d("不显示图标NORMAL position=" + i);
|
||||
imageView.setVisibility(View.GONE);
|
||||
imageView.setImageURI("");
|
||||
textView1.setTextColor(imageView.getContext().getResources().getColor(R.color.white));
|
||||
textView2.setTextColor(imageView.getContext().getResources().getColor(R.color.index_nav_text_nor));
|
||||
} else if (extraDataBeanList.get(i).getBtnStatus() == D1TypeBean.PLAYING) {
|
||||
LogUtils.d("显示播放图标PLAYING position=" + i);
|
||||
imageView.setImageURI(imgFocus);
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
textView1.setTextColor(imageView.getContext().getResources().getColor(R.color.floor_D1_color));
|
||||
textView2.setTextColor(imageView.getContext().getResources().getColor(R.color.floor_D1_color));
|
||||
} else if (extraDataBeanList.get(i).getBtnStatus() == D1TypeBean.FOCUSED) {
|
||||
LogUtils.d("不显示图标FOCUSED position=" + i);
|
||||
imageView.setVisibility(View.GONE);
|
||||
imageView.setImageURI("");
|
||||
textView1.setTextColor(textView1.getContext().getResources().getColor(R.color.index_top_text_focus));
|
||||
textView2.setTextColor(textView2.getContext().getResources().getColor(R.color.index_top_text_focus_second));
|
||||
} else if (extraDataBeanList.get(i).getBtnStatus() == D1TypeBean.PLAYINGANDFOCUSED) {
|
||||
LogUtils.d("显示播放和获取焦点图标 position=" + i);
|
||||
imageView.setImageURI(imgUrl);
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
textView1.setTextColor(textView1.getContext().getResources().getColor(R.color.index_top_text_focus));
|
||||
textView2
|
||||
.setTextColor(textView2.getContext().getResources().getColor(R.color.index_top_text_focus_second));
|
||||
}
|
||||
}
|
||||
|
||||
private void setClickListener(int position, D1ContentViewHolder viewHolder) {
|
||||
viewHolder.itemView.setOnClickListener(v -> {
|
||||
LogUtils.d("点击OK键,切换节目 position=" + position);
|
||||
initBtnStatus();
|
||||
if (getItemCount() > 0) {
|
||||
// 恢复以前的样式, 选中的样式不变
|
||||
for (int i = 0; i < getItemCount(); i++) {
|
||||
if (i != position) {
|
||||
notifyItemChanged(i);
|
||||
}
|
||||
}
|
||||
isNeedRestore = true;
|
||||
}
|
||||
extraDataBeanList.get(position).setBtnStatus(D1TypeBean.PLAYINGANDFOCUSED);
|
||||
changeStyle(viewHolder, position);
|
||||
if (null != onItemClickListener) {
|
||||
onItemClickListener.onItemClick(position);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 初始化选项状态
|
||||
*/
|
||||
private void initBtnStatus() {
|
||||
if (null != extraDataBeanList && extraDataBeanList.size() > 0) {
|
||||
for (int i = 0; i < extraDataBeanList.size(); i++) {
|
||||
//平时状态
|
||||
extraDataBeanList.get(i).setBtnStatus(D1TypeBean.NORMAL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动播放下一级,更新节目样式
|
||||
*/
|
||||
public void nextPlayChangeStyle(int position) {
|
||||
if (null != extraDataBeanList && position < extraDataBeanList.size()) {
|
||||
initBtnStatus();
|
||||
extraDataBeanList.get(position).setBtnStatus(D1TypeBean.PLAYING);
|
||||
if (getItemCount() > 0) {
|
||||
for (int i = 0; i < getItemCount(); i++) {
|
||||
notifyItemChanged(i);
|
||||
}
|
||||
isNeedRestore = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setPlayingItemPosition(int playingItemPosition) {
|
||||
this.playingItemPosition = playingItemPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (extraDataBeanList != null) {
|
||||
return extraDataBeanList.size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public List<GetLayoutBean.DataBean.ExtraDataBean> getExtraDataBeanList() {
|
||||
return extraDataBeanList;
|
||||
}
|
||||
|
||||
private OnItemClickListener onItemClickListener;
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
|
||||
this.onItemClickListener = onItemClickListener;
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(int pos);
|
||||
}
|
||||
|
||||
public static class D1ContentViewHolder extends RecyclerView.ViewHolder {
|
||||
RelativeLayout mRlD1ContentItem;
|
||||
|
||||
TextView mTvTitleName, mTvSubTitle;
|
||||
|
||||
PkSimpleDraweeView mIvPlayIc;
|
||||
|
||||
private final PkSimpleDraweeView mIvVip;
|
||||
|
||||
public D1ContentViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mRlD1ContentItem = itemView.findViewById(R.id.id_rl_d1_contentItem);
|
||||
mIvPlayIc = itemView.findViewById(R.id.id_iv_playIc);
|
||||
mTvTitleName = itemView.findViewById(R.id.id_tv_title);
|
||||
mTvSubTitle = itemView.findViewById(R.id.id_tv_subTitle);
|
||||
mIvVip = itemView.findViewById(R.id.id_iv_vip);
|
||||
}
|
||||
}
|
||||
}
|
||||
349
app/src/main/java/com/pukka/jiecheng/index/adapter/D3ContentAdapter.java
Executable file
349
app/src/main/java/com/pukka/jiecheng/index/adapter/D3ContentAdapter.java
Executable file
@@ -0,0 +1,349 @@
|
||||
|
||||
package com.pukka.jiecheng.index.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Animatable;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.facebook.drawee.controller.ControllerListener;
|
||||
import com.facebook.drawee.interfaces.DraweeController;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.facebook.imagepipeline.image.ImageInfo;
|
||||
import com.migu.bean.GetGameSeasonInfoListBean;
|
||||
import com.migu.bean.GetLayoutBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.index.IndexConstant;
|
||||
import com.pukka.jiecheng.utils.UiUtils;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
import com.pukka.libcore.utils.DateUtils;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:Sandy
|
||||
* @Date:2023-03-21-09-26
|
||||
* @Description:
|
||||
*/
|
||||
public class D3ContentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
implements View.OnFocusChangeListener {
|
||||
public final static String TAG = "D3ContentAdapter";
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
private List<GetGameSeasonInfoListBean.ResultEntity> matchList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 点击推荐位埋点用到
|
||||
*/
|
||||
private final GetLayoutBean.DataBean floor;
|
||||
|
||||
private GetLayoutBean.DataBean.ExtraDataBean currentExtraDataBean;
|
||||
|
||||
private String time;
|
||||
|
||||
public D3ContentAdapter(GetLayoutBean.DataBean floor, Context mContext) {
|
||||
this.floor = floor;
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setCurrentExtraDataBean(GetLayoutBean.DataBean.ExtraDataBean currentExtraDataBean) {
|
||||
this.currentExtraDataBean = currentExtraDataBean;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void setMatchList(List<GetGameSeasonInfoListBean.ResultEntity> matchList, String time) {
|
||||
if (matchList.size() == 0) {
|
||||
matchList.add(new GetGameSeasonInfoListBean.ResultEntity(true));
|
||||
}
|
||||
this.matchList = matchList;
|
||||
this.time = time;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||
View view = inflater.inflate(R.layout.item_match_list, parent, false);
|
||||
return new MatchViewHolder(view);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
|
||||
MatchViewHolder viewHolder = (MatchViewHolder) holder;
|
||||
String status = bindFloorData(position, viewHolder);
|
||||
setFocusChangeListener(viewHolder);
|
||||
setClickListener(position, viewHolder, status);
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private String bindFloorData(int position, MatchViewHolder viewHolder) {
|
||||
String status;
|
||||
try {
|
||||
GetGameSeasonInfoListBean.ResultEntity resultEntity = matchList.get(position);
|
||||
status = IndexConstant.matchStatus(resultEntity, this.time);
|
||||
viewHolder.matchListLv.setVisibility(View.VISIBLE);
|
||||
if (resultEntity.getDualed() == 1) {
|
||||
viewHolder.mTvGameName.setVisibility(View.VISIBLE);
|
||||
viewHolder.mllRight.setVisibility(View.VISIBLE);
|
||||
viewHolder.mllLeft.setVisibility(View.VISIBLE);
|
||||
viewHolder.mTvGameName.setText(resultEntity.getGamename());
|
||||
String timeStr = DateUtils.formatDate(resultEntity.getStarttimeString(),DateUtils.FORMAT_STYLE_1,"MM月dd日 HH:mm");
|
||||
viewHolder.mTvGameTime.setText(timeStr);
|
||||
viewHolder.mTvLeftName.setText(resultEntity.getHomeTeamName());
|
||||
loadTeamLogo(position, viewHolder);
|
||||
viewHolder.mTvRightName.setText(resultEntity.getVisitingTeamName());
|
||||
viewHolder.mTvScore.setText("VS");
|
||||
if ("2".equals(status) || "3".equals(status) || "4".equals(status)) {
|
||||
String score = "VS";
|
||||
if (null != resultEntity.getHomeScore() && null != resultEntity.getVisitingScore()) {
|
||||
score = resultEntity.getHomeScore() + ":" + resultEntity.getVisitingScore();
|
||||
}
|
||||
if (null != resultEntity.getHomeScore() && null == resultEntity.getVisitingScore()) {
|
||||
score = resultEntity.getHomeScore() + ":0";
|
||||
}
|
||||
if (null == resultEntity.getHomeScore() && null != resultEntity.getVisitingScore()) {
|
||||
score = "0:" + resultEntity.getVisitingScore();
|
||||
}
|
||||
viewHolder.mTvScore.setText(score);
|
||||
}
|
||||
} else {
|
||||
viewHolder.mTvGameName.setVisibility(View.GONE);
|
||||
viewHolder.mllRight.setVisibility(View.GONE);
|
||||
viewHolder.mllLeft.setVisibility(View.GONE);
|
||||
viewHolder.mTvScore.setText(resultEntity.getName());
|
||||
|
||||
String timeStr = DateUtils.formatDate(resultEntity.getStarttimeString(),DateUtils.FORMAT_STYLE_1,"MM月dd日 HH:mm");
|
||||
viewHolder.mTvGameTime.setText(timeStr);
|
||||
}
|
||||
|
||||
// VIP角标
|
||||
setCornerMark(viewHolder.mIvVip, resultEntity.getCornerUrl());
|
||||
// 须判断
|
||||
viewHolder.mTvStatus.setText(IndexConstant.getMatchStatus(status));
|
||||
// 直播中按钮颜色特殊处理
|
||||
if ("1".equals(status)) {
|
||||
viewHolder.mTvStatus.setTextColor(mContext.getResources().getColor(R.color.white));
|
||||
viewHolder.mTvStatus.setBackground(
|
||||
AppCompatResources.getDrawable(mContext, R.drawable.common_matchtextlive_bg_unfocus));
|
||||
} else {
|
||||
viewHolder.mTvStatus.setTextColor(ContextCompat.getColor(mContext, R.color.white));
|
||||
viewHolder.mTvStatus
|
||||
.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.common_matchtext_bg_unfocus));
|
||||
}
|
||||
return status;
|
||||
} catch (Exception e) {
|
||||
LogUtils.e("wcg, D3 e: " + e.getMessage());
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void setFocusChangeListener(MatchViewHolder viewHolder) {
|
||||
viewHolder.itemView.setOnFocusChangeListener((view, hasFocus) -> {
|
||||
LogUtils.d("d3 contentItem onFocusChange");
|
||||
viewHolder.mTvLeftName.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.white));
|
||||
viewHolder.mTvGameName.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.white4));
|
||||
viewHolder.mTvGameTime.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.white4));
|
||||
viewHolder.mTvRightName.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.white));
|
||||
viewHolder.mTvStatus.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.white));
|
||||
viewHolder.mTvScore.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.white));
|
||||
|
||||
viewHolder.mTvScore.setSelected(hasFocus);
|
||||
viewHolder.mTvRightName.setSelected(hasFocus);
|
||||
viewHolder.mTvLeftName.setSelected(hasFocus);
|
||||
viewHolder.mTvGameName.setSelected(hasFocus);
|
||||
viewHolder.mTvGameTime.setSelected(hasFocus);
|
||||
|
||||
viewHolder.mTvScore.setEllipsize(hasFocus ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END);
|
||||
viewHolder.mTvRightName.setEllipsize(hasFocus ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END);
|
||||
viewHolder.mTvLeftName.setEllipsize(hasFocus ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END);
|
||||
viewHolder.mTvGameName.setEllipsize(hasFocus ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END);
|
||||
viewHolder.mTvGameTime.setEllipsize(hasFocus ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END);
|
||||
|
||||
// 非直播中按钮颜色需要变化 直播中的不变
|
||||
if (!"直播中".contentEquals(viewHolder.mTvStatus.getText())) {
|
||||
viewHolder.mTvStatus.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.white));
|
||||
viewHolder.mTvStatus.setBackground(AppCompatResources.getDrawable(mContext,
|
||||
hasFocus ? R.drawable.common_matchtext_bg_focus : R.drawable.common_matchtext_bg_unfocus));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void setClickListener(int position, MatchViewHolder viewHolder, String status) {
|
||||
String finalStatus = IndexConstant.getMatchStatus(status);
|
||||
GetGameSeasonInfoListBean.ResultEntity resultEntity = matchList.get(position);
|
||||
viewHolder.itemView.setOnClickListener(v -> {
|
||||
if (resultEntity.getMatchstatus() < 3) {
|
||||
String gameParam = resultEntity.getId() + "&" + resultEntity.getGameid();
|
||||
String targetMgjsCode = resultEntity.getMgjscode();
|
||||
HashMap<String, String> map = new HashMap<>(16);
|
||||
map.put("actionType", "common");
|
||||
if (floor != null) {
|
||||
map.put("blockIndex", String.valueOf(floor.getTitlecode()));
|
||||
map.put("blockName", floor.getTitle());
|
||||
}
|
||||
|
||||
if (currentExtraDataBean != null) {
|
||||
map.put("positionId", currentExtraDataBean.getPositionid());
|
||||
map.put("targetProgramId", currentExtraDataBean.getContentcode());
|
||||
map.put("targetProgramName", currentExtraDataBean.getName());
|
||||
}
|
||||
map.put("targetMgjsCode", targetMgjsCode);
|
||||
map.put("targetPageType", "体育详情页");
|
||||
map.put("targetPageId", "sport_detail");
|
||||
map.put("targetPageName", "体育详情页");
|
||||
//AmberPoint.epgPagePositionClickEvent(map);
|
||||
//ItemOnClickUtils.go2Epg(mContext, gameParam, IndexConstant.getSportDetailUrl(), "sportDetail", "");
|
||||
} else {// 大于等于3的为特殊比赛情况 需要toast提示
|
||||
if (resultEntity.getMatchstatus() + 2 == 6 || resultEntity.getMatchstatus() + 2 == 8) {
|
||||
Toast.makeText(mContext, "该场比赛已" + finalStatus, Toast.LENGTH_SHORT).show();
|
||||
} else if (resultEntity.getMatchstatus() + 2 == 7) {
|
||||
Toast.makeText(mContext, "该场比赛已延期", Toast.LENGTH_SHORT).show();
|
||||
} else if (resultEntity.getMatchstatus() + 2 == 9) {
|
||||
Toast.makeText(mContext, "该场比赛主客队待确定", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(mContext, "该场比赛" + finalStatus, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadTeamLogo(int position, MatchViewHolder viewHolder) {
|
||||
GetGameSeasonInfoListBean.ResultEntity resultEntity = matchList.get(position);
|
||||
if (null == resultEntity) {
|
||||
return;
|
||||
}
|
||||
|
||||
viewHolder.mIvLeft.setImageURI(resultEntity.getHomeTeamlogo());
|
||||
viewHolder.mIvRight.setImageURI(resultEntity.getVisitingTeamlogo());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (matchList != null) {
|
||||
return matchList.size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置角标
|
||||
*
|
||||
* @param cornerMarkIv cornerMarkIv
|
||||
* @param cornerMarkUrl 角标地址
|
||||
*/
|
||||
private void setCornerMark(PkSimpleDraweeView cornerMarkIv, String cornerMarkUrl) {
|
||||
if (TextUtils.isEmpty(cornerMarkUrl)) {
|
||||
cornerMarkIv.setVisibility(View.INVISIBLE);
|
||||
return;
|
||||
}
|
||||
|
||||
DraweeController controller = Fresco.newDraweeControllerBuilder()
|
||||
.setOldController(cornerMarkIv.getController())
|
||||
.setControllerListener(new ControllerListener<ImageInfo>() {
|
||||
@Override
|
||||
public void onSubmit(String id, Object callerContext) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
|
||||
adjustSdv(cornerMarkIv, imageInfo.getWidth(), imageInfo.getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntermediateImageSet(String id, ImageInfo imageInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntermediateImageFailed(String id, Throwable throwable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String id, Throwable throwable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRelease(String id) {
|
||||
|
||||
}
|
||||
})
|
||||
.setUri(Uri.parse(cornerMarkUrl))
|
||||
.build();
|
||||
|
||||
cornerMarkIv.setController(controller);
|
||||
cornerMarkIv.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void adjustSdv(SimpleDraweeView image, int width, int height) {
|
||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) image.getLayoutParams();
|
||||
UiUtils.resetLayoutParams(mContext, width, height, UiUtils.POSITION_TYPE_SPORT_CARD, params);
|
||||
image.setLayoutParams(params);
|
||||
}
|
||||
|
||||
public static class MatchViewHolder extends RecyclerView.ViewHolder {
|
||||
LinearLayout matchListLv;
|
||||
|
||||
TextView mTvGameName, mTvGameTime, mTvLeftName, mTvRightName, mTvStatus, mTvScore;
|
||||
|
||||
PkSimpleDraweeView mIvLeft, mIvRight;
|
||||
|
||||
private final LinearLayout mllRight;
|
||||
|
||||
private final LinearLayout mllLeft;
|
||||
|
||||
private final PkSimpleDraweeView mIvVip;
|
||||
|
||||
public MatchViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
matchListLv = itemView.findViewById(R.id.matchListLv);
|
||||
mTvGameName = itemView.findViewById(R.id.id_tv_gameName);
|
||||
mTvGameTime = itemView.findViewById(R.id.id_tv_gameTime);
|
||||
mIvLeft = itemView.findViewById(R.id.img_left_icon);
|
||||
mIvRight = itemView.findViewById(R.id.img_right_icon);
|
||||
mTvLeftName = itemView.findViewById(R.id.id_tv_leftName);
|
||||
mTvRightName = itemView.findViewById(R.id.id_tv_rightName);
|
||||
mTvStatus = itemView.findViewById(R.id.id_tv_status);
|
||||
mTvScore = itemView.findViewById(R.id.txt_score);
|
||||
mllRight = itemView.findViewById(R.id.ll_right);
|
||||
mllLeft = itemView.findViewById(R.id.ll_left);
|
||||
mIvVip = itemView.findViewById(R.id.img_vip_icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
131
app/src/main/java/com/pukka/jiecheng/index/adapter/D3NavAdapter.java
Executable file
131
app/src/main/java/com/pukka/jiecheng/index/adapter/D3NavAdapter.java
Executable file
@@ -0,0 +1,131 @@
|
||||
package com.pukka.jiecheng.index.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.migu.bean.GetLayoutBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:Sandy
|
||||
* @Date:2023-03-21-09-25
|
||||
* @Description:
|
||||
*/
|
||||
public class D3NavAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements View.OnFocusChangeListener {
|
||||
public final static String TAG = "D3NavAdapter";
|
||||
private List<GetLayoutBean.DataBean.ExtraDataBean> navList = new ArrayList<>();
|
||||
private OnCatalogIdListener onCatalogIdListener;
|
||||
//导航列表驻留索引
|
||||
private int resideIndex = 0;
|
||||
private String nowNavId;
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void setNavList(List<GetLayoutBean.DataBean.ExtraDataBean> list) {
|
||||
navList = list;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setOnCatalogIdListener(OnCatalogIdListener onCatalogIdListener) {
|
||||
this.onCatalogIdListener = onCatalogIdListener;
|
||||
}
|
||||
|
||||
public int getResideIndex() {
|
||||
return resideIndex;
|
||||
}
|
||||
|
||||
public int getFirstFocusNav() {
|
||||
int firstFocus = 0;
|
||||
// if(navList != null && navList.size()>0){
|
||||
// return firstFocus;
|
||||
// }
|
||||
return firstFocus;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_d3_nav, parent, false);
|
||||
return new ItemViewHolder(view);
|
||||
}
|
||||
|
||||
@SuppressLint("ResourceAsColor")
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
|
||||
ItemViewHolder itemViewHolder = (ItemViewHolder) holder;
|
||||
itemViewHolder.mTvNavName.setText(navList.get(position).getName());
|
||||
itemViewHolder.mIvNavName.setVisibility(View.GONE);
|
||||
itemViewHolder.itemView.setOnFocusChangeListener((view, hasFocus) -> {
|
||||
LogUtils.d("d3 nav onFocusChange");
|
||||
if (onCatalogIdListener != null && hasFocus) {
|
||||
GetLayoutBean.DataBean.ExtraDataBean edataBean = navList.get(position);
|
||||
if (edataBean != null && edataBean.getParam() != null && !TextUtils.isEmpty(edataBean.getParam())) {
|
||||
String params = edataBean.getParam();
|
||||
String[] arr = params.split("&");
|
||||
nowNavId = "339";
|
||||
if (arr != null && arr.length > 0) {
|
||||
nowNavId = arr[0];
|
||||
}
|
||||
}
|
||||
onCatalogIdListener.getCatalogId(nowNavId, edataBean);
|
||||
}
|
||||
if (hasFocus) {
|
||||
itemViewHolder.mTvNavName
|
||||
.setTextColor(view.getContext().getResources().getColor(R.color.index_top_text_focus));
|
||||
itemViewHolder.mIvNavLine.setVisibility(View.GONE);
|
||||
resideIndex = position;
|
||||
} else {
|
||||
itemViewHolder.mTvNavName
|
||||
.setTextColor(view.getContext().getResources().getColor(R.color.index_top_text_nor));
|
||||
}
|
||||
});
|
||||
itemViewHolder.itemView.setOnClickListener(v -> v.requestFocus());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
LogUtils.d("navList.size=" + navList.size());
|
||||
return navList.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
|
||||
}
|
||||
|
||||
public static class ItemViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView mTvNavName;
|
||||
ImageView mIvNavLine;
|
||||
PkSimpleDraweeView mIvNavName;
|
||||
RelativeLayout navAll;
|
||||
|
||||
public ItemViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mTvNavName = itemView.findViewById(R.id.id_tv_nav_name);
|
||||
mIvNavName = itemView.findViewById(R.id.id_iv_nav_name);
|
||||
mIvNavLine = itemView.findViewById(R.id.id_iv_nav_line);
|
||||
navAll = itemView.findViewById(R.id.nav_all);
|
||||
}
|
||||
}
|
||||
|
||||
public interface OnCatalogIdListener {
|
||||
void getCatalogId(String catalogId, GetLayoutBean.DataBean.ExtraDataBean mExtraDataBean);
|
||||
}
|
||||
|
||||
public List<GetLayoutBean.DataBean.ExtraDataBean> getNavList() {
|
||||
return navList;
|
||||
}
|
||||
}
|
||||
125
app/src/main/java/com/pukka/jiecheng/index/adapter/D4ContentAdapter.java
Executable file
125
app/src/main/java/com/pukka/jiecheng/index/adapter/D4ContentAdapter.java
Executable file
@@ -0,0 +1,125 @@
|
||||
package com.pukka.jiecheng.index.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.migu.bean.GetGameSeasonInfoRecommendBean;
|
||||
import com.migu.bean.GetcontentlistBean;
|
||||
import com.pukka.jiecheng.utils.MgRoute;
|
||||
import com.pukka.jiecheng.widget.CornerBadgeView;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @Author:Sandy
|
||||
* @Date:2023-03-21-09-26
|
||||
* @Description:
|
||||
*/
|
||||
public class D4ContentAdapter extends RecyclerView.Adapter<D4ContentAdapter.ItemViewHolder> {
|
||||
public final static String TAG = "D3ContentAdapter";
|
||||
private List<GetcontentlistBean.ResultEntity> contentList = new ArrayList<>();
|
||||
private List<GetGameSeasonInfoRecommendBean.ResultEntity> matchList = new ArrayList<>();
|
||||
private int viewType;
|
||||
private Context mContext;
|
||||
|
||||
public D4ContentAdapter(int type, Context mContext) {
|
||||
viewType = type;
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void setContentList(List<GetcontentlistBean.ResultEntity> contentList) {
|
||||
if (contentList.size() == 0) {
|
||||
contentList.add(new GetcontentlistBean.ResultEntity(true));
|
||||
}
|
||||
this.contentList = contentList;
|
||||
notifyDataSetChanged();//渲染
|
||||
}
|
||||
|
||||
public List<GetcontentlistBean.ResultEntity> getContentList() {
|
||||
return contentList;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ItemViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_image_txt_hor, parent, false);
|
||||
return new ItemViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ItemViewHolder viewHolder, @SuppressLint("RecyclerView") int position) {
|
||||
try {
|
||||
if (contentList.get(position).getNoData()) {
|
||||
viewHolder.mImageView.setVisibility(View.INVISIBLE);
|
||||
viewHolder.mTextView.setVisibility(View.INVISIBLE);
|
||||
} else {
|
||||
viewHolder.mImageView.setVisibility(View.VISIBLE);
|
||||
viewHolder.mTextView.setVisibility(View.VISIBLE);
|
||||
viewHolder.mImageView.setImageUri(contentList.get(position).getPosterimg());
|
||||
viewHolder.mImageView.setCornerRightUp(contentList.get(position).getCornerUrl());
|
||||
viewHolder.mTextView.setText(contentList.get(position).getName());
|
||||
viewHolder.itemView.setOnFocusChangeListener((view, hasFocus) -> {
|
||||
LogUtils.d("d4 contentItem onFocusChange");
|
||||
if (hasFocus) {
|
||||
viewHolder.mTextView.setSelected(true);
|
||||
viewHolder.mTextView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
|
||||
viewHolder.mTextView
|
||||
.setTextColor(view.getContext().getResources().getColor(R.color.index_top_text_focus));
|
||||
} else {
|
||||
viewHolder.mTextView.setSelected(false);
|
||||
viewHolder.mTextView.setEllipsize(TextUtils.TruncateAt.END);
|
||||
viewHolder.mTextView
|
||||
.setTextColor(view.getContext().getResources().getColor(R.color.white));
|
||||
}
|
||||
});
|
||||
|
||||
viewHolder.itemView.setOnClickListener(v -> {
|
||||
|
||||
try {
|
||||
String contentCode = contentList.get(position).getCode();
|
||||
LogUtils.d("contentCode:" + contentCode);
|
||||
MgRoute.go2DetailActivity(mContext, contentCode);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
} catch (Exception ep) {
|
||||
LogUtils.d("D3");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (contentList != null) {
|
||||
return contentList.size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
public static class ItemViewHolder extends RecyclerView.ViewHolder {
|
||||
public CornerBadgeView mImageView;
|
||||
public TextView mTextView;
|
||||
|
||||
public ItemViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
mImageView = itemView.findViewById(R.id.id_iv_1);
|
||||
mTextView = itemView.findViewById(R.id.id_tv_1);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
141
app/src/main/java/com/pukka/jiecheng/index/adapter/IndexContentAdapter.java
Executable file
141
app/src/main/java/com/pukka/jiecheng/index/adapter/IndexContentAdapter.java
Executable file
@@ -0,0 +1,141 @@
|
||||
|
||||
package com.pukka.jiecheng.index.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.text.TextUtils;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.migu.bean.GetLayoutBean;
|
||||
import com.pukka.jiecheng.index.IndexConstant;
|
||||
import com.pukka.jiecheng.index.bean.ItemTypeBean;
|
||||
import com.pukka.jiecheng.index.manager.FloorOnBindViewHolderManager;
|
||||
import com.pukka.jiecheng.index.manager.FloorOnCreateViewHolderManager;
|
||||
import com.pukka.jiecheng.index.viewmodel.ContentViewModel;
|
||||
import com.pukka.libcore.utils.ListUtils;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
import com.pukka.libcore.viewmodel.BaseVM;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Date: 2023/1/12 14:31
|
||||
* Description:首页楼层适配器
|
||||
*
|
||||
* @author wxf
|
||||
*/
|
||||
public class IndexContentAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
public static final String TAG = "IndexContentAdapter";
|
||||
|
||||
private List<GetLayoutBean.DataBean> layoutNavLists = new ArrayList<>();
|
||||
|
||||
private final FloorOnCreateViewHolderManager onCreateViewHolderManger;
|
||||
|
||||
private final FloorOnBindViewHolderManager onBindViewHolderManger;
|
||||
|
||||
/**
|
||||
* 标记楼层和所用type的关系
|
||||
*/
|
||||
private HashMap<Integer, Integer> floorMap = new HashMap<>(16);
|
||||
|
||||
private String gameId;
|
||||
private final ContentViewModel contentViewModel;
|
||||
|
||||
public IndexContentAdapter(Fragment fragment) {
|
||||
onCreateViewHolderManger = new FloorOnCreateViewHolderManager(fragment);
|
||||
onBindViewHolderManger = new FloorOnBindViewHolderManager();
|
||||
contentViewModel = BaseVM.getSafeViewModel(fragment, ContentViewModel.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* layoutNavLists notifyDataSetChanged需要发生变化的话 必须要layoutNavLists发生变化
|
||||
*
|
||||
* @param layoutNavLists layoutNavLists
|
||||
*/
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void setLayoutNavList(List<GetLayoutBean.DataBean> layoutNavLists) {
|
||||
if (layoutNavLists == null) {
|
||||
return;
|
||||
}
|
||||
floorMap.clear();
|
||||
List<GetLayoutBean.DataBean> dataList = new ArrayList<>();
|
||||
int layoutNavListSize = layoutNavLists.size();
|
||||
int floorMapListSize = IndexConstant.floorMapList.size();
|
||||
for (int i = 0; i < layoutNavListSize; i++) {
|
||||
for (int j = 0; j < floorMapListSize; j++) {
|
||||
GetLayoutBean.DataBean dataBean = layoutNavLists.get(i);
|
||||
ItemTypeBean itemTypeBean = IndexConstant.floorMapList.get(j);
|
||||
if (!TextUtils.isEmpty(dataBean.getType()) && dataBean.getType().equals(itemTypeBean.getType())) {
|
||||
LogUtils
|
||||
.d("floor=" + itemTypeBean.getFloor() +" ,type>>>"+itemTypeBean.getType()+ ",positionType>>>" + itemTypeBean.getPositionType());
|
||||
floorMap.put(i, itemTypeBean.getPositionType());
|
||||
dataList.add(dataBean);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.layoutNavLists = dataList;
|
||||
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return onCreateViewHolderManger.createViewHolder(parent, viewType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
if (!ListUtils.isEmpty(layoutNavLists) && !ListUtils.isEmpty(layoutNavLists.get(position).getExtraData())) {
|
||||
onBindViewHolderManger.bindViewHolder(holder, layoutNavLists, position, gameId);
|
||||
}
|
||||
}
|
||||
|
||||
public void goOnPlayVideo(){
|
||||
onCreateViewHolderManger.goOnPlayVideo();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return ListUtils.isEmpty(layoutNavLists) ? 0 : layoutNavLists.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
Integer viewType = floorMap.get(position);
|
||||
LogUtils.d("getItemViewType: position="+position +" viewType="+viewType);
|
||||
if (viewType != null) {
|
||||
return viewType;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
public void setGameId(@NonNull String gameId) {
|
||||
LogUtils.d("setGameId=" + gameId);
|
||||
this.gameId = gameId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||
super.onDetachedFromRecyclerView(recyclerView);
|
||||
LogUtils.d("wcg, onDetachedFromRecyclerView");
|
||||
onCreateViewHolderManger.clearViewList();
|
||||
onBindViewHolderManger.onDestroyHandler();
|
||||
layoutNavLists.clear();
|
||||
layoutNavLists = null;
|
||||
floorMap.clear();
|
||||
floorMap = null;
|
||||
}
|
||||
}
|
||||
305
app/src/main/java/com/pukka/jiecheng/index/adapter/IndexGroupNavAdapter.java
Executable file
305
app/src/main/java/com/pukka/jiecheng/index/adapter/IndexGroupNavAdapter.java
Executable file
@@ -0,0 +1,305 @@
|
||||
|
||||
package com.pukka.jiecheng.index.adapter;
|
||||
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.drawable.Animatable;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.facebook.drawee.controller.ControllerListener;
|
||||
import com.facebook.drawee.interfaces.DraweeController;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.facebook.imagepipeline.image.ImageInfo;
|
||||
import com.migu.bean.GetLayoutNavBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.index.adapter.interfaces.OnNavidListener;
|
||||
import com.pukka.jiecheng.index.bean.NavBean;
|
||||
import com.pukka.jiecheng.index.viewmodel.NavViewModel;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
import com.pukka.libcore.utils.ListUtils;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import static com.pukka.jiecheng.widget.HomeNavLinearLayoutManagerTv.NAV_INDEX;
|
||||
|
||||
/**
|
||||
* [导航栏 子Tab适配器]<BR>
|
||||
*
|
||||
* @author wcg
|
||||
* @version [V0.1.0.1, 2023/11/24 0024]
|
||||
* @since V0.1.0.1
|
||||
*/
|
||||
public class IndexGroupNavAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
public static final String TAG = "IndexNavAdapter";
|
||||
|
||||
private List<GetLayoutNavBean.DataBean.SubNavDataBean> mGroupNavDataList = new ArrayList<>();
|
||||
|
||||
private OnNavidListener onNavidListener;
|
||||
|
||||
private NavViewModel navViewModel;
|
||||
|
||||
/**
|
||||
* tab的一级下标 - 本组tab的下标
|
||||
*/
|
||||
private int groupIndex;
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void setLayoutNavList(int groupIndex, List<GetLayoutNavBean.DataBean.SubNavDataBean> groupNavDataList) {
|
||||
this.groupIndex = groupIndex;
|
||||
this.mGroupNavDataList = groupNavDataList;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setOnNavidListener(OnNavidListener onNavidListener) {
|
||||
this.onNavidListener = onNavidListener;
|
||||
}
|
||||
|
||||
public void setNavViewModel(NavViewModel navViewModel) {
|
||||
this.navViewModel = navViewModel;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_group_item_nav, parent, false);
|
||||
return new SubNavViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
GetLayoutNavBean.DataBean.SubNavDataBean mCurrentNavItem = mGroupNavDataList.get(position);
|
||||
if (mCurrentNavItem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String currentNavName = mCurrentNavItem.getNavname();
|
||||
String currentNavId = mCurrentNavItem.getNavid();
|
||||
String pageCode = mCurrentNavItem.getPageCode();
|
||||
|
||||
SubNavViewHolder myHolder = (SubNavViewHolder) holder;
|
||||
if (mCurrentNavItem.getShowType() == 0) {
|
||||
myHolder.mTvNavName.setVisibility(View.VISIBLE);
|
||||
myHolder.nav_tv_rl.setVisibility(View.VISIBLE);
|
||||
myHolder.mIvNavName.setVisibility(View.GONE);
|
||||
} else if (mCurrentNavItem.getShowType() == 1) {
|
||||
myHolder.mTvNavName.setVisibility(View.GONE);
|
||||
myHolder.nav_tv_rl.setVisibility(View.GONE);
|
||||
myHolder.mIvNavName.setVisibility(View.VISIBLE);
|
||||
setImage(myHolder, mCurrentNavItem.getNavBimage());
|
||||
}
|
||||
myHolder.mIvNavLine.setVisibility(View.GONE);
|
||||
myHolder.mTvNavName.setText(currentNavName);
|
||||
setFocusListener(position, mCurrentNavItem, currentNavName, currentNavId,pageCode, myHolder);
|
||||
setClickListener(position, mCurrentNavItem, currentNavName, currentNavId, pageCode, myHolder);
|
||||
}
|
||||
|
||||
private void setFocusListener(int position, GetLayoutNavBean.DataBean.SubNavDataBean mCurrentNavItem,
|
||||
String currentNavName, String currentNavId,String pageCode, SubNavViewHolder myHolder) {
|
||||
myHolder.itemView.setOnFocusChangeListener((view, b) -> {
|
||||
boolean passParamsToActivity = onNavidListener != null && b && (null == navViewModel.nowNavBean.getValue()
|
||||
|| !navViewModel.nowNavBean.getValue().getNowNavId().equals(currentNavId));
|
||||
if (mCurrentNavItem.getShowType() == 0) {// 文字
|
||||
if (b) {
|
||||
myHolder.mTvNavName
|
||||
.setTextColor(ContextCompat.getColor(view.getContext(), R.color.index_top_text_focus));
|
||||
myHolder.nav_tv_rl.setBackground(
|
||||
AppCompatResources.getDrawable(view.getContext(), R.drawable.common_text_bg_cir_focus));
|
||||
myHolder.mIvNavLine.setVisibility(View.GONE);
|
||||
if (null != navViewModel.resideIndex.getValue()
|
||||
&& navViewModel.resideIndex.getValue().getResideIndexSub() != position) {
|
||||
HashMap<String, String> map = new HashMap<>(16);
|
||||
// AmberPoint.pageIdMinPlay = AmberPoint.pageId;
|
||||
// AmberPoint.pageNameMinPlay = AmberPoint.pageName;
|
||||
// AmberPoint.pageId = currentNavId;
|
||||
// AmberPoint.pageName = currentNavName;
|
||||
String pageType =
|
||||
myHolder.itemView.getContext().getString(R.string.play_type_index);
|
||||
map.put("pageType", pageType);
|
||||
map.put("mgjsCode", "");
|
||||
// AmberPoint.newSessionId(1);
|
||||
// AmberPoint.epgPageVisitEvent(map);
|
||||
}
|
||||
|
||||
navViewModel.resideIndex.getValue().setResideIndex(groupIndex);
|
||||
navViewModel.resideIndex.getValue().setResideIndexSub(position);
|
||||
LogUtils.d("wcg, resideIndex:" + navViewModel.resideIndex.getValue().getResideIndex()
|
||||
+ " resideIndexSub: " + navViewModel.resideIndex.getValue().getResideIndexSub());
|
||||
} else {
|
||||
myHolder.mTvNavName
|
||||
.setTextColor(ContextCompat.getColor(view.getContext(), R.color.index_top_text_nor));
|
||||
myHolder.nav_tv_rl.setBackground(AppCompatResources.getDrawable(view.getContext(), R.color.transparent));
|
||||
}
|
||||
} else {// 图片
|
||||
if (b) {
|
||||
myHolder.navAll
|
||||
.setBackground(AppCompatResources.getDrawable(view.getContext(), R.color.transparent));
|
||||
setImage(myHolder, mCurrentNavItem.getNavFimage());
|
||||
if (null != navViewModel.resideIndex.getValue()
|
||||
&& navViewModel.resideIndex.getValue().getResideIndexSub() != position) {
|
||||
// HashMap<String, String> map = new HashMap<>(16);
|
||||
// AmberPoint.pageId = currentNavId;
|
||||
// AmberPoint.pageName = currentNavName;
|
||||
// String pageType =
|
||||
// myHolder.itemView.getContext().getString(R.string.play_type_index);
|
||||
// map.put("pageType", pageType);
|
||||
// map.put("mgjsCode", "");
|
||||
// AmberPoint.newSessionId(1);
|
||||
// AmberPoint.epgPageVisitEvent(map);
|
||||
}
|
||||
|
||||
navViewModel.resideIndex.getValue().setResideIndex(groupIndex);
|
||||
navViewModel.resideIndex.getValue().setResideIndexSub(position);
|
||||
LogUtils.d("wcg, resideIndex:" + navViewModel.resideIndex.getValue().getResideIndex()
|
||||
+ " resideIndexSub: " + navViewModel.resideIndex.getValue().getResideIndexSub());
|
||||
} else {
|
||||
if (null != navViewModel.resideIndex.getValue()
|
||||
&& navViewModel.resideIndex.getValue().getResideIndexSub() == NAV_INDEX) {// 拦截的上下键等于当前的index
|
||||
// 表示是在当前位置按上或者下了
|
||||
// 这里就是active态 进去以后赋为空
|
||||
NAV_INDEX = -1;
|
||||
setImage(myHolder, mCurrentNavItem.getNavAimage());
|
||||
myHolder.mIvNavLine.setVisibility(View.GONE);
|
||||
} else {
|
||||
setImage(myHolder, mCurrentNavItem.getNavBimage());
|
||||
}
|
||||
myHolder.navAll.setBackground(
|
||||
AppCompatResources.getDrawable(view.getContext(), R.drawable.index_nav_item_bg_selector));
|
||||
}
|
||||
}
|
||||
|
||||
if (passParamsToActivity) {
|
||||
NavBean navBean = new NavBean();
|
||||
navBean.setNowNavId(currentNavId);
|
||||
navBean.setNowNavName(currentNavName);
|
||||
navViewModel.nowNavBean.setValue(navBean);
|
||||
// 把参数传出去到activity
|
||||
onNavidListener.getNavId(currentNavId, currentNavName, mCurrentNavItem.getType(),
|
||||
mCurrentNavItem.getGame_id(),pageCode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setClickListener(int position, GetLayoutNavBean.DataBean.SubNavDataBean mCurrentNavItem,
|
||||
String currentNavName, String currentNavId, String pageCode,
|
||||
SubNavViewHolder myHolder) {
|
||||
myHolder.itemView.setOnClickListener(v -> {
|
||||
if (!v.hasFocus()) {
|
||||
v.requestFocus();
|
||||
}
|
||||
if (null != navViewModel.resideIndex.getValue()) {
|
||||
navViewModel.resideIndex.getValue().setResideIndex(groupIndex);
|
||||
navViewModel.resideIndex.getValue().setResideIndexSub(position);
|
||||
}
|
||||
boolean passParamsToActivity = onNavidListener != null && (null == navViewModel.nowNavBean.getValue()
|
||||
|| !currentNavId.equals(navViewModel.nowNavBean.getValue().getNowNavId()));
|
||||
if (passParamsToActivity) {
|
||||
NavBean navBean = new NavBean();
|
||||
navBean.setNowNavId(currentNavId);
|
||||
navBean.setNowNavName(currentNavName);
|
||||
navViewModel.nowNavBean.setValue(navBean);
|
||||
onNavidListener.getNavId(currentNavId, currentNavName, mCurrentNavItem.getType(),
|
||||
mCurrentNavItem.getGame_id(), pageCode);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void setImage(SubNavViewHolder myHolder, String imageUrl) {
|
||||
if (TextUtils.isEmpty(imageUrl)) {
|
||||
myHolder.mIvNavName.setVisibility(View.INVISIBLE);
|
||||
return;
|
||||
}
|
||||
|
||||
myHolder.navAll.post(() -> {
|
||||
DraweeController controller = Fresco.newDraweeControllerBuilder()
|
||||
.setOldController(myHolder.mIvNavName.getController())
|
||||
.setControllerListener(new ControllerListener<ImageInfo>() {
|
||||
@Override
|
||||
public void onSubmit(String id, Object callerContext) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
|
||||
if (null == imageInfo) {
|
||||
return;
|
||||
}
|
||||
|
||||
float bl = (float) myHolder.navAll.getHeight() / imageInfo.getHeight();
|
||||
adjustSdv(myHolder.mIvNavName, imageInfo.getWidth() * bl, imageInfo.getHeight() * bl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntermediateImageSet(String id, ImageInfo imageInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntermediateImageFailed(String id, Throwable throwable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String id, Throwable throwable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRelease(String id) {
|
||||
|
||||
}
|
||||
})
|
||||
.setUri(Uri.parse(imageUrl))
|
||||
.build();
|
||||
|
||||
myHolder.mIvNavName.setController(controller);
|
||||
});
|
||||
}
|
||||
|
||||
private void adjustSdv(SimpleDraweeView image, float width, float height) {
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) image.getLayoutParams();
|
||||
params.width = (int) width;
|
||||
params.height = (int) height;
|
||||
image.setLayoutParams(params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return ListUtils.isEmpty(mGroupNavDataList) ? 0 : mGroupNavDataList.size();
|
||||
}
|
||||
|
||||
public static class SubNavViewHolder extends RecyclerView.ViewHolder {
|
||||
private final TextView mTvNavName;
|
||||
|
||||
private final ImageView mIvNavLine;
|
||||
|
||||
private final PkSimpleDraweeView mIvNavName;
|
||||
|
||||
private final RelativeLayout navAll;
|
||||
private final RelativeLayout nav_tv_rl;
|
||||
|
||||
public SubNavViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mTvNavName = itemView.findViewById(R.id.id_tv_nav_name);
|
||||
nav_tv_rl = itemView.findViewById(R.id.nav_tv_rl);
|
||||
mIvNavName = itemView.findViewById(R.id.id_iv_nav_name);
|
||||
mIvNavLine = itemView.findViewById(R.id.id_iv_nav_line);
|
||||
navAll = itemView.findViewById(R.id.id_sub_nav_all);
|
||||
}
|
||||
}
|
||||
}
|
||||
143
app/src/main/java/com/pukka/jiecheng/index/adapter/IndexMyCollectAdapter.java
Executable file
143
app/src/main/java/com/pukka/jiecheng/index/adapter/IndexMyCollectAdapter.java
Executable file
@@ -0,0 +1,143 @@
|
||||
package com.pukka.jiecheng.index.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ScrollView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.migu.bean.GetlistcollBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.index.fragment.MyFragment;
|
||||
import com.pukka.jiecheng.utils.TopStyleUtils;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
import com.pukka.libcore.utils.ScreenUtil;
|
||||
import com.pukka.libcore.utils.StringUtils;
|
||||
import com.pukka.libcore.widget.AlwaysMarqueeTextView;
|
||||
|
||||
|
||||
/**
|
||||
* Author: yxy
|
||||
* Date: 2023/3/22 10:20
|
||||
* Description:首页我的页面历史记录
|
||||
*/
|
||||
public class IndexMyCollectAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements View.OnFocusChangeListener {
|
||||
public static final String TAG = "IndexMyCollectAdapter";
|
||||
private GetlistcollBean mGetlistCollBean;
|
||||
private final Context mContext;
|
||||
private OnItemClickListener mOnItemClickListener;
|
||||
|
||||
private final ScrollView scrollView;
|
||||
|
||||
public IndexMyCollectAdapter(Context mContext, GetlistcollBean getlistcollBean, ScrollView scrollView) {
|
||||
this.mContext = mContext;
|
||||
this.mGetlistCollBean = getlistcollBean;
|
||||
this.scrollView = scrollView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
*
|
||||
* @param getlistcollBean
|
||||
*/
|
||||
public void updateData(GetlistcollBean getlistcollBean) {
|
||||
int oldCount = getItemCount();
|
||||
this.mGetlistCollBean = getlistcollBean;
|
||||
int newCount = getItemCount();
|
||||
if (newCount > oldCount) {
|
||||
notifyItemRangeInserted(0, newCount - oldCount);
|
||||
} else if (oldCount > newCount) {
|
||||
notifyItemRangeRemoved(0, oldCount - newCount);
|
||||
}
|
||||
notifyItemRangeChanged(0, newCount);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_my_collect, parent, false);
|
||||
return new CollectHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
|
||||
if (null != mGetlistCollBean) {
|
||||
CollectHolder collectHolder = (CollectHolder) holder;
|
||||
collectHolder.itemView.setOnFocusChangeListener(this);
|
||||
//判断是否设置了监听器
|
||||
if (mOnItemClickListener != null) {
|
||||
//为ItemView设置监听器
|
||||
collectHolder.itemView.setOnClickListener(v -> {
|
||||
int position1 = collectHolder.getLayoutPosition(); // 1
|
||||
mOnItemClickListener.onItemClick(collectHolder.itemView, position1); // 2
|
||||
});
|
||||
}
|
||||
try {
|
||||
String imgUrl = mGetlistCollBean.getResult().get(position).getMidimg();
|
||||
if (StringUtils.isEmpty(imgUrl)) {
|
||||
imgUrl = mGetlistCollBean.getResult().get(position).getMidimg2();
|
||||
}
|
||||
collectHolder.mIvCollect.setImageURI(imgUrl);
|
||||
collectHolder.mTvCollectName.setText(mGetlistCollBean.getResult().get(position).getContentname());
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (null != mGetlistCollBean) {
|
||||
int size = mGetlistCollBean.getResult().size();
|
||||
return Math.min(size, 5);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean b) {
|
||||
AlwaysMarqueeTextView textView = view.findViewById(R.id.id_tv_collect_name);
|
||||
if (b) {
|
||||
textView.setTextColor(ContextCompat.getColor(mContext, R.color.index_nav_text_focus));
|
||||
textView.setEllipsize(TextUtils.TruncateAt.valueOf("MARQUEE"));
|
||||
scrollView.smoothScrollTo(0, MyFragment.getRvCollect().getTop() + (int) mContext.getResources().getDimension(R.dimen.qb_px_260));
|
||||
} else {
|
||||
textView.setTextColor(ContextCompat.getColor(mContext, R.color.my_history_text_color));
|
||||
textView.setEllipsize(TextUtils.TruncateAt.valueOf("END"));
|
||||
}
|
||||
TopStyleUtils.topImageChange(view, b);
|
||||
}
|
||||
|
||||
|
||||
public static class CollectHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
AlwaysMarqueeTextView mTvCollectName;
|
||||
PkSimpleDraweeView mIvCollect;
|
||||
|
||||
public CollectHolder(View itemView) {
|
||||
super(itemView);
|
||||
mTvCollectName = itemView.findViewById(R.id.id_tv_collect_name);
|
||||
mIvCollect = itemView.findViewById(R.id.id_iv_collect);
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener mOnItemClickListener) {
|
||||
this.mOnItemClickListener = mOnItemClickListener;
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(View view, int position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||
super.onDetachedFromRecyclerView(recyclerView);
|
||||
mGetlistCollBean = null;
|
||||
mOnItemClickListener = null;
|
||||
}
|
||||
}
|
||||
178
app/src/main/java/com/pukka/jiecheng/index/adapter/IndexMyHistoryAdapter.java
Executable file
178
app/src/main/java/com/pukka/jiecheng/index/adapter/IndexMyHistoryAdapter.java
Executable file
@@ -0,0 +1,178 @@
|
||||
package com.pukka.jiecheng.index.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.migu.bean.GetFindPlayrecordBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.index.fragment.MyFragment;
|
||||
import com.pukka.jiecheng.utils.TopStyleUtils;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
import com.pukka.libcore.utils.DateUtils;
|
||||
import com.pukka.libcore.utils.StringUtils;
|
||||
import com.pukka.libcore.widget.AlwaysMarqueeTextView;
|
||||
|
||||
|
||||
/**
|
||||
* Author: wxf
|
||||
* Date: 2023/3/13 16:40
|
||||
* Description:首页我的页面历史记录
|
||||
*/
|
||||
public class IndexMyHistoryAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements View.OnFocusChangeListener {
|
||||
public static final String TAG = "IndexMyHistoryAdapter";
|
||||
private GetFindPlayrecordBean mGetFindPlayrecordBean;
|
||||
private final Context mContext;
|
||||
private OnItemClickListener mOnItemClickListener;
|
||||
|
||||
private final ScrollView scrollView;
|
||||
|
||||
public IndexMyHistoryAdapter(Context mContext, GetFindPlayrecordBean getFindPlayrecordBean, ScrollView scrollView) {
|
||||
this.mContext = mContext;
|
||||
this.mGetFindPlayrecordBean = getFindPlayrecordBean;
|
||||
this.scrollView = scrollView;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新数据
|
||||
*
|
||||
* @param getFindPlayrecordBean
|
||||
*/
|
||||
public void updateData(GetFindPlayrecordBean getFindPlayrecordBean) {
|
||||
int oldCount = getItemCount();
|
||||
this.mGetFindPlayrecordBean = getFindPlayrecordBean;
|
||||
int newCount = getItemCount();
|
||||
if (newCount > oldCount) {
|
||||
notifyItemRangeInserted(0, newCount - oldCount);
|
||||
} else if (oldCount > newCount) {
|
||||
notifyItemRangeRemoved(0, oldCount - newCount);
|
||||
}
|
||||
notifyItemRangeChanged(0, newCount);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_my_history, parent, false);
|
||||
return new HistoryHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
|
||||
if (null != mGetFindPlayrecordBean) {
|
||||
HistoryHolder historyHolder = (HistoryHolder) holder;
|
||||
historyHolder.itemView.setOnFocusChangeListener(this);
|
||||
//判断是否设置了监听器
|
||||
if (mOnItemClickListener != null) {
|
||||
//为ItemView设置监听器
|
||||
historyHolder.itemView.setOnClickListener(v -> {
|
||||
int position1 = historyHolder.getLayoutPosition(); // 1
|
||||
mOnItemClickListener.onItemClick(historyHolder.itemView, position1, mGetFindPlayrecordBean); // 2
|
||||
});
|
||||
}
|
||||
try {
|
||||
String imgUrl = mGetFindPlayrecordBean.getData().get(position).getMidimg();
|
||||
if (StringUtils.isEmpty(imgUrl)) {
|
||||
imgUrl = mGetFindPlayrecordBean.getData().get(position).getMidimg2();
|
||||
}
|
||||
historyHolder.mIvHistory.setImageURI(imgUrl);
|
||||
historyHolder.mTvHistoryName.setText(mGetFindPlayrecordBean.getData().get(position).getContentname());
|
||||
//episodeindex
|
||||
int contentType = mGetFindPlayrecordBean.getData().get(position).getContenttype();
|
||||
if (contentType == 2) {
|
||||
int inx = mGetFindPlayrecordBean.getData().get(position).getEpisodeindex();
|
||||
historyHolder.mTvHistoryInfo.setText("播放至第" + inx + (mGetFindPlayrecordBean.getData().get(position).getCategoryname().equals("综艺") ? " 期" : " 集"));
|
||||
} else {
|
||||
int time = mGetFindPlayrecordBean.getData().get(position).getPlaylong();
|
||||
String tip = "观看至" + DateUtils.secToTime(time / 1000);
|
||||
if (time == 0) {
|
||||
tip = "已观看完毕";
|
||||
}
|
||||
historyHolder.mTvHistoryInfo.setText(tip);
|
||||
}
|
||||
// long playLong1 = Math.max(playLong / (60 * 1000), 1);
|
||||
// String str = "观看至" + playLong1 + "分钟";
|
||||
// historyHolder.mTvHistoryInfo.setText(str);
|
||||
// historyHolder.mIvMask.setVisibility(View.VISIBLE);
|
||||
// float temp = ((float) playLong / (mGetFindPlayrecordBean.getData().get(position).getDuration() * 60 * 1000));
|
||||
// int temp2 = (int) (temp * 100);
|
||||
// //进度条
|
||||
// historyHolder.mSeekBar.setProgress((int) temp2);
|
||||
historyHolder.mSeekBar.setVisibility(View.GONE);
|
||||
//蒙层隐藏
|
||||
historyHolder.mIvMask.setVisibility(View.GONE);
|
||||
|
||||
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (null != mGetFindPlayrecordBean) {
|
||||
int size = mGetFindPlayrecordBean.getData().size();
|
||||
return Math.min(size, 5);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean b) {
|
||||
AlwaysMarqueeTextView textView = view.findViewById(R.id.id_tv_history_name);
|
||||
if (b) {
|
||||
textView.setTextColor(ContextCompat.getColor(mContext, R.color.index_nav_text_focus));
|
||||
textView.setEllipsize(TextUtils.TruncateAt.valueOf("MARQUEE"));
|
||||
int topValue = MyFragment.getRvHistory().getHeight() + MyFragment.getRvCollect().getHeight() + (int) mContext.getResources().getDimension(R.dimen.qb_px_140);
|
||||
scrollView.smoothScrollTo(0, topValue);
|
||||
} else {
|
||||
textView.setTextColor(ContextCompat.getColor(mContext, R.color.my_history_text_color));
|
||||
textView.setEllipsize(TextUtils.TruncateAt.valueOf("END"));
|
||||
}
|
||||
TopStyleUtils.topImageChange(view, b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||
super.onDetachedFromRecyclerView(recyclerView);
|
||||
mGetFindPlayrecordBean = null;
|
||||
mOnItemClickListener = null;
|
||||
}
|
||||
|
||||
public static class HistoryHolder extends RecyclerView.ViewHolder {
|
||||
TextView mTvHistoryInfo;
|
||||
AlwaysMarqueeTextView mTvHistoryName;
|
||||
PkSimpleDraweeView mIvHistory, mIvMask;
|
||||
SeekBar mSeekBar;
|
||||
|
||||
public HistoryHolder(View itemView) {
|
||||
super(itemView);
|
||||
mTvHistoryName = itemView.findViewById(R.id.id_tv_history_name);
|
||||
mTvHistoryInfo = itemView.findViewById(R.id.id_tv_history_info);
|
||||
mIvHistory = itemView.findViewById(R.id.id_iv_history);
|
||||
mSeekBar = itemView.findViewById(R.id.id_seekBar);
|
||||
mIvMask = itemView.findViewById(R.id.id_iv_mask);
|
||||
mIvMask.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener mOnItemClickListener) {
|
||||
this.mOnItemClickListener = mOnItemClickListener;
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(View view, int position, GetFindPlayrecordBean mGetFindPlayrecordBean);
|
||||
}
|
||||
|
||||
}
|
||||
102
app/src/main/java/com/pukka/jiecheng/index/adapter/IndexMySetMoreAdapter.java
Executable file
102
app/src/main/java/com/pukka/jiecheng/index/adapter/IndexMySetMoreAdapter.java
Executable file
@@ -0,0 +1,102 @@
|
||||
package com.pukka.jiecheng.index.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.migu.bean.GetLayoutBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.index.fragment.MyFragment;
|
||||
import com.pukka.jiecheng.utils.TopStyleUtils;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
|
||||
/**
|
||||
* Author: wxf
|
||||
* Date: 2023/3/13 13:22
|
||||
* Description:首页我的页面设置更多
|
||||
*/
|
||||
public class IndexMySetMoreAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
public static final String TAG = "IndexMySetMoreAdapter";
|
||||
private final GetLayoutBean.DataBean mSettingData;
|
||||
private final Context mContext;
|
||||
private OnItemClickListener mOnItemClickListener;
|
||||
|
||||
private final ScrollView scrollView;
|
||||
|
||||
public IndexMySetMoreAdapter(Context mContext, GetLayoutBean.DataBean settingData, ScrollView scrollView) {
|
||||
this.mContext = mContext;
|
||||
this.mSettingData = settingData;
|
||||
this.scrollView = scrollView;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_my_set_more, parent, false);
|
||||
return new SetMoreViewHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, @SuppressLint("RecyclerView") int position) {
|
||||
if (null != mSettingData) {
|
||||
SetMoreViewHolder setMoreViewHolder = (SetMoreViewHolder) holder;
|
||||
//判断是否设置了监听器
|
||||
if (mOnItemClickListener != null) {
|
||||
//为ItemView设置监听器
|
||||
setMoreViewHolder.itemView.setOnClickListener(v -> {
|
||||
int position1 = setMoreViewHolder.getLayoutPosition(); // 1
|
||||
mOnItemClickListener.onItemClick(setMoreViewHolder.itemView, position1); // 2
|
||||
});
|
||||
}
|
||||
setMoreViewHolder.mIvSetMore.setImageURI(mSettingData.getExtraData().get(position).getImage());
|
||||
setMoreViewHolder.mTvSetMore.setText(mSettingData.getExtraData().get(position).getName().trim());
|
||||
setMoreViewHolder.itemView.setOnFocusChangeListener((view, b) -> {
|
||||
if (b) {
|
||||
setMoreViewHolder.mIvSetMore.setImageURI(mSettingData.getExtraData().get(position).getFocusImage());
|
||||
setMoreViewHolder.mTvSetMore.setTextColor(ContextCompat.getColor(mContext, R.color.index_nav_text_focus));
|
||||
// //int topValue = MyFragment.getRvMore().getTop();
|
||||
// scrollView.smoothScrollTo(0, topValue + 200);
|
||||
} else {
|
||||
setMoreViewHolder.mIvSetMore.setImageURI(mSettingData.getExtraData().get(position).getImage());
|
||||
setMoreViewHolder.mTvSetMore.setTextColor(ContextCompat.getColor(mContext, R.color.white20));
|
||||
}
|
||||
TopStyleUtils.topImageChange(view, b);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if (null != mSettingData) {
|
||||
return mSettingData.getExtraData().size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static class SetMoreViewHolder extends RecyclerView.ViewHolder {
|
||||
TextView mTvSetMore;
|
||||
PkSimpleDraweeView mIvSetMore;
|
||||
|
||||
public SetMoreViewHolder(View itemView) {
|
||||
super(itemView);
|
||||
mTvSetMore = itemView.findViewById(R.id.id_tv_set_more);
|
||||
mIvSetMore = itemView.findViewById(R.id.id_iv_set_more);
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener mOnItemClickListener) {
|
||||
this.mOnItemClickListener = mOnItemClickListener;
|
||||
}
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(View view, int position);
|
||||
}
|
||||
|
||||
}
|
||||
285
app/src/main/java/com/pukka/jiecheng/index/adapter/IndexNavAdapter.java
Executable file
285
app/src/main/java/com/pukka/jiecheng/index/adapter/IndexNavAdapter.java
Executable file
@@ -0,0 +1,285 @@
|
||||
|
||||
package com.pukka.jiecheng.index.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.migu.bean.GetLayoutNavBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.index.adapter.interfaces.OnNavidListener;
|
||||
import com.pukka.jiecheng.index.adapter.viewholder.GroupNavViewHolder;
|
||||
import com.pukka.jiecheng.index.adapter.viewholder.NavViewHolder;
|
||||
import com.pukka.jiecheng.index.bean.MyIndexBean;
|
||||
import com.pukka.jiecheng.index.bean.NavFocusBean;
|
||||
import com.pukka.jiecheng.index.viewmodel.NavViewModel;
|
||||
import com.pukka.libcore.utils.ListUtils;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* [新版首页顶部导航列表适配器]<BR>
|
||||
*
|
||||
* @author wcg
|
||||
* @version [V0.1.0.1, 2023/11/24 0024]
|
||||
* @since V0.1.0.1
|
||||
*/
|
||||
public class IndexNavAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
|
||||
private static final Object PAYLOAD_SELECTION = new Object();
|
||||
/**
|
||||
* 单Item类型
|
||||
*/
|
||||
private static final int SINGLE_ITEM = 0;
|
||||
|
||||
/**
|
||||
* 分组Item类型
|
||||
*/
|
||||
private static final int GROUP_ITEM = 1;
|
||||
|
||||
private int viewType;
|
||||
|
||||
private List<GetLayoutNavBean.DataBean> mLayoutNavList = new ArrayList<>();
|
||||
|
||||
private OnNavidListener mOnNavidListener;
|
||||
|
||||
private NavViewModel mNavViewModel;
|
||||
private Context mContext;
|
||||
private int selectedPosition = RecyclerView.NO_POSITION;
|
||||
|
||||
public IndexNavAdapter(Context context) {
|
||||
this.mContext = context;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void setLayoutNavList(List<GetLayoutNavBean.DataBean> layoutNavList) {
|
||||
this.mLayoutNavList = layoutNavList;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setSelectedPosition(int position) {
|
||||
if (position < 0 || position >= getItemCount()) {
|
||||
return;
|
||||
}
|
||||
if (selectedPosition == position) {
|
||||
notifyItemChanged(position, PAYLOAD_SELECTION);
|
||||
return;
|
||||
}
|
||||
int oldPosition = selectedPosition;
|
||||
selectedPosition = position;
|
||||
if (oldPosition != RecyclerView.NO_POSITION) {
|
||||
notifyItemChanged(oldPosition, PAYLOAD_SELECTION);
|
||||
}
|
||||
notifyItemChanged(selectedPosition, PAYLOAD_SELECTION);
|
||||
}
|
||||
|
||||
public int getSelectedPosition() {
|
||||
return selectedPosition;
|
||||
}
|
||||
|
||||
public int findPositionByNavType(int navType) {
|
||||
if (ListUtils.isEmpty(mLayoutNavList)) {
|
||||
return RecyclerView.NO_POSITION;
|
||||
}
|
||||
int size = mLayoutNavList.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
List<GetLayoutNavBean.DataBean.SubNavDataBean> navList = mLayoutNavList.get(i).getNavList();
|
||||
if (ListUtils.isEmpty(navList)) {
|
||||
continue;
|
||||
}
|
||||
int subSize = navList.size();
|
||||
for (int j = 0; j < subSize; j++) {
|
||||
GetLayoutNavBean.DataBean.SubNavDataBean navBean = navList.get(j);
|
||||
if (navBean != null && navBean.getType() == navType) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return RecyclerView.NO_POSITION;
|
||||
}
|
||||
|
||||
public int findPositionByNavId(String navId) {
|
||||
if (TextUtils.isEmpty(navId) || ListUtils.isEmpty(mLayoutNavList)) {
|
||||
return RecyclerView.NO_POSITION;
|
||||
}
|
||||
int size = mLayoutNavList.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
List<GetLayoutNavBean.DataBean.SubNavDataBean> navList = mLayoutNavList.get(i).getNavList();
|
||||
if (ListUtils.isEmpty(navList)) {
|
||||
continue;
|
||||
}
|
||||
int subSize = navList.size();
|
||||
for (int j = 0; j < subSize; j++) {
|
||||
GetLayoutNavBean.DataBean.SubNavDataBean navBean = navList.get(j);
|
||||
if (navBean != null && TextUtils.equals(navId, navBean.getNavid())) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
}
|
||||
return RecyclerView.NO_POSITION;
|
||||
}
|
||||
|
||||
public void setOnNavidListener(OnNavidListener onNavidListener) {
|
||||
this.mOnNavidListener = onNavidListener;
|
||||
}
|
||||
|
||||
public void setNavViewModel(NavViewModel navViewModel) {
|
||||
this.mNavViewModel = navViewModel;
|
||||
}
|
||||
|
||||
@SuppressLint("InflateParams")
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
if (viewType == GROUP_ITEM) {
|
||||
View itemNavGroup = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_nav_group, null);
|
||||
return new GroupNavViewHolder(itemNavGroup, mOnNavidListener, mNavViewModel);
|
||||
}
|
||||
|
||||
View itemNavSingle = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_nav, null);
|
||||
return new NavViewHolder(mContext, itemNavSingle, mOnNavidListener, mNavViewModel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
boolean isSelected = selectedPosition == position;
|
||||
if (viewType == GROUP_ITEM) {
|
||||
GroupNavViewHolder navGroupViewHolder = (GroupNavViewHolder) holder;
|
||||
navGroupViewHolder.bindGroupData(position, mLayoutNavList.get(position).getNavList(),
|
||||
mLayoutNavList.get(position).getNavColor(), mLayoutNavList.get(position).getCornerUrl());
|
||||
} else {
|
||||
NavViewHolder navViewHolder = (NavViewHolder) holder;
|
||||
navViewHolder.bindData(mLayoutNavList.get(position).getNavList(), position, isSelected);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position, @NonNull List<Object> payloads) {
|
||||
if (!payloads.isEmpty()) {
|
||||
onBindViewHolder(holder, position);
|
||||
return;
|
||||
}
|
||||
super.onBindViewHolder(holder, position, payloads);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return !ListUtils.isEmpty(mLayoutNavList) ? mLayoutNavList.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
viewType = TextUtils.isEmpty(mLayoutNavList.get(position).getNavColor())
|
||||
&& TextUtils.isEmpty(mLayoutNavList.get(position).getCornerUrl())
|
||||
&& mLayoutNavList.get(position).getNavList().size() == 1 ? SINGLE_ITEM : GROUP_ITEM;
|
||||
return viewType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导航默认焦点索引:优先找到名称包含「电影」的 Tab;找不到回退到第 0 个。
|
||||
*
|
||||
* @param mediaId 不为空时,焦点落焦到mediaId上(本次未改动逻辑)
|
||||
* @return NavFocusBean
|
||||
*/
|
||||
public NavFocusBean getFistFocusIndex(String mediaId) {
|
||||
NavFocusBean firstFocusBean = new NavFocusBean();
|
||||
int targetIndex = 0;
|
||||
int targetIndexSub = -1;
|
||||
boolean found = false;
|
||||
if (null != mLayoutNavList && !mLayoutNavList.isEmpty()) {
|
||||
int size = mLayoutNavList.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
GetLayoutNavBean.DataBean bean = mLayoutNavList.get(i);
|
||||
List<GetLayoutNavBean.DataBean.SubNavDataBean> subList = bean.getNavList();
|
||||
if (ListUtils.isEmpty(subList)) continue;
|
||||
boolean isSingle = TextUtils.isEmpty(bean.getNavColor())
|
||||
&& TextUtils.isEmpty(bean.getCornerUrl())
|
||||
&& subList.size() == 1;
|
||||
if (isSingle) {
|
||||
String navName = subList.get(0).getNavname();
|
||||
if (navName != null && navName.contains("电影")) {
|
||||
targetIndex = i;
|
||||
targetIndexSub = -1;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
int subSize = subList.size();
|
||||
for (int j = 0; j < subSize; j++) {
|
||||
GetLayoutNavBean.DataBean.SubNavDataBean subBean = subList.get(j);
|
||||
String navName = subBean.getNavname();
|
||||
if (navName != null && navName.contains("电影")) {
|
||||
targetIndex = i;
|
||||
targetIndexSub = j;
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found) break;
|
||||
}
|
||||
}
|
||||
// 兜底:找不到「电影」回退到 0(列表至少有一个,否则进不来外层 if)
|
||||
if (!found) {
|
||||
targetIndex = 0;
|
||||
targetIndexSub = -1;
|
||||
}
|
||||
}
|
||||
|
||||
firstFocusBean.setIndex(targetIndex);
|
||||
firstFocusBean.setIndexSub(targetIndexSub);
|
||||
if (null != mNavViewModel && null != mNavViewModel.defaultFocusIndex.getValue()) {
|
||||
mNavViewModel.defaultFocusIndex.getValue().setDefaultIndex(targetIndex);
|
||||
mNavViewModel.defaultFocusIndex.getValue().setDefaultIndexSub(targetIndexSub);
|
||||
}
|
||||
return firstFocusBean;
|
||||
}
|
||||
|
||||
private void logDefaultFocusIndex() {
|
||||
if (null != mNavViewModel.defaultFocusIndex.getValue()) {
|
||||
LogUtils.d("wcg, defaultFocusIndex:" + mNavViewModel.defaultFocusIndex.getValue().getDefaultIndex()
|
||||
+ " defaultFocusIndexSub: " + mNavViewModel.defaultFocusIndex.getValue().getDefaultIndexSub());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取导航文字匹配的索引
|
||||
*
|
||||
* @param text text
|
||||
* @return NavFocusBean
|
||||
*/
|
||||
public NavFocusBean getIndexByText(String text) {
|
||||
NavFocusBean navFocusBean = new NavFocusBean();
|
||||
if (null != mLayoutNavList && !mLayoutNavList.isEmpty() && null != mNavViewModel.resideIndex.getValue()) {
|
||||
int size = mLayoutNavList.size();
|
||||
for (int i = 0; i < size; i++) {
|
||||
List<GetLayoutNavBean.DataBean.SubNavDataBean> subNavDataBeanList = mLayoutNavList.get(i).getNavList();
|
||||
if (TextUtils.isEmpty(mLayoutNavList.get(i).getNavColor())
|
||||
&& TextUtils.isEmpty(mLayoutNavList.get(i).getCornerUrl()) && subNavDataBeanList.size() == 1) {
|
||||
String navName = mLayoutNavList.get(i).getNavList().get(0).getNavname();
|
||||
if (navName.equals(text)) {
|
||||
navFocusBean.setIndex(i);
|
||||
navFocusBean.setIndexSub(-1);
|
||||
}
|
||||
} else {
|
||||
int subNavSize = subNavDataBeanList.size();
|
||||
for (int j = 0; j < subNavSize; j++) {
|
||||
GetLayoutNavBean.DataBean.SubNavDataBean subNavDataBean = subNavDataBeanList.get(j);
|
||||
String navName = subNavDataBean.getNavname();
|
||||
if (navName.equals(text)) {
|
||||
navFocusBean.setIndex(i);
|
||||
navFocusBean.setIndexSub(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return navFocusBean;
|
||||
}
|
||||
|
||||
}
|
||||
502
app/src/main/java/com/pukka/jiecheng/index/adapter/MatchListAdapter.java
Executable file
502
app/src/main/java/com/pukka/jiecheng/index/adapter/MatchListAdapter.java
Executable file
@@ -0,0 +1,502 @@
|
||||
|
||||
package com.pukka.jiecheng.index.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Animatable;
|
||||
import android.net.Uri;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.facebook.drawee.controller.ControllerListener;
|
||||
import com.facebook.drawee.interfaces.DraweeController;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.facebook.imagepipeline.image.ImageInfo;
|
||||
import com.migu.bean.GetGameSeasonInfoRecommendBean;
|
||||
import com.migu.bean.GetLayoutBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.index.IndexConstant;
|
||||
import com.pukka.jiecheng.utils.TopStyleUtils;
|
||||
import com.pukka.jiecheng.utils.UiUtils;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
import com.pukka.libcore.utils.DateUtils;
|
||||
import com.pukka.libcore.utils.ListUtils;
|
||||
import com.pukka.libcore.utils.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class MatchListAdapter extends RecyclerView.Adapter<MatchListAdapter.ItemHolder> {
|
||||
private String gameId = "";
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
private List<GetGameSeasonInfoRecommendBean.ResultEntity> matchList = new ArrayList<>();
|
||||
|
||||
private String mTime;
|
||||
|
||||
private long timerTime = 0;
|
||||
|
||||
/**
|
||||
* 点击推荐位埋点用到
|
||||
*/
|
||||
private GetLayoutBean.DataBean floor;
|
||||
|
||||
private GetLayoutBean.DataBean.ExtraDataBean currentExtraDataBean;
|
||||
|
||||
private Handler handler = new Handler(Looper.getMainLooper());
|
||||
|
||||
public MatchListAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void setData(GetLayoutBean.DataBean floor, String gameId, GetLayoutBean.DataBean.ExtraDataBean currentExtraDataBean) {
|
||||
this.floor = floor;
|
||||
this.gameId = gameId;
|
||||
this.currentExtraDataBean = currentExtraDataBean;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
public void setMatchList(List<GetGameSeasonInfoRecommendBean.ResultEntity> resultList, String time) {
|
||||
if (!ListUtils.isEmpty(resultList)) {
|
||||
this.matchList = resultList;
|
||||
}
|
||||
this.mTime = time;
|
||||
changeStatus(0);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public ItemHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_match_list, parent, false);
|
||||
return new ItemHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ItemHolder itemHolder, int position) {
|
||||
String status = "";
|
||||
try {
|
||||
GetGameSeasonInfoRecommendBean.ResultEntity resultEntity = matchList.get(position);
|
||||
if (TextUtils.equals("1", resultEntity.getShowType())
|
||||
|| TextUtils.equals("2", resultEntity.getShowType())) {
|
||||
itemHolder.allLeft.setVisibility(View.VISIBLE);
|
||||
itemHolder.matchItemBig.setBackground(AppCompatResources.getDrawable(mContext, R.color.transparent));
|
||||
itemHolder.matchItem.setVisibility(View.GONE);
|
||||
itemHolder.mIvVip.setVisibility(View.GONE);
|
||||
} else {
|
||||
status = IndexConstant.matchStatus(resultEntity, this.mTime, timerTime);
|
||||
bindShowType2Data(itemHolder, resultEntity, status);
|
||||
}
|
||||
|
||||
setFocusChangeListener(itemHolder, resultEntity);
|
||||
setItemViewClickListener(itemHolder, resultEntity, status, position);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setFocusChangeListener(@NonNull ItemHolder itemHolder,
|
||||
GetGameSeasonInfoRecommendBean.ResultEntity resultEntity) {
|
||||
itemHolder.itemView.setOnFocusChangeListener((view, hasFocus) -> {
|
||||
if (TextUtils.equals("1", resultEntity.getShowType())
|
||||
|| TextUtils.equals("2", resultEntity.getShowType())) {
|
||||
itemHolder.allLeft.setBackground(
|
||||
AppCompatResources.getDrawable(mContext, hasFocus ? R.mipmap.all_game_foc : R.mipmap.all_game_nor));
|
||||
} else {
|
||||
itemHolder.mTvLeftName.setTextColor(ContextCompat.getColor(mContext,
|
||||
hasFocus ? R.color.index_top_text_focus : R.color.white));
|
||||
itemHolder.mTvGameName.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.white4));
|
||||
itemHolder.mTvGameTime.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.white4));
|
||||
itemHolder.mTvRightName.setTextColor(ContextCompat.getColor(mContext,
|
||||
hasFocus ? R.color.index_top_text_focus : R.color.white));
|
||||
itemHolder.mTvScore.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.white));
|
||||
|
||||
itemHolder.mTvScore.setSelected(hasFocus);
|
||||
itemHolder.mTvRightName.setSelected(hasFocus);
|
||||
itemHolder.mTvLeftName.setSelected(hasFocus);
|
||||
itemHolder.mTvGameName.setSelected(hasFocus);
|
||||
itemHolder.mTvGameTime.setSelected(hasFocus);
|
||||
|
||||
itemHolder.mTvScore.setEllipsize(hasFocus ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END);
|
||||
itemHolder.mTvRightName
|
||||
.setEllipsize(hasFocus ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END);
|
||||
itemHolder.mTvLeftName.setEllipsize(hasFocus ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END);
|
||||
itemHolder.mTvGameName.setEllipsize(hasFocus ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END);
|
||||
itemHolder.mTvGameTime.setEllipsize(hasFocus ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END);
|
||||
// 非直播中按钮颜色需要变化 直播中的不变
|
||||
if (!"直播中".contentEquals(itemHolder.mTvStatus.getText())) {
|
||||
itemHolder.mTvStatus.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.white));
|
||||
itemHolder.mTvStatus.setBackground(AppCompatResources.getDrawable(mContext,
|
||||
hasFocus ? R.drawable.common_matchtext_bg_focus : R.drawable.common_matchtext_bg_unfocus));
|
||||
}
|
||||
}
|
||||
TopStyleUtils.topImageChange(view, hasFocus);
|
||||
|
||||
|
||||
// 单名称时 UI样式调整
|
||||
if (resultEntity.getDualed() != 1) {
|
||||
int paddingValueScore =
|
||||
itemHolder.mTvScore.getContext().getResources().getDimensionPixelSize(R.dimen.qb_px_8);
|
||||
if (hasFocus) {
|
||||
itemHolder.mTvScore.setPadding(0, 0, 0, 0);
|
||||
} else {
|
||||
itemHolder.mTvScore.setPadding(paddingValueScore, 0, paddingValueScore, 0);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private void bindShowType2Data(ItemHolder itemHolder
|
||||
, GetGameSeasonInfoRecommendBean.ResultEntity resultEntity, String status) {
|
||||
itemHolder.allLeft.setVisibility(View.GONE);
|
||||
itemHolder.matchItemBig.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.match_list_selector_sport));
|
||||
itemHolder.matchItem.setVisibility(View.VISIBLE);
|
||||
//是否对抗类{0:否,1:是}
|
||||
if (resultEntity.getDualed() == 1) {
|
||||
itemHolder.mTvGameName.setVisibility(View.VISIBLE);
|
||||
itemHolder.mllRight.setVisibility(View.VISIBLE);
|
||||
itemHolder.mllLeft.setVisibility(View.VISIBLE);
|
||||
itemHolder.mTvGameName.setText(resultEntity.getGamename());
|
||||
String timeStr = null;
|
||||
try {
|
||||
timeStr = DateUtils.formatDate(resultEntity.getStarttimeString(), DateUtils.FORMAT_STYLE_1, "MM月dd日 HH:mm");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
itemHolder.mTvGameTime.setText(timeStr);
|
||||
itemHolder.mTvLeftName.setText(resultEntity.getHomeTeamName());
|
||||
itemHolder.mTvRightName.setText(resultEntity.getVisitingTeamName());
|
||||
loadTeamLogo(itemHolder, resultEntity);
|
||||
itemHolder.mTvScore.setText("VS");
|
||||
|
||||
if ("2".equals(status) || "3".equals(status) || "4".equals(status)) {
|
||||
String score = "VS";
|
||||
if (null != resultEntity.getHomeScore() && null != resultEntity.getVisitingScore()) {
|
||||
score = resultEntity.getHomeScore() + ":" + resultEntity.getVisitingScore();
|
||||
}
|
||||
if (null != resultEntity.getHomeScore() && null == resultEntity.getVisitingScore()) {
|
||||
score = resultEntity.getHomeScore() + ":0";
|
||||
}
|
||||
if (null == resultEntity.getHomeScore() && null != resultEntity.getVisitingScore()) {
|
||||
score = "0:" + resultEntity.getVisitingScore();
|
||||
}
|
||||
itemHolder.mTvScore.setPadding(0, 0, 0, 0);
|
||||
itemHolder.mTvScore.setText(score);
|
||||
}
|
||||
} else {
|
||||
int paddingValueScore =
|
||||
itemHolder.mTvScore.getContext().getResources().getDimensionPixelSize(R.dimen.qb_px_8);
|
||||
itemHolder.mTvScore.setPadding(paddingValueScore, 0, paddingValueScore, 0);
|
||||
itemHolder.mTvGameName.setVisibility(View.GONE);
|
||||
itemHolder.mllRight.setVisibility(View.GONE);
|
||||
itemHolder.mllLeft.setVisibility(View.GONE);
|
||||
itemHolder.mTvScore.setText(resultEntity.getName());
|
||||
|
||||
String timeStr = null;
|
||||
try {
|
||||
timeStr = DateUtils.formatDate(resultEntity.getStarttimeString(), DateUtils.FORMAT_STYLE_1, "MM月dd日 HH:mm");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
itemHolder.mTvGameTime.setText(timeStr);
|
||||
}
|
||||
|
||||
itemHolder.mTvStatus.setText(IndexConstant.getMatchStatus(status));
|
||||
// VIP角标
|
||||
setCornerMark(itemHolder.mIvVip, resultEntity.getCornerMarkPic());
|
||||
|
||||
// 直播中按钮颜色特殊处理
|
||||
if ("1".equals(status)) {
|
||||
itemHolder.mTvStatus.setTextColor(ContextCompat.getColor(mContext, R.color.white));
|
||||
itemHolder.mTvStatus
|
||||
.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.common_matchtextlive_bg_unfocus));
|
||||
} else {
|
||||
itemHolder.mTvStatus.setTextColor(ContextCompat.getColor(mContext, R.color.white));
|
||||
itemHolder.mTvStatus
|
||||
.setBackground(AppCompatResources.getDrawable(mContext, R.drawable.common_matchtext_bg_unfocus));
|
||||
}
|
||||
}
|
||||
|
||||
private void setItemViewClickListener(ItemHolder itemHolder, GetGameSeasonInfoRecommendBean.ResultEntity resultEntity
|
||||
, String status, int position) {
|
||||
String finalStatus = IndexConstant.getMatchStatus(status);
|
||||
itemHolder.itemView.setOnClickListener(v -> {
|
||||
if (TextUtils.equals("1", resultEntity.getShowType())
|
||||
|| TextUtils.equals("2", resultEntity.getShowType())) {
|
||||
addPagePositionClickEvent("all_schedule", "");
|
||||
if ("".equals(gameId)) {
|
||||
//ItemOnClickUtils.go2Epg(mContext, "", IndexConstant.getScheduleUrl(), "noparam", "");
|
||||
} else {
|
||||
String newGameId = "";
|
||||
// if (IndexConstant.getScheduleUrl().contains("schedule_new") ){
|
||||
// if (!TextUtils.isEmpty(currentExtraDataBean.getRemark())&& currentExtraDataBean.getRemark().contains("@@@")){
|
||||
// LogUtils.d("Remark: "+currentExtraDataBean.getRemark());
|
||||
// String[] split = currentExtraDataBean.getRemark().split("@@@");
|
||||
// if (split.length >=2){
|
||||
// newGameId = "?seniorId=" + split[0] + "&scheduleSubId=" + split[1];
|
||||
// } else if (split.length==1){
|
||||
// newGameId = "?seniorId=" + split[0];
|
||||
// }else {
|
||||
// newGameId = "?seniorId=";
|
||||
// }
|
||||
// }else {
|
||||
// newGameId = "?seniorId=";
|
||||
// }
|
||||
// }else {
|
||||
// newGameId = gameId;
|
||||
// }
|
||||
//ItemOnClickUtils.go2Epg(mContext, newGameId, IndexConstant.getScheduleUrl(), "list_with_gameId", "");
|
||||
}
|
||||
} else {
|
||||
if (matchList.get(position).getMatchstatus() < 3) {
|
||||
String gameParam = matchList.get(position).getId() + "&" + matchList.get(position).getGameid();
|
||||
String targetMgjsCode = matchList.get(position).getMgjscode();
|
||||
addPagePositionClickEvent("common", targetMgjsCode);
|
||||
//ItemOnClickUtils.go2Epg(mContext, gameParam, IndexConstant.getSportDetailUrl(), "sportDetail", "");
|
||||
} else {// 大于等于3的为特殊比赛情况 需要toast提示
|
||||
if (matchList.get(position).getMatchstatus() + 2 == 6
|
||||
|| matchList.get(position).getMatchstatus() + 2 == 8) {
|
||||
Toast.makeText(mContext, "该场比赛已" + finalStatus, Toast.LENGTH_SHORT).show();
|
||||
} else if (matchList.get(position).getMatchstatus() + 2 == 7) {
|
||||
Toast.makeText(mContext, "该场比赛已延期", Toast.LENGTH_SHORT).show();
|
||||
} else if (matchList.get(position).getMatchstatus() + 2 == 9) {
|
||||
Toast.makeText(mContext, "该场比赛主客队待确定", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(mContext, "该场比赛" + finalStatus, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadTeamLogo(ItemHolder itemHolder, GetGameSeasonInfoRecommendBean.ResultEntity resultEntity) {
|
||||
if (null == resultEntity) {
|
||||
return;
|
||||
}
|
||||
|
||||
itemHolder.mIvLeft.setImageURI(resultEntity.getHomeTeamlogo());
|
||||
itemHolder.mIvRight.setImageURI(resultEntity.getVisitingTeamlogo());
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置角标
|
||||
*
|
||||
* @param cornerMarkIv cornerMarkIv
|
||||
* @param cornerMarkUrl 角标地址
|
||||
*/
|
||||
private void setCornerMark(PkSimpleDraweeView cornerMarkIv, String cornerMarkUrl) {
|
||||
if (TextUtils.isEmpty(cornerMarkUrl)) {
|
||||
cornerMarkIv.setVisibility(View.INVISIBLE);
|
||||
return;
|
||||
}
|
||||
|
||||
DraweeController controller = Fresco.newDraweeControllerBuilder()
|
||||
.setOldController(cornerMarkIv.getController())
|
||||
.setControllerListener(new ControllerListener<ImageInfo>() {
|
||||
@Override
|
||||
public void onSubmit(String id, Object callerContext) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
|
||||
adjustSdv(cornerMarkIv, imageInfo.getWidth(), imageInfo.getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntermediateImageSet(String id, ImageInfo imageInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntermediateImageFailed(String id, Throwable throwable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String id, Throwable throwable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRelease(String id) {
|
||||
|
||||
}
|
||||
})
|
||||
.setUri(Uri.parse(cornerMarkUrl))
|
||||
.build();
|
||||
|
||||
cornerMarkIv.setController(controller);
|
||||
cornerMarkIv.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void adjustSdv(SimpleDraweeView image, int width, int height) {
|
||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) image.getLayoutParams();
|
||||
UiUtils.resetLayoutParams(mContext, width, height, UiUtils.POSITION_TYPE_SPORT_CARD, params);
|
||||
image.setLayoutParams(params);
|
||||
}
|
||||
|
||||
private void addPagePositionClickEvent(String actionType, String targetMGjsCode) {
|
||||
HashMap<String, String> map = new HashMap<>(16);
|
||||
map.put("actionType", actionType);
|
||||
if (floor != null) {
|
||||
map.put("blockIndex", String.valueOf(floor.getTitlecode()));
|
||||
map.put("blockName", floor.getTitle());
|
||||
}
|
||||
|
||||
if (currentExtraDataBean != null) {
|
||||
map.put("positionId", currentExtraDataBean.getPositionid());
|
||||
}
|
||||
map.put("targetProgramId", "");
|
||||
map.put("targetProgramName", "");
|
||||
if ("all_schedule".equals(actionType)) {
|
||||
map.put("targetPageType", "赛程页");
|
||||
map.put("targetPageId", "schedule");
|
||||
map.put("targetPageName", "赛程页_近期赛程");
|
||||
} else {
|
||||
map.put("targetPageType", "体育详情页");
|
||||
map.put("targetPageId", "sport_detail");
|
||||
map.put("targetPageName", "体育详情页");
|
||||
}
|
||||
if (!StringUtils.isEmpty(targetMGjsCode)) {
|
||||
map.put("targetMgjsCode", targetMGjsCode);
|
||||
map.put("targetMatchId", targetMGjsCode);
|
||||
}
|
||||
//AmberPoint.epgPagePositionClickEvent(map);
|
||||
}
|
||||
|
||||
private void changeStatus(long nextTime) {
|
||||
long time = refreshMatchTime(nextTime) + 5000;
|
||||
if (time > 10000) {
|
||||
handler.postDelayed(() -> {
|
||||
timerTime = timerTime + time;
|
||||
notifyDataSetChanged();
|
||||
changeStatus(time);
|
||||
}, time);
|
||||
}
|
||||
}
|
||||
|
||||
public void destroyHandler() {
|
||||
if (handler != null) {
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
handler = null;
|
||||
}
|
||||
}
|
||||
|
||||
private Long refreshMatchTime(long nextTime) {
|
||||
long time = 0;
|
||||
long starttime = 0;
|
||||
long beforetime = 0;
|
||||
long linuxtimeStemp = 0;
|
||||
String sTimeStr;
|
||||
|
||||
if (!TextUtils.isEmpty(this.mTime)) {
|
||||
linuxtimeStemp = DateUtils.stringDateToStamp(this.mTime, DateUtils.FORMAT_STYLE_1) + nextTime;
|
||||
}
|
||||
|
||||
if (!matchList.isEmpty()) {
|
||||
for (int i = 0; i < matchList.size(); i++) {
|
||||
sTimeStr = matchList.get(i).getStarttimeString();
|
||||
try {
|
||||
if (!TextUtils.isEmpty(sTimeStr)) {
|
||||
starttime = DateUtils.stringDateToStamp(matchList.get(i).getStarttimeString(), DateUtils.FORMAT_STYLE_1);
|
||||
}
|
||||
if (!TextUtils.isEmpty(matchList.get(i).getBeforetime())) {
|
||||
beforetime = Long.parseLong(matchList.get(i).getBeforetime()) * 60 * 1000;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (starttime - beforetime > linuxtimeStemp) {
|
||||
long temp = starttime - beforetime - linuxtimeStemp;
|
||||
// 这里给time赋最小值
|
||||
if (time == 0 || temp < time) {
|
||||
time = temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return time;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return null != matchList && !matchList.isEmpty() ? matchList.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
public static class ItemHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
TextView mTvGameName;
|
||||
|
||||
TextView mTvGameTime;
|
||||
|
||||
TextView mTvLeftName;
|
||||
|
||||
TextView mTvRightName;
|
||||
|
||||
TextView mTvStatus;
|
||||
|
||||
TextView mTvScore;
|
||||
|
||||
PkSimpleDraweeView mIvVip;
|
||||
|
||||
PkSimpleDraweeView mIvLeft;
|
||||
|
||||
PkSimpleDraweeView mIvRight;
|
||||
|
||||
private final LinearLayout mllRight;
|
||||
|
||||
private final LinearLayout mllLeft;
|
||||
|
||||
private final LinearLayout matchItem;
|
||||
|
||||
private final RelativeLayout allLeft;
|
||||
|
||||
private final FrameLayout matchItemBig;
|
||||
|
||||
ItemHolder(View itemView) {
|
||||
super(itemView);
|
||||
mTvGameName = itemView.findViewById(R.id.id_tv_gameName);
|
||||
mTvGameTime = itemView.findViewById(R.id.id_tv_gameTime);
|
||||
mIvLeft = itemView.findViewById(R.id.img_left_icon);
|
||||
mIvRight = itemView.findViewById(R.id.img_right_icon);
|
||||
mTvLeftName = itemView.findViewById(R.id.id_tv_leftName);
|
||||
mTvRightName = itemView.findViewById(R.id.id_tv_rightName);
|
||||
mTvStatus = itemView.findViewById(R.id.id_tv_status);
|
||||
mTvScore = itemView.findViewById(R.id.txt_score);
|
||||
mllRight = itemView.findViewById(R.id.ll_right);
|
||||
mllLeft = itemView.findViewById(R.id.ll_left);
|
||||
allLeft = itemView.findViewById(R.id.id_rl_left);
|
||||
matchItem = itemView.findViewById(R.id.matchListLv);
|
||||
matchItemBig = itemView.findViewById(R.id.matchListRv);
|
||||
mIvVip = itemView.findViewById(R.id.img_vip_icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
383
app/src/main/java/com/pukka/jiecheng/index/adapter/MatchListHorAdapter.java
Executable file
383
app/src/main/java/com/pukka/jiecheng/index/adapter/MatchListHorAdapter.java
Executable file
@@ -0,0 +1,383 @@
|
||||
|
||||
package com.pukka.jiecheng.index.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Animatable;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.facebook.drawee.controller.ControllerListener;
|
||||
import com.facebook.drawee.interfaces.DraweeController;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.facebook.imagepipeline.image.ImageInfo;
|
||||
import com.migu.bean.GetGameSeasonInfoRecommendBean;
|
||||
import com.migu.bean.GetLayoutBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.index.IndexConstant;
|
||||
import com.pukka.jiecheng.utils.TopStyleUtils;
|
||||
import com.pukka.jiecheng.utils.UiUtils;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
import com.pukka.libcore.utils.DateUtils;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
import com.pukka.libcore.utils.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class MatchListHorAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder>
|
||||
implements View.OnFocusChangeListener {
|
||||
private final Context mContext;
|
||||
|
||||
private List<GetGameSeasonInfoRecommendBean.ResultEntity> matchList = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 点击推荐位埋点用到
|
||||
*/
|
||||
private GetLayoutBean.DataBean currentFloor;
|
||||
|
||||
private GetLayoutBean.DataBean.ExtraDataBean currentExtraDataBean;
|
||||
|
||||
public MatchListHorAdapter(Context mContext) {
|
||||
this.mContext = mContext;
|
||||
}
|
||||
|
||||
public void setCurrentData(GetLayoutBean.DataBean currentFloor,
|
||||
GetLayoutBean.DataBean.ExtraDataBean currentExtraDataBean) {
|
||||
this.currentFloor = currentFloor;
|
||||
this.currentExtraDataBean = currentExtraDataBean;
|
||||
}
|
||||
|
||||
private String time;
|
||||
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
public void setMatchList(List<GetGameSeasonInfoRecommendBean.ResultEntity> resultList, String time) {
|
||||
LogUtils.d("notifyDataSetChanged matchList");
|
||||
if (resultList.size() > 3) {
|
||||
this.matchList = resultList.subList(0, 3);
|
||||
} else {
|
||||
this.matchList = resultList;
|
||||
}
|
||||
this.time = time;
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
LogUtils.d("hor onCreateViewHolder=");
|
||||
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
|
||||
View view = inflater.inflate(R.layout.item_match_list_hor, parent, false);
|
||||
return new ItemHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
|
||||
final ItemHolder itemHolder = (ItemHolder) holder;
|
||||
String status;
|
||||
LogUtils.d("hor onBindViewHolder=" + position);
|
||||
try {
|
||||
GetGameSeasonInfoRecommendBean.ResultEntity resultEntity = matchList.get(position);
|
||||
if (resultEntity.getDualed() == 1) {
|
||||
LogUtils.d("对抗类展示");
|
||||
status = bindPkData(position, itemHolder, resultEntity);
|
||||
} else {
|
||||
LogUtils.d("非对抗类展示");
|
||||
status = bindNoPkData(position, itemHolder);
|
||||
}
|
||||
|
||||
// VIP角标
|
||||
setCornerMark(itemHolder.mIvVip, resultEntity.getCornerUrl());
|
||||
|
||||
setListener(position, itemHolder, status);
|
||||
} catch (Exception ex) {
|
||||
LogUtils.d("onBindViewHolder=" + ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void setListener(int position, ItemHolder itemHolder, String status) {
|
||||
itemHolder.itemView.setOnFocusChangeListener((view, hasFocus) -> {
|
||||
LogUtils.d("recyview hasFocus =" + hasFocus);
|
||||
TopStyleUtils.topImageChange(view, hasFocus);
|
||||
itemHolder.mTvTeam1.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.index_nav_text_nor));
|
||||
itemHolder.mTvName.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.index_nav_text_nor));
|
||||
itemHolder.mTvTime.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.index_nav_text_nor));
|
||||
itemHolder.mTvTeam2.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.index_nav_text_nor));
|
||||
itemHolder.mTvStatus.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.white));
|
||||
itemHolder.mTvScore.setTextColor(
|
||||
ContextCompat.getColor(mContext, hasFocus ? R.color.index_top_text_focus : R.color.index_nav_text_nor));
|
||||
itemHolder.mTvTeam1.setSelected(hasFocus);
|
||||
itemHolder.mTvScore.setSelected(hasFocus);
|
||||
itemHolder.mTvTeam2.setSelected(hasFocus);
|
||||
itemHolder.mTvScore.setEllipsize(hasFocus ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END);
|
||||
itemHolder.mTvTeam1.setEllipsize(hasFocus ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END);
|
||||
itemHolder.mTvTeam2.setEllipsize(hasFocus ? TextUtils.TruncateAt.MARQUEE : TextUtils.TruncateAt.END);
|
||||
|
||||
});
|
||||
|
||||
String finalStatus = IndexConstant.getMatchStatus(status);
|
||||
itemHolder.itemView.setOnClickListener(v -> {
|
||||
if (matchList.get(position).getMatchstatus() < 3) {
|
||||
// String gameparam = matchList.get(position).getId() + "&" + matchList.get(position).getGameid();
|
||||
// String targetMgjsCode = matchList.get(position).getMgjscode();
|
||||
// addPagePositionClickEvent(targetMgjsCode);
|
||||
// ItemOnClickUtils.go2Epg(mContext, gameparam, IndexConstant.getSportDetailUrl(), "sportDetail", "");
|
||||
} else {// 大于等于3的为特殊比赛情况 需要toast提示
|
||||
if (matchList.get(position).getMatchstatus() + 2 == 6
|
||||
|| matchList.get(position).getMatchstatus() + 2 == 8) {
|
||||
Toast.makeText(mContext, "该场比赛已" + finalStatus, Toast.LENGTH_SHORT).show();
|
||||
} else if (matchList.get(position).getMatchstatus() + 2 == 7) {
|
||||
Toast.makeText(mContext, "该场比赛已延期", Toast.LENGTH_SHORT).show();
|
||||
} else if (matchList.get(position).getMatchstatus() + 2 == 9) {
|
||||
Toast.makeText(mContext, "该场比赛主客队待确定", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
Toast.makeText(mContext, "该场比赛" + finalStatus, Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 点击埋点
|
||||
*
|
||||
* @param targetMGjsCode
|
||||
*/
|
||||
private void addPagePositionClickEvent(String targetMGjsCode) {
|
||||
HashMap<String, String> map = new HashMap<>(16);
|
||||
map.put("actionType", "common");
|
||||
if (currentFloor != null) {
|
||||
map.put("blockIndex", String.valueOf(currentFloor.getTitlecode()));
|
||||
map.put("blockName", currentFloor.getTitle());
|
||||
}
|
||||
|
||||
if (currentExtraDataBean != null) {
|
||||
map.put("positionId", currentExtraDataBean.getPositionid());
|
||||
map.put("targetProgramId", currentExtraDataBean.getContentcode());
|
||||
map.put("targetProgramName", currentExtraDataBean.getName());
|
||||
}
|
||||
map.put("targetPageType", "体育详情页");
|
||||
map.put("targetPageId", "sport_detail");
|
||||
map.put("targetPageName", "体育详情页");
|
||||
if (!StringUtils.isEmpty(targetMGjsCode)) {
|
||||
map.put("targetMgjsCode", targetMGjsCode);
|
||||
}
|
||||
//AmberPoint.epgPagePositionClickEvent(map);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private String bindNoPkData(int position, ItemHolder itemHolder) {
|
||||
String status;
|
||||
itemHolder.mRLItem1.setVisibility(View.GONE);
|
||||
itemHolder.mRLItem2.setVisibility(View.VISIBLE);
|
||||
itemHolder.mRLItem3.setVisibility(View.GONE);
|
||||
itemHolder.mRLItem4.setVisibility(View.VISIBLE);
|
||||
itemHolder.mTvScore.setText(matchList.get(position).getName());
|
||||
// 须判断
|
||||
status = IndexConstant.matchStatus(matchList.get(position), this.time);
|
||||
itemHolder.mTvStatus.setText(IndexConstant.getMatchStatus(status));
|
||||
|
||||
itemHolder.mTvName.setText(matchList.get(position).getGamename());
|
||||
String timeStr = null;
|
||||
try {
|
||||
timeStr = DateUtils.formatDate(matchList.get(position).getStarttimeString(),DateUtils.FORMAT_STYLE_1, "MM月dd日 HH:mm");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
itemHolder.mTvTime.setText(timeStr);
|
||||
return status;
|
||||
}
|
||||
|
||||
@SuppressLint("SetTextI18n")
|
||||
private String bindPkData(int position, ItemHolder itemHolder,
|
||||
GetGameSeasonInfoRecommendBean.ResultEntity resultEntity) {
|
||||
String status;
|
||||
itemHolder.mRLItem1.setVisibility(View.VISIBLE);
|
||||
itemHolder.mRLItem2.setVisibility(View.VISIBLE);
|
||||
itemHolder.mRLItem3.setVisibility(View.VISIBLE);
|
||||
itemHolder.mRLItem4.setVisibility(View.VISIBLE);
|
||||
|
||||
itemHolder.mTvTeam1.setText(resultEntity.getHomeTeamName());
|
||||
itemHolder.mTvName.setText(resultEntity.getGamename());
|
||||
String timeStr = null;
|
||||
try {
|
||||
timeStr = DateUtils.formatDate(resultEntity.getStarttimeString(), DateUtils.FORMAT_STYLE_1,"MM月dd日 HH:mm");
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
itemHolder.mTvTime.setText(timeStr);
|
||||
itemHolder.mTvTeam2.setText(resultEntity.getVisitingTeamName());
|
||||
loadTeamLogo(position, itemHolder);
|
||||
|
||||
itemHolder.mTvScore.setText("VS");
|
||||
// 须判断
|
||||
status = IndexConstant.matchStatus(resultEntity, this.time);
|
||||
itemHolder.mTvStatus.setText(IndexConstant.getMatchStatus(status));
|
||||
|
||||
if ("2".equals(status) || "3".equals(status) || "4".equals(status)) {
|
||||
String score = "VS";
|
||||
if (null != resultEntity.getHomeScore() && null != resultEntity.getVisitingScore()) {
|
||||
score = resultEntity.getHomeScore() + ":" + resultEntity.getVisitingScore();
|
||||
}
|
||||
if (null != resultEntity.getHomeScore() && null == resultEntity.getVisitingScore()) {
|
||||
score = resultEntity.getHomeScore() + ":0";
|
||||
}
|
||||
if (null == resultEntity.getHomeScore() && null != resultEntity.getVisitingScore()) {
|
||||
score = "0:" + resultEntity.getVisitingScore();
|
||||
}
|
||||
itemHolder.mTvScore.setText(score);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
private void loadTeamLogo(int position, ItemHolder itemHolder) {
|
||||
GetGameSeasonInfoRecommendBean.ResultEntity resultEntity = matchList.get(position);
|
||||
if (null == resultEntity) {
|
||||
return;
|
||||
}
|
||||
|
||||
itemHolder.mIvTeam1.setImageURI(resultEntity.getHomeTeamlogo());
|
||||
itemHolder.mIvTeam2.setImageURI(resultEntity.getVisitingTeamlogo());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
// MGJSEPG-12982
|
||||
return null != matchList ? matchList.size() : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean hasFocus) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置角标
|
||||
*
|
||||
* @param cornerMarkIv cornerMarkIv
|
||||
* @param cornerMarkUrl 角标地址
|
||||
*/
|
||||
private void setCornerMark(PkSimpleDraweeView cornerMarkIv, String cornerMarkUrl) {
|
||||
if (TextUtils.isEmpty(cornerMarkUrl)) {
|
||||
cornerMarkIv.setVisibility(View.INVISIBLE);
|
||||
return;
|
||||
}
|
||||
|
||||
DraweeController controller = Fresco.newDraweeControllerBuilder()
|
||||
.setOldController(cornerMarkIv.getController())
|
||||
.setControllerListener(new ControllerListener<ImageInfo>() {
|
||||
@Override
|
||||
public void onSubmit(String id, Object callerContext) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
|
||||
adjustSdv(cornerMarkIv, imageInfo.getWidth(), imageInfo.getHeight());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntermediateImageSet(String id, ImageInfo imageInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntermediateImageFailed(String id, Throwable throwable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String id, Throwable throwable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRelease(String id) {
|
||||
|
||||
}
|
||||
})
|
||||
.setUri(Uri.parse(cornerMarkUrl))
|
||||
.build();
|
||||
|
||||
cornerMarkIv.setController(controller);
|
||||
cornerMarkIv.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void adjustSdv(SimpleDraweeView image, int width, int height) {
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) image.getLayoutParams();
|
||||
UiUtils.resetLayoutParams(mContext, width, height, UiUtils.POSITION_TYPE_SPORT_CARD, params);
|
||||
image.setLayoutParams(params);
|
||||
}
|
||||
|
||||
public static class ItemHolder extends RecyclerView.ViewHolder {
|
||||
private final PkSimpleDraweeView mIvTeam1;
|
||||
|
||||
private final TextView mTvTeam1;
|
||||
|
||||
private final TextView mTvScore;
|
||||
|
||||
private final TextView mTvStatus;
|
||||
|
||||
private final PkSimpleDraweeView mIvTeam2;
|
||||
|
||||
private final TextView mTvTeam2;
|
||||
|
||||
private final TextView mTvTime;
|
||||
|
||||
private final TextView mTvName;
|
||||
|
||||
private final RelativeLayout mRLItem1;
|
||||
|
||||
private final RelativeLayout mRLItem2;
|
||||
|
||||
private final RelativeLayout mRLItem3;
|
||||
|
||||
private final RelativeLayout mRLItem4;
|
||||
private final PkSimpleDraweeView mIvVip;
|
||||
private final RelativeLayout matchItemBig;
|
||||
|
||||
ItemHolder(View itemView) {
|
||||
super(itemView);
|
||||
mRLItem1 = itemView.findViewById(R.id.id_ll_item1);
|
||||
mRLItem2 = itemView.findViewById(R.id.id_ll_item2);
|
||||
mRLItem3 = itemView.findViewById(R.id.id_ll_item3);
|
||||
mRLItem4 = itemView.findViewById(R.id.id_ll_item4);
|
||||
mIvTeam1 = itemView.findViewById(R.id.id_iv_team1);
|
||||
mTvTeam1 = itemView.findViewById(R.id.id_tv_team1);
|
||||
mTvScore = itemView.findViewById(R.id.id_iv_score);
|
||||
mTvStatus = itemView.findViewById(R.id.id_tv_status);
|
||||
mIvTeam2 = itemView.findViewById(R.id.id_iv_team2);
|
||||
mTvTeam2 = itemView.findViewById(R.id.id_tv_team2);
|
||||
mTvTime = itemView.findViewById(R.id.id_iv_time);
|
||||
mTvName = itemView.findViewById(R.id.id_tv_name);
|
||||
mIvVip = itemView.findViewById(R.id.img_vip_icon);
|
||||
matchItemBig = itemView.findViewById(R.id.matchListRv);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
270
app/src/main/java/com/pukka/jiecheng/index/adapter/ShortVideoAdapter.java
Executable file
270
app/src/main/java/com/pukka/jiecheng/index/adapter/ShortVideoAdapter.java
Executable file
@@ -0,0 +1,270 @@
|
||||
package com.pukka.jiecheng.index.adapter;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.facebook.drawee.interfaces.DraweeController;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.migu.bean.GetFindPlayrecordBean;
|
||||
import com.migu.bean.GetShortVideoBean;
|
||||
import com.migu.bean.GetcontentlistBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.index.IndexActivity;
|
||||
import com.pukka.jiecheng.index.viewmodel.ShortVideoViewModel;
|
||||
import com.pukka.jiecheng.newtv.NewTvUtils;
|
||||
import com.pukka.jiecheng.utils.JetsenxSdkUtil;
|
||||
import com.pukka.jiecheng.widget.CornerBadgeView;
|
||||
import com.pukka.libcore.utils.ContextUtils;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
import com.pukka.libcore.widget.AlwaysMarqueeTextView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* [短视频适配器]<BR>
|
||||
*
|
||||
* @author wxf
|
||||
* @version [V0.1.0.1, 2025/7/9]
|
||||
* @since V0.1.0.1
|
||||
*/
|
||||
public class ShortVideoAdapter extends RecyclerView.Adapter<ShortVideoAdapter.ShortVideoHolder>{
|
||||
|
||||
private RecyclerView mRecyclerView;
|
||||
private Context mContext;
|
||||
private final ShortVideoViewModel mShortVideoViewModel;
|
||||
//是否展示提示
|
||||
private boolean isShowTipFlag;
|
||||
private int direction;
|
||||
private GetShortVideoBean getShortVideoBean;
|
||||
List<GetShortVideoBean.ResultDTO> resultEntityList = new ArrayList<>();
|
||||
private OnItemClickListener mOnItemClickListener;
|
||||
private OnItemFocusChangeListener mOnItemFocusChangeListener;
|
||||
//有节目单的时候, 按返回键,不需要重新播放当前节目
|
||||
private boolean isNeedRePlay;
|
||||
private boolean isZaiPingMuQian;
|
||||
|
||||
public void setZaiPingMuQian(boolean zaiPingMuQian) {
|
||||
isZaiPingMuQian = zaiPingMuQian;
|
||||
}
|
||||
|
||||
public ShortVideoAdapter(Context context, ShortVideoViewModel shortVideoViewModel){
|
||||
LogUtils.d("init ShortVideoAdapter");
|
||||
mShortVideoViewModel= shortVideoViewModel;
|
||||
mContext = context;
|
||||
isShowTipFlag = true;
|
||||
}
|
||||
public void setLayoutContentList(GetShortVideoBean getShortVideoBean) {
|
||||
this.getShortVideoBean = getShortVideoBean;
|
||||
if(null != getShortVideoBean.getResult()) {
|
||||
resultEntityList = getShortVideoBean.getResult();
|
||||
}
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
public void initShowTipFlag(){
|
||||
isShowTipFlag = true;
|
||||
}
|
||||
@NonNull
|
||||
@Override
|
||||
public ShortVideoHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_short_vod, parent, false);
|
||||
return new ShortVideoHolder(view);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull ShortVideoHolder holder, @SuppressLint("RecyclerView")int position) {
|
||||
try {
|
||||
holder.mTvName1.setText(resultEntityList.get(position).getContentName());
|
||||
holder.mTvName2.setText(resultEntityList.get(position).getDescription());
|
||||
holder.mIv1.setImageUri(resultEntityList.get(position).getImageUrl());
|
||||
if(position==0){
|
||||
if(isShowTipFlag) {
|
||||
LogUtils.d("切换到短视频栏目,显示正常播放图标");
|
||||
initShortPlayingIc(holder);
|
||||
}
|
||||
}
|
||||
holder.itemView.setOnFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean b) {
|
||||
LogUtils.d("ShortVideoFragment b="+b+" direction="+direction+" position="+position);
|
||||
itemStyle(holder,b);
|
||||
if(position==0 && isShowTipFlag) {
|
||||
mShortVideoViewModel.showOrHideTipUI(b);
|
||||
}
|
||||
if(position==1){
|
||||
if(mRecyclerView != null){
|
||||
LogUtils.d("ShortVideoFragment 第一个节目播放结束,自动播放第二节目,隐藏第一个节目的正在播放的图标");
|
||||
if(null!=mRecyclerView.getLayoutManager().findViewByPosition(0)) {
|
||||
mRecyclerView.getLayoutManager().findViewByPosition(0).findViewById(R.id.id_iv_playing).setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(position == 1){
|
||||
isShowTipFlag = false;
|
||||
}
|
||||
if(b){
|
||||
IndexActivity indexActivity = (IndexActivity) mContext;
|
||||
indexActivity.hideTopLayout();
|
||||
initShortPlayingIc(holder);
|
||||
String contentCode = resultEntityList.get(position).getContentCode();
|
||||
if(mOnItemFocusChangeListener != null){
|
||||
mOnItemFocusChangeListener.onItemFocusChange(position);
|
||||
}
|
||||
if(position == 0 && (direction == -1 ||direction == 4)){
|
||||
LogUtils.d("从短视频导航移动到第一个,视频已经正在播放,不需要再播放");
|
||||
return;
|
||||
}
|
||||
LogUtils.d("ShortVideoFragment","isNeedRePlay="+isNeedRePlay);
|
||||
if(isNeedRePlay&&!isZaiPingMuQian){
|
||||
LogUtils.d("ShortVideoFragment","有节目单的时候, 按返回键,不需要重新播放当前节目");
|
||||
return;
|
||||
}
|
||||
isZaiPingMuQian = false;
|
||||
mShortVideoViewModel.selectItem("2001");
|
||||
|
||||
String contentName = resultEntityList.get(position).getContentName();
|
||||
|
||||
JetsenxSdkUtil.newtvCheckQuery(contentCode,contentName, new JetsenxSdkUtil.GetVideoUrlCallback() {
|
||||
@Override
|
||||
public void onResponse(String videoUrl) {
|
||||
mShortVideoViewModel.gotoPlay(contentCode+"@@@"+videoUrl);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}else{
|
||||
if(direction != 4) {
|
||||
//不是按返回键,按返回键显示
|
||||
holder.mIvPlaying.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//判断是否设置了监听器
|
||||
if (mOnItemClickListener != null) {
|
||||
//为ItemView设置监听器
|
||||
holder.itemView.setOnClickListener(v -> {
|
||||
int position1 = holder.getLayoutPosition(); // 1
|
||||
mOnItemClickListener.onItemClick(holder.itemView, position1); // 2
|
||||
});
|
||||
}
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void initShortPlayingIc(@NonNull ShortVideoHolder holder) {
|
||||
Uri uri = Uri.parse("res://com.pukka.jiecheng/" + R.drawable.ic_short_playing);
|
||||
holder.mIvPlaying.setImageURI(uri);
|
||||
DraweeController controller = Fresco.newDraweeControllerBuilder()
|
||||
.setUri(uri)
|
||||
.setAutoPlayAnimations(true) // 设置自动播放动画
|
||||
.build();
|
||||
holder.mIvPlaying.setController(controller);
|
||||
holder.mIvPlaying.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
public void itemStyle(ShortVideoHolder holder,boolean b){
|
||||
if(b){
|
||||
holder.mTvName1.setTextColor(mContext.getResources().getColor(R.color.white));
|
||||
holder.mTvName2.setTextColor(mContext.getResources().getColor(R.color.white));
|
||||
holder.mTvName1.setEllipsize(TextUtils.TruncateAt.valueOf("MARQUEE"));
|
||||
}else {
|
||||
holder.mTvName1.setTextColor(mContext.getResources().getColor(R.color.short_video_text_color));
|
||||
holder.mTvName2.setTextColor(mContext.getResources().getColor(R.color.short_video_text_color2));
|
||||
holder.mTvName1.setEllipsize(TextUtils.TruncateAt.valueOf("END"));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
if(null != resultEntityList){
|
||||
return resultEntityList.size();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public void add(GetShortVideoBean.ResultDTO item) {
|
||||
if (null == resultEntityList) {
|
||||
return;
|
||||
}
|
||||
resultEntityList.add(item);
|
||||
notifyItemInserted(resultEntityList.size() - 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加下一页数据
|
||||
*/
|
||||
public void addAll(List<GetShortVideoBean.ResultDTO> newItems) {
|
||||
for (GetShortVideoBean.ResultDTO item : newItems) {
|
||||
add(item);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 获取数据源
|
||||
* */
|
||||
public List<GetShortVideoBean.ResultDTO> getData(){
|
||||
return resultEntityList;
|
||||
}
|
||||
@Override
|
||||
public void onAttachedToRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||
super.onAttachedToRecyclerView(recyclerView);
|
||||
this.mRecyclerView = recyclerView;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDetachedFromRecyclerView(@NonNull RecyclerView recyclerView) {
|
||||
super.onDetachedFromRecyclerView(recyclerView);
|
||||
this.mRecyclerView = null;
|
||||
}
|
||||
|
||||
public void setDirection(int direction) {
|
||||
this.direction = direction;
|
||||
}
|
||||
|
||||
public void setNeedRePlay(boolean needRePlay) {
|
||||
isNeedRePlay = needRePlay;
|
||||
}
|
||||
|
||||
public static class ShortVideoHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
AlwaysMarqueeTextView mTvName1;
|
||||
CornerBadgeView mIv1;
|
||||
TextView mTvName2;
|
||||
SimpleDraweeView mIvPlaying;
|
||||
|
||||
public ShortVideoHolder(View itemView) {
|
||||
super(itemView);
|
||||
mTvName1 = itemView.findViewById(R.id.id_tv_name1);
|
||||
mIv1 = itemView.findViewById(R.id.id_iv_1);
|
||||
float cornerSize = ContextUtils.getContext().getResources().getDimension(R.dimen.qb_px_6);
|
||||
mIv1.posterCustomCorner(cornerSize,0,0,cornerSize);
|
||||
mTvName2 = itemView.findViewById(R.id.id_tv_name2);
|
||||
mIvPlaying = itemView.findViewById(R.id.id_iv_playing);
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnItemClickListener(OnItemClickListener mOnItemClickListener) {
|
||||
this.mOnItemClickListener = mOnItemClickListener;
|
||||
}
|
||||
public void setOnFocusChangeListener(OnItemFocusChangeListener mOnItemFocusChangeListener){
|
||||
this.mOnItemFocusChangeListener = mOnItemFocusChangeListener;
|
||||
}
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(View view, int position);
|
||||
}
|
||||
public interface OnItemFocusChangeListener {
|
||||
void onItemFocusChange(int position);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
|
||||
package com.pukka.jiecheng.index.adapter.interfaces;
|
||||
|
||||
/**
|
||||
* [导航tab选中监听]<BR>
|
||||
*
|
||||
* @author wcg
|
||||
* @version [V0.1.0.1, 2023/11/24 0024]
|
||||
* @since V0.1.0.1
|
||||
*/
|
||||
public interface OnNavidListener {
|
||||
/**
|
||||
* 获取navId
|
||||
*
|
||||
* @param navid navid
|
||||
* @param navName navName
|
||||
* @param navType navType
|
||||
* @param gameId gameId
|
||||
*/
|
||||
void getNavId(String navid, String navName, Integer navType, Integer gameId,String pageCode);
|
||||
}
|
||||
@@ -0,0 +1,137 @@
|
||||
|
||||
package com.pukka.jiecheng.index.adapter.viewholder;
|
||||
|
||||
import android.graphics.drawable.Animatable;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.facebook.drawee.controller.ControllerListener;
|
||||
import com.facebook.drawee.interfaces.DraweeController;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.facebook.imagepipeline.image.ImageInfo;
|
||||
import com.migu.bean.GetLayoutNavBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.index.adapter.IndexGroupNavAdapter;
|
||||
import com.pukka.jiecheng.index.adapter.interfaces.OnNavidListener;
|
||||
import com.pukka.jiecheng.index.viewmodel.NavViewModel;
|
||||
import com.pukka.jiecheng.utils.ColorUtil;
|
||||
import com.pukka.jiecheng.widget.HomeNavLinearLayoutManagerTv;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* [首页导航栏 多集合类型ViewHolder]<BR>
|
||||
*
|
||||
* @author wcg
|
||||
* @version [V0.1.0.1, 2023/11/24 0024]
|
||||
* @since V0.1.0.1
|
||||
*/
|
||||
public class GroupNavViewHolder extends RecyclerView.ViewHolder {
|
||||
private RecyclerView subNavRv;
|
||||
|
||||
private PkSimpleDraweeView navCornerMarkIv;
|
||||
|
||||
private final IndexGroupNavAdapter subNavAdapter;
|
||||
|
||||
public GroupNavViewHolder(View itemView, OnNavidListener onNavidListener, NavViewModel navViewModel) {
|
||||
super(itemView);
|
||||
initView(itemView);
|
||||
|
||||
subNavAdapter = new IndexGroupNavAdapter();
|
||||
subNavAdapter.setOnNavidListener(onNavidListener);
|
||||
subNavAdapter.setNavViewModel(navViewModel);
|
||||
|
||||
HomeNavLinearLayoutManagerTv linearLayoutManager =
|
||||
new HomeNavLinearLayoutManagerTv(itemView.getContext(), LinearLayoutManager.HORIZONTAL, false);
|
||||
subNavRv.setLayoutManager(linearLayoutManager);
|
||||
subNavRv.setAdapter(subNavAdapter);
|
||||
}
|
||||
|
||||
private void initView(View itemView) {
|
||||
subNavRv = itemView.findViewById(R.id.id_rv_sub_nav);
|
||||
navCornerMarkIv = itemView.findViewById(R.id.id_nav_corer_mark);
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定列表数据
|
||||
*
|
||||
* @param groupIndex groupIndex
|
||||
* @param groupNavDataList groupNavDataList
|
||||
* @param bgColor bgColor
|
||||
* @param cornerMarkUrl cornerMarkUrl
|
||||
*/
|
||||
public void bindGroupData(int groupIndex, List<GetLayoutNavBean.DataBean.SubNavDataBean> groupNavDataList,
|
||||
String bgColor, String cornerMarkUrl) {
|
||||
subNavAdapter.setLayoutNavList(groupIndex, groupNavDataList);
|
||||
|
||||
ColorUtil.setBackgroundShapeColor(subNavRv, bgColor,
|
||||
subNavRv.getContext().getResources().getDimensionPixelSize(R.dimen.qb_px_1));
|
||||
setCornerMark(cornerMarkUrl);
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置角标
|
||||
*
|
||||
* @param cornerMarkUrl 角标地址
|
||||
*/
|
||||
private void setCornerMark(String cornerMarkUrl) {
|
||||
if (TextUtils.isEmpty(cornerMarkUrl)) {
|
||||
navCornerMarkIv.setVisibility(View.INVISIBLE);
|
||||
return;
|
||||
}
|
||||
|
||||
DraweeController controller = Fresco.newDraweeControllerBuilder()
|
||||
.setOldController(navCornerMarkIv.getController())
|
||||
.setControllerListener(new ControllerListener<ImageInfo>() {
|
||||
@Override
|
||||
public void onSubmit(String id, Object callerContext) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
|
||||
float bl = (float) navCornerMarkIv.getHeight()/imageInfo.getHeight();
|
||||
adjustSdv(navCornerMarkIv, imageInfo.getWidth()*bl, imageInfo.getHeight()*bl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntermediateImageSet(String id, ImageInfo imageInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntermediateImageFailed(String id, Throwable throwable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String id, Throwable throwable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRelease(String id) {
|
||||
|
||||
}
|
||||
})
|
||||
.setUri(Uri.parse(cornerMarkUrl))
|
||||
.build();
|
||||
|
||||
navCornerMarkIv.setController(controller);
|
||||
navCornerMarkIv.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void adjustSdv(SimpleDraweeView image, float width, float height) {
|
||||
FrameLayout.LayoutParams params = (FrameLayout.LayoutParams) image.getLayoutParams();
|
||||
params.width = (int)width;
|
||||
params.height = (int)height;
|
||||
image.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
313
app/src/main/java/com/pukka/jiecheng/index/adapter/viewholder/NavViewHolder.java
Executable file
313
app/src/main/java/com/pukka/jiecheng/index/adapter/viewholder/NavViewHolder.java
Executable file
@@ -0,0 +1,313 @@
|
||||
|
||||
package com.pukka.jiecheng.index.adapter.viewholder;
|
||||
|
||||
import static com.pukka.jiecheng.widget.HomeNavLinearLayoutManagerTv.NAV_INDEX;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Animatable;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.facebook.drawee.backends.pipeline.Fresco;
|
||||
import com.facebook.drawee.controller.ControllerListener;
|
||||
import com.facebook.drawee.interfaces.DraweeController;
|
||||
import com.facebook.drawee.view.SimpleDraweeView;
|
||||
import com.facebook.imagepipeline.image.ImageInfo;
|
||||
import com.migu.bean.GetLayoutNavBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.index.adapter.interfaces.OnNavidListener;
|
||||
import com.pukka.jiecheng.index.bean.NavBean;
|
||||
import com.pukka.jiecheng.index.viewmodel.NavViewModel;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* * [首页导航栏 单个类型ViewHolder]<BR>
|
||||
*
|
||||
* @author wcg
|
||||
* @version [V0.1.0.1, 2023/11/24 0024]
|
||||
* @since V0.1.0.1
|
||||
*/
|
||||
public class NavViewHolder extends RecyclerView.ViewHolder {
|
||||
private final TextView mTvNavName;
|
||||
|
||||
private final ImageView mIvNavLine;
|
||||
|
||||
private final PkSimpleDraweeView mIvNavName;
|
||||
|
||||
private final LinearLayout navAllLl;
|
||||
|
||||
private final RelativeLayout navAll;
|
||||
private final RelativeLayout nav_tv_rl;
|
||||
|
||||
private final OnNavidListener onNavidListener;
|
||||
|
||||
private final NavViewModel navViewModel;
|
||||
|
||||
private final Context mContext;
|
||||
|
||||
/**
|
||||
* 是否第一次落焦,解决第一次落焦时没走epgPageVisitEvent问题
|
||||
*/
|
||||
private boolean isFirstOnFocus = true;
|
||||
|
||||
public NavViewHolder(Context context,View itemView, OnNavidListener onNavidListener, NavViewModel navViewModel) {
|
||||
super(itemView);
|
||||
this.mContext = context;
|
||||
mTvNavName = itemView.findViewById(R.id.id_tv_nav_name);
|
||||
mIvNavName = itemView.findViewById(R.id.id_iv_nav_name);
|
||||
mIvNavLine = itemView.findViewById(R.id.id_iv_nav_line);
|
||||
navAllLl = itemView.findViewById(R.id.id_nav_all_ll);
|
||||
navAll = itemView.findViewById(R.id.nav_all);
|
||||
nav_tv_rl = itemView.findViewById(R.id.nav_tv_rl);
|
||||
this.onNavidListener = onNavidListener;
|
||||
this.navViewModel = navViewModel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 绑定导航数据
|
||||
*
|
||||
* @param navList 导航数据
|
||||
* @param position
|
||||
*/
|
||||
public void bindData(List<GetLayoutNavBean.DataBean.SubNavDataBean> navList, int position, boolean isSelected) {
|
||||
GetLayoutNavBean.DataBean.SubNavDataBean mCurrentNavItem = navList.get(0);
|
||||
if (mCurrentNavItem == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String currentNavName = mCurrentNavItem.getNavname();
|
||||
String currentNavId = mCurrentNavItem.getNavid();
|
||||
String pageCode = mCurrentNavItem.getPageCode();
|
||||
if (mCurrentNavItem.getShowType() == 0) {
|
||||
mTvNavName.setVisibility(View.VISIBLE);
|
||||
nav_tv_rl.setVisibility(View.VISIBLE);
|
||||
mIvNavName.setVisibility(View.GONE);
|
||||
|
||||
} else if (mCurrentNavItem.getShowType() == 1) {
|
||||
mTvNavName.setVisibility(View.GONE);
|
||||
nav_tv_rl.setVisibility(View.GONE);
|
||||
mIvNavName.setVisibility(View.VISIBLE);
|
||||
setImage(mCurrentNavItem.getNavBimage());
|
||||
|
||||
}
|
||||
mIvNavLine.setVisibility(View.GONE);
|
||||
mTvNavName.setText(currentNavName);
|
||||
itemView.setTag(R.id.id_nav_all_ll, mCurrentNavItem);
|
||||
if (mCurrentNavItem.getShowType() == 0) {
|
||||
applyTextNavStyle(navAllLl, isSelected);
|
||||
} else {
|
||||
applyImageNavStyle(navAllLl, mCurrentNavItem, isSelected);
|
||||
}
|
||||
|
||||
setFocusListener(position, mCurrentNavItem, currentNavName, currentNavId,pageCode);
|
||||
setClickListener(position, mCurrentNavItem, currentNavName, currentNavId, pageCode);
|
||||
}
|
||||
|
||||
private void setFocusListener(int position, GetLayoutNavBean.DataBean.SubNavDataBean mCurrentNavItem,
|
||||
String currentNavName, String currentNavId,String pageCode) {
|
||||
navAllLl.setOnFocusChangeListener((view, b) -> {
|
||||
boolean passParamsToActivity = onNavidListener != null && b && (null == navViewModel.nowNavBean.getValue()
|
||||
|| !navViewModel.nowNavBean.getValue().getNowNavId().equals(currentNavId));
|
||||
if (mCurrentNavItem.getShowType() == 0) {// 文字
|
||||
applyTextNavStyle(view, b);
|
||||
if (b) {
|
||||
updateResideIndex(position);
|
||||
}
|
||||
} else {// 图片
|
||||
if (b) {
|
||||
applyImageNavStyle(view, mCurrentNavItem, true);
|
||||
updateResideIndex(position);
|
||||
} else {
|
||||
applyImageNavStyle(view, mCurrentNavItem, false);
|
||||
}
|
||||
}
|
||||
|
||||
dispatchNavIfNeed(passParamsToActivity, currentNavId, currentNavName, mCurrentNavItem, pageCode);
|
||||
});
|
||||
}
|
||||
|
||||
private void setClickListener(int position, GetLayoutNavBean.DataBean.SubNavDataBean mCurrentNavItem,
|
||||
String currentNavName, String currentNavId, String pageCode) {
|
||||
navAllLl.setOnClickListener(v -> {
|
||||
if (!v.hasFocus()) {
|
||||
v.requestFocus();
|
||||
}
|
||||
if (mCurrentNavItem.getShowType() == 0) {
|
||||
applyTextNavStyle(v, true);
|
||||
} else {
|
||||
applyImageNavStyle(v, mCurrentNavItem, true);
|
||||
}
|
||||
syncClickNavStyle(currentNavId);
|
||||
updateResideIndex(position);
|
||||
boolean passParamsToActivity = onNavidListener != null && isNeedDispatch(currentNavId,
|
||||
navViewModel.nowNavBean.getValue());
|
||||
dispatchNavIfNeed(passParamsToActivity, currentNavId, currentNavName, mCurrentNavItem, pageCode);
|
||||
});
|
||||
}
|
||||
|
||||
private void applyTextNavStyle(View view, boolean hasFocus) {
|
||||
TextView currentTextView = view.findViewById(R.id.id_tv_nav_name);
|
||||
RelativeLayout currentTextContainer = view.findViewById(R.id.nav_tv_rl);
|
||||
ImageView currentNavLine = view.findViewById(R.id.id_iv_nav_line);
|
||||
if (currentTextView == null || currentTextContainer == null) {
|
||||
return;
|
||||
}
|
||||
int textColor = hasFocus ? R.color.index_top_text_focus : R.color.index_top_text_nor;
|
||||
int bgRes = hasFocus ? R.drawable.common_text_bg_cir_focus : R.color.transparent;
|
||||
currentTextView.setTextColor(ContextCompat.getColor(view.getContext(), textColor));
|
||||
currentTextContainer.setBackground(AppCompatResources.getDrawable(view.getContext(), bgRes));
|
||||
if (currentNavLine != null) {
|
||||
currentNavLine.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private void applyImageNavStyle(View view, GetLayoutNavBean.DataBean.SubNavDataBean currentNavItem, boolean hasFocus) {
|
||||
RelativeLayout currentNavContainer = view.findViewById(R.id.nav_all);
|
||||
PkSimpleDraweeView currentNavImage = view.findViewById(R.id.id_iv_nav_name);
|
||||
ImageView currentNavLine = view.findViewById(R.id.id_iv_nav_line);
|
||||
if (currentNavContainer == null || currentNavImage == null) {
|
||||
return;
|
||||
}
|
||||
if (hasFocus) {
|
||||
currentNavContainer.setBackground(AppCompatResources.getDrawable(view.getContext(), R.color.transparent));
|
||||
setImage(currentNavImage, currentNavContainer, currentNavItem.getNavFimage());
|
||||
return;
|
||||
}
|
||||
|
||||
if (null != navViewModel.resideIndex.getValue()
|
||||
&& navViewModel.resideIndex.getValue().getResideIndex() == NAV_INDEX) {
|
||||
NAV_INDEX = -1;
|
||||
setImage(currentNavImage, currentNavContainer, currentNavItem.getNavAimage());
|
||||
if (currentNavLine != null) {
|
||||
currentNavLine.setVisibility(View.GONE);
|
||||
}
|
||||
} else {
|
||||
setImage(currentNavImage, currentNavContainer, currentNavItem.getNavBimage());
|
||||
}
|
||||
currentNavContainer.setBackground(
|
||||
AppCompatResources.getDrawable(view.getContext(), R.drawable.index_nav_item_bg_selector));
|
||||
}
|
||||
|
||||
private void syncClickNavStyle(String currentNavId) {
|
||||
View parentView = (View) itemView.getParent();
|
||||
if (!(parentView instanceof RecyclerView)) {
|
||||
return;
|
||||
}
|
||||
RecyclerView recyclerView = (RecyclerView) parentView;
|
||||
int childCount = recyclerView.getChildCount();
|
||||
for (int i = 0; i < childCount; i++) {
|
||||
View childView = recyclerView.getChildAt(i);
|
||||
Object tagObj = childView.getTag(R.id.id_nav_all_ll);
|
||||
if (!(tagObj instanceof GetLayoutNavBean.DataBean.SubNavDataBean)) {
|
||||
continue;
|
||||
}
|
||||
GetLayoutNavBean.DataBean.SubNavDataBean tabItem = (GetLayoutNavBean.DataBean.SubNavDataBean) tagObj;
|
||||
if (tabItem.getShowType() == 0) {
|
||||
applyTextNavStyle(childView, TextUtils.equals(currentNavId, tabItem.getNavid()));
|
||||
} else {
|
||||
applyImageNavStyle(childView, tabItem, TextUtils.equals(currentNavId, tabItem.getNavid()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateResideIndex(int position) {
|
||||
if (isFirstOnFocus || (null != navViewModel.resideIndex.getValue()
|
||||
&& navViewModel.resideIndex.getValue().getResideIndex() != position)) {
|
||||
isFirstOnFocus = false;
|
||||
}
|
||||
if (null != navViewModel.resideIndex.getValue()) {
|
||||
navViewModel.resideIndex.getValue().setResideIndex(position);
|
||||
navViewModel.resideIndex.getValue().setResideIndexSub(-1);
|
||||
LogUtils.d("wcg, resideIndex:" + navViewModel.resideIndex.getValue().getResideIndex()
|
||||
+ " resideIndexSub: " + navViewModel.resideIndex.getValue().getResideIndexSub());
|
||||
}
|
||||
}
|
||||
|
||||
private void dispatchNavIfNeed(boolean passParamsToActivity, String currentNavId, String currentNavName,
|
||||
GetLayoutNavBean.DataBean.SubNavDataBean currentNavItem, String pageCode) {
|
||||
if (!passParamsToActivity) {
|
||||
return;
|
||||
}
|
||||
NavBean navBean = new NavBean();
|
||||
navBean.setNowNavId(currentNavId);
|
||||
navBean.setNowNavName(currentNavName);
|
||||
navViewModel.nowNavBean.setValue(navBean);
|
||||
onNavidListener.getNavId(currentNavId, currentNavName, currentNavItem.getType(),
|
||||
currentNavItem.getGame_id(), pageCode);
|
||||
}
|
||||
|
||||
static boolean isNeedDispatch(String currentNavId, NavBean nowNavBean) {
|
||||
return nowNavBean == null || !currentNavId.equals(nowNavBean.getNowNavId());
|
||||
}
|
||||
|
||||
private void setImage(String imageUrl) {
|
||||
setImage(mIvNavName, navAll, imageUrl);
|
||||
}
|
||||
|
||||
private void setImage(PkSimpleDraweeView imageView, RelativeLayout navContainer, String imageUrl) {
|
||||
if (TextUtils.isEmpty(imageUrl)) {
|
||||
imageView.setVisibility(View.INVISIBLE);
|
||||
return;
|
||||
}
|
||||
|
||||
DraweeController controller = Fresco.newDraweeControllerBuilder()
|
||||
.setOldController(imageView.getController())
|
||||
.setControllerListener(new ControllerListener<ImageInfo>() {
|
||||
@Override
|
||||
public void onSubmit(String id, Object callerContext) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFinalImageSet(String id, ImageInfo imageInfo, Animatable animatable) {
|
||||
if (imageInfo == null || imageInfo.getHeight() == 0) {
|
||||
return;
|
||||
}
|
||||
float bl = (float) navContainer.getHeight() / imageInfo.getHeight();
|
||||
adjustSdv(imageView, imageInfo.getWidth() * bl, imageInfo.getHeight() * bl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntermediateImageSet(String id, ImageInfo imageInfo) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onIntermediateImageFailed(String id, Throwable throwable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(String id, Throwable throwable) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRelease(String id) {
|
||||
|
||||
}
|
||||
})
|
||||
.setUri(Uri.parse(imageUrl))
|
||||
.build();
|
||||
imageView.setController(controller);
|
||||
}
|
||||
|
||||
private void adjustSdv(SimpleDraweeView image, float width, float height) {
|
||||
RelativeLayout.LayoutParams params = (RelativeLayout.LayoutParams) image.getLayoutParams();
|
||||
params.width = (int) width;
|
||||
params.height = (int) height;
|
||||
image.setLayoutParams(params);
|
||||
}
|
||||
}
|
||||
52
app/src/main/java/com/pukka/jiecheng/index/bean/CornerMarkBean.java
Executable file
52
app/src/main/java/com/pukka/jiecheng/index/bean/CornerMarkBean.java
Executable file
@@ -0,0 +1,52 @@
|
||||
package com.pukka.jiecheng.index.bean;
|
||||
/***
|
||||
* 角标 4角标功能
|
||||
* */
|
||||
public class CornerMarkBean {
|
||||
private String cornerLeftUp;
|
||||
private String cornerRightUp;
|
||||
private String cornerLeftDown;
|
||||
private String cornerRightDown;
|
||||
|
||||
public String getCornerLeftUp() {
|
||||
return cornerLeftUp;
|
||||
}
|
||||
|
||||
public void setCornerLeftUp(String cornerLeftUp) {
|
||||
this.cornerLeftUp = cornerLeftUp;
|
||||
}
|
||||
|
||||
public String getCornerRightUp() {
|
||||
return cornerRightUp;
|
||||
}
|
||||
|
||||
public void setCornerRightUp(String cornerRightUp) {
|
||||
this.cornerRightUp = cornerRightUp;
|
||||
}
|
||||
|
||||
public String getCornerLeftDown() {
|
||||
return cornerLeftDown;
|
||||
}
|
||||
|
||||
public void setCornerLeftDown(String cornerLeftDown) {
|
||||
this.cornerLeftDown = cornerLeftDown;
|
||||
}
|
||||
|
||||
public String getCornerRightDown() {
|
||||
return cornerRightDown;
|
||||
}
|
||||
|
||||
public void setCornerRightDown(String cornerRightDown) {
|
||||
this.cornerRightDown = cornerRightDown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "CornerMarkBean{" +
|
||||
"cornerLeftUp='" + cornerLeftUp + '\'' +
|
||||
", cornerRightUp='" + cornerRightUp + '\'' +
|
||||
", cornerLeftDown='" + cornerLeftDown + '\'' +
|
||||
", cornerRightDown='" + cornerRightDown + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
65
app/src/main/java/com/pukka/jiecheng/index/bean/D1TypeBean.java
Executable file
65
app/src/main/java/com/pukka/jiecheng/index/bean/D1TypeBean.java
Executable file
@@ -0,0 +1,65 @@
|
||||
package com.pukka.jiecheng.index.bean;
|
||||
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
|
||||
public class D1TypeBean {
|
||||
|
||||
/**
|
||||
* 平时状态
|
||||
*/
|
||||
public static final int NORMAL = 0;
|
||||
|
||||
/**
|
||||
* 获取焦点的
|
||||
*/
|
||||
public static final int FOCUSED = 1;
|
||||
|
||||
/**
|
||||
* 播放状态
|
||||
*/
|
||||
public static final int PLAYING = 2;
|
||||
|
||||
/**
|
||||
* 播放状态和焦点状态并存
|
||||
*/
|
||||
public static final int PLAYINGANDFOCUSED = 3;
|
||||
|
||||
// private int btnStatus;
|
||||
//
|
||||
// private PkSimpleDraweeView gifView;
|
||||
//
|
||||
// private RelativeLayout view;
|
||||
//
|
||||
// public D1TypeBean(int btnStatus, RelativeLayout view, PkSimpleDraweeView gifView) {
|
||||
// this.btnStatus = btnStatus;
|
||||
// this.view = view;
|
||||
// this.gifView = gifView;
|
||||
// }
|
||||
//
|
||||
// public RelativeLayout getView() {
|
||||
// return view;
|
||||
// }
|
||||
//
|
||||
// public void setView(RelativeLayout view) {
|
||||
// this.view = view;
|
||||
// }
|
||||
//
|
||||
// public int getBtnStatus() {
|
||||
// return btnStatus;
|
||||
// }
|
||||
//
|
||||
// public void setBtnStatus(int btnStatus) {
|
||||
// this.btnStatus = btnStatus;
|
||||
// }
|
||||
//
|
||||
// public PkSimpleDraweeView getGifView() {
|
||||
// return gifView;
|
||||
// }
|
||||
//
|
||||
// public void setGifView(PkSimpleDraweeView gifView) {
|
||||
// this.gifView = gifView;
|
||||
// }
|
||||
|
||||
}
|
||||
31
app/src/main/java/com/pukka/jiecheng/index/bean/DefaultNavFocusBean.java
Executable file
31
app/src/main/java/com/pukka/jiecheng/index/bean/DefaultNavFocusBean.java
Executable file
@@ -0,0 +1,31 @@
|
||||
|
||||
package com.pukka.jiecheng.index.bean;
|
||||
|
||||
/**
|
||||
* [默认落焦位置]<BR>
|
||||
*
|
||||
* @author wcg
|
||||
* @version [V0.1.0.1, 2023/12/4 0004]
|
||||
* @since V0.1.0.1
|
||||
*/
|
||||
public class DefaultNavFocusBean {
|
||||
private int defaultIndex = -1;
|
||||
|
||||
private int defaultIndexSub = -1;
|
||||
|
||||
public int getDefaultIndex() {
|
||||
return defaultIndex;
|
||||
}
|
||||
|
||||
public void setDefaultIndex(int defaultIndex) {
|
||||
this.defaultIndex = defaultIndex;
|
||||
}
|
||||
|
||||
public int getDefaultIndexSub() {
|
||||
return defaultIndexSub;
|
||||
}
|
||||
|
||||
public void setDefaultIndexSub(int defaultIndexSub) {
|
||||
this.defaultIndexSub = defaultIndexSub;
|
||||
}
|
||||
}
|
||||
37
app/src/main/java/com/pukka/jiecheng/index/bean/ItemTypeBean.java
Executable file
37
app/src/main/java/com/pukka/jiecheng/index/bean/ItemTypeBean.java
Executable file
@@ -0,0 +1,37 @@
|
||||
package com.pukka.jiecheng.index.bean;
|
||||
|
||||
public class ItemTypeBean {
|
||||
private String type;
|
||||
private String floor;
|
||||
private int positionType;
|
||||
|
||||
public ItemTypeBean(int positionType, String type, String floor){
|
||||
this.positionType = positionType;
|
||||
this.type = type;
|
||||
this.floor = floor;
|
||||
}
|
||||
|
||||
public String getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(String type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getFloor() {
|
||||
return floor;
|
||||
}
|
||||
|
||||
public void setFloor(String floor) {
|
||||
this.floor = floor;
|
||||
}
|
||||
|
||||
public int getPositionType() {
|
||||
return positionType;
|
||||
}
|
||||
|
||||
public void setPositionType(int positionType) {
|
||||
this.positionType = positionType;
|
||||
}
|
||||
}
|
||||
27
app/src/main/java/com/pukka/jiecheng/index/bean/LogOutBean.java
Executable file
27
app/src/main/java/com/pukka/jiecheng/index/bean/LogOutBean.java
Executable file
@@ -0,0 +1,27 @@
|
||||
package com.pukka.jiecheng.index.bean;
|
||||
|
||||
import com.google.gson.annotations.SerializedName;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
public class LogOutBean implements Serializable {
|
||||
@SerializedName("retCode")
|
||||
private String retCode;
|
||||
@SerializedName("retMsg")
|
||||
private String retMsg;
|
||||
public String getRetCode() {
|
||||
return retCode;
|
||||
}
|
||||
|
||||
public void setRetCode(String retCode) {
|
||||
this.retCode = retCode;
|
||||
}
|
||||
|
||||
public String getRetMsg() {
|
||||
return retMsg;
|
||||
}
|
||||
|
||||
public void setRetMsg(String retMsg) {
|
||||
this.retMsg = retMsg;
|
||||
}
|
||||
}
|
||||
32
app/src/main/java/com/pukka/jiecheng/index/bean/MyIndexBean.java
Executable file
32
app/src/main/java/com/pukka/jiecheng/index/bean/MyIndexBean.java
Executable file
@@ -0,0 +1,32 @@
|
||||
|
||||
package com.pukka.jiecheng.index.bean;
|
||||
|
||||
/**
|
||||
* [一句话功能简述]<BR>
|
||||
* [我的TAB下标]<BR>
|
||||
*
|
||||
* @author wcg
|
||||
* @version [V0.1.0.1, 2023/11/28 0028]
|
||||
* @since V0.1.0.1
|
||||
*/
|
||||
public class MyIndexBean {
|
||||
private int myIndex;
|
||||
|
||||
private int myIndexSub = -1;
|
||||
|
||||
public int getMyIndex() {
|
||||
return myIndex;
|
||||
}
|
||||
|
||||
public void setMyIndex(int myIndex) {
|
||||
this.myIndex = myIndex;
|
||||
}
|
||||
|
||||
public int getMyIndexSub() {
|
||||
return myIndexSub;
|
||||
}
|
||||
|
||||
public void setMyIndexSub(int myIndexSub) {
|
||||
this.myIndexSub = myIndexSub;
|
||||
}
|
||||
}
|
||||
31
app/src/main/java/com/pukka/jiecheng/index/bean/NavBean.java
Executable file
31
app/src/main/java/com/pukka/jiecheng/index/bean/NavBean.java
Executable file
@@ -0,0 +1,31 @@
|
||||
|
||||
package com.pukka.jiecheng.index.bean;
|
||||
|
||||
/**
|
||||
* [Nav数据类 用于埋点]<BR>
|
||||
*
|
||||
* @author devel
|
||||
* @version [V0.1.0.1, 2023/12/7 0007]
|
||||
* @since V0.1.0.1
|
||||
*/
|
||||
public class NavBean {
|
||||
private String nowNavName;
|
||||
|
||||
private String nowNavId;
|
||||
|
||||
public String getNowNavName() {
|
||||
return nowNavName;
|
||||
}
|
||||
|
||||
public void setNowNavName(String nowNavName) {
|
||||
this.nowNavName = nowNavName;
|
||||
}
|
||||
|
||||
public String getNowNavId() {
|
||||
return nowNavId;
|
||||
}
|
||||
|
||||
public void setNowNavId(String nowNavId) {
|
||||
this.nowNavId = nowNavId;
|
||||
}
|
||||
}
|
||||
31
app/src/main/java/com/pukka/jiecheng/index/bean/NavFocusBean.java
Executable file
31
app/src/main/java/com/pukka/jiecheng/index/bean/NavFocusBean.java
Executable file
@@ -0,0 +1,31 @@
|
||||
|
||||
package com.pukka.jiecheng.index.bean;
|
||||
|
||||
/**
|
||||
* [焦点数据类 - 用于mediaId不为空或者根据Tab名称寻焦]<BR>
|
||||
*
|
||||
* @author wcg
|
||||
* @version [V0.1.0.1, 2023/12/7 0007]
|
||||
* @since V0.1.0.1
|
||||
*/
|
||||
public class NavFocusBean {
|
||||
private int index;
|
||||
|
||||
private int indexSub;
|
||||
|
||||
public int getIndex() {
|
||||
return index;
|
||||
}
|
||||
|
||||
public void setIndex(int index) {
|
||||
this.index = index;
|
||||
}
|
||||
|
||||
public int getIndexSub() {
|
||||
return indexSub;
|
||||
}
|
||||
|
||||
public void setIndexSub(int indexSub) {
|
||||
this.indexSub = indexSub;
|
||||
}
|
||||
}
|
||||
36
app/src/main/java/com/pukka/jiecheng/index/bean/NavResideBean.java
Executable file
36
app/src/main/java/com/pukka/jiecheng/index/bean/NavResideBean.java
Executable file
@@ -0,0 +1,36 @@
|
||||
|
||||
package com.pukka.jiecheng.index.bean;
|
||||
|
||||
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
/**
|
||||
* [选中的下标位置]<BR>
|
||||
*
|
||||
* @author wcg
|
||||
* @version [V0.1.0.1, 2023/12/4 0004]
|
||||
* @since V0.1.0.1
|
||||
*/
|
||||
public class NavResideBean {
|
||||
private int resideIndex;
|
||||
|
||||
private int resideIndexSub = -1;
|
||||
|
||||
public int getResideIndex() {
|
||||
return resideIndex;
|
||||
}
|
||||
|
||||
public void setResideIndex(int resideIndex) {
|
||||
this.resideIndex = resideIndex;
|
||||
LogUtils.d("wcg, setResideIndex: " + resideIndex);
|
||||
}
|
||||
|
||||
public int getResideIndexSub() {
|
||||
return resideIndexSub;
|
||||
}
|
||||
|
||||
public void setResideIndexSub(int resideIndexSub) {
|
||||
this.resideIndexSub = resideIndexSub;
|
||||
LogUtils.d("wcg, setResideIndexSub: " + resideIndexSub);
|
||||
}
|
||||
}
|
||||
163
app/src/main/java/com/pukka/jiecheng/index/dialog/BackImgDialog.java
Executable file
163
app/src/main/java/com/pukka/jiecheng/index/dialog/BackImgDialog.java
Executable file
@@ -0,0 +1,163 @@
|
||||
package com.pukka.jiecheng.index.dialog;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.migu.bean.GetsystemBean;
|
||||
import com.migu.callback.AijiaCallback;
|
||||
import com.migu.httputils.HomeHttpUtils;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.utils.DataValueUtils;
|
||||
import com.pukka.jiecheng.utils.MgRoute;
|
||||
import com.pukka.jiecheng.video.VideoDetailActivity;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
|
||||
public class BackImgDialog extends Dialog {
|
||||
private Activity activity;
|
||||
private OnDialogCallBack onDialogCallBack;
|
||||
|
||||
public BackImgDialog(@NonNull Activity activity) {
|
||||
super(activity);
|
||||
//适配安卓4.4,上部存在一条明显蓝线显示问题
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
this.activity = activity;
|
||||
initView();
|
||||
}
|
||||
|
||||
public void setOnDialogCallBack(OnDialogCallBack onDialogCallBack) {
|
||||
this.onDialogCallBack = onDialogCallBack;
|
||||
}
|
||||
|
||||
private TextView left, right;
|
||||
private PkSimpleDraweeView img;
|
||||
private FrameLayout flImg;
|
||||
private String corner_url = "";
|
||||
private String contentCode = "";
|
||||
|
||||
private String type_tatus, shim_code;
|
||||
|
||||
private void initView() {
|
||||
View view = View.inflate(activity, R.layout.layout_dialog_backimg, null);
|
||||
left = view.findViewById(R.id.left);
|
||||
flImg = view.findViewById(R.id.flImg);
|
||||
img = view.findViewById(R.id.img);
|
||||
right = view.findViewById(R.id.right);
|
||||
|
||||
addContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
|
||||
setCancelable(true);//用户可以点击后退键关闭 Dialog
|
||||
setCanceledOnTouchOutside(false);//用户不可以点击外部来关闭 Dialog
|
||||
|
||||
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
left.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
onDialogCallBack.onFinish();
|
||||
}
|
||||
});
|
||||
right.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
}
|
||||
});
|
||||
flImg.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (TextUtils.equals("5", type_tatus)) {
|
||||
if (TextUtils.isEmpty(shim_code)) {
|
||||
return;
|
||||
}
|
||||
MgRoute.go2SimpleWebActivity(activity, shim_code);
|
||||
} else {
|
||||
if (TextUtils.isEmpty(contentCode)) {
|
||||
return;
|
||||
}
|
||||
VideoDetailActivity.start(activity, contentCode, "", VideoDetailActivity.ModuleSourceType.RETENTION_PAGE);
|
||||
}
|
||||
onDialogCallBack.onImgClick();
|
||||
}
|
||||
});
|
||||
setData();
|
||||
}
|
||||
|
||||
public void setData() {
|
||||
HomeHttpUtils.getsystemData(new AijiaCallback.GetsystemCallBack() {
|
||||
@Override
|
||||
public void onResponse(GetsystemBean response) {
|
||||
try {
|
||||
if (response == null) {
|
||||
return;
|
||||
}
|
||||
if (response.getResult() == null
|
||||
|| response.getResult().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (GetsystemBean.ResultBean bean : response.getResult()
|
||||
) {
|
||||
if (bean.getType()==1) {
|
||||
type_tatus = bean.getType_tatus();
|
||||
if (type_tatus.equals("5")) {
|
||||
shim_code = bean.getShim_code();
|
||||
} else {
|
||||
contentCode = DataValueUtils.getDataValues(bean.getDescription(), "contentCode");
|
||||
}
|
||||
corner_url = bean.getCorner_url();
|
||||
LogUtils.d("BackImgDialog corner_url:" + corner_url);
|
||||
LogUtils.d("BackImgDialog contentCode:" + contentCode);
|
||||
LogUtils.d("BackImgDialog type_tatus:" + type_tatus);
|
||||
LogUtils.d("BackImgDialog shim_code:" + shim_code);
|
||||
if (!TextUtils.isEmpty(corner_url)) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
img.setImageURI(corner_url);
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void netFail() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void show() {
|
||||
if (TextUtils.isEmpty(corner_url)) {
|
||||
setData();
|
||||
}
|
||||
super.show();
|
||||
}
|
||||
|
||||
public interface OnDialogCallBack {
|
||||
void onFinish();
|
||||
|
||||
void onImgClick();
|
||||
}
|
||||
}
|
||||
160
app/src/main/java/com/pukka/jiecheng/index/dialog/BackRetentionDialog.java
Executable file
160
app/src/main/java/com/pukka/jiecheng/index/dialog/BackRetentionDialog.java
Executable file
@@ -0,0 +1,160 @@
|
||||
package com.pukka.jiecheng.index.dialog;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.Window;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.video.face.NavigationInterface;
|
||||
import com.pukka.jiecheng.video.fragment.RecommendFragment;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
|
||||
public class BackRetentionDialog extends DialogFragment {
|
||||
|
||||
private final FragmentManager fragmentManager;
|
||||
private FragmentTransaction fragmentTransaction;
|
||||
|
||||
public BackRetentionDialog(FragmentManager fragmentManager) {
|
||||
this.fragmentManager = fragmentManager;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.layout_retention_back, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
initView(view);
|
||||
fragmentTransaction = getChildFragmentManager().beginTransaction();
|
||||
addRecommendRetentionFragment(catalogIdStr, leftBtnView);
|
||||
onShowHideCallBack.onOnShowHide(true);
|
||||
}
|
||||
|
||||
public void setOnShowHideCallBack(OnShowHideCallBack onShowHideCallBack) {
|
||||
this.onShowHideCallBack = onShowHideCallBack;
|
||||
}
|
||||
|
||||
Dialog dialog;
|
||||
@Override
|
||||
public void onStart() {
|
||||
super.onStart();
|
||||
dialog = getDialog();
|
||||
if (dialog != null) {
|
||||
Window window = dialog.getWindow();
|
||||
window.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
|
||||
window.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel(@NonNull DialogInterface dialog) {
|
||||
onShowHideCallBack.onOnShowHide(false);
|
||||
super.onCancel(dialog);
|
||||
}
|
||||
|
||||
private String catalogIdStr = "485";
|
||||
TextView titleView;
|
||||
TextView rightBtnView;
|
||||
TextView leftBtnView;
|
||||
|
||||
private void initView(View view) {
|
||||
titleView = view.findViewById(R.id.id_tv_title);
|
||||
leftBtnView = view.findViewById(R.id.id_back2);
|
||||
rightBtnView = view.findViewById(R.id.id_goon2);
|
||||
titleView.setText("是否退出程序,为您推荐更多精彩内容");
|
||||
|
||||
leftBtnView.requestFocus();
|
||||
leftBtnView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
onShowHideCallBack.onFinish();
|
||||
}
|
||||
});
|
||||
rightBtnView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
hideRetention();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void addRecommendRetentionFragment(String catalogid, View upFocusView) {
|
||||
if (TextUtils.isEmpty(catalogid)) {
|
||||
LogUtils.d("Detail Content not recommend list.");
|
||||
return;
|
||||
}
|
||||
RecommendFragment recommendRetentionFragment = new RecommendFragment();
|
||||
recommendRetentionFragment.setOnUpDateList(new RecommendFragment.OnUpDateList() {
|
||||
@Override
|
||||
public void onUpData(View view, int type) {
|
||||
LogUtils.d("setOnUpDateList222." + type);
|
||||
if (type != 1) {
|
||||
return;
|
||||
}
|
||||
view.setNextFocusUpId(upFocusView.getId());
|
||||
view.setNextFocusDownId(upFocusView.getId());
|
||||
view.setNextFocusRightId(upFocusView.getId());
|
||||
upFocusView.setNextFocusDownId(view.getId());
|
||||
}
|
||||
});
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putString("catalogid", catalogid);
|
||||
bundle.putString("Retention", "Retention");
|
||||
recommendRetentionFragment.setArguments(bundle);
|
||||
recommendRetentionFragment.setNavigationInterface(new NavigationInterface() {
|
||||
@Override
|
||||
public void navigationTop() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void navigationRecommend() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRecommendItemClick() {
|
||||
|
||||
}
|
||||
});
|
||||
fragmentTransaction.replace(R.id.id_fl_recommend_retention2, recommendRetentionFragment)
|
||||
.commit();
|
||||
|
||||
}
|
||||
|
||||
public void showRetention() {
|
||||
showNow(fragmentManager, "RetentionBackDialog");
|
||||
}
|
||||
|
||||
public void hideRetention() {
|
||||
dismiss();
|
||||
}
|
||||
|
||||
private OnShowHideCallBack onShowHideCallBack;
|
||||
|
||||
public interface OnShowHideCallBack {
|
||||
void onFinish();
|
||||
|
||||
void onOnShowHide(boolean isShow);
|
||||
}
|
||||
|
||||
}
|
||||
173
app/src/main/java/com/pukka/jiecheng/index/dialog/FullimgDialog.java
Executable file
173
app/src/main/java/com/pukka/jiecheng/index/dialog/FullimgDialog.java
Executable file
@@ -0,0 +1,173 @@
|
||||
package com.pukka.jiecheng.index.dialog;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.Window;
|
||||
import android.view.WindowManager;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.migu.bean.GetsystemBean;
|
||||
import com.migu.callback.AijiaCallback;
|
||||
import com.migu.httputils.HomeHttpUtils;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.order.OrderActivity;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
|
||||
public class FullimgDialog extends Dialog {
|
||||
private Activity activity;
|
||||
|
||||
public FullimgDialog(@NonNull Activity activity) {
|
||||
super(activity);
|
||||
//适配安卓4.4,上部存在一条明显蓝线显示问题
|
||||
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
this.activity = activity;
|
||||
initView();
|
||||
}
|
||||
|
||||
|
||||
private PkSimpleDraweeView img;
|
||||
private String corner_url = "";
|
||||
private String shim_code = "";
|
||||
private TextView timeTv;
|
||||
|
||||
private void initView() {
|
||||
View view = View.inflate(activity, R.layout.layout_dialog_fullimg, null);
|
||||
img = view.findViewById(R.id.img);
|
||||
timeTv = view.findViewById(R.id.timeTv);
|
||||
|
||||
setContentView(view);
|
||||
setCancelable(true);//用户可以点击后退键关闭 Dialog
|
||||
setCanceledOnTouchOutside(false);//用户不可以点击外部来关闭 Dialog
|
||||
Window window = this.getWindow();
|
||||
if (window != null) {
|
||||
// 关键设置:让Dialog充满宽度
|
||||
WindowManager.LayoutParams layoutParams = window.getAttributes();
|
||||
layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
layoutParams.height = WindowManager.LayoutParams.MATCH_PARENT;
|
||||
|
||||
// 可选:设置窗口位置和动画
|
||||
layoutParams.gravity = Gravity.CENTER;
|
||||
window.setAttributes(layoutParams);
|
||||
|
||||
// 设置背景,确保圆角等样式生效
|
||||
window.setBackgroundDrawableResource(android.R.color.transparent);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void setData() {
|
||||
img.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
//orderCenter&&policyCode=197615
|
||||
// Toast.makeText(activity, "跳转"+shim_code, Toast.LENGTH_SHORT).show();
|
||||
if (!TextUtils.isEmpty(shim_code)&&shim_code.contains("orderCenter")){
|
||||
dismiss();
|
||||
Intent intent = new Intent(activity, OrderActivity.class);
|
||||
if (shim_code.contains("policyCode=")){
|
||||
String result = shim_code.split("=")[1];
|
||||
intent.putExtra("policyCode",result);
|
||||
}
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
}
|
||||
});
|
||||
HomeHttpUtils.getsystemData(new AijiaCallback.GetsystemCallBack() {
|
||||
@Override
|
||||
public void onResponse(GetsystemBean response) {
|
||||
try {
|
||||
if (response == null) {
|
||||
return;
|
||||
}
|
||||
if (response.getResult() == null
|
||||
|| response.getResult().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
for (GetsystemBean.ResultBean bean : response.getResult()
|
||||
) {
|
||||
if (bean.getType()==6) {
|
||||
corner_url = bean.getCorner_url();
|
||||
timeNum = bean.getLookDuration()==0?5:bean.getLookDuration();
|
||||
shim_code = bean.getShim_code();
|
||||
LogUtils.d("kaiji corner_url:"+corner_url);
|
||||
LogUtils.d("kaiji timeNum:"+timeNum);
|
||||
LogUtils.d("kaiji shim_code:"+shim_code);
|
||||
if (!TextUtils.isEmpty(corner_url) && timeNum>0) {
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
img.setImageURI(corner_url);
|
||||
showDialog();
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void netFail() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fail() {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private int timeNum = 10;
|
||||
private final Handler stopHandler = new Handler();
|
||||
private final Runnable stopRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (isShowing()) {
|
||||
timeNum--;
|
||||
if (timeNum <= 0) {
|
||||
dismiss();
|
||||
} else {
|
||||
timeTv.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
timeTv.setText(timeNum + "");
|
||||
}
|
||||
});
|
||||
stopHandler.postDelayed(stopRunnable, 1000);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
public void showAd(){
|
||||
setData();
|
||||
}
|
||||
|
||||
public void showDialog() {
|
||||
if (TextUtils.isEmpty(corner_url)) {
|
||||
return;
|
||||
}
|
||||
super.show();
|
||||
timeTv.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
timeTv.setText(timeNum + "");
|
||||
}
|
||||
});
|
||||
stopHandler.postDelayed(stopRunnable, 1000);
|
||||
}
|
||||
}
|
||||
53
app/src/main/java/com/pukka/jiecheng/index/dialog/UserExitDialog.java
Executable file
53
app/src/main/java/com/pukka/jiecheng/index/dialog/UserExitDialog.java
Executable file
@@ -0,0 +1,53 @@
|
||||
package com.pukka.jiecheng.index.dialog;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.pukka.jiecheng.R;
|
||||
|
||||
|
||||
public class UserExitDialog extends Dialog {
|
||||
private Activity activity;
|
||||
|
||||
public UserExitDialog(@NonNull Activity activity,OnUserExitCallBack onUserExitCallBack) {
|
||||
super(activity);
|
||||
this.activity = activity;
|
||||
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
initView(onUserExitCallBack);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private ImageView right;
|
||||
|
||||
private void initView(OnUserExitCallBack onUserExitCallBack) {
|
||||
View view = View.inflate(activity, R.layout.layout_dialog_user_exit, null);
|
||||
right = view.findViewById(R.id.left);
|
||||
addContentView(view, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
||||
//setCancelable(false);//用户可以点击后退键关闭 Dialog
|
||||
//setCanceledOnTouchOutside(false);//用户不可以点击外部来关闭 Dialog
|
||||
getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
|
||||
right.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
dismiss();
|
||||
onUserExitCallBack.onExitCallBack();
|
||||
}
|
||||
});
|
||||
right.requestFocus();
|
||||
}
|
||||
public interface OnUserExitCallBack {
|
||||
void onExitCallBack();
|
||||
}
|
||||
}
|
||||
350
app/src/main/java/com/pukka/jiecheng/index/fragment/ContentFragment.java
Executable file
350
app/src/main/java/com/pukka/jiecheng/index/fragment/ContentFragment.java
Executable file
@@ -0,0 +1,350 @@
|
||||
|
||||
package com.pukka.jiecheng.index.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.ViewStub;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.RelativeLayout;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.migu.bean.GetLayoutBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.index.IndexActivity;
|
||||
import com.pukka.jiecheng.index.adapter.IndexContentAdapter;
|
||||
import com.pukka.jiecheng.index.viewholder.C7ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.D2ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.D2_1ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewmodel.ContentViewModel;
|
||||
import com.pukka.jiecheng.utils.VideoContainerHelper;
|
||||
import com.pukka.jiecheng.widget.SpaceItemDecoration;
|
||||
import com.pukka.jiecheng.widget.VerticalRecyclerViewEx;
|
||||
import com.pukka.libcore.threading.DispatchQueue;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
import com.pukka.libcore.viewmodel.BaseVM;
|
||||
import com.pukka.libcore.widget.TVLinearLayoutManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 内容 Fragment
|
||||
*/
|
||||
public class ContentFragment extends Fragment {
|
||||
private FrameLayout rootView;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private IndexContentAdapter indexContentAdapter;
|
||||
|
||||
private List<GetLayoutBean.DataBean> layoutNavLists = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* 那个楼层
|
||||
*/
|
||||
private int goAfterFloorPosition = -1;
|
||||
|
||||
/**
|
||||
* 楼层下面的Index
|
||||
*/
|
||||
private int goAfterPosition = -1;
|
||||
|
||||
private ContentViewModel contentViewModel;
|
||||
|
||||
private String mNavId;
|
||||
|
||||
/**
|
||||
* 是否已经添加了回到顶部的楼层数据
|
||||
*/
|
||||
private boolean hasAddToTopFloor;
|
||||
|
||||
/**
|
||||
* 是否需求重新落焦
|
||||
*/
|
||||
private boolean needRequestFocus;
|
||||
|
||||
public static ContentFragment newInstance() {
|
||||
return new ContentFragment();
|
||||
}
|
||||
|
||||
public void setNavId(String mNavId) {
|
||||
this.mNavId = mNavId;
|
||||
}
|
||||
|
||||
public String getNavId() {
|
||||
return mNavId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
LogUtils.d("wcg, onCreate");
|
||||
}
|
||||
|
||||
private VerticalRecyclerViewEx mRvContent;
|
||||
|
||||
private ViewStub vsNoData;
|
||||
private boolean hasInflated;
|
||||
private RelativeLayout mRlNoData;
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_content, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, Bundle savedInstanceState) {
|
||||
Log.e("wxf", "contentFragment onViewCreated");
|
||||
initView(view);
|
||||
mContext = requireActivity();
|
||||
contentViewModel = BaseVM.getSafeViewModel(this, ContentViewModel.class);
|
||||
registerObservers();
|
||||
}
|
||||
|
||||
private void initView(View view) {
|
||||
rootView = view.findViewById(R.id.root_fl);
|
||||
mRvContent = view.findViewById(R.id.recyclerView);
|
||||
vsNoData = view.findViewById(R.id.vs_noData);
|
||||
initContentRecyclerView();
|
||||
}
|
||||
|
||||
private void initContentRecyclerView() {
|
||||
TVLinearLayoutManager linearLayoutManager =
|
||||
new TVLinearLayoutManager(mContext, LinearLayoutManager.VERTICAL, false);
|
||||
mRvContent.setHandLastKey(true, true, false, true);
|
||||
mRvContent.setLayoutManager(linearLayoutManager);
|
||||
int spacingInPixels = getResources().getDimensionPixelSize(R.dimen.qb_px_20);
|
||||
mRvContent.addItemDecoration(new SpaceItemDecoration(spacingInPixels, 5));
|
||||
if (null != ((SimpleItemAnimator) mRvContent.getItemAnimator())) {
|
||||
((SimpleItemAnimator) mRvContent.getItemAnimator()).setSupportsChangeAnimations(false);
|
||||
}
|
||||
}
|
||||
|
||||
// 获取 导航内容
|
||||
public void upData() {
|
||||
LogUtils.d("upData navId:" + mNavId);
|
||||
clearAdapterCaches();
|
||||
hasAddToTopFloor = false;
|
||||
hideNoDataUI();
|
||||
goAfterFloorPosition = -1;
|
||||
goAfterPosition = -1;
|
||||
if (null != contentViewModel) {
|
||||
contentViewModel.getLayoutBeanData(mNavId, requireActivity());
|
||||
}
|
||||
}
|
||||
|
||||
private void setLayoutNavLists() {
|
||||
if (null == layoutNavLists || layoutNavLists.isEmpty()) {
|
||||
showNoDataUI();
|
||||
} else {
|
||||
if (!hasAddToTopFloor) {
|
||||
layoutNavLists.add(new GetLayoutBean.DataBean("toTop"));
|
||||
hasAddToTopFloor = true;
|
||||
}
|
||||
|
||||
if (null == indexContentAdapter) {
|
||||
createContentRecyclerViewAdapter();
|
||||
}
|
||||
indexContentAdapter.setLayoutNavList(layoutNavLists);
|
||||
if (needRequestFocus) {
|
||||
requestD2Focus();
|
||||
needRequestFocus = false;
|
||||
}
|
||||
if (goAfterFloorPosition != -1 && null != contentViewModel) {
|
||||
LogUtils.d("wcg, setLayoutNavLists goAfterFloorPosition");
|
||||
DispatchQueue.main.after(300, () -> contentViewModel.goAfterFocusLiveData.postValue(""));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public RecyclerView getRvContent() {
|
||||
return mRvContent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前Position恢复到默认
|
||||
*/
|
||||
public void initCurrentPosition() {
|
||||
if (mRvContent != null) {
|
||||
mRvContent.initCurrentPosition();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
RecyclerView.LayoutManager layoutManager = mRvContent.getLayoutManager();
|
||||
if (layoutManager instanceof LinearLayoutManager) {
|
||||
VideoContainerHelper.getInstance().setLinearLayoutManager((LinearLayoutManager) layoutManager);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
LogUtils.d("onDestroy()");
|
||||
rootView.removeAllViews();
|
||||
contentViewModel = null;
|
||||
clearAdapterCaches();
|
||||
}
|
||||
|
||||
/**
|
||||
* 没数据,显示无数据的界面
|
||||
*/
|
||||
private void showNoDataUI() {
|
||||
if (!hasInflated) {
|
||||
mRlNoData = vsNoData.inflate().findViewById(R.id.id_rl_noData);
|
||||
hasInflated = true;
|
||||
} else {
|
||||
FrameLayout.LayoutParams layoutParams_txt = (FrameLayout.LayoutParams) mRlNoData.getLayoutParams();
|
||||
layoutParams_txt.topMargin = -(int) mContext.getResources().getDimension(R.dimen.qb_px_70);
|
||||
}
|
||||
|
||||
mRlNoData.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void hideNoDataUI() {
|
||||
if (!hasInflated) {
|
||||
mRlNoData = vsNoData.inflate().findViewById(R.id.id_rl_noData);
|
||||
hasInflated = true;
|
||||
}
|
||||
mRlNoData.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册observer
|
||||
*/
|
||||
private void registerObservers() {
|
||||
if (null == contentViewModel) {
|
||||
return;
|
||||
}
|
||||
contentViewModel.goAfterFocusLiveData.observe(getViewLifecycleOwner(), s -> findLastSaveFocusedView());
|
||||
|
||||
contentViewModel.layoutBeanLiveData.observe(getViewLifecycleOwner(), response -> {
|
||||
if (null != response && null != response.getData() && !response.getData().isEmpty()) {
|
||||
LogUtils.d("wcg, layoutBeanLiveData observe response: " + new Gson().toJson(response));
|
||||
if (!layoutNavLists.isEmpty()) {
|
||||
layoutNavLists.clear();
|
||||
}
|
||||
hasAddToTopFloor = false;
|
||||
layoutNavLists = removeHeaderData(response.getData());
|
||||
setLayoutNavLists();
|
||||
} else {
|
||||
showNoDataUI();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void createContentRecyclerViewAdapter() {
|
||||
if (mRvContent != null) {
|
||||
mRvContent.initCurrentPosition();
|
||||
}
|
||||
|
||||
indexContentAdapter = new IndexContentAdapter(this);
|
||||
indexContentAdapter.setHasStableIds(true);
|
||||
mRvContent.setAdapter(indexContentAdapter);
|
||||
}
|
||||
|
||||
public void findLastSaveFocusedView() {
|
||||
if (null != mRvContent.getLayoutManager()) {
|
||||
if (requireActivity() instanceof IndexActivity) {
|
||||
IndexActivity indexActivity = ((IndexActivity) requireActivity());
|
||||
indexActivity.getTopView().mIvLogo.setFocusable(false);
|
||||
}
|
||||
RecyclerView.ViewHolder holder = mRvContent.getChildViewHolder(mRvContent.getChildAt(goAfterFloorPosition));
|
||||
LogUtils.d("holder:" + holder.toString());
|
||||
if (holder instanceof C7ViewHolder) {
|
||||
return;
|
||||
}
|
||||
ViewGroup viewGroup = (ViewGroup) mRvContent.getLayoutManager().getChildAt(goAfterFloorPosition);
|
||||
if (null != viewGroup) {
|
||||
View view = viewGroup.findViewById(goAfterPosition);
|
||||
if (view != null) {
|
||||
LogUtils.d("wcg, hasFocusedView");
|
||||
view.requestFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void goToPlay() {
|
||||
try {
|
||||
indexContentAdapter.goOnPlayVideo();
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除header楼层数据
|
||||
*
|
||||
* @param navList 服务器下发的数据
|
||||
* @return 楼层数据
|
||||
*/
|
||||
@NonNull
|
||||
private List<GetLayoutBean.DataBean> removeHeaderData(List<GetLayoutBean.DataBean> navList) {
|
||||
List<GetLayoutBean.DataBean> finalList = new ArrayList<>();
|
||||
for (int i = 0; i < navList.size(); i++) {
|
||||
GetLayoutBean.DataBean dataBean = navList.get(i);
|
||||
if (!TextUtils.equals("header", dataBean.getType())) {
|
||||
finalList.add(dataBean);
|
||||
}
|
||||
}
|
||||
return finalList;
|
||||
}
|
||||
|
||||
private void requestD2Focus() {
|
||||
mRvContent.post(() -> {
|
||||
RecyclerView.LayoutManager layoutManager = mRvContent.getLayoutManager();
|
||||
if (layoutManager instanceof LinearLayoutManager) {
|
||||
LinearLayoutManager mLinearLayoutManager = (LinearLayoutManager) layoutManager;
|
||||
int firstPosition = mLinearLayoutManager.findFirstVisibleItemPosition();
|
||||
int lastPosition = mLinearLayoutManager.findLastVisibleItemPosition();
|
||||
for (int pos = firstPosition; pos <= lastPosition; pos++) {
|
||||
View itemView = mLinearLayoutManager.findViewByPosition(pos);
|
||||
if (null == itemView) {
|
||||
return;
|
||||
}
|
||||
|
||||
RecyclerView.ViewHolder holder = mRvContent.getChildViewHolder(itemView);
|
||||
LogUtils.d("holder:" + holder.toString());
|
||||
if (holder instanceof D2ViewHolder) {
|
||||
((D2ViewHolder) holder).requestFirstFocus();
|
||||
} else if (holder instanceof D2_1ViewHolder) {
|
||||
((D2_1ViewHolder) holder).requestFirstFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换tab或者页面onDestroy时,释放adapter缓存
|
||||
*/
|
||||
private void clearAdapterCaches() {
|
||||
if (null != mRvContent && null != mRvContent.getAdapter()) {
|
||||
mRvContent.setAdapter(null);
|
||||
indexContentAdapter = null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHiddenChanged(boolean hidden) {
|
||||
super.onHiddenChanged(hidden);
|
||||
if (hidden) {
|
||||
clearAdapterCaches();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
181
app/src/main/java/com/pukka/jiecheng/index/fragment/HotelMyFragment.java
Executable file
181
app/src/main/java/com/pukka/jiecheng/index/fragment/HotelMyFragment.java
Executable file
@@ -0,0 +1,181 @@
|
||||
|
||||
package com.pukka.jiecheng.index.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.downapk.DownApkDialog;
|
||||
import com.pukka.jiecheng.index.HotelMyActivity;
|
||||
import com.pukka.jiecheng.index.IndexActivity;
|
||||
import com.pukka.jiecheng.index.viewmodel.MyViewModel;
|
||||
import com.pukka.jiecheng.utils.MgRoute;
|
||||
import com.pukka.jiecheng.utils.ToastUtils;
|
||||
import com.pukka.jiecheng.utils.TopStyleUtils;
|
||||
import com.pukka.libcore.boxShared.MacUtils;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
import com.pukka.libcore.viewmodel.BaseVM;
|
||||
|
||||
/**
|
||||
* Author: wxf
|
||||
* Date: 2025/11/27 15:03
|
||||
* Description:酒店渠道我的页面
|
||||
*/
|
||||
public class HotelMyFragment extends Fragment implements View.OnClickListener , View.OnFocusChangeListener{
|
||||
private RelativeLayout mIv3, mIv4, mIv5, mIv6;
|
||||
|
||||
private TextView userIdTv, mVipExpireTime;
|
||||
|
||||
private ConstraintLayout mClLeftUser;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private ScrollView mSvContent;
|
||||
|
||||
|
||||
private MyViewModel myViewModel;
|
||||
|
||||
|
||||
public HotelMyFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static HotelMyFragment newInstance() {
|
||||
return new HotelMyFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_hotel_my, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
mContext = getActivity();
|
||||
initView(view);
|
||||
myViewModel = BaseVM.getSafeViewModel(this, MyViewModel.class);
|
||||
initFocus();
|
||||
registerObserver();
|
||||
getPageData();
|
||||
}
|
||||
|
||||
private void initFocus() {
|
||||
mClLeftUser.setNextFocusLeftId(R.id.id_cl_user_left);
|
||||
mIv4.setNextFocusRightId(R.id.id_iv_device_4);
|
||||
mIv6.setNextFocusRightId(R.id.id_iv_6);
|
||||
}
|
||||
|
||||
private void getPageData() {
|
||||
if (null == myViewModel) {
|
||||
return;
|
||||
}
|
||||
// myViewModel.queryVipInfo();
|
||||
}
|
||||
|
||||
private void initView(View view) {
|
||||
mClLeftUser = view.findViewById(R.id.id_cl_user_left);
|
||||
mSvContent = view.findViewById(R.id.id_sv_main);
|
||||
userIdTv = view.findViewById(R.id.id_tv_user);
|
||||
mVipExpireTime = view.findViewById(R.id.id_tv_vip_expiretime);
|
||||
userBind();
|
||||
mIv3 = view.findViewById(R.id.id_iv_3);
|
||||
mIv4 = view.findViewById(R.id.id_iv_device_4);
|
||||
mIv5 = view.findViewById(R.id.id_iv_5);
|
||||
mIv6 = view.findViewById(R.id.id_iv_6);
|
||||
mIv3.setOnClickListener(this);
|
||||
mIv4.setOnClickListener(this);
|
||||
mIv5.setOnClickListener(this);
|
||||
mIv6.setOnClickListener(this);
|
||||
mClLeftUser.setOnFocusChangeListener(this);
|
||||
mIv3.setOnFocusChangeListener(this);
|
||||
mIv4.setOnFocusChangeListener(this);
|
||||
mIv5.setOnFocusChangeListener(this);
|
||||
mIv6.setOnFocusChangeListener(this);
|
||||
if(mContext instanceof HotelMyActivity){
|
||||
//爱视酒店版本单独成为页面,隐藏返回顶部和搜索按钮
|
||||
ConstraintLayout mClToTop = view.findViewById(R.id.id_cl_to_top);
|
||||
mClToTop.setVisibility(View.GONE);
|
||||
ConstraintLayout searchCl = view.findViewById(R.id.id_bottom_cl_search);
|
||||
searchCl.setVisibility(View.GONE);
|
||||
}else {
|
||||
// 返回顶部楼层
|
||||
ConstraintLayout mClToTop = view.findViewById(R.id.id_cl_to_top);
|
||||
ConstraintLayout searchCl = view.findViewById(R.id.id_bottom_cl_search);
|
||||
mClToTop.setOnClickListener(this);
|
||||
searchCl.setOnClickListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
private void userBind() {
|
||||
userIdTv.setText("MAC:" + MacUtils.getMac(mContext));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (view.getId() == R.id.id_bottom_cl_search) {
|
||||
MgRoute.go2Search(mContext, 2);
|
||||
} else if (view.getId() == R.id.id_iv_3) {
|
||||
ToastUtils.showLongToast("功能开发中");
|
||||
} else if (view.getId() == R.id.id_iv_device_4) {
|
||||
MgRoute.go2Device(mContext);
|
||||
} else if (view.getId() == R.id.id_iv_5) {
|
||||
//检测更新
|
||||
// TODO: 2025/6/10 APK更新
|
||||
// new DownApkDialog(getActivity()).initDown2();
|
||||
ToastUtils.showLongBottomToast("暂无新版本");
|
||||
} else if (view.getId() == R.id.id_cl_to_top) {
|
||||
IndexActivity indexActivity = (IndexActivity) mContext;
|
||||
indexActivity.scrollToTop();
|
||||
} else if (view.getId() == R.id.id_iv_6) {
|
||||
MgRoute.go2AboutMy(mContext);
|
||||
}
|
||||
}
|
||||
|
||||
public ScrollView getScrollView() {
|
||||
return mSvContent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
private void registerObserver() {
|
||||
if (null == myViewModel) {
|
||||
return;
|
||||
}
|
||||
String expireTime = com.pukka.jiecheng.config.AppConfiguration.getInstance().getExpireTime();
|
||||
if (expireTime != null && !expireTime.isEmpty()) {
|
||||
mVipExpireTime.setText("会员截止日期:" + expireTime);
|
||||
} else {
|
||||
mVipExpireTime.setText("会员截止日期:暂无数据");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHiddenChanged(boolean hidden) {
|
||||
super.onHiddenChanged(hidden);
|
||||
LogUtils.d("wcg, onHiddenChanged: " + hidden);
|
||||
if (!hidden) {
|
||||
getPageData();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean b) {
|
||||
TopStyleUtils.topImageChange(view, b);
|
||||
}
|
||||
}
|
||||
452
app/src/main/java/com/pukka/jiecheng/index/fragment/MyFragment.java
Executable file
452
app/src/main/java/com/pukka/jiecheng/index/fragment/MyFragment.java
Executable file
@@ -0,0 +1,452 @@
|
||||
|
||||
package com.pukka.jiecheng.index.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
|
||||
import com.migu.bean.GetFindPlayrecordBean;
|
||||
import com.migu.bean.GetLayoutBean;
|
||||
import com.migu.bean.GetlistcollBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.index.IndexActivity;
|
||||
import com.pukka.jiecheng.index.adapter.IndexMyCollectAdapter;
|
||||
import com.pukka.jiecheng.index.adapter.IndexMyHistoryAdapter;
|
||||
import com.pukka.jiecheng.index.dialog.UserExitDialog;
|
||||
import com.pukka.jiecheng.index.viewmodel.MyViewModel;
|
||||
import com.pukka.jiecheng.login.LoginActivity;
|
||||
import com.pukka.jiecheng.newtv.NewTvUtils;
|
||||
import com.pukka.jiecheng.utils.MgRoute;
|
||||
import com.pukka.jiecheng.utils.TopStyleUtils;
|
||||
import com.pukka.libcore.boxShared.BoxSharedParameters;
|
||||
import com.pukka.libcore.boxShared.BoxSharedParamsUtils;
|
||||
import com.pukka.libcore.fresco.PkSimpleDraweeView;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
import com.pukka.libcore.utils.ScreenUtil;
|
||||
import com.pukka.libcore.utils.SpTimeUtils;
|
||||
import com.pukka.libcore.utils.StringUtils;
|
||||
import com.pukka.libcore.viewmodel.BaseVM;
|
||||
import com.pukka.libcore.widget.HorizontalRecyclerViewTv;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: wxf
|
||||
* Date: 2023/3/8 15:03
|
||||
* Description:我的页面
|
||||
*/
|
||||
public class MyFragment extends Fragment implements View.OnClickListener, View.OnFocusChangeListener {
|
||||
private RelativeLayout mIv2, mIv3, mIv4, mIv5;
|
||||
|
||||
private static HorizontalRecyclerViewTv mRvHistory;
|
||||
|
||||
private static HorizontalRecyclerViewTv mRvCollect;
|
||||
|
||||
|
||||
private ConstraintLayout mClHistoryNo;
|
||||
|
||||
private ConstraintLayout mClCollectNo;
|
||||
|
||||
private ConstraintLayout mUserManager;
|
||||
|
||||
private ImageView mIvHistoryMore, mIvCollectMore;
|
||||
|
||||
private TextView userIdTv, userManagerTv, userIdPreTv;
|
||||
private TextView mTvProductInfo;
|
||||
|
||||
private Context mContext;
|
||||
|
||||
private ScrollView mSvContent;
|
||||
|
||||
private List<GetLayoutBean.DataBean> layoutNavLists = new ArrayList<>();
|
||||
|
||||
|
||||
private IndexMyHistoryAdapter myHistoryAdapter;
|
||||
|
||||
private IndexMyCollectAdapter myCollectAdapter;
|
||||
|
||||
// 默认 -1 , 历史 1 ,收藏 2
|
||||
public int gotoPage = -1;
|
||||
|
||||
private MyViewModel myViewModel;
|
||||
|
||||
public String navId;
|
||||
|
||||
public MyFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static MyFragment newInstance() {
|
||||
return new MyFragment();
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_my, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
gotoPage = -1;
|
||||
mContext = getActivity();
|
||||
initView(view);
|
||||
myViewModel = BaseVM.getSafeViewModel(this, MyViewModel.class);
|
||||
initFocus();
|
||||
registerObserver();
|
||||
|
||||
getPageData();
|
||||
}
|
||||
|
||||
private void initFocus() {
|
||||
mIv2.setNextFocusRightId(R.id.id_iv_order_2);
|
||||
if(BoxSharedParamsUtils.isJcCloud()){
|
||||
mIv2.setNextFocusLeftId(R.id.id_iv_order_2);
|
||||
}
|
||||
mIv3.setNextFocusLeftId(R.id.id_iv_3);
|
||||
mIv5.setNextFocusRightId(R.id.id_iv_5);
|
||||
}
|
||||
|
||||
private void getPageData() {
|
||||
LogUtils.d("wcg, getPageData");
|
||||
if (null == myViewModel) {
|
||||
return;
|
||||
}
|
||||
LogUtils.d("wcg, getPageData 11");
|
||||
getCollectAndRecordData();
|
||||
}
|
||||
|
||||
private void initView(View view) {
|
||||
mSvContent = view.findViewById(R.id.id_sv_main);
|
||||
mTvProductInfo = view.findViewById(R.id.id_tv_product_info);
|
||||
userIdPreTv = view.findViewById(R.id.id_tv_user);
|
||||
userIdTv = view.findViewById(R.id.id_tv_userId);
|
||||
userManagerTv = view.findViewById(R.id.id_tv_userManager);
|
||||
userBind();
|
||||
PkSimpleDraweeView mIv1 = view.findViewById(R.id.id_iv_1);
|
||||
mIv2 = view.findViewById(R.id.id_iv_order_2);
|
||||
mIv3 = view.findViewById(R.id.id_iv_3);
|
||||
mIv4 = view.findViewById(R.id.id_iv_device_4);
|
||||
mIv5 = view.findViewById(R.id.id_iv_5);
|
||||
|
||||
mIvHistoryMore = view.findViewById(R.id.id_iv_history);
|
||||
mIvCollectMore = view.findViewById(R.id.id_iv_collect);
|
||||
|
||||
mIv1.setOnFocusChangeListener(this);
|
||||
mIv1.setOnClickListener(this);
|
||||
mIv2.setOnFocusChangeListener(this);
|
||||
mIv2.setOnClickListener(this);
|
||||
mIv3.setOnFocusChangeListener(this);
|
||||
mIv3.setOnClickListener(this);
|
||||
mIv4.setOnFocusChangeListener(this);
|
||||
mIv4.setOnClickListener(this);
|
||||
mIv5.setOnFocusChangeListener(this);
|
||||
mIv5.setOnClickListener(this);
|
||||
mIvHistoryMore.setOnFocusChangeListener(this);
|
||||
mIvHistoryMore.setOnClickListener(this);
|
||||
mIvCollectMore.setOnFocusChangeListener(this);
|
||||
mIvCollectMore.setOnClickListener(this);
|
||||
|
||||
|
||||
mRvHistory = view.findViewById(R.id.id_rv_history);
|
||||
mRvCollect = view.findViewById(R.id.id_rv_collect);
|
||||
mClHistoryNo = view.findViewById(R.id.id_cl_history_no);
|
||||
mClCollectNo = view.findViewById(R.id.id_cl_collect_no);
|
||||
mUserManager = view.findViewById(R.id.id_cl_userManager);
|
||||
if(BoxSharedParamsUtils.isJcCloud() || BoxSharedParamsUtils.isJcHotel()){
|
||||
//云主机版本和酒店版本 隐藏登录和退出按钮
|
||||
mUserManager.setVisibility(View.INVISIBLE);
|
||||
}
|
||||
mUserManager.setOnClickListener(this);
|
||||
mUserManager.setOnFocusChangeListener(this);
|
||||
mClCollectNo.setOnFocusChangeListener(this);
|
||||
mClHistoryNo.setOnFocusChangeListener(this);
|
||||
|
||||
// 返回顶部楼层
|
||||
ConstraintLayout mClToTop = view.findViewById(R.id.id_cl_to_top);
|
||||
ConstraintLayout searchCl = view.findViewById(R.id.id_bottom_cl_search);
|
||||
mClToTop.setOnClickListener(this);
|
||||
searchCl.setOnClickListener(this);
|
||||
mClToTop.setOnFocusChangeListener(this);
|
||||
searchCl.setOnFocusChangeListener(this);
|
||||
}
|
||||
|
||||
private void userBind() {
|
||||
userIdTv.setText("");
|
||||
mTvProductInfo.setText("");
|
||||
if (BoxSharedParameters.getInstance().isLogin()) {
|
||||
userIdTv.setText(maskPhoneNumber(BoxSharedParameters.getInstance().getUserId()));
|
||||
userManagerTv.setText("退出登录");
|
||||
userIdPreTv.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
userIdPreTv.setVisibility(View.INVISIBLE);
|
||||
userManagerTv.setText("登录账号");
|
||||
}
|
||||
}
|
||||
|
||||
private void noHistoryData() {
|
||||
LogUtils.d("gotoPage=" + gotoPage);
|
||||
mRvHistory.setVisibility(View.GONE);
|
||||
mClHistoryNo.setVisibility(View.VISIBLE);
|
||||
mIvHistoryMore.setVisibility(View.GONE);
|
||||
if (gotoPage == 1) {
|
||||
LogUtils.d("mClGoJin request focus");
|
||||
mClHistoryNo.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
private void noCollectData() {
|
||||
mRvCollect.setVisibility(View.GONE);
|
||||
mClCollectNo.setVisibility(View.VISIBLE);
|
||||
mIvCollectMore.setVisibility(View.GONE);
|
||||
LogUtils.d("gotoPage=" + gotoPage);
|
||||
if (gotoPage == 2) {
|
||||
mClCollectNo.requestFocus();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
if (view.getId() == R.id.id_iv_history) {
|
||||
LogUtils.d("go to all_history,");
|
||||
gotoPage = 1;
|
||||
LogUtils.d("go to all_history,gotoPage=" + gotoPage);
|
||||
MgRoute.go2HisMore(mContext);
|
||||
} else if (view.getId() == R.id.id_iv_collect) {
|
||||
gotoPage = 2;
|
||||
MgRoute.go2ColMore(mContext, 1);
|
||||
} else if (view.getId() == R.id.id_bottom_cl_search) {
|
||||
MgRoute.go2Search(mContext, 2);
|
||||
} else if (view.getId() == R.id.id_iv_order_2) {
|
||||
//跳到收银台
|
||||
MgRoute.go2Order(mContext);
|
||||
} else if (view.getId() == R.id.id_iv_3) {
|
||||
MgRoute.go2Order(mContext, "2");
|
||||
} else if (view.getId() == R.id.id_iv_device_4) {
|
||||
MgRoute.go2Device(mContext);
|
||||
} else if (view.getId() == R.id.id_iv_5) {
|
||||
MgRoute.go2AboutMy(mContext);
|
||||
} else if (view.getId() == R.id.id_cl_to_top) {
|
||||
IndexActivity indexActivity = (IndexActivity) mContext;
|
||||
indexActivity.scrollToTop();
|
||||
} else if (view.getId() == R.id.id_cl_userManager) {
|
||||
if (BoxSharedParameters.getInstance().isLogin()) {
|
||||
new UserExitDialog(getActivity(), new UserExitDialog.OnUserExitCallBack() {
|
||||
@Override
|
||||
public void onExitCallBack() {
|
||||
LogUtils.d("go to logout");
|
||||
if (null != myViewModel) {
|
||||
myViewModel.logout();
|
||||
}
|
||||
}
|
||||
}).show();
|
||||
|
||||
} else {
|
||||
LoginActivity.start(getActivity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@SuppressLint("UseCompatLoadingForDrawables")
|
||||
@Override
|
||||
public void onFocusChange(View view, boolean b) {
|
||||
if (view.getId() == R.id.id_cl_to_top) {
|
||||
if (b) {
|
||||
mSvContent.smoothScrollTo(0, ScreenUtil.getDeviceHeight(mSvContent));
|
||||
}
|
||||
return;
|
||||
} else if (view.getId() == R.id.id_bottom_cl_search) {
|
||||
if (b) {
|
||||
mSvContent.smoothScrollTo(0, ScreenUtil.getDeviceHeight(mSvContent));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (view.getId() == R.id.id_cl_userManager) {
|
||||
mSvContent.smoothScrollTo(0, 0);
|
||||
if (b) {
|
||||
userManagerTv.setTextColor(ContextCompat.getColor(mContext, R.color.white));
|
||||
} else {
|
||||
userManagerTv.setTextColor(ContextCompat.getColor(mContext, R.color.index_top_text_nor));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (view.getId() == R.id.id_iv_3 || view.getId() == R.id.id_iv_5 || view.getId() == R.id.id_iv_device_4) {
|
||||
mSvContent.smoothScrollTo(0, 0);
|
||||
}
|
||||
|
||||
if (b) {
|
||||
if (view.getId() == R.id.id_iv_history || view.getId() == R.id.id_cl_history_no) {
|
||||
LogUtils.d("mSvContent :" + "250");
|
||||
int topValue = getRvHistory().getHeight() + getRvCollect().getHeight() + (int) mContext.getResources().getDimension(R.dimen.qb_px_140);
|
||||
mSvContent.smoothScrollTo(0, topValue);
|
||||
}
|
||||
if (view.getId() == R.id.id_iv_collect || view.getId() == R.id.id_cl_collect_no) {
|
||||
LogUtils.d("mSvContent :" + "750");
|
||||
mSvContent.smoothScrollTo(0, MyFragment.getRvCollect().getTop() + (int) mContext.getResources().getDimension(R.dimen.qb_px_260));
|
||||
}
|
||||
}
|
||||
if(view.getId() == R.id.id_cl_collect_no || view.getId() == R.id.id_cl_history_no){
|
||||
TopStyleUtils.topImageChange3(view, b);
|
||||
}else {
|
||||
TopStyleUtils.topImageChange(view, b);
|
||||
}
|
||||
}
|
||||
|
||||
public ScrollView getScrollView() {
|
||||
return mSvContent;
|
||||
}
|
||||
|
||||
public static HorizontalRecyclerViewTv getRvHistory() {
|
||||
return mRvHistory;
|
||||
}
|
||||
|
||||
public static HorizontalRecyclerViewTv getRvCollect() {
|
||||
return mRvCollect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
mRvCollect = null;
|
||||
mRvHistory = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 请求收藏和历史记录
|
||||
*/
|
||||
public void getCollectAndRecordData() {
|
||||
if (null == myViewModel) {
|
||||
return;
|
||||
}
|
||||
userBind();
|
||||
myViewModel.getFindPlayRecord();
|
||||
myViewModel.getCollectData();
|
||||
myViewModel.requestOrderList();
|
||||
}
|
||||
|
||||
private void registerObserver() {
|
||||
if (null == myViewModel) {
|
||||
return;
|
||||
}
|
||||
myViewModel.getPlayRecordBeanLiveData().observe(getViewLifecycleOwner(), this::dealPlayRecordData);
|
||||
myViewModel.getCollectLiveData().observe(getViewLifecycleOwner(), this::dealCollectData);
|
||||
myViewModel.getProductInfoData().observe(getViewLifecycleOwner(), productStr -> {
|
||||
mTvProductInfo.setText(productStr);
|
||||
});
|
||||
myViewModel.getLogoutData().observe(getViewLifecycleOwner(), logoutStr -> {
|
||||
if ("success".equals(logoutStr)) {
|
||||
LogUtils.d("logout success");
|
||||
// NewTvUtils.logout(true);
|
||||
BoxSharedParameters.getInstance().logout();
|
||||
SpTimeUtils.getInstance(getActivity()).setString("phoneMember2", "");
|
||||
userBind();
|
||||
}else {
|
||||
// NewTvUtils.logout(false);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理历史记录
|
||||
*/
|
||||
private void dealPlayRecordData(GetFindPlayrecordBean response) {
|
||||
if (null != response && null != response.getData() && !response.getData().isEmpty()) {
|
||||
LogUtils.d("HistoryResponse=" + response.getData().size());
|
||||
mIvHistoryMore.setVisibility(View.VISIBLE);
|
||||
mRvHistory.setVisibility(View.VISIBLE);
|
||||
mClHistoryNo.setVisibility(View.GONE);
|
||||
mRvHistory.setItemAnimator(null);
|
||||
if (null == myHistoryAdapter) {
|
||||
myHistoryAdapter = new IndexMyHistoryAdapter(mContext, response, mSvContent);
|
||||
mRvHistory.setAdapter(myHistoryAdapter);
|
||||
mRvHistory.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
|
||||
} else {
|
||||
myHistoryAdapter.updateData(response);
|
||||
}
|
||||
mRvHistory.requestLayout();
|
||||
myHistoryAdapter.setOnItemClickListener((view, position, mGetFindPlayrecordBean) -> {
|
||||
LogUtils.d("getParentId:" + response.getData().get(position).getParentid());
|
||||
String parentcode = response.getData().get(position).getParentcode();
|
||||
String type = response.getData().get(position).getContenttype() + "";
|
||||
MgRoute.go2DetailActivity(mContext, parentcode, type);
|
||||
});
|
||||
} else {
|
||||
noHistoryData();
|
||||
}
|
||||
|
||||
if (gotoPage == 1) {
|
||||
// 恢复默认
|
||||
gotoPage = -1;
|
||||
}
|
||||
}
|
||||
|
||||
private void dealCollectData(GetlistcollBean response) {
|
||||
if (null != response && null != response.getResult() && !response.getResult().isEmpty()) {
|
||||
LogUtils.d("CollectResponse=" + response);
|
||||
mIvCollectMore.setVisibility(View.VISIBLE);
|
||||
mRvCollect.setVisibility(View.VISIBLE);
|
||||
mClCollectNo.setVisibility(View.GONE);
|
||||
mRvCollect.setItemAnimator(null);
|
||||
if (null == myCollectAdapter) {
|
||||
myCollectAdapter = new IndexMyCollectAdapter(mContext, response, mSvContent);
|
||||
mRvCollect.setAdapter(myCollectAdapter);
|
||||
mRvCollect.setLayoutManager(new LinearLayoutManager(mContext, LinearLayoutManager.HORIZONTAL, false));
|
||||
} else {
|
||||
myCollectAdapter.updateData(response);
|
||||
}
|
||||
mRvCollect.requestLayout();
|
||||
myCollectAdapter.setOnItemClickListener((view, position) -> {
|
||||
String id = response.getResult().get(position).getContentcode();
|
||||
if (!StringUtils.isEmpty(id)) {
|
||||
gotoPage = 2;
|
||||
String type = response.getResult().get(position).getContenttype() + "";
|
||||
MgRoute.go2DetailActivity(mContext, id, type);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
noCollectData();
|
||||
}
|
||||
|
||||
if (gotoPage == 2) {
|
||||
// 恢复默认
|
||||
gotoPage = -1;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHiddenChanged(boolean hidden) {
|
||||
super.onHiddenChanged(hidden);
|
||||
LogUtils.d("wcg, onHiddenChanged: " + hidden);
|
||||
if (!hidden) {
|
||||
getPageData();
|
||||
} else {
|
||||
layoutNavLists.clear();
|
||||
mRvHistory.setAdapter(null);
|
||||
myHistoryAdapter = null;
|
||||
mRvCollect.setAdapter(null);
|
||||
myCollectAdapter = null;
|
||||
}
|
||||
}
|
||||
|
||||
public String maskPhoneNumber(String phoneNumber) {
|
||||
// 正则匹配:捕获前3位和最后4位,中间4位替换成 ****
|
||||
return phoneNumber.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
|
||||
}
|
||||
}
|
||||
743
app/src/main/java/com/pukka/jiecheng/index/fragment/ShortVideoFragment.java
Executable file
743
app/src/main/java/com/pukka/jiecheng/index/fragment/ShortVideoFragment.java
Executable file
@@ -0,0 +1,743 @@
|
||||
package com.pukka.jiecheng.index.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.migu.bean.GetShortVideoBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.base.SystemConfigManager;
|
||||
import com.pukka.jiecheng.index.IndexActivity;
|
||||
import com.pukka.jiecheng.index.adapter.ShortVideoAdapter;
|
||||
import com.pukka.jiecheng.index.viewmodel.ShortVideoViewModel;
|
||||
import com.pukka.jiecheng.newtv.NewTvUtils;
|
||||
import com.pukka.jiecheng.utils.JetsenxSdkUtil;
|
||||
import com.pukka.jiecheng.utils.MgRoute;
|
||||
import com.pukka.jiecheng.utils.PageNumberUtil;
|
||||
import com.pukka.jiecheng.video.utils.PlayRecordManager;
|
||||
import com.pukka.jiecheng.video.utils.PlayRecordShortManager;
|
||||
import com.pukka.jiecheng.widget.SpaceItemDecoration;
|
||||
import com.pukka.libcore.boxShared.BoxSharedParameters;
|
||||
import com.pukka.libcore.boxShared.BoxSharedParamsUtils;
|
||||
import com.pukka.libcore.threading.DispatchQueue;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
import com.pukka.libcore.utils.StringUtils;
|
||||
import com.pukka.libcore.viewmodel.BaseVM;
|
||||
import com.pukka.libcore.widget.VerticalLinearLayoutManagerTv;
|
||||
import com.pukka.libcore.widget.VerticalRecyclerViewTv;
|
||||
import com.pukka.videoplayertv.IMediaPlayer;
|
||||
import com.pukka.videoplayertv.IRenderView;
|
||||
import com.pukka.videoplayertv.VideoViewTv;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: wxf
|
||||
* Date: 2025/7/7 15:03
|
||||
* Description:短视频页面
|
||||
*/
|
||||
public class ShortVideoFragment extends Fragment {
|
||||
|
||||
private VerticalRecyclerViewTv mRvTv;
|
||||
private ImageView mIvUpTip, mTvOkTip;
|
||||
private ShortVideoAdapter mShortVideoAdapter;
|
||||
private Context mContext;
|
||||
private VerticalLinearLayoutManagerTv mLayoutManager;
|
||||
private ShortVideoViewModel mShortVideoViewModel;
|
||||
private VideoViewTv mVideoViewTv;
|
||||
private ConstraintLayout mClCheckPlay;
|
||||
public String pageCode;
|
||||
private boolean needGotoPlay;
|
||||
//页面类型 游戏版本=7 ;其他=!7
|
||||
public int navType;
|
||||
|
||||
//分页逻辑
|
||||
private final int PAGE_SIZE = 10;
|
||||
//总数量
|
||||
private int sizeTotal;
|
||||
//总页面
|
||||
private int TOTAL_PAGES = 0;
|
||||
private boolean isLoading = false;
|
||||
private boolean isLastPage = false;
|
||||
//当前页
|
||||
private int currentPage = 2;//默认 首次请求10条数据,首次请求数据从第2页开始
|
||||
|
||||
private int itemCurrentPosition = 0;
|
||||
private String mCurrentPlayUrl;
|
||||
//自动播放X(后台可配)个短视频后,如没有进行任何操作,暂停播放视频并弹窗提示:您是否还在屏幕前?
|
||||
private int notMovPlayNum = 0;
|
||||
private boolean hidden;
|
||||
// private boolean isLogin;
|
||||
//视频起播后,3秒后自动隐藏顶部导航和节目单
|
||||
private boolean isNeedHidePlayList = true;
|
||||
//是否自动播放下一个节目
|
||||
private boolean isNextPlay = true;
|
||||
private boolean isShortVideData;
|
||||
PlayRecordShortManager playRecordManager;
|
||||
private final Handler headHandler = new Handler();
|
||||
private final Runnable headRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// start、ing、pause、end、error;
|
||||
if (playRecordManager != null && mVideoViewTv != null) {
|
||||
if (mVideoViewTv.isPlaying()) {
|
||||
playRecordManager.extReport("ing", "");
|
||||
}
|
||||
}
|
||||
headHandler.postDelayed(headRunnable, 10000);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
public ShortVideoFragment() {
|
||||
// Required empty public constructor
|
||||
}
|
||||
|
||||
public static ShortVideoFragment newInstance() {
|
||||
return new ShortVideoFragment();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||
Bundle savedInstanceState) {
|
||||
// Inflate the layout for this fragment
|
||||
return inflater.inflate(R.layout.fragment_short_video, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
LogUtils.d("onViewCreated()");
|
||||
mContext = getActivity();
|
||||
notMovPlayNum = 0;
|
||||
mShortVideoViewModel = BaseVM.getSafeViewModel(this, ShortVideoViewModel.class);
|
||||
initView(view);
|
||||
//首次
|
||||
getShortVideDataFirst(pageCode, "1", "10", true);
|
||||
initVideoView();
|
||||
registerObserver();
|
||||
bindData();
|
||||
initListener();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHiddenChanged(boolean hidden) {
|
||||
LogUtils.d("onHiddenChanged() hidden=" + hidden);
|
||||
this.hidden = hidden;
|
||||
if (!hidden) {
|
||||
LogUtils.d("进入ShortVideoFragment");
|
||||
notMovPlayNum = 0;
|
||||
isNeedHidePlayList = true;
|
||||
mRvTv.initLastFocusPosition();
|
||||
initOkUi();
|
||||
mTvOkTip.setVisibility(View.VISIBLE);
|
||||
mShortVideoAdapter = new ShortVideoAdapter(mContext, mShortVideoViewModel);
|
||||
mShortVideoAdapter.initShowTipFlag();
|
||||
mRvTv.setAdapter(mShortVideoAdapter);
|
||||
mRvTv.setVisibility(View.VISIBLE);
|
||||
initAdapterListener();
|
||||
} else {
|
||||
LogUtils.d("退出ShortVideoFragment");
|
||||
mShortVideoAdapter = null;
|
||||
mRvTv.setAdapter(null);
|
||||
if (null != mVideoViewTv) {
|
||||
NewTvUtils.sensorsPlayBean.setPlayLengths(mVideoViewTv.getCurrentPosition());
|
||||
NewTvUtils.stop(NewTvUtils.sensorsPlayBean.getCpID(), NewTvUtils.sensorsPlayBean.getCpName(), "", "", true, NewTvUtils.sensorsPlayBean.getPlayid(), NewTvUtils.sensorsPlayBean.getPlayLengths());
|
||||
}
|
||||
release(true);
|
||||
}
|
||||
super.onHiddenChanged(hidden);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
LogUtils.d("onDestroy()");
|
||||
}
|
||||
|
||||
private void initView(View view) {
|
||||
mRvTv = view.findViewById(R.id.id_rv_short_vod);
|
||||
mRvTv.setVerticalCenter();
|
||||
mRvTv.setFocusMoveSpeedLimit();
|
||||
mIvUpTip = view.findViewById(R.id.id_iv_up_tip);
|
||||
mTvOkTip = view.findViewById(R.id.id_iv_ok_tip);
|
||||
mClCheckPlay = view.findViewById(R.id.id_cl_check_play);
|
||||
}
|
||||
|
||||
private void initListener() {
|
||||
mLayoutManager.setOnInterceptFocusSearchListener(new VerticalLinearLayoutManagerTv.IonFocusSearchListener() {
|
||||
@Override
|
||||
public void onInterceptFocusSearch(@NonNull View focused, int direction) {
|
||||
LogUtils.d("focused=" + focused + " direction=" + direction);
|
||||
//按上下键
|
||||
mShortVideoAdapter.setDirection(20);
|
||||
}
|
||||
});
|
||||
mRvTv.addOnScrollListener(new RecyclerView.OnScrollListener() {
|
||||
@Override
|
||||
public void onScrolled(@NonNull RecyclerView recyclerView, int dx, int dy) {
|
||||
super.onScrolled(recyclerView, dx, dy);
|
||||
LinearLayoutManager layoutManager = (LinearLayoutManager) recyclerView.getLayoutManager();
|
||||
int visibleItemCount = layoutManager.getChildCount();
|
||||
|
||||
int totalItemCount = layoutManager.getItemCount();
|
||||
int firstVisibleItemPosition = layoutManager.findFirstVisibleItemPosition();
|
||||
LogUtils.d("pageManage visibleItemCount=" + visibleItemCount + " totalItemCount=" + totalItemCount + " firstVisibleItemPosition=" + firstVisibleItemPosition);
|
||||
LogUtils.d("pageManage isLoading=" + isLoading + " isLastPage=" + isLastPage);
|
||||
if (!isLoading && !isLastPage) {
|
||||
if ((visibleItemCount + firstVisibleItemPosition) >= totalItemCount
|
||||
&& firstVisibleItemPosition >= 0
|
||||
&& totalItemCount >= PAGE_SIZE) {
|
||||
loadNextPage();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
initAdapterListener();
|
||||
|
||||
}
|
||||
|
||||
private void initAdapterListener() {
|
||||
mShortVideoAdapter.setOnItemClickListener(new ShortVideoAdapter.OnItemClickListener() {
|
||||
@Override
|
||||
public void onItemClick(View view, int position) {
|
||||
itemCurrentPosition = position;
|
||||
LogUtils.d("按ok键 itemCurrentPosition==" + position);
|
||||
notMovPlayNum = 0;
|
||||
goToDetail(false);
|
||||
}
|
||||
});
|
||||
mShortVideoAdapter.setOnFocusChangeListener(new ShortVideoAdapter.OnItemFocusChangeListener() {
|
||||
@Override
|
||||
public void onItemFocusChange(int position) {
|
||||
LogUtils.d("切换节目单更新 itemCurrentPosition==" + position);
|
||||
itemCurrentPosition = position;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void loadNextPage() {
|
||||
LogUtils.d("pageManage loadNextPage() currentPage=" + currentPage);
|
||||
if (currentPage <= TOTAL_PAGES && !isLoading) {
|
||||
isLoading = true;
|
||||
mRvTv.setIsPageLoading(true);
|
||||
if (navType == 7) {
|
||||
mShortVideoViewModel.getContentListGamePage(pageCode, currentPage + "", PAGE_SIZE + "");
|
||||
} else {
|
||||
mShortVideoViewModel.getContentListPage(pageCode, currentPage + "", PAGE_SIZE + "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 按返回键
|
||||
*/
|
||||
public void setAdapterDirection(int keyCode) {
|
||||
if (null != mShortVideoAdapter) {
|
||||
mShortVideoAdapter.setDirection(keyCode);
|
||||
}
|
||||
}
|
||||
|
||||
private void initPageManage() {
|
||||
currentPage = 2;
|
||||
isLoading = false;
|
||||
isLastPage = false;
|
||||
}
|
||||
|
||||
public void getShortVideDataFirst(String pageCode, String pageIndex, String pageSize, boolean needG) {
|
||||
getShortVideData(pageCode, "1", "10", true);
|
||||
isShortVideData = true;
|
||||
}
|
||||
|
||||
public void getShortVideData(String pageCode, String pageIndex, String pageSize, boolean needG) {
|
||||
LogUtils.d("getShortVideData()====111 pageCode=" + pageCode);
|
||||
if (isShortVideData){
|
||||
isShortVideData = false;
|
||||
return;
|
||||
}
|
||||
needGotoPlay = needG;
|
||||
itemCurrentPosition = 0;
|
||||
notMovPlayNum = 0;
|
||||
if (null != mShortVideoViewModel) {
|
||||
LogUtils.d("getShortVideData()====222");
|
||||
this.pageCode = pageCode;
|
||||
initPageManage();
|
||||
if (navType == 7) {
|
||||
LogUtils.d("getShortVideData()====navType = 7,游戏视频数据获取");
|
||||
mShortVideoViewModel.getGameChannel(pageCode, pageIndex, pageSize);
|
||||
} else {
|
||||
mShortVideoViewModel.getShortVideo(pageCode, pageIndex, pageSize);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void bindData() {
|
||||
mLayoutManager = new VerticalLinearLayoutManagerTv(mContext, LinearLayoutManager.VERTICAL, false);
|
||||
mRvTv.setLayoutManager(mLayoutManager);
|
||||
int spacingInPixel2 = getResources().getDimensionPixelSize(R.dimen.qb_px_20);
|
||||
mRvTv.addItemDecoration(new SpaceItemDecoration(spacingInPixel2, 5));
|
||||
mShortVideoAdapter = new ShortVideoAdapter(mContext, mShortVideoViewModel);
|
||||
mShortVideoAdapter.setDirection(-1);
|
||||
mRvTv.setAdapter(mShortVideoAdapter);
|
||||
}
|
||||
|
||||
private void registerObserver() {
|
||||
if (null == mShortVideoViewModel) {
|
||||
return;
|
||||
}
|
||||
mShortVideoViewModel.showTipData.observe(getViewLifecycleOwner(), b -> {
|
||||
if (b) {
|
||||
mIvUpTip.setVisibility(View.VISIBLE);
|
||||
} else {
|
||||
mIvUpTip.setVisibility(View.GONE);
|
||||
}
|
||||
mTvOkTip.setVisibility(View.GONE);
|
||||
});
|
||||
mShortVideoViewModel.gotoPlayData.observe(getViewLifecycleOwner(), data -> {
|
||||
String[] vz = data.split("@@@");
|
||||
String code = vz[0];
|
||||
String playUrl = vz.length>1?vz[1]:"";
|
||||
LogUtils.d("playUrl=" + playUrl);
|
||||
if ((!StringUtils.isEmpty(playUrl) && playUrl.equals("1001")) || StringUtils.isEmpty(playUrl)) {
|
||||
LogUtils.d("未来鉴权不通过 或者没有获取到播放地址,销毁播放器,自动跳转下一个");
|
||||
if (null != mVideoViewTv) {
|
||||
mVideoViewTv.release(true);
|
||||
mVideoViewTv.releaseError(true);
|
||||
}
|
||||
//自动跳转到下一个
|
||||
DispatchQueue.main.after(500, () -> {
|
||||
if (null != mRvTv) {
|
||||
IndexActivity indexActivity = (IndexActivity) mContext;
|
||||
if (null != indexActivity) {
|
||||
boolean isFull = indexActivity.isFullMode();
|
||||
if (isFull) {
|
||||
if (isNextPlay) {
|
||||
LogUtils.d("自动跳转到下一个 isNextPlay=" + isNextPlay);
|
||||
mShortVideoAdapter.setDirection(20);
|
||||
mRvTv.requestNextPositionFocus();
|
||||
}else {
|
||||
LogUtils.d("向上节目不播,焦点停在这个不播的节目上="+isNextPlay);
|
||||
// mShortVideoAdapter.setDirection(20);
|
||||
// mRvTv.requestPrePositionFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
goToPlay(playUrl, code);
|
||||
});
|
||||
mShortVideoViewModel.selectItemData.observe(getViewLifecycleOwner(), str -> {
|
||||
if (!StringUtils.isEmpty(str) && str.equals("2001")) {
|
||||
if (null != mVideoViewTv) {
|
||||
//未来播控 用户操作结束 上报
|
||||
if (mVideoViewTv.getDuration() > 0 && mVideoViewTv.getCurrentPosition() > 0) {
|
||||
LogUtils.d("左侧节目单切换,销毁播放器,未来播控,用户操作结束,播放上报");
|
||||
NewTvUtils.sensorsPlayBean.setPlayLengths(mVideoViewTv.getCurrentPosition());
|
||||
NewTvUtils.stop(NewTvUtils.sensorsPlayBean.getCpID(), NewTvUtils.sensorsPlayBean.getCpName(), "", "", true, NewTvUtils.sensorsPlayBean.getPlayid(), NewTvUtils.sensorsPlayBean.getPlayLengths());
|
||||
|
||||
}
|
||||
mVideoViewTv.release(true);
|
||||
mVideoViewTv.releaseError(true);
|
||||
}
|
||||
}
|
||||
});
|
||||
mShortVideoViewModel.getShortVideoBeanData.observe(getViewLifecycleOwner(), shortVideoBean -> {
|
||||
if (null != shortVideoBean) {
|
||||
if (needGotoPlay) {
|
||||
try {
|
||||
//进入短视频页面,获取第一项播放地址,播放默认的视频
|
||||
// isLogin = BoxSharedParameters.getInstance().isLogin();
|
||||
// LogUtils.d("用户是否登录?isLogin=" + isLogin);
|
||||
String contentCode = shortVideoBean.getResult().get(0).getContentCode();
|
||||
String contentName = shortVideoBean.getResult().get(0).getContentName();
|
||||
|
||||
JetsenxSdkUtil.newtvCheckQuery(contentCode, contentName, new JetsenxSdkUtil.GetVideoUrlCallback() {
|
||||
@Override
|
||||
public void onResponse(String videoUrl) {
|
||||
LogUtils.d("进入短视频页面,获取第一项播放地址");
|
||||
if (null != mShortVideoAdapter) {
|
||||
mShortVideoAdapter.setDirection(-1);
|
||||
}
|
||||
if (TextUtils.isEmpty(videoUrl)){
|
||||
headHandler.removeCallbacks(headRunnable);
|
||||
playRecordManager.setContentcode(contentCode);
|
||||
playRecordManager.extReport("error","获取播放地址失败");
|
||||
}
|
||||
if (!StringUtils.isEmpty(videoUrl) && videoUrl.equals("1001")) {
|
||||
LogUtils.d("未来鉴权不通过,首个节目不播放");
|
||||
headHandler.removeCallbacks(headRunnable);
|
||||
// playRecordManager.setContentcode(contentCode);
|
||||
// playRecordManager.extReport("error","1001|未来鉴权不通过");
|
||||
return;
|
||||
}
|
||||
goToPlay(videoUrl, contentCode);
|
||||
}
|
||||
});
|
||||
needGotoPlay = false;
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
try {
|
||||
TOTAL_PAGES = PageNumberUtil.calculateTotalPages(shortVideoBean.getSizetotal(), PAGE_SIZE);
|
||||
sizeTotal = shortVideoBean.getSizetotal();
|
||||
LogUtils.d("pageManage TOTAL_PAGES=" + TOTAL_PAGES + " sizeTotal=" + sizeTotal);
|
||||
mShortVideoAdapter.setLayoutContentList(shortVideoBean);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mShortVideoViewModel.contentListPageData.observe(getViewLifecycleOwner(), shortVideoBean -> {
|
||||
LogUtils.d("pageManage 获取分页数据成功 currentPage=" + currentPage);
|
||||
try {
|
||||
if (null == shortVideoBean) {
|
||||
return;
|
||||
}
|
||||
isLoading = false;
|
||||
currentPage++;
|
||||
mShortVideoAdapter.addAll(shortVideoBean.getResult());
|
||||
DispatchQueue.main.after(200, () -> {
|
||||
LogUtils.d("pageManage 页面加载完成,允许滑动 isPageLoading");
|
||||
mRvTv.setIsPageLoading(false);
|
||||
});
|
||||
if (currentPage > TOTAL_PAGES) {
|
||||
isLastPage = true;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void initVideoView() {
|
||||
IndexActivity indexActivity = (IndexActivity) mContext;
|
||||
mVideoViewTv = indexActivity.getVideoViewTv();
|
||||
playRecordManager = new PlayRecordShortManager(mVideoViewTv);
|
||||
mVideoViewTv.setmCompletionListener(new IMediaPlayer.OnCompletionListener() {
|
||||
@Override
|
||||
public void onCompletion(IMediaPlayer mp) {
|
||||
LogUtils.d("onCompletion====");
|
||||
LogUtils.d("mVideoViewTv.getDuration()=" + mVideoViewTv.getDuration());
|
||||
//未来播控 点播正常结束 上报
|
||||
// NewTvUtils.newtvUplodLog(4, "3,"+""+"," + NewTvUtils.programID + "," + 0 + "," + NewTvUtils.resolution + ","
|
||||
// + mVideoViewTv.getDuration() + "," + mVideoViewTv.getDuration() +",0,"+ NewTvUtils.getPlayId(), "false");
|
||||
NewTvUtils.stop(NewTvUtils.sensorsPlayBean.getCpID(), NewTvUtils.sensorsPlayBean.getCpName(), "", "", true, NewTvUtils.sensorsPlayBean.getPlayid(), NewTvUtils.sensorsPlayBean.getPlayLengths());
|
||||
|
||||
mTvOkTip.setVisibility(View.GONE);
|
||||
notMovPlayNum++;
|
||||
LogUtils.d("播放结束,播放下一个节目 notMovPlayNum=" + notMovPlayNum + " shortParseNum=" + SystemConfigManager.getInstance().getShortParseNum());
|
||||
//test
|
||||
if (notMovPlayNum < SystemConfigManager.getInstance().getShortParseNum()) {
|
||||
// if (notMovPlayNum < 5) {
|
||||
mShortVideoAdapter.setDirection(20);
|
||||
mRvTv.requestNextPositionFocus();
|
||||
} else {
|
||||
//弹出 您是否还在屏幕前弹窗
|
||||
LogUtils.d("弹出 您是否还在屏幕前弹窗");
|
||||
mClCheckPlay.setVisibility(View.VISIBLE);
|
||||
headHandler.removeCallbacks(headRunnable);
|
||||
playRecordManager.extReport("end","");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
mVideoViewTv.setmInfoListener(new IMediaPlayer.OnInfoListener() {
|
||||
@Override
|
||||
public boolean onInfo(IMediaPlayer mp, int what, int extra) {
|
||||
if (what == 3) {
|
||||
LogUtils.d("视频起播后,3秒后自动隐藏顶部导航 isNeedHidePlayList=" + isNeedHidePlayList);
|
||||
isNeedHidePlayList = true;
|
||||
DispatchQueue.main.remove(goHidePlayListRunnable);
|
||||
DispatchQueue.main.after(3000, goHidePlayListRunnable);
|
||||
//未来播控 点播开始 上报
|
||||
// NewTvUtils.newtvUplodLog(4, "0,"+""+"," + NewTvUtils.programID + "," + 0 + "," + NewTvUtils.resolution + ","
|
||||
// + mVideoViewTv.getDuration() + "," + NewTvUtils.getPlayId(), "false");
|
||||
|
||||
//神策 点播开始 上报
|
||||
NewTvUtils.sensorsPlayBean.setPlayid(NewTvUtils.getPlayId());
|
||||
//方便自然结束上报
|
||||
if (null != mVideoViewTv) {
|
||||
NewTvUtils.sensorsPlayBean.setPlayLengths(mVideoViewTv.getDuration());
|
||||
}
|
||||
//神策上报
|
||||
NewTvUtils.play(NewTvUtils.sensorsPlayBean.getCpID(), NewTvUtils.sensorsPlayBean.getCpName(), "", "", true, NewTvUtils.sensorsPlayBean.getPlayid());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 视频起播后,3秒后自动隐藏顶部导航和节目单
|
||||
*/
|
||||
private final Runnable goHidePlayListRunnable = () -> {
|
||||
LogUtils.d("goHidePlayListRunnable ---- 3000");
|
||||
mRvTv.requestLastItemFocus();
|
||||
mIvUpTip.setVisibility(View.GONE);
|
||||
mRvTv.setVisibility(View.GONE);
|
||||
if (mContext != null) {
|
||||
IndexActivity indexActivity = (IndexActivity) mContext;
|
||||
if (null != indexActivity) {
|
||||
indexActivity.setVideoMarkVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public void goToPlay(String playUrl) {
|
||||
goToPlay(playUrl, null);
|
||||
}
|
||||
|
||||
public void goToPlay(String playUrl, String code) {
|
||||
LogUtils.d("playUrl==" + playUrl);
|
||||
// if (!isLogin) {
|
||||
// LogUtils.d("用户点Ok,进去登录页面,进行登录返回,需重新获取播放地址");
|
||||
// isLogin = BoxSharedParameters.getInstance().isLogin();
|
||||
// LogUtils.d("用户是否登录?isLogin=" + isLogin);
|
||||
// if (isLogin) {
|
||||
// List<GetShortVideoBean.ResultDTO> resultEntityList = mShortVideoAdapter.getData();
|
||||
// if (resultEntityList.size() > 0) {
|
||||
// String contentCode = resultEntityList.get(itemCurrentPosition).getContentCode();
|
||||
// String contentName = resultEntityList.get(itemCurrentPosition).getContentName();
|
||||
// JetsenxSdkUtil.newtvCheckQuery(contentCode, contentName, new JetsenxSdkUtil.GetVideoUrlCallback() {
|
||||
// @Override
|
||||
// public void onResponse(String videoUrl) {
|
||||
// LogUtils.d("进入短视频页面,获取第一项播放地址");
|
||||
// if (null != mShortVideoAdapter) {
|
||||
// mShortVideoAdapter.setDirection(-1);
|
||||
// }
|
||||
// goToPlay(videoUrl);
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// return;
|
||||
// }
|
||||
LogUtils.d("hidden==" + hidden);
|
||||
if (hidden) {
|
||||
LogUtils.d("已经离开短视频页面,不在播放");
|
||||
return;
|
||||
}
|
||||
if (null == mVideoViewTv) {
|
||||
initVideoView();
|
||||
}
|
||||
if (null != mVideoViewTv && !StringUtils.isEmpty(playUrl)) {
|
||||
mCurrentPlayUrl = playUrl;
|
||||
mVideoViewTv.setmCurrentAspectRatio(IRenderView.AR_ASPECT_FIT_PARENT);
|
||||
mVideoViewTv.setVisibility(View.VISIBLE);
|
||||
mVideoViewTv.release(true);
|
||||
mVideoViewTv.releaseError(true);
|
||||
mVideoViewTv.setVideoPath(playUrl);
|
||||
mVideoViewTv.start();
|
||||
headHandler.removeCallbacks(headRunnable);
|
||||
if (!TextUtils.isEmpty(playRecordManager.getUpType())) {
|
||||
playRecordManager.extReport("end", "");
|
||||
}
|
||||
playRecordManager.setContentcode(code);
|
||||
playRecordManager.extReport("start", "");
|
||||
headHandler.postDelayed(headRunnable, 10000);
|
||||
}
|
||||
if (StringUtils.isEmpty(playUrl)) {
|
||||
if (null != mVideoViewTv) {
|
||||
mVideoViewTv.release(true);
|
||||
mVideoViewTv.releaseError(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void release(boolean b) {
|
||||
if (null != mVideoViewTv) {
|
||||
headHandler.removeCallbacks(headRunnable);
|
||||
playRecordManager.extReport("end","");
|
||||
LogUtils.d("release =b=" + b);
|
||||
mVideoViewTv.setVisibility(View.INVISIBLE);
|
||||
mVideoViewTv.release(true);
|
||||
mVideoViewTv.releaseError(true);
|
||||
if (b) {
|
||||
mVideoViewTv = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 跳转到详情页
|
||||
*/
|
||||
public void goToDetail(boolean isFromIndex) {
|
||||
if (mClCheckPlay.getVisibility() == View.VISIBLE) {
|
||||
headHandler.removeCallbacks(headRunnable);
|
||||
playRecordManager.extReport("end","");
|
||||
LogUtils.d("用户在屏幕前,关闭对话框,继续播放");
|
||||
mShortVideoAdapter.setZaiPingMuQian(true);
|
||||
notMovPlayNum = 0;
|
||||
mShortVideoAdapter.setDirection(20);
|
||||
mRvTv.requestNextPositionFocus();
|
||||
mClCheckPlay.setVisibility(View.GONE);
|
||||
} else {
|
||||
if (isFromIndex) {
|
||||
if (BoxSharedParamsUtils.isJcCloud() || BoxSharedParamsUtils.isJcHotel()) {
|
||||
if (mRvTv.getVisibility() == View.VISIBLE) {
|
||||
LogUtils.d("节目单存在,在游戏场景下,不执行跳转,让adapter的click跳转,防止错位");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
LogUtils.d("itemCurrentPosition=" + itemCurrentPosition);
|
||||
List<GetShortVideoBean.ResultDTO> resultEntityList = mShortVideoAdapter.getData();
|
||||
if (resultEntityList.size() > 0) {
|
||||
if (navType == 7) {
|
||||
String param = resultEntityList.get(itemCurrentPosition).getParam();
|
||||
String appParams = MgRoute.getGameParam(param);
|
||||
String packageName = resultEntityList.get(itemCurrentPosition).getPackageName();
|
||||
String className = resultEntityList.get(itemCurrentPosition).getClassName();
|
||||
LogUtils.d("appParams=" + appParams);
|
||||
MgRoute.startActivityByClass(mContext, packageName, className, appParams);
|
||||
} else {
|
||||
String code = resultEntityList.get(itemCurrentPosition).getDetailContentCode();
|
||||
LogUtils.d("code=" + code);
|
||||
MgRoute.go2DetailActivity(mContext, code);
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mVideoViewTv!=null&&!mVideoViewTv.isPlaying()){
|
||||
headHandler.removeCallbacks(headRunnable);
|
||||
playRecordManager.extReport("end","");
|
||||
}
|
||||
}
|
||||
},500);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void closeCheckPlayDialog() {
|
||||
if (null == mClCheckPlay) {
|
||||
return;
|
||||
}
|
||||
if (mClCheckPlay.getVisibility() == View.VISIBLE) {
|
||||
LogUtils.d("用户上下滑动焦点,关闭是否在屏幕前对话框");
|
||||
mClCheckPlay.setVisibility(View.GONE);
|
||||
headHandler.removeCallbacks(headRunnable);
|
||||
playRecordManager.extReport("end","");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public String getCurrentPlayUrl() {
|
||||
return mCurrentPlayUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* 自动播放X(后台可配)个短视频后,如没有进行任何操作,暂停播放视频并弹窗提示:您是否还在屏幕前?
|
||||
* 按键响应X则清0
|
||||
*
|
||||
* @param backKey true 用户按了返回按键
|
||||
*/
|
||||
public void initNotMovPlayNum(boolean backKey) {
|
||||
LogUtils.d("按键响应 initNotMovPlayNum backKey=" + backKey);
|
||||
notMovPlayNum = 0;
|
||||
//在3秒内,操作则不隐藏
|
||||
isNeedHidePlayList = false;
|
||||
DispatchQueue.main.remove(goHidePlayListRunnable);
|
||||
closeCheckPlayDialog();
|
||||
if (backKey) {
|
||||
if (mRvTv != null) {
|
||||
if (mRvTv.getVisibility() != View.VISIBLE) {
|
||||
LogUtils.d("按返回键,显示节目单");
|
||||
mShortVideoAdapter.setNeedRePlay(true);
|
||||
LogUtils.d("按返回键,显示节目单,不需要重新播放");
|
||||
mRvTv.setVisibility(View.VISIBLE);
|
||||
mIvUpTip.setVisibility(View.GONE);
|
||||
|
||||
} else {
|
||||
LogUtils.d("按返回键,没显示节目单场景,正常流程");
|
||||
mShortVideoAdapter.setNeedRePlay(false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
LogUtils.d("按非返回键,播放下一个节目,不影响流程");
|
||||
if (null != mShortVideoAdapter) {
|
||||
mShortVideoAdapter.setNeedRePlay(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取节目单
|
||||
*/
|
||||
public boolean getRvTvVisibility() {
|
||||
if (mRvTv != null) {
|
||||
if (mRvTv.getVisibility() == View.VISIBLE) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 按上下键切节目
|
||||
*/
|
||||
public void changeProgram(int down) {
|
||||
if (down == 1) {
|
||||
isNextPlay = true;
|
||||
if (!getRvTvVisibility()) {
|
||||
LogUtils.d("按下键,播放下一个节目");
|
||||
notMovPlayNum = 0;
|
||||
mShortVideoAdapter.setDirection(20);
|
||||
mRvTv.requestNextPositionFocus();
|
||||
}
|
||||
} else {
|
||||
isNextPlay = false;
|
||||
if (!getRvTvVisibility()) {
|
||||
LogUtils.d("按上键,播放上一个节目");
|
||||
notMovPlayNum = 0;
|
||||
mShortVideoAdapter.setDirection(20);
|
||||
mRvTv.requestPrePositionFocus();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 游戏和短视频 差异UI显示
|
||||
*/
|
||||
public void initOkUi() {
|
||||
if (navType == 7) {
|
||||
ConstraintLayout.LayoutParams conParams = (ConstraintLayout.LayoutParams) mTvOkTip.getLayoutParams();
|
||||
conParams.width = (int) getResources().getDimension(R.dimen.qb_px_220);
|
||||
mTvOkTip.setLayoutParams(conParams);
|
||||
mTvOkTip.setImageResource(R.drawable.short_ok_game_tip);
|
||||
mIvUpTip.setImageResource(R.drawable.short_up_game_tip);
|
||||
} else {
|
||||
ConstraintLayout.LayoutParams conParams = (ConstraintLayout.LayoutParams) mTvOkTip.getLayoutParams();
|
||||
conParams.width = (int) getResources().getDimension(R.dimen.qb_px_200);
|
||||
mTvOkTip.setLayoutParams(conParams);
|
||||
mTvOkTip.setImageResource(R.drawable.short_ok_tip);
|
||||
mIvUpTip.setImageResource(R.drawable.short_up_tip);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
|
||||
package com.pukka.jiecheng.index.manager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.migu.bean.GetLayoutBean;
|
||||
import com.pukka.jiecheng.index.viewholder.BaseViewHolder;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class FloorOnBindViewHolderManager {
|
||||
//private RecyclerView.ViewHolder viewHolder;
|
||||
|
||||
public FloorOnBindViewHolderManager() {
|
||||
}
|
||||
|
||||
public void bindViewHolder(@NonNull RecyclerView.ViewHolder holder, List<GetLayoutBean.DataBean> floorList,
|
||||
int position, String gameId) {
|
||||
LogUtils.d("gameId=" + gameId);
|
||||
if (holder instanceof BaseViewHolder) {
|
||||
if (gameId != null) {
|
||||
((BaseViewHolder) holder).setGameId(gameId);
|
||||
}
|
||||
((BaseViewHolder) holder).bindFloorData(floorList.get(position), position);
|
||||
}
|
||||
|
||||
// if (holder instanceof B2_4ViewHolder) {
|
||||
// viewHolder = holder;
|
||||
// }
|
||||
}
|
||||
|
||||
public void onDestroyHandler() {
|
||||
// if (null != viewHolder && viewHolder instanceof B2_4ViewHolder) {
|
||||
// B2_4ViewHolder viewHolder = (B2_4ViewHolder) this.viewHolder;
|
||||
// viewHolder.onDestroyHandler();
|
||||
// this.viewHolder = null;
|
||||
// }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
|
||||
package com.pukka.jiecheng.index.manager;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.index.viewholder.A49ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.B11ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.B13ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.B1ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.B2ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.B3ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.B5ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.B5_2ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.B9ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.BaseViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.C3ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.C7ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.D1ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.D3ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.D4ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.JC1ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.JC32ViewHolder;
|
||||
import com.pukka.jiecheng.index.viewholder.ToTopViewHolder;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class FloorOnCreateViewHolderManager {
|
||||
private final Fragment mFragment;
|
||||
|
||||
private List<RecyclerView.ViewHolder> viewHolderList = new ArrayList<>();
|
||||
|
||||
public FloorOnCreateViewHolderManager(Fragment fragment) {
|
||||
this.mFragment = fragment;
|
||||
}
|
||||
|
||||
public RecyclerView.ViewHolder createViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
RecyclerView.ViewHolder viewHolder;
|
||||
switch (viewType) {
|
||||
case 1:
|
||||
viewHolder = new B1ViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_b1, parent, false),
|
||||
parent.getContext());
|
||||
break;
|
||||
case 2:
|
||||
viewHolder = new B2ViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_b2, parent, false),
|
||||
parent.getContext());
|
||||
break;
|
||||
case 5:
|
||||
viewHolder = new B3ViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_b3, parent, false),
|
||||
parent.getContext());
|
||||
break;
|
||||
case 7:
|
||||
viewHolder = new B5ViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_b5, parent, false),
|
||||
parent.getContext());
|
||||
break;
|
||||
case 8:
|
||||
viewHolder = new B5_2ViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_b5_2, parent, false),
|
||||
parent.getContext());
|
||||
break;
|
||||
case 12:
|
||||
viewHolder = new B9ViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_b9, parent, false),
|
||||
parent.getContext());
|
||||
break;
|
||||
case 14:
|
||||
viewHolder = new B11ViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_b11, parent, false),
|
||||
parent.getContext());
|
||||
break;
|
||||
case 16:
|
||||
viewHolder = new B13ViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_b13, parent, false),
|
||||
parent.getContext());
|
||||
break;
|
||||
case 21:
|
||||
viewHolder = new C3ViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_c3, parent, false),
|
||||
parent.getContext());
|
||||
break;
|
||||
case 26:
|
||||
viewHolder = new C7ViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_c7, parent, false),
|
||||
parent.getContext(), mFragment);
|
||||
break;
|
||||
case 55:
|
||||
viewHolder = new A49ViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_a49, parent, false),
|
||||
parent.getContext());
|
||||
break;
|
||||
case 57:
|
||||
viewHolder = new ToTopViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_totop, parent, false),
|
||||
parent.getContext());
|
||||
break;
|
||||
case 58:
|
||||
viewHolder = new JC1ViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_jc1, parent, false),
|
||||
parent.getContext());
|
||||
break;
|
||||
case 29:
|
||||
viewHolder = new D1ViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_d1, parent, false),
|
||||
parent.getContext(),mFragment);
|
||||
break;
|
||||
// hotMovie
|
||||
case 31:
|
||||
LogUtils.d("hotMovie2");
|
||||
viewHolder = new D4ViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_d4, parent, false),
|
||||
parent.getContext(), viewType);
|
||||
break;
|
||||
case 59:
|
||||
viewHolder = new JC32ViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_jc32, parent, false),
|
||||
parent.getContext(),mFragment);
|
||||
break;
|
||||
|
||||
default:
|
||||
LogUtils.d("floor not match viewType=" + viewType);
|
||||
// A49ViewHolder 55 只有一个楼层
|
||||
viewHolder = new A49ViewHolder(
|
||||
LayoutInflater.from(parent.getContext()).inflate(R.layout.item_index_floor_a49, parent, false),
|
||||
parent.getContext());
|
||||
break;
|
||||
}
|
||||
viewHolderList.add(viewHolder);
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
public void goOnPlayVideo(){
|
||||
for (RecyclerView.ViewHolder viewHolder : viewHolderList) {
|
||||
if (null != viewHolder) {
|
||||
if (viewHolder instanceof C7ViewHolder) {
|
||||
((C7ViewHolder) viewHolder).goOnPlayVideo();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void clearViewList() {
|
||||
for (RecyclerView.ViewHolder viewHolder : viewHolderList) {
|
||||
if (null != viewHolder) {
|
||||
if (viewHolder instanceof D1ViewHolder) {
|
||||
((D1ViewHolder) viewHolder).clearList();
|
||||
}
|
||||
if (viewHolder instanceof D3ViewHolder) {
|
||||
((D3ViewHolder) viewHolder).clearList();
|
||||
}
|
||||
if (viewHolder instanceof D4ViewHolder) {
|
||||
((D4ViewHolder) viewHolder).clearList();
|
||||
}
|
||||
if (viewHolder instanceof BaseViewHolder) {
|
||||
((BaseViewHolder) viewHolder).clearList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
viewHolderList.clear();
|
||||
viewHolderList = null;
|
||||
}
|
||||
}
|
||||
90
app/src/main/java/com/pukka/jiecheng/index/viewholder/A49ViewHolder.java
Executable file
90
app/src/main/java/com/pukka/jiecheng/index/viewholder/A49ViewHolder.java
Executable file
@@ -0,0 +1,90 @@
|
||||
|
||||
package com.pukka.jiecheng.index.viewholder;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import com.migu.bean.GetLayoutBean;
|
||||
import com.pukka.jiecheng.R;
|
||||
import com.pukka.jiecheng.index.IndexAmberManager;
|
||||
import com.pukka.jiecheng.index.bean.CornerMarkBean;
|
||||
import com.pukka.jiecheng.utils.ItemOnClickUtils;
|
||||
import com.pukka.jiecheng.utils.TopStyleUtils;
|
||||
import com.pukka.jiecheng.widget.CornerBadgeView;
|
||||
import com.pukka.libcore.utils.LogUtils;
|
||||
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Author: wxf
|
||||
* Date: 2023/2/27 14:31
|
||||
* Description:首页楼层--A49楼层 type==imgHFloorR1C1A49
|
||||
* 一行1列(横, 不带标题)
|
||||
*/
|
||||
public class A49ViewHolder extends BaseViewHolder {
|
||||
// 海报
|
||||
private CornerBadgeView mIv1;
|
||||
|
||||
private Context mcontext;
|
||||
|
||||
public A49ViewHolder(@NonNull View itemView, Context mcontext) {
|
||||
super(itemView);
|
||||
this.mcontext = mcontext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initView(@NonNull View itemView) {
|
||||
mTvTitle = itemView.findViewById(R.id.id_tv_title);
|
||||
mIv1 = itemView.findViewById(R.id.id_iv_1);
|
||||
mIv1.setOnFocusChangeListener((view, hasFocus) -> {
|
||||
TopStyleUtils.topImageChange3(view,hasFocus);
|
||||
mIv1.changeTitleStyle(hasFocus);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindViews() {
|
||||
viewList.add(mIv1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void bindImageList(List<String> imageUrls, List<CornerMarkBean> cornerMarks, GetLayoutBean.DataBean floor) {
|
||||
try {
|
||||
mIv1.setImageUri(imageUrls.get(0));
|
||||
mIv1.setCornerRightUp(cornerMarks.get(0).getCornerRightUp());
|
||||
mIv1.setCornerLeftUp(cornerMarks.get(0).getCornerLeftUp());
|
||||
mIv1.setCornerLeftDown(cornerMarks.get(0).getCornerLeftDown());
|
||||
mIv1.setCornerRightDown(cornerMarks.get(0).getCornerRightDown());
|
||||
|
||||
viewList.clear();
|
||||
viewList.add(mIv1);
|
||||
for (int i = 0; i < viewList.size(); i++) {
|
||||
int a = i;
|
||||
viewList.get(a).setOnClickListener(v -> {
|
||||
ItemOnClickUtils.indexItemOnClick(viewList.get(a), floor, a, this.mcontext);
|
||||
});
|
||||
}
|
||||
mIv1.setMainTitle(floor.getExtraData().get(0).getName());
|
||||
mIv1.setSubTitle(floor.getExtraData().get(0).getTitle());
|
||||
} catch (Exception ex) {
|
||||
LogUtils.d("bindImage exception==" + ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void bindFloorData(GetLayoutBean.DataBean floor,int position) {
|
||||
try {
|
||||
IndexAmberManager.floorPosition = position;
|
||||
baseBindFloorData(floor);
|
||||
} catch (Exception ex) {
|
||||
LogUtils.d("bindFloorData exception==" + ex.getMessage());
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user