Compare commits
No commits in common. "new1.1.1" and "master" have entirely different histories.
16
Android_Mireo/.gitignore
vendored
Normal file
16
Android_Mireo/.gitignore
vendored
Normal file
@ -0,0 +1,16 @@
|
||||
*.iml
|
||||
.gradle
|
||||
/local.properties
|
||||
/.idea/caches
|
||||
/.idea/libraries
|
||||
/.idea/modules.xml
|
||||
/.idea/workspace.xml
|
||||
/.idea/navEditor.xml
|
||||
/.idea/assetWizardSettings.xml
|
||||
.DS_Store
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.cxx
|
||||
local.properties
|
||||
/app/release
|
@ -1,8 +1,6 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'android-aspectjx'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
apply plugin: 'com.google.firebase.crashlytics'
|
||||
apply plugin: 'com.google.firebase.firebase-perf'
|
||||
apply from: '../common.gradle'
|
||||
|
||||
|
||||
@ -10,7 +8,7 @@ android {
|
||||
|
||||
|
||||
defaultConfig {
|
||||
applicationId 'com.localee.mireo.shortapp'
|
||||
applicationId 'com.localee.mireo.app'
|
||||
resConfigs 'zh'
|
||||
resConfigs 'xxhdpi'
|
||||
proguardFiles 'proguard-sdk.pro', 'proguard-app.pro'
|
||||
@ -37,7 +35,7 @@ android {
|
||||
|
||||
debug {
|
||||
|
||||
// applicationIdSuffix '.debug'
|
||||
applicationIdSuffix '.debug'
|
||||
debuggable true
|
||||
jniDebuggable true
|
||||
zipAlignEnabled false
|
||||
@ -79,6 +77,10 @@ android {
|
||||
exclude 'META-INF/*******'
|
||||
}
|
||||
|
||||
aspectjx {
|
||||
include android.defaultConfig.applicationId
|
||||
}
|
||||
|
||||
applicationVariants.all { variant ->
|
||||
variant.outputs.all { output ->
|
||||
outputFileName = rootProject.getName() + '_v' + variant.versionName + '_' + variant.buildType.name
|
||||
@ -88,17 +90,14 @@ android {
|
||||
outputFileName += '.apk'
|
||||
}
|
||||
}
|
||||
sourceSets {
|
||||
main {
|
||||
res.srcDirs(
|
||||
'src/main/res',
|
||||
'src/main/res-sw',
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':library:base')
|
||||
implementation project(':library:widget')
|
||||
|
||||
implementation 'com.github.getActivity:XXPermissions:12.3'
|
||||
|
||||
implementation 'com.github.getActivity:TitleBar:9.2'
|
||||
|
||||
implementation 'com.github.getActivity:ToastUtils:9.5'
|
||||
@ -109,20 +108,27 @@ dependencies {
|
||||
implementation 'com.google.code.gson:gson:2.8.8'
|
||||
implementation 'com.github.getActivity:GsonFactory:5.2'
|
||||
|
||||
implementation 'com.github.getActivity:ShapeView:9.6'
|
||||
implementation 'com.github.getActivity:ShapeView:9.0'
|
||||
|
||||
implementation 'org.aspectj:aspectjrt:1.9.6'
|
||||
|
||||
implementation 'com.github.bumptech.glide:glide:4.12.0'
|
||||
kapt 'com.github.bumptech.glide:compiler:4.12.0'
|
||||
|
||||
implementation 'com.gyf.immersionbar:immersionbar:3.0.0'
|
||||
|
||||
implementation 'com.github.Baseflow:PhotoView:2.3.0'
|
||||
|
||||
implementation 'com.airbnb.android:lottie:4.1.0'
|
||||
|
||||
implementation 'com.scwang.smart:refresh-layout-kernel:2.0.3'
|
||||
implementation 'com.scwang.smart:refresh-header-material:2.0.3'
|
||||
|
||||
implementation 'com.jakewharton.timber:timber:4.7.1'
|
||||
|
||||
implementation 'com.tencent:mmkv:1.3.0'
|
||||
implementation 'me.relex:circleindicator:2.1.6'
|
||||
|
||||
implementation 'com.tencent:mmkv-static:1.2.10'
|
||||
|
||||
// banner
|
||||
implementation 'io.github.youth5201314:banner:2.2.3'
|
||||
@ -136,29 +142,11 @@ dependencies {
|
||||
implementation "androidx.media3:media3-exoplayer:1.4.0"
|
||||
implementation "androidx.media3:media3-exoplayer-dash:1.4.0"
|
||||
implementation "androidx.media3:media3-exoplayer-hls:1.4.0"
|
||||
implementation(files("libs/lib-drama-decoder-ffmpeg.aar"))
|
||||
implementation(files("libs/lib-decoder-ffmpeg-release.aar"))
|
||||
|
||||
implementation "org.greenrobot:eventbus:3.3.1"
|
||||
implementation("com.blankj:utilcodex:1.31.1")
|
||||
implementation("com.github.li-xiaojun:XPopup:2.10.0")
|
||||
|
||||
implementation("com.android.billingclient:billing:7.0.0")
|
||||
|
||||
implementation("com.facebook.android:facebook-android-sdk:17.0.2")
|
||||
|
||||
implementation("com.adjust.sdk:adjust-android:5.2.0")
|
||||
implementation("com.adjust.sdk:adjust-android-webbridge:5.2.0")
|
||||
implementation("com.android.installreferrer:installreferrer:2.2")
|
||||
|
||||
|
||||
implementation(platform("com.google.firebase:firebase-bom:32.3.1"))
|
||||
implementation("com.google.firebase:firebase-messaging-ktx:24.0.0")
|
||||
implementation("androidx.work:work-runtime-ktx:2.9.1")
|
||||
implementation("com.google.firebase:firebase-analytics-ktx")
|
||||
implementation("com.google.firebase:firebase-crashlytics")
|
||||
implementation("com.google.firebase:firebase-perf")
|
||||
implementation("com.github.centerzx:ShapeBlurView:1.0.5")
|
||||
|
||||
implementation("com.google.android.flexbox:flexbox:3.0.0")
|
||||
|
||||
}
|
36
Android_Mireo/app/proguard-app.pro
Normal file
36
Android_Mireo/app/proguard-app.pro
Normal file
@ -0,0 +1,36 @@
|
||||
#-ignorewarning
|
||||
|
||||
-libraryjars libs/lib-decoder-ffmpeg-release.aar
|
||||
|
||||
-keep class com.localee.mireo.app.http.api.** {
|
||||
<fields>;
|
||||
}
|
||||
-keep class com.localee.mireo.app.http.response.** {
|
||||
<fields>;
|
||||
}
|
||||
-keep class com.localee.mireo.app.http.model.** {
|
||||
<fields>;
|
||||
}
|
||||
-keep class com.localee.mireo.app.http.exception.** {
|
||||
<fields>;
|
||||
}
|
||||
|
||||
-keepclassmembernames class ** {
|
||||
@com.localee.mireo.app.aop.Log <methods>;
|
||||
}
|
||||
|
||||
|
||||
-keep public class * extends android.view.View{
|
||||
*** get*();
|
||||
void set*(***);
|
||||
public <init>(android.content.Context);
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
-keepclasseswithmembers class * {
|
||||
public <init>(android.content.Context, android.util.AttributeSet);
|
||||
public <init>(android.content.Context, android.util.AttributeSet, int);
|
||||
}
|
||||
-keepclassmembers class * {
|
||||
public void *(android.view.View);
|
||||
}
|
45
Android_Mireo/app/proguard-sdk.pro
Normal file
45
Android_Mireo/app/proguard-sdk.pro
Normal file
@ -0,0 +1,45 @@
|
||||
# Glide
|
||||
-keep public class * implements com.bumptech.glide.module.GlideModule
|
||||
-keep class * extends com.bumptech.glide.module.AppGlideModule {
|
||||
<init>(...);
|
||||
}
|
||||
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
|
||||
**[] $VALUES;
|
||||
public *;
|
||||
}
|
||||
-keep class com.bumptech.glide.load.data.ParcelFileDescriptorRewinder$InternalRewinder {
|
||||
*** rewind();
|
||||
}
|
||||
|
||||
# for DexGuard only
|
||||
#-keepresourcexmlelements manifest/application/meta-data@value=GlideModule
|
||||
|
||||
# Bugly
|
||||
-dontwarn com.tencent.bugly.**
|
||||
-keep public class com.tencent.bugly.**{*;}
|
||||
|
||||
# AOP
|
||||
-adaptclassstrings
|
||||
-keepattributes InnerClasses, EnclosingMethod, Signature, *Annotation*
|
||||
|
||||
-keepnames @org.aspectj.lang.annotation.Aspect class * {
|
||||
public <methods>;
|
||||
}
|
||||
|
||||
# OkHttp3
|
||||
-keepattributes Signature
|
||||
-keepattributes *Annotation*
|
||||
-keep class okhttp3.** { *; }
|
||||
-keep interface okhttp3.** { *; }
|
||||
-dontwarn okhttp3.**
|
||||
-dontwarn okio.**
|
||||
-dontwarn org.conscrypt.**
|
||||
|
||||
-keep class com.gyf.immersionbar.* {*;}
|
||||
-dontwarn com.gyf.immersionbar.**
|
||||
|
||||
# com.hjq
|
||||
-keep class com.hjq.permissions.** {*;}
|
||||
-keep class com.hjq.bar.** {*;}
|
||||
-keep class com.hjq.toast.** {*;}
|
||||
-keep class com.hjq.shape.** {*;}
|
125
Android_Mireo/app/src/main/AndroidManifest.xml
Normal file
125
Android_Mireo/app/src/main/AndroidManifest.xml
Normal file
@ -0,0 +1,125 @@
|
||||
<?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.localee.mireo.app">
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||
<uses-permission
|
||||
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
|
||||
tools:ignore="ScopedStorage" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_IMAGES" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_AUDIO" />
|
||||
<uses-permission android:name="android.permission.READ_MEDIA_VIDEO" />
|
||||
|
||||
|
||||
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
|
||||
|
||||
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
|
||||
<application
|
||||
android:name=".app.AppApplication"
|
||||
android:allowBackup="false"
|
||||
android:icon="@mipmap/ic_app_logo"
|
||||
android:label="${app_name}"
|
||||
android:networkSecurityConfig="@xml/network_security_config"
|
||||
android:requestLegacyExternalStorage="true"
|
||||
android:resizeableActivity="true"
|
||||
android:roundIcon="@mipmap/ic_app_logo"
|
||||
android:supportsRtl="false"
|
||||
android:theme="@style/AppTheme"
|
||||
android:usesCleartextTraffic="true"
|
||||
tools:ignore="AllowBackup,LockedOrientationActivity"
|
||||
tools:replace="android:allowBackup,android:supportsRtl"
|
||||
tools:targetApi="31">
|
||||
|
||||
<meta-data
|
||||
android:name="ScopedStorage"
|
||||
android:value="true" />
|
||||
|
||||
<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>
|
||||
|
||||
<activity
|
||||
android:name=".ui.activity.SplashActivity"
|
||||
android:exported="true"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/Theme.Splash"
|
||||
>
|
||||
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
|
||||
</activity>
|
||||
|
||||
<activity
|
||||
android:name=".ui.activity.HomeActivity"
|
||||
android:launchMode="singleTask"
|
||||
android:screenOrientation="portrait"
|
||||
android:windowSoftInputMode="adjustPan" />
|
||||
|
||||
<activity
|
||||
android:name=".ui.activity.SettingActivity"
|
||||
android:label="@string/setting_title"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
|
||||
<activity
|
||||
android:name=".ui.activity.AboutActivity"
|
||||
android:label="@string/about_title"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".ui.activity.BrowserActivity"
|
||||
android:label="@string/web_title"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
<activity
|
||||
android:name=".ui.activity.VideoPlayActivity"
|
||||
android:launchMode="singleTop"
|
||||
android:theme="@style/FullScreenTheme" />
|
||||
|
||||
<activity
|
||||
android:name=".ui.activity.SearchActivity"
|
||||
android:launchMode="singleTop"
|
||||
android:screenOrientation="portrait" />
|
||||
|
||||
|
||||
</application>
|
||||
|
||||
<queries>
|
||||
|
||||
<intent>
|
||||
<action android:name="android.intent.action.SEND" />
|
||||
</intent>
|
||||
|
||||
<intent>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
</intent>
|
||||
|
||||
<intent>
|
||||
<action android:name="android.intent.action.GET_CONTENT" />
|
||||
</intent>
|
||||
</queries>
|
||||
|
||||
</manifest>
|
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
@ -1,4 +1,4 @@
|
||||
package com.localee.mireo.drama.absdiff
|
||||
package com.localee.mireo.app.action
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.net.ConnectivityManager
|
||||
@ -7,59 +7,17 @@ import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.RawRes
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.drama.biguint.UHHead
|
||||
import com.localee.mireo.drama.biguint.UHHead.OnRetryListener
|
||||
import kotlin.math.min
|
||||
import kotlin.math.max
|
||||
|
||||
@Volatile
|
||||
private var dismissUserDebugMargin: Double = 3146.0
|
||||
@Volatile
|
||||
var iconActivity_str: String = "research"
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.widget.StatusLayout
|
||||
import com.localee.mireo.app.widget.StatusLayout.OnRetryListener
|
||||
|
||||
|
||||
interface StatusAction {
|
||||
|
||||
|
||||
interface NStyleRect {
|
||||
fun getStatusLayout(): StatusLayout?
|
||||
|
||||
|
||||
fun showLayout(drawable: Drawable?, hint: CharSequence?, listener: OnRetryListener?) {
|
||||
getStatusLayout()?.let {
|
||||
it.show()
|
||||
it.setIcon(drawable)
|
||||
it.setHint(hint)
|
||||
it.setOnRetryListener(listener)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun showLayout(@DrawableRes drawableId: Int, @StringRes stringId: Int, listener: OnRetryListener?) {
|
||||
getStatusLayout()?.let {
|
||||
showLayout(ContextCompat.getDrawable(it.context, drawableId), it.context.getString(stringId), listener)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun showError(listener: OnRetryListener?) {
|
||||
getStatusLayout()?.let {
|
||||
val manager: ConnectivityManager? = ContextCompat.getSystemService(it.context, ConnectivityManager::class.java)
|
||||
if (manager != null) {
|
||||
val info: NetworkInfo? = manager.activeNetworkInfo
|
||||
if (info == null || !info.isConnected) {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun getStatusLayout(): UHHead?
|
||||
|
||||
|
||||
fun showEmpty() {
|
||||
}
|
||||
|
||||
fun showLoading(@RawRes id: Int = R.raw.loading) {
|
||||
getStatusLayout()?.let {
|
||||
it.show()
|
||||
@ -69,6 +27,7 @@ interface NStyleRect {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun showComplete() {
|
||||
getStatusLayout()?.let {
|
||||
if (!it.isShow()) {
|
||||
@ -77,4 +36,39 @@ interface NStyleRect {
|
||||
it.hide()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun showEmpty() {
|
||||
// showLayout(R.drawable.status_empty_ic, R.string.status_layout_no_data, null)
|
||||
}
|
||||
|
||||
|
||||
fun showError(listener: OnRetryListener?) {
|
||||
getStatusLayout()?.let {
|
||||
val manager: ConnectivityManager? = ContextCompat.getSystemService(it.context, ConnectivityManager::class.java)
|
||||
if (manager != null) {
|
||||
val info: NetworkInfo? = manager.activeNetworkInfo
|
||||
if (info == null || !info.isConnected) {
|
||||
// showLayout(R.drawable.status_network_ic, R.string.status_layout_error_network, listener)
|
||||
return
|
||||
}
|
||||
}
|
||||
// showLayout(R.drawable.status_error_ic, R.string.status_layout_error_request, listener)
|
||||
}
|
||||
}
|
||||
|
||||
fun showLayout(@DrawableRes drawableId: Int, @StringRes stringId: Int, listener: OnRetryListener?) {
|
||||
getStatusLayout()?.let {
|
||||
showLayout(ContextCompat.getDrawable(it.context, drawableId), it.context.getString(stringId), listener)
|
||||
}
|
||||
}
|
||||
|
||||
fun showLayout(drawable: Drawable?, hint: CharSequence?, listener: OnRetryListener?) {
|
||||
getStatusLayout()?.let {
|
||||
it.show()
|
||||
it.setIcon(drawable)
|
||||
it.setHint(hint)
|
||||
it.setOnRetryListener(listener)
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,7 @@
|
||||
package com.localee.mireo.app.aop
|
||||
|
||||
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
|
||||
@Target(AnnotationTarget.FUNCTION,
|
||||
AnnotationTarget.PROPERTY_GETTER,
|
||||
AnnotationTarget.PROPERTY_SETTER)
|
||||
annotation class CheckNet
|
@ -0,0 +1,36 @@
|
||||
package com.localee.mireo.app.aop
|
||||
|
||||
import android.app.*
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.NetworkInfo
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.manager.ActivityManager
|
||||
import com.hjq.toast.ToastUtils
|
||||
import org.aspectj.lang.ProceedingJoinPoint
|
||||
import org.aspectj.lang.annotation.Around
|
||||
import org.aspectj.lang.annotation.Aspect
|
||||
import org.aspectj.lang.annotation.Pointcut
|
||||
|
||||
@Suppress("unused")
|
||||
@Aspect
|
||||
class CheckNetAspect {
|
||||
|
||||
@Pointcut("execution(@com.localee.mireo.app.aop.CheckNet * *(..))")
|
||||
fun method() {}
|
||||
|
||||
@Around("method() && @annotation(checkNet)")
|
||||
@Throws(Throwable::class)
|
||||
fun aroundJoinPoint(joinPoint: ProceedingJoinPoint, checkNet: CheckNet) {
|
||||
val application: Application = ActivityManager.getInstance().getApplication()
|
||||
val manager: ConnectivityManager? = ContextCompat.getSystemService(application, ConnectivityManager::class.java)
|
||||
if (manager != null) {
|
||||
val info: NetworkInfo? = manager.activeNetworkInfo
|
||||
if (info == null || !info.isConnected) {
|
||||
ToastUtils.show(R.string.common_network_hint)
|
||||
return
|
||||
}
|
||||
}
|
||||
joinPoint.proceed()
|
||||
}
|
||||
}
|
@ -0,0 +1,8 @@
|
||||
package com.localee.mireo.app.aop
|
||||
|
||||
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
|
||||
@Target(AnnotationTarget.FUNCTION,
|
||||
AnnotationTarget.PROPERTY_GETTER,
|
||||
AnnotationTarget.PROPERTY_SETTER,
|
||||
AnnotationTarget.CONSTRUCTOR)
|
||||
annotation class Log constructor(val value: String = "AppLog")
|
@ -0,0 +1,96 @@
|
||||
package com.localee.mireo.app.aop
|
||||
|
||||
import android.os.Looper
|
||||
import android.os.Trace
|
||||
import org.aspectj.lang.ProceedingJoinPoint
|
||||
import org.aspectj.lang.Signature
|
||||
import org.aspectj.lang.annotation.Around
|
||||
import org.aspectj.lang.annotation.Aspect
|
||||
import org.aspectj.lang.annotation.Pointcut
|
||||
import org.aspectj.lang.reflect.CodeSignature
|
||||
import org.aspectj.lang.reflect.MethodSignature
|
||||
import timber.log.Timber
|
||||
import java.util.concurrent.TimeUnit
|
||||
|
||||
@Suppress("unused")
|
||||
@Aspect
|
||||
class LogAspect {
|
||||
|
||||
@Pointcut("execution(@com.localee.mireo.app.aop.Log *.new(..))")
|
||||
fun constructor() {}
|
||||
|
||||
@Pointcut("execution(@com.localee.mireo.app.aop.Log * *(..))")
|
||||
fun method() {}
|
||||
|
||||
@Around("(method() || constructor()) && @annotation(log)")
|
||||
@Throws(Throwable::class)
|
||||
fun aroundJoinPoint(joinPoint: ProceedingJoinPoint, log: Log): Any? {
|
||||
enterMethod(joinPoint, log)
|
||||
val startNanos: Long = System.nanoTime()
|
||||
val result: Any? = joinPoint.proceed()
|
||||
val stopNanos: Long = System.nanoTime()
|
||||
exitMethod(joinPoint, log, result, TimeUnit.NANOSECONDS.toMillis(stopNanos - startNanos))
|
||||
return result
|
||||
}
|
||||
|
||||
private fun enterMethod(joinPoint: ProceedingJoinPoint, log: Log) {
|
||||
val codeSignature: CodeSignature = joinPoint.signature as CodeSignature
|
||||
|
||||
val className: String = codeSignature.declaringType.name
|
||||
val methodName: String = codeSignature.name
|
||||
val parameterNames: Array<String?> = codeSignature.parameterNames
|
||||
val parameterValues: Array<Any?> = joinPoint.args
|
||||
|
||||
val builder: StringBuilder =
|
||||
getMethodLogInfo(className, methodName, parameterNames, parameterValues)
|
||||
log(log.value, builder.toString())
|
||||
val section: String = builder.substring(2)
|
||||
Trace.beginSection(section)
|
||||
}
|
||||
|
||||
private fun getMethodLogInfo(className: String, methodName: String, parameterNames: Array<String?>, parameterValues: Array<Any?>): StringBuilder {
|
||||
val builder: StringBuilder = StringBuilder("\u21E2 ")
|
||||
builder.append(className)
|
||||
.append(".")
|
||||
.append(methodName)
|
||||
.append('(')
|
||||
for (i in parameterValues.indices) {
|
||||
if (i > 0) {
|
||||
builder.append(", ")
|
||||
}
|
||||
builder.append(parameterNames[i]).append('=')
|
||||
builder.append(parameterValues[i].toString())
|
||||
}
|
||||
builder.append(')')
|
||||
if (Looper.myLooper() != Looper.getMainLooper()) {
|
||||
builder.append(" [Thread:\"").append(Thread.currentThread().name).append("\"]")
|
||||
}
|
||||
return builder
|
||||
}
|
||||
|
||||
private fun exitMethod(joinPoint: ProceedingJoinPoint, log: Log, result: Any?, lengthMillis: Long) {
|
||||
Trace.endSection()
|
||||
val signature: Signature = joinPoint.signature
|
||||
val className: String? = signature.declaringType.name
|
||||
val methodName: String? = signature.name
|
||||
val builder: StringBuilder = StringBuilder("\u21E0 ")
|
||||
.append(className)
|
||||
.append(".")
|
||||
.append(methodName)
|
||||
.append(" [")
|
||||
.append(lengthMillis)
|
||||
.append("ms]")
|
||||
|
||||
// 判断方法是否有返回值
|
||||
if (signature is MethodSignature && signature.returnType != Void.TYPE) {
|
||||
builder.append(" = ")
|
||||
builder.append(result.toString())
|
||||
}
|
||||
log(log.value, builder.toString())
|
||||
}
|
||||
|
||||
private fun log(tag: String?, msg: String?) {
|
||||
Timber.tag(tag)
|
||||
Timber.d(msg)
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.localee.mireo.app.aop
|
||||
|
||||
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
|
||||
@Target(AnnotationTarget.FUNCTION,
|
||||
AnnotationTarget.PROPERTY_GETTER,
|
||||
AnnotationTarget.PROPERTY_SETTER)
|
||||
annotation class Permissions constructor(
|
||||
vararg val value: String
|
||||
)
|
@ -0,0 +1,62 @@
|
||||
package com.localee.mireo.app.aop
|
||||
|
||||
import android.app.Activity
|
||||
import com.hjq.permissions.XXPermissions
|
||||
import com.localee.mireo.app.manager.ActivityManager
|
||||
import com.localee.mireo.app.other.PermissionCallback
|
||||
import org.aspectj.lang.ProceedingJoinPoint
|
||||
import org.aspectj.lang.annotation.Around
|
||||
import org.aspectj.lang.annotation.Aspect
|
||||
import org.aspectj.lang.annotation.Pointcut
|
||||
import timber.log.Timber
|
||||
|
||||
@Suppress("unused")
|
||||
@Aspect
|
||||
class PermissionsAspect {
|
||||
@Pointcut("execution(@com.localee.mireo.app.aop.Permissions * *(..))")
|
||||
fun method() {
|
||||
}
|
||||
|
||||
@Around("method() && @annotation(permissions)")
|
||||
fun aroundJoinPoint(joinPoint: ProceedingJoinPoint, permissions: Permissions) {
|
||||
var activity: Activity? = null
|
||||
|
||||
val parameterValues: Array<Any?> = joinPoint.args
|
||||
for (arg: Any? in parameterValues) {
|
||||
if (arg !is Activity) {
|
||||
continue
|
||||
}
|
||||
activity = arg
|
||||
break
|
||||
}
|
||||
if ((activity == null) || activity.isFinishing || activity.isDestroyed) {
|
||||
activity = ActivityManager.getInstance().getTopActivity()
|
||||
}
|
||||
if ((activity == null) || activity.isFinishing || activity.isDestroyed) {
|
||||
Timber.e("The activity has been destroyed and permission requests cannot be made")
|
||||
return
|
||||
}
|
||||
requestPermissions(joinPoint, activity, permissions.value)
|
||||
}
|
||||
|
||||
private fun requestPermissions(
|
||||
joinPoint: ProceedingJoinPoint,
|
||||
activity: Activity,
|
||||
permissions: Array<out String>
|
||||
) {
|
||||
XXPermissions.with(activity)
|
||||
.permission(*permissions)
|
||||
.request(object : PermissionCallback() {
|
||||
override fun onGranted(permissions: MutableList<String?>?, all: Boolean) {
|
||||
if (all) {
|
||||
try {
|
||||
// 获得权限,执行原方法
|
||||
joinPoint.proceed()
|
||||
} catch (e: Throwable) {
|
||||
// CrashReport.postCatchedException(e)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package com.localee.mireo.app.aop
|
||||
|
||||
@kotlin.annotation.Retention(AnnotationRetention.RUNTIME)
|
||||
@Target(AnnotationTarget.FUNCTION,
|
||||
AnnotationTarget.PROPERTY_GETTER,
|
||||
AnnotationTarget.PROPERTY_SETTER)
|
||||
annotation class SingleClick constructor(
|
||||
val value: Long = 1000
|
||||
)
|
@ -0,0 +1,51 @@
|
||||
package com.localee.mireo.app.aop
|
||||
|
||||
import org.aspectj.lang.ProceedingJoinPoint
|
||||
import org.aspectj.lang.annotation.Around
|
||||
import org.aspectj.lang.annotation.Aspect
|
||||
import org.aspectj.lang.annotation.Pointcut
|
||||
import org.aspectj.lang.reflect.CodeSignature
|
||||
import timber.log.Timber
|
||||
|
||||
@Suppress("unused")
|
||||
@Aspect
|
||||
class SingleClickAspect {
|
||||
|
||||
private var lastTime: Long = 0
|
||||
|
||||
private var lastTag: String? = null
|
||||
|
||||
@Pointcut("execution(@com.localee.mireo.app.aop.SingleClick * *(..))")
|
||||
fun method() {}
|
||||
|
||||
@Around("method() && @annotation(singleClick)")
|
||||
@Throws(Throwable::class)
|
||||
fun aroundJoinPoint(joinPoint: ProceedingJoinPoint, singleClick: SingleClick) {
|
||||
val codeSignature: CodeSignature = joinPoint.signature as CodeSignature
|
||||
val className: String = codeSignature.declaringType.name
|
||||
val methodName: String = codeSignature.name
|
||||
val builder: StringBuilder = StringBuilder("$className.$methodName")
|
||||
builder.append("(")
|
||||
val parameterValues: Array<Any?> = joinPoint.args
|
||||
for (i in parameterValues.indices) {
|
||||
val arg: Any? = parameterValues[i]
|
||||
if (i == 0) {
|
||||
builder.append(arg)
|
||||
} else {
|
||||
builder.append(", ")
|
||||
.append(arg)
|
||||
}
|
||||
}
|
||||
builder.append(")")
|
||||
val tag: String = builder.toString()
|
||||
val currentTimeMillis: Long = System.currentTimeMillis()
|
||||
if (currentTimeMillis - lastTime < singleClick.value && (tag == lastTag)) {
|
||||
Timber.tag("SingleClick")
|
||||
Timber.i("Within %s milliseconds, there was a rapid click:%s", singleClick.value, tag)
|
||||
return
|
||||
}
|
||||
lastTime = currentTimeMillis
|
||||
lastTag = tag
|
||||
joinPoint.proceed()
|
||||
}
|
||||
}
|
@ -6,9 +6,9 @@ import android.view.View
|
||||
import androidx.annotation.StringRes
|
||||
import com.gyf.immersionbar.ImmersionBar
|
||||
import com.hjq.bar.TitleBar
|
||||
import com.localee.mireo.app.base.BaseActivity
|
||||
import com.localee.mireo.app.base.BaseDialog
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.hjq.base.BaseActivity
|
||||
import com.hjq.base.BaseDialog
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.action.TitleBarAction
|
||||
import com.localee.mireo.app.action.ToastAction
|
||||
import com.localee.mireo.app.http.model.HttpData
|
@ -4,7 +4,7 @@ import android.content.Context
|
||||
import android.view.View
|
||||
import androidx.annotation.IntRange
|
||||
import androidx.annotation.LayoutRes
|
||||
import com.localee.mireo.app.base.BaseAdapter
|
||||
import com.hjq.base.BaseAdapter
|
||||
import java.util.*
|
||||
|
||||
abstract class AppAdapter<T> constructor(context: Context) :
|
@ -0,0 +1,165 @@
|
||||
package com.localee.mireo.app.app
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.net.ConnectivityManager
|
||||
import android.net.Network
|
||||
import android.os.Build
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.lifecycle.Lifecycle
|
||||
import androidx.lifecycle.LifecycleOwner
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.google.gson.stream.JsonToken
|
||||
import com.hjq.bar.TitleBar
|
||||
import com.hjq.gson.factory.GsonFactory
|
||||
import com.hjq.http.EasyConfig
|
||||
import com.hjq.http.config.IRequestInterceptor
|
||||
import com.hjq.http.model.HttpHeaders
|
||||
import com.hjq.http.model.HttpParams
|
||||
import com.hjq.http.request.HttpRequest
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.aop.Log
|
||||
import com.localee.mireo.app.http.exception.HttpBodyInterceptor
|
||||
import com.localee.mireo.app.http.model.RequestHandler
|
||||
import com.localee.mireo.app.http.model.RequestServer
|
||||
import com.localee.mireo.app.manager.ActivityManager
|
||||
import com.localee.mireo.app.other.AppConfig
|
||||
import com.localee.mireo.app.other.CrashHandler
|
||||
import com.localee.mireo.app.other.DebugLoggerTree
|
||||
import com.localee.mireo.app.other.MaterialHeader
|
||||
import com.localee.mireo.app.other.SmartBallPulseFooter
|
||||
import com.localee.mireo.app.other.TitleBarStyle
|
||||
import com.localee.mireo.app.other.ToastStyle
|
||||
import com.localee.mireo.app.utils.MsMMKVUtils
|
||||
import com.localee.mireo.app.utils.MsSystemUtlis
|
||||
import com.scwang.smart.refresh.layout.SmartRefreshLayout
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import com.tencent.mmkv.MMKV
|
||||
import okhttp3.OkHttpClient
|
||||
import timber.log.Timber
|
||||
|
||||
class AppApplication : Application() {
|
||||
|
||||
@Log("启动耗时")
|
||||
override fun onCreate() {
|
||||
super.onCreate()
|
||||
instance = this;
|
||||
initSdk(this)
|
||||
}
|
||||
|
||||
override fun onLowMemory() {
|
||||
super.onLowMemory()
|
||||
}
|
||||
|
||||
override fun onTrimMemory(level: Int) {
|
||||
super.onTrimMemory(level)
|
||||
}
|
||||
|
||||
companion object {
|
||||
lateinit var instance: Application;
|
||||
var isCurrentPage: Boolean = true
|
||||
|
||||
fun initSdk(application: Application) {
|
||||
TitleBar.setDefaultStyle(TitleBarStyle())
|
||||
|
||||
SmartRefreshLayout.setDefaultRefreshHeaderCreator { context: Context, layout: RefreshLayout ->
|
||||
MaterialHeader(context).setColorSchemeColors(
|
||||
ContextCompat.getColor(
|
||||
context,
|
||||
R.color.common_accent_color
|
||||
)
|
||||
)
|
||||
}
|
||||
SmartRefreshLayout.setDefaultRefreshFooterCreator { context: Context, layout: RefreshLayout ->
|
||||
SmartBallPulseFooter(context)
|
||||
}
|
||||
SmartRefreshLayout.setDefaultRefreshInitializer { context: Context, layout: RefreshLayout ->
|
||||
layout.setEnableHeaderTranslationContent(true)
|
||||
.setEnableFooterTranslationContent(true)
|
||||
.setEnableFooterFollowWhenNoMoreData(true)
|
||||
.setEnableLoadMoreWhenContentNotFull(false)
|
||||
.setEnableOverScrollDrag(false)
|
||||
}
|
||||
|
||||
ToastUtils.init(application, ToastStyle())
|
||||
ToastUtils.setDebugMode(AppConfig.isDebug())
|
||||
|
||||
CrashHandler.register(application)
|
||||
|
||||
ActivityManager.getInstance().init(application)
|
||||
|
||||
MMKV.initialize(application)
|
||||
|
||||
val okHttpClient: OkHttpClient = OkHttpClient.Builder()
|
||||
.addInterceptor(HttpBodyInterceptor())
|
||||
.build()
|
||||
|
||||
|
||||
EasyConfig.with(okHttpClient)
|
||||
.setLogEnabled(AppConfig.isLogEnable())
|
||||
.setServer(RequestServer())
|
||||
.setHandler(RequestHandler(application))
|
||||
.setRetryCount(1)
|
||||
.setInterceptor(object : IRequestInterceptor {
|
||||
override fun interceptArguments(
|
||||
httpRequest: HttpRequest<*>,
|
||||
params: HttpParams,
|
||||
headers: HttpHeaders
|
||||
) {
|
||||
headers.put("Content-Type", "application/json; charset=utf-8")
|
||||
headers.put("Content-Type", "text/plain; charset=utf-8")
|
||||
|
||||
headers.put("Authorization", MsMMKVUtils.getToken())
|
||||
headers.put(
|
||||
"device-id",
|
||||
MsSystemUtlis.getDeviceId(instance).toString()
|
||||
)
|
||||
headers.put(
|
||||
"lang-key",
|
||||
"en"
|
||||
)
|
||||
headers.put("system-type", "android")
|
||||
headers.put(
|
||||
"app_version",
|
||||
MsSystemUtlis.getVerNameInfo(instance)
|
||||
)
|
||||
// headers.put("security","true")
|
||||
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
.into()
|
||||
|
||||
GsonFactory.setJsonCallback { typeToken: TypeToken<*>, fieldName: String?, jsonToken: JsonToken ->
|
||||
}
|
||||
|
||||
if (AppConfig.isLogEnable()) {
|
||||
Timber.plant(DebugLoggerTree())
|
||||
}
|
||||
|
||||
val connectivityManager: ConnectivityManager? =
|
||||
ContextCompat.getSystemService(application, ConnectivityManager::class.java)
|
||||
if (connectivityManager != null && Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
connectivityManager.registerDefaultNetworkCallback(object :
|
||||
ConnectivityManager.NetworkCallback() {
|
||||
override fun onLost(network: Network) {
|
||||
val topActivity: Activity? = ActivityManager.getInstance().getTopActivity()
|
||||
if (topActivity !is LifecycleOwner) {
|
||||
return
|
||||
}
|
||||
val lifecycleOwner: LifecycleOwner = topActivity
|
||||
if (lifecycleOwner.lifecycle.currentState != Lifecycle.State.RESUMED) {
|
||||
return
|
||||
}
|
||||
ToastUtils.show(R.string.common_network_error)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,12 +1,11 @@
|
||||
package com.localee.mireo.app.app
|
||||
|
||||
import com.localee.mireo.app.base.BaseFragment
|
||||
import com.hjq.base.BaseFragment
|
||||
import com.localee.mireo.app.action.ToastAction
|
||||
import com.localee.mireo.app.http.model.HttpData
|
||||
import com.hjq.http.config.IRequestApi
|
||||
import com.hjq.http.listener.OnHttpListener
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.localee.mireo.app.other.MsConstants
|
||||
|
||||
abstract class AppFragment<A : AppActivity> : BaseFragment<A>(),
|
||||
ToastAction, OnHttpListener<Any> {
|
||||
@ -38,10 +37,8 @@ abstract class AppFragment<A : AppActivity> : BaseFragment<A>(),
|
||||
}
|
||||
|
||||
override fun onHttpFail(throwable: Throwable) {
|
||||
if (!MsConstants.IsFirst){
|
||||
ToastUtils.show(throwable.message)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onHttpEnd(api: IRequestApi) {
|
||||
hideDialog()
|
@ -4,7 +4,7 @@ import android.os.Bundle
|
||||
import android.view.*
|
||||
import com.gyf.immersionbar.ImmersionBar
|
||||
import com.hjq.bar.TitleBar
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.action.TitleBarAction
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
package com.localee.mireo.app.http.bean
|
||||
package com.localee.mireo.app.http.api
|
||||
|
||||
class HistoryBean (
|
||||
val list: List<Data>,
|
||||
@ -15,7 +15,7 @@ class HistoryBean (
|
||||
val current_episode: String,
|
||||
var is_collect: Boolean,
|
||||
var is_check: Boolean,
|
||||
val category: List<String>
|
||||
val categoryList: List<categoryBean>
|
||||
)
|
||||
|
||||
data class Pagination(
|
@ -1,8 +1,6 @@
|
||||
package com.localee.mireo.app.http.api
|
||||
|
||||
import com.hjq.http.config.IRequestApi
|
||||
import com.localee.mireo.app.http.api.HomeModuleApi.RecommandDataBean
|
||||
import com.localee.mireo.app.http.bean.RecommendBean
|
||||
import java.io.Serializable
|
||||
|
||||
|
||||
@ -12,12 +10,7 @@ class HomeBannerApi : IRequestApi {
|
||||
return "getBanners"
|
||||
}
|
||||
|
||||
|
||||
class Bean : Serializable {
|
||||
var list: List<BannerBean>? = null
|
||||
}
|
||||
|
||||
class BannerBean : Serializable{
|
||||
class Bean : Serializable{
|
||||
var id: Int? = null
|
||||
var short_id: Int? = null
|
||||
var short_play_id: Int? = null
|
@ -1,7 +1,7 @@
|
||||
package com.localee.mireo.app.http.api
|
||||
|
||||
import com.hjq.http.config.IRequestApi
|
||||
import com.localee.mireo.app.http.bean.RecommendBean
|
||||
import java.io.Serializable
|
||||
|
||||
|
||||
class HomeDayMaxRechargeShortPlayRankApi : IRequestApi {
|
@ -1,7 +1,6 @@
|
||||
package com.localee.mireo.app.http.api
|
||||
|
||||
import com.hjq.http.config.IRequestApi
|
||||
import com.localee.mireo.app.http.bean.RecommendBean
|
||||
import java.io.Serializable
|
||||
|
||||
|
||||
@ -19,7 +18,6 @@ class HomeModuleApi : IRequestApi {
|
||||
var newTopThree: List<RecommendBean>? = null
|
||||
var highestPayment: List<RecommendBean>? = null
|
||||
var hottestPist: List<RecommendBean>? = null
|
||||
var nineSquare: RecommandDataBean? = null
|
||||
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.localee.mireo.app.http.api
|
||||
|
||||
import com.hjq.http.config.IRequestApi
|
||||
import com.localee.mireo.app.http.bean.RecommendBean
|
||||
import java.io.Serializable
|
||||
|
||||
|
||||
class HomeVideoListApi : IRequestApi {
|
||||
@ -25,6 +25,9 @@ class HomeVideoListApi : IRequestApi {
|
||||
val page_total: Int,
|
||||
val total_size: Int
|
||||
)
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package com.localee.mireo.app.http.bean
|
||||
package com.localee.mireo.app.http.api
|
||||
|
||||
class RecommendBean(
|
||||
var id: Int,
|
@ -19,7 +19,7 @@ class UserInfoRes (
|
||||
val registered_days: Int = 0,
|
||||
val send_coin_left_total: Int = 0,
|
||||
val third_access_platform: String = "",
|
||||
val vip_end_time: String = "",
|
||||
val vip_end_time: Int = 0,
|
||||
val vip_type: String = ""
|
||||
) {
|
||||
companion object {
|
@ -3,7 +3,7 @@ package com.localee.mireo.app.http.api
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import com.hjq.http.config.IRequestApi
|
||||
import java.util.ArrayList
|
||||
import java.io.Serializable
|
||||
|
||||
|
||||
class VideoDetailsApi : IRequestApi {
|
||||
@ -16,11 +16,6 @@ class VideoDetailsApi : IRequestApi {
|
||||
|
||||
var video_id: Int? = null
|
||||
|
||||
var activity_id: Int? = null
|
||||
|
||||
var revolution: String? = null
|
||||
|
||||
|
||||
|
||||
data class Bean(
|
||||
val episodeList: List<Episode>,
|
||||
@ -105,8 +100,7 @@ class VideoDetailsApi : IRequestApi {
|
||||
val name: String,
|
||||
val process: Int,
|
||||
val short_id: Int,
|
||||
val watch_total: Int,
|
||||
val category: ArrayList<String>?
|
||||
val watch_total: Int
|
||||
): Parcelable {
|
||||
constructor(parcel: Parcel) : this(
|
||||
parcel.readInt(),
|
||||
@ -120,8 +114,7 @@ class VideoDetailsApi : IRequestApi {
|
||||
parcel.readString().toString(),
|
||||
parcel.readInt(),
|
||||
parcel.readInt(),
|
||||
parcel.readInt(),
|
||||
parcel.createStringArrayList()
|
||||
parcel.readInt()
|
||||
) {
|
||||
}
|
||||
|
||||
@ -138,7 +131,6 @@ class VideoDetailsApi : IRequestApi {
|
||||
parcel.writeInt(process)
|
||||
parcel.writeInt(short_id)
|
||||
parcel.writeInt(watch_total)
|
||||
parcel.writeStringList(category)
|
||||
}
|
||||
|
||||
override fun describeContents(): Int {
|
||||
@ -154,7 +146,6 @@ class VideoDetailsApi : IRequestApi {
|
||||
return arrayOfNulls(size)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
data class VideoInfo(
|
@ -1,12 +1,8 @@
|
||||
package com.localee.mireo.app.http.exception
|
||||
|
||||
import com.localee.mireo.app.other.MsConstants
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.withContext
|
||||
import okhttp3.Interceptor
|
||||
import okhttp3.Response
|
||||
import okhttp3.ResponseBody
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.io.IOException
|
||||
|
||||
|
||||
@ -16,9 +12,7 @@ class HttpBodyInterceptor : Interceptor {
|
||||
@kotlin.jvm.Throws(IOException::class)
|
||||
override fun intercept(chain: Interceptor.Chain): Response {
|
||||
val k_center = chain.proceed(chain.request())
|
||||
if (k_center.code() != 200) {
|
||||
return k_center
|
||||
}
|
||||
|
||||
return if (k_center.body() != null && k_center.body()!!.contentType() != null) {
|
||||
val actiity = k_center.body()!!.contentType()
|
||||
val circle = k_center.body()!!.string()
|
||||
@ -88,35 +82,4 @@ class HttpBodyInterceptor : Interceptor {
|
||||
}
|
||||
}
|
||||
|
||||
private var lastPostTime: Long = 0L
|
||||
private val lock = Any()
|
||||
private val lock1 = Any()
|
||||
|
||||
suspend fun handle401Response() = withContext(Dispatchers.Main) {
|
||||
synchronized(lock1) {
|
||||
val currentTime = System.currentTimeMillis()
|
||||
if (currentTime - lastPostTime >= DELAY_TIME_MILLIS) {
|
||||
EventBus.getDefault()
|
||||
.post(MsConstants.CONSTANTS_auth_refresh)
|
||||
lastPostTime = currentTime
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
suspend fun handle402Response() = withContext(Dispatchers.Main) {
|
||||
synchronized(lock) {
|
||||
val currentTime = System.currentTimeMillis()
|
||||
if (currentTime - lastPostTime >= DELAY_TIME_MILLIS) {
|
||||
EventBus.getDefault()
|
||||
.post(MsConstants.CONSTANTS_out_login)
|
||||
lastPostTime = currentTime
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val DELAY_TIME_MILLIS = 2000L // 延迟时间,单位毫秒
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -24,11 +24,7 @@ open class HttpData<T> {
|
||||
return code == 200
|
||||
}
|
||||
|
||||
fun is401Failure(): Boolean {
|
||||
return code == 401
|
||||
}
|
||||
|
||||
fun is402Failure(): Boolean {
|
||||
return code == 402
|
||||
fun isTokenFailure(): Boolean {
|
||||
return code == 1001
|
||||
}
|
||||
}
|
@ -19,20 +19,12 @@ import com.hjq.http.exception.ServerException
|
||||
import com.hjq.http.exception.TimeoutException
|
||||
import com.hjq.http.request.HttpRequest
|
||||
import com.localee.mireo.app.http.exception.ResultException
|
||||
import com.localee.mireo.app.http.exception.Token402Exception
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.http.exception.TokenException
|
||||
import com.localee.mireo.app.other.MsConstants
|
||||
import com.localee.mireo.app.utils.TranslatesUtils
|
||||
import com.localee.mireo.shortapp.R
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import com.tencent.mmkv.MMKV
|
||||
import okhttp3.Headers
|
||||
import okhttp3.Response
|
||||
import okhttp3.ResponseBody
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import java.io.IOException
|
||||
import java.io.InputStream
|
||||
import java.lang.reflect.GenericArrayType
|
||||
@ -49,52 +41,21 @@ class RequestHandler constructor(private val mApplication: Application) : IReque
|
||||
return response
|
||||
}
|
||||
|
||||
|
||||
if (!response.isSuccessful) {
|
||||
if (response.code() == 401) {
|
||||
throw if (TranslatesUtils.translates() != null) {
|
||||
TokenException(
|
||||
TranslatesUtils.translates()?.mireo_http_token_error
|
||||
)
|
||||
} else {
|
||||
TokenException(
|
||||
mApplication.getString(R.string.http_token_error)
|
||||
)
|
||||
}
|
||||
} else if (response.code() == 402) {
|
||||
throw if (TranslatesUtils.translates() != null) {
|
||||
Token402Exception(
|
||||
TranslatesUtils.translates()?.mireo_http_token_error
|
||||
)
|
||||
} else {
|
||||
Token402Exception(
|
||||
mApplication.getString(R.string.http_token_error)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
throw if (TranslatesUtils.translates() != null) {
|
||||
ResponseException(
|
||||
TranslatesUtils.translates()?.mireo_http_server_error, response
|
||||
)
|
||||
} else {
|
||||
ResponseException(
|
||||
throw ResponseException(
|
||||
String.format(
|
||||
mApplication.getString(R.string.http_response_error),
|
||||
response.code(), response.message()
|
||||
), response
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (Headers::class.java == type) {
|
||||
return response.headers()
|
||||
}
|
||||
|
||||
val body = response.body()
|
||||
?: throw if (TranslatesUtils.translates() != null) {
|
||||
NullBodyException(TranslatesUtils.translates()?.mireo_http_server_error)
|
||||
} else {
|
||||
NullBodyException(mApplication.getString(R.string.http_response_null_body))
|
||||
}
|
||||
?: throw NullBodyException(mApplication.getString(R.string.http_response_null_body))
|
||||
if (ResponseBody::class.java == type) {
|
||||
return body
|
||||
}
|
||||
@ -122,11 +83,7 @@ class RequestHandler constructor(private val mApplication: Application) : IReque
|
||||
try {
|
||||
text = body.string()
|
||||
} catch (e: IOException) {
|
||||
throw if (TranslatesUtils.translates() != null) {
|
||||
DataException(TranslatesUtils.translates()?.mireo_http_server_error, e)
|
||||
} else {
|
||||
DataException(mApplication.getString(R.string.http_data_explain_error), e)
|
||||
}
|
||||
throw DataException(mApplication.getString(R.string.http_data_explain_error), e)
|
||||
}
|
||||
|
||||
EasyLog.printJson(httpRequest, text)
|
||||
@ -140,11 +97,7 @@ class RequestHandler constructor(private val mApplication: Application) : IReque
|
||||
try {
|
||||
result = GsonFactory.getSingletonGson().fromJson(text, type)
|
||||
} catch (e: JsonSyntaxException) {
|
||||
throw if (TranslatesUtils.translates() != null) {
|
||||
DataException(TranslatesUtils.translates()?.mireo_http_server_error, e)
|
||||
} else {
|
||||
DataException(mApplication.getString(R.string.http_data_explain_error), e)
|
||||
}
|
||||
throw DataException(mApplication.getString(R.string.http_data_explain_error), e)
|
||||
}
|
||||
|
||||
if (result is HttpData<*>) {
|
||||
@ -160,80 +113,45 @@ class RequestHandler constructor(private val mApplication: Application) : IReque
|
||||
return result
|
||||
}
|
||||
|
||||
if (model.is401Failure()) {
|
||||
if (model.isTokenFailure()) {
|
||||
throw TokenException(
|
||||
mApplication.getString(R.string.http_token_error)
|
||||
)
|
||||
}
|
||||
if (model.is402Failure()) {
|
||||
throw Token402Exception(
|
||||
mApplication.getString(R.string.http_token_error)
|
||||
)
|
||||
}
|
||||
|
||||
throw ResultException(model.getMessage(), model)
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
@OptIn(DelicateCoroutinesApi::class)
|
||||
override fun requestFail(httpRequest: HttpRequest<*>, throwable: Throwable): Throwable {
|
||||
if (throwable is HttpException) {
|
||||
if (throwable is TokenException) {
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
handle401Response()
|
||||
}
|
||||
} else if (throwable is Token402Exception) {
|
||||
GlobalScope.launch(Dispatchers.Main) {
|
||||
handle402Response()
|
||||
}
|
||||
}
|
||||
return throwable
|
||||
}
|
||||
|
||||
if (throwable is SocketTimeoutException) {
|
||||
return if (TranslatesUtils.translates() != null) {
|
||||
TimeoutException(
|
||||
TranslatesUtils.translates()?.mireo_http_server_out_time,
|
||||
throwable
|
||||
)
|
||||
} else {
|
||||
TimeoutException(
|
||||
return TimeoutException(
|
||||
mApplication.getString(R.string.http_server_out_time),
|
||||
throwable
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
if (throwable is UnknownHostException) {
|
||||
val info =
|
||||
(mApplication.getSystemService(Context.CONNECTIVITY_SERVICE) as ConnectivityManager).activeNetworkInfo
|
||||
if (info != null && info.isConnected) {
|
||||
return if (TranslatesUtils.translates() != null) {
|
||||
ServerException(
|
||||
TranslatesUtils.translates()?.mireo_http_server_error,
|
||||
throwable
|
||||
)
|
||||
} else {
|
||||
ServerException(
|
||||
return ServerException(
|
||||
mApplication.getString(R.string.http_server_error),
|
||||
throwable
|
||||
)
|
||||
}
|
||||
}
|
||||
return if (TranslatesUtils.translates() != null) {
|
||||
NetworkException(TranslatesUtils.translates()?.mireo_no_network, throwable)
|
||||
} else {
|
||||
NetworkException(mApplication.getString(R.string.http_network_error), throwable)
|
||||
}
|
||||
return NetworkException(mApplication.getString(R.string.http_network_error), throwable)
|
||||
}
|
||||
|
||||
if (throwable is IOException) {
|
||||
return if (TranslatesUtils.translates() != null) {
|
||||
CancelException(TranslatesUtils.translates()?.mireo_http_request_cancel, throwable)
|
||||
} else {
|
||||
CancelException(mApplication.getString(R.string.http_request_cancel), throwable)
|
||||
}
|
||||
return CancelException(mApplication.getString(R.string.http_request_cancel), throwable)
|
||||
}
|
||||
|
||||
return HttpException(throwable.message, throwable)
|
||||
@ -316,34 +234,5 @@ class RequestHandler constructor(private val mApplication: Application) : IReque
|
||||
HttpCacheManager.clearCache()
|
||||
}
|
||||
|
||||
private var lastPostTime: Long = 0L
|
||||
private val lock = Any()
|
||||
private val lock1 = Any()
|
||||
|
||||
private suspend fun handle401Response() = withContext(Dispatchers.Main) {
|
||||
synchronized(lock1) {
|
||||
val currentTime = System.currentTimeMillis()
|
||||
if (currentTime - lastPostTime >= DELAY_TIME_MILLIS) {
|
||||
EventBus.getDefault()
|
||||
.post(MsConstants.CONSTANTS_auth_refresh)
|
||||
lastPostTime = currentTime
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun handle402Response() = withContext(Dispatchers.Main) {
|
||||
synchronized(lock) {
|
||||
val currentTime = System.currentTimeMillis()
|
||||
if (currentTime - lastPostTime >= DELAY_TIME_MILLIS) {
|
||||
EventBus.getDefault()
|
||||
.post(MsConstants.CONSTANTS_out_login)
|
||||
lastPostTime = currentTime
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
private const val DELAY_TIME_MILLIS = 2000L // 延迟时间,单位毫秒
|
||||
}
|
||||
|
||||
}
|
@ -5,6 +5,7 @@ import android.app.Application
|
||||
import android.app.Application.ActivityLifecycleCallbacks
|
||||
import android.os.Bundle
|
||||
import androidx.collection.ArrayMap
|
||||
import timber.log.Timber
|
||||
import java.util.*
|
||||
|
||||
class ActivityManager private constructor() : ActivityLifecycleCallbacks {
|
||||
@ -57,7 +58,6 @@ class ActivityManager private constructor() : ActivityLifecycleCallbacks {
|
||||
fun registerApplicationLifecycleCallback(callback: ApplicationLifecycleCallback) {
|
||||
lifecycleCallbacks.add(callback)
|
||||
}
|
||||
|
||||
fun unregisterApplicationLifecycleCallback(callback: ApplicationLifecycleCallback) {
|
||||
lifecycleCallbacks.remove(callback)
|
||||
}
|
||||
@ -108,32 +108,39 @@ class ActivityManager private constructor() : ActivityLifecycleCallbacks {
|
||||
}
|
||||
|
||||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) {
|
||||
Timber.i("%s - onCreate", activity.javaClass.simpleName)
|
||||
if (activitySet.size == 0) {
|
||||
for (callback: ApplicationLifecycleCallback? in lifecycleCallbacks) {
|
||||
callback?.onApplicationCreate(activity)
|
||||
}
|
||||
Timber.i("%s - onApplicationCreate", activity.javaClass.simpleName)
|
||||
}
|
||||
activitySet[getObjectTag(activity)] = activity
|
||||
topActivity = activity
|
||||
}
|
||||
|
||||
override fun onActivityStarted(activity: Activity) {
|
||||
Timber.i("%s - onStart", activity.javaClass.simpleName)
|
||||
}
|
||||
|
||||
override fun onActivityResumed(activity: Activity) {
|
||||
Timber.i("%s - onResume", activity.javaClass.simpleName)
|
||||
if (topActivity === activity && resumedActivity == null) {
|
||||
for (callback: ApplicationLifecycleCallback in lifecycleCallbacks) {
|
||||
callback.onApplicationForeground(activity)
|
||||
}
|
||||
Timber.i("%s - onApplicationForeground", activity.javaClass.simpleName)
|
||||
}
|
||||
topActivity = activity
|
||||
resumedActivity = activity
|
||||
}
|
||||
|
||||
override fun onActivityPaused(activity: Activity) {
|
||||
Timber.i("%s - onPause", activity.javaClass.simpleName)
|
||||
}
|
||||
|
||||
override fun onActivityStopped(activity: Activity) {
|
||||
Timber.i("%s - onStop", activity.javaClass.simpleName)
|
||||
if (resumedActivity === activity) {
|
||||
resumedActivity = null
|
||||
}
|
||||
@ -141,13 +148,16 @@ class ActivityManager private constructor() : ActivityLifecycleCallbacks {
|
||||
for (callback: ApplicationLifecycleCallback in lifecycleCallbacks) {
|
||||
callback.onApplicationBackground(activity)
|
||||
}
|
||||
Timber.i("%s - onApplicationBackground", activity.javaClass.simpleName)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) {
|
||||
Timber.i("%s - onSaveInstanceState", activity.javaClass.simpleName)
|
||||
}
|
||||
|
||||
override fun onActivityDestroyed(activity: Activity) {
|
||||
Timber.i("%s - onDestroy", activity.javaClass.simpleName)
|
||||
activitySet.remove(getObjectTag(activity))
|
||||
if (topActivity === activity) {
|
||||
topActivity = null
|
||||
@ -156,6 +166,7 @@ class ActivityManager private constructor() : ActivityLifecycleCallbacks {
|
||||
for (callback: ApplicationLifecycleCallback in lifecycleCallbacks) {
|
||||
callback.onApplicationDestroy(activity)
|
||||
}
|
||||
Timber.i("%s - onApplicationDestroy", activity.javaClass.simpleName)
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.localee.mireo.app.other
|
||||
|
||||
import com.localee.mireo.shortapp.BuildConfig
|
||||
import com.localee.mireo.app.BuildConfig
|
||||
|
||||
object AppConfig {
|
||||
|
@ -0,0 +1,19 @@
|
||||
package com.localee.mireo.app.other
|
||||
|
||||
import android.os.Build
|
||||
import timber.log.Timber.DebugTree
|
||||
|
||||
class DebugLoggerTree : DebugTree() {
|
||||
|
||||
companion object {
|
||||
private const val MAX_TAG_LENGTH: Int = 23
|
||||
}
|
||||
|
||||
override fun createStackElementTag(element: StackTraceElement): String {
|
||||
val tag: String = "(" + element.fileName + ":" + element.lineNumber + ")"
|
||||
if (tag.length <= MAX_TAG_LENGTH || Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
return tag
|
||||
}
|
||||
return tag.substring(0, MAX_TAG_LENGTH)
|
||||
}
|
||||
}
|
@ -11,7 +11,7 @@ import android.widget.ImageView
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.annotation.ColorRes
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.app.R
|
||||
import com.scwang.smart.refresh.header.material.CircleImageView
|
||||
import com.scwang.smart.refresh.header.material.MaterialProgressDrawable
|
||||
import com.scwang.smart.refresh.layout.api.RefreshHeader
|
@ -1,27 +1,6 @@
|
||||
package com.localee.mireo.drama.mins
|
||||
import kotlin.math.min
|
||||
import kotlin.math.max
|
||||
|
||||
@Volatile
|
||||
var maximumCheckedStartedCount: Int = 9360
|
||||
@Volatile
|
||||
var verticalTotalMsgSum: Long = 643L
|
||||
@Volatile
|
||||
private var managerArray_tag: Long = 1426L
|
||||
@Volatile
|
||||
private var can_MeasurePaginationFactory: Boolean = false
|
||||
|
||||
|
||||
|
||||
object VMErrorFinish {
|
||||
@Volatile
|
||||
var coinsCallFile_dict: MutableMap<String,Float> = mutableMapOf<String,Float>()
|
||||
@Volatile
|
||||
var decorationTransparentOffset: Float = 8862.0f
|
||||
@Volatile
|
||||
var float_aPathMoreString: String = "ranking"
|
||||
|
||||
package com.localee.mireo.app.other
|
||||
|
||||
object MsConstants {
|
||||
|
||||
const val ACCESS_TOKEN = "access_token"
|
||||
const val APP_LANG = "app_langs"
|
@ -0,0 +1,188 @@
|
||||
package com.localee.mireo.app.other
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.*
|
||||
import android.os.*
|
||||
import com.hjq.base.BaseDialog
|
||||
import com.localee.mireo.app.manager.*
|
||||
import com.localee.mireo.app.ui.dialog.MessageDialog
|
||||
import com.hjq.permissions.OnPermissionCallback
|
||||
import com.hjq.permissions.Permission
|
||||
import com.hjq.permissions.XXPermissions
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.localee.mireo.app.manager.ActivityManager
|
||||
import java.util.*
|
||||
import com.localee.mireo.app.R
|
||||
|
||||
abstract class PermissionCallback : OnPermissionCallback {
|
||||
|
||||
override fun onDenied(permissions: MutableList<String>, never: Boolean) {
|
||||
if (never) {
|
||||
showPermissionDialog(permissions)
|
||||
return
|
||||
}
|
||||
if (permissions.size == 1 && (Permission.ACCESS_BACKGROUND_LOCATION == permissions[0])) {
|
||||
ToastUtils.show(R.string.common_permission_fail_4)
|
||||
return
|
||||
}
|
||||
ToastUtils.show(R.string.common_permission_fail_1)
|
||||
}
|
||||
|
||||
protected fun showPermissionDialog(permissions: MutableList<String>) {
|
||||
val activity: Activity? = ActivityManager.getInstance().getTopActivity()
|
||||
if ((activity == null) || activity.isFinishing || activity.isDestroyed) {
|
||||
return
|
||||
}
|
||||
MessageDialog.Builder(activity)
|
||||
.setTitle(R.string.common_permission_alert)
|
||||
.setMessage(getPermissionHint(activity, permissions))
|
||||
.setConfirm(R.string.common_permission_goto)
|
||||
.setCancel(null)
|
||||
.setCancelable(false)
|
||||
.setListener(object : MessageDialog.OnListener {
|
||||
|
||||
override fun onConfirm(dialog: BaseDialog?) {
|
||||
XXPermissions.startPermissionActivity(activity, permissions)
|
||||
}
|
||||
})
|
||||
.show()
|
||||
}
|
||||
|
||||
protected fun getPermissionHint(context: Context, permissions: MutableList<String>): String {
|
||||
if (permissions.isEmpty()) {
|
||||
return context.getString(R.string.common_permission_fail_2)
|
||||
}
|
||||
val hints: MutableList<String> = ArrayList()
|
||||
for (permission: String? in permissions) {
|
||||
when (permission) {
|
||||
Permission.READ_EXTERNAL_STORAGE,
|
||||
Permission.WRITE_EXTERNAL_STORAGE,
|
||||
Permission.MANAGE_EXTERNAL_STORAGE -> {
|
||||
val hint: String = context.getString(R.string.common_permission_storage)
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint)
|
||||
}
|
||||
}
|
||||
Permission.CAMERA -> {
|
||||
val hint: String = context.getString(R.string.common_permission_camera)
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint)
|
||||
}
|
||||
}
|
||||
Permission.RECORD_AUDIO -> {
|
||||
val hint: String = context.getString(R.string.common_permission_microphone)
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint)
|
||||
}
|
||||
}
|
||||
Permission.ACCESS_FINE_LOCATION,
|
||||
Permission.ACCESS_COARSE_LOCATION,
|
||||
Permission.ACCESS_BACKGROUND_LOCATION -> {
|
||||
val hint: String = if (!permissions.contains(Permission.ACCESS_FINE_LOCATION) &&
|
||||
!permissions.contains(Permission.ACCESS_COARSE_LOCATION)) {
|
||||
context.getString(R.string.common_permission_location_background)
|
||||
} else {
|
||||
context.getString(R.string.common_permission_location)
|
||||
}
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint)
|
||||
}
|
||||
}
|
||||
Permission.READ_PHONE_STATE,
|
||||
Permission.CALL_PHONE,
|
||||
Permission.ADD_VOICEMAIL,
|
||||
Permission.USE_SIP,
|
||||
Permission.READ_PHONE_NUMBERS,
|
||||
Permission.ANSWER_PHONE_CALLS -> {
|
||||
val hint: String = context.getString(R.string.common_permission_phone)
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint)
|
||||
}
|
||||
}
|
||||
Permission.GET_ACCOUNTS,
|
||||
Permission.READ_CONTACTS,
|
||||
Permission.WRITE_CONTACTS -> {
|
||||
val hint: String = context.getString(R.string.common_permission_contacts)
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint)
|
||||
}
|
||||
}
|
||||
Permission.READ_CALENDAR,
|
||||
Permission.WRITE_CALENDAR -> {
|
||||
val hint: String = context.getString(R.string.common_permission_calendar)
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint)
|
||||
}
|
||||
}
|
||||
Permission.READ_CALL_LOG,
|
||||
Permission.WRITE_CALL_LOG,
|
||||
Permission.PROCESS_OUTGOING_CALLS -> {
|
||||
val hint: String = context.getString(if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) R.string.common_permission_call_log else R.string.common_permission_phone)
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint)
|
||||
}
|
||||
}
|
||||
Permission.BODY_SENSORS -> {
|
||||
val hint: String = context.getString(R.string.common_permission_sensors)
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint)
|
||||
}
|
||||
}
|
||||
Permission.ACTIVITY_RECOGNITION -> {
|
||||
val hint: String = context.getString(R.string.common_permission_activity_recognition)
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint)
|
||||
}
|
||||
}
|
||||
Permission.SEND_SMS,
|
||||
Permission.RECEIVE_SMS,
|
||||
Permission.READ_SMS,
|
||||
Permission.RECEIVE_WAP_PUSH,
|
||||
Permission.RECEIVE_MMS -> {
|
||||
val hint: String = context.getString(R.string.common_permission_sms)
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint)
|
||||
}
|
||||
}
|
||||
Permission.REQUEST_INSTALL_PACKAGES -> {
|
||||
val hint: String = context.getString(R.string.common_permission_install)
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint)
|
||||
}
|
||||
}
|
||||
Permission.NOTIFICATION_SERVICE -> {
|
||||
val hint: String = context.getString(R.string.common_permission_notification)
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint)
|
||||
}
|
||||
}
|
||||
Permission.SYSTEM_ALERT_WINDOW -> {
|
||||
val hint: String = context.getString(R.string.common_permission_window)
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint)
|
||||
}
|
||||
}
|
||||
Permission.WRITE_SETTINGS -> {
|
||||
val hint: String = context.getString(R.string.common_permission_setting)
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (hints.isNotEmpty()) {
|
||||
val builder: StringBuilder = StringBuilder()
|
||||
for (text: String? in hints) {
|
||||
if (builder.isEmpty()) {
|
||||
builder.append(text)
|
||||
} else {
|
||||
builder.append("、")
|
||||
.append(text)
|
||||
}
|
||||
}
|
||||
builder.append(" ")
|
||||
return context.getString(R.string.common_permission_fail_3, builder.toString())
|
||||
}
|
||||
return context.getString(R.string.common_permission_fail_2)
|
||||
}
|
||||
}
|
@ -9,7 +9,7 @@ import android.util.AttributeSet
|
||||
import android.view.animation.AccelerateDecelerateInterpolator
|
||||
import androidx.annotation.ColorInt
|
||||
import androidx.core.graphics.ColorUtils
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.app.R
|
||||
import com.scwang.smart.refresh.layout.api.RefreshFooter
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import com.scwang.smart.refresh.layout.constant.SpinnerStyle
|
@ -7,8 +7,8 @@ import android.widget.TextView
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.core.content.ContextCompat
|
||||
import com.hjq.bar.style.LightBarStyle
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.app.widget.view.PressAlphaTextView
|
||||
import com.localee.mireo.app.R
|
||||
import com.hjq.widget.view.PressAlphaTextView
|
||||
|
||||
class TitleBarStyle : LightBarStyle() {
|
||||
|
@ -3,7 +3,7 @@ package com.localee.mireo.app.other
|
||||
import android.content.Context
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.graphics.drawable.GradientDrawable
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.app.R
|
||||
import com.hjq.toast.style.BlackToastStyle
|
||||
|
||||
class ToastStyle : BlackToastStyle() {
|
@ -0,0 +1,45 @@
|
||||
package com.localee.mireo.app.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.net.Uri
|
||||
import android.view.View
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.aop.SingleClick
|
||||
import com.localee.mireo.app.app.AppActivity
|
||||
import com.localee.mireo.app.other.MsConstants
|
||||
|
||||
class AboutActivity : AppActivity() {
|
||||
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.about_activity
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
setOnClickListener(R.id.sb_about_web, R.id.sb_about_privacy, R.id.sb_about_agreement)
|
||||
|
||||
}
|
||||
|
||||
override fun initData() {
|
||||
}
|
||||
|
||||
@SingleClick
|
||||
override fun onClick(view: View) {
|
||||
when (view.id) {
|
||||
R.id.sb_about_web -> {
|
||||
val webIntent = Intent(Intent.ACTION_VIEW, Uri.parse(MsConstants.Constants_web))
|
||||
startActivity(webIntent)
|
||||
}
|
||||
|
||||
R.id.sb_about_privacy -> {
|
||||
BrowserActivity.start(this, MsConstants.Constants_privacy_policy)
|
||||
}
|
||||
|
||||
R.id.sb_about_agreement -> {
|
||||
BrowserActivity.start(this, MsConstants.Constants_user_agreement)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,17 +1,17 @@
|
||||
package com.localee.mireo.app.ui.activity
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.content.*
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.drawable.BitmapDrawable
|
||||
import android.text.TextUtils
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.*
|
||||
import android.webkit.WebView
|
||||
import android.widget.ProgressBar
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.action.StatusAction
|
||||
import com.localee.mireo.app.aop.CheckNet
|
||||
import com.localee.mireo.app.aop.Log
|
||||
import com.localee.mireo.app.app.AppActivity
|
||||
import com.localee.mireo.app.widget.BrowserView
|
||||
import com.localee.mireo.app.widget.BrowserView.BrowserChromeClient
|
||||
@ -28,6 +28,8 @@ class BrowserActivity : AppActivity(), StatusAction, OnRefreshListener {
|
||||
|
||||
const val INTENT_KEY_IN_URL: String = "url"
|
||||
|
||||
@CheckNet
|
||||
@Log
|
||||
fun start(context: Context, url: String) {
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
return
|
||||
@ -83,6 +85,7 @@ class BrowserActivity : AppActivity(), StatusAction, OnRefreshListener {
|
||||
return super.onKeyDown(keyCode, event)
|
||||
}
|
||||
|
||||
@CheckNet
|
||||
private fun reload() {
|
||||
browserView?.reload()
|
||||
}
|
||||
@ -96,12 +99,7 @@ class BrowserActivity : AppActivity(), StatusAction, OnRefreshListener {
|
||||
|
||||
private inner class AppBrowserViewClient : BrowserViewClient() {
|
||||
|
||||
override fun onReceivedError(
|
||||
view: WebView,
|
||||
errorCode: Int,
|
||||
description: String,
|
||||
failingUrl: String
|
||||
) {
|
||||
override fun onReceivedError(view: WebView, errorCode: Int, description: String, failingUrl: String) {
|
||||
post {
|
||||
showError(object : OnRetryListener {
|
||||
override fun onRetry(layout: StatusLayout) {
|
||||
@ -122,8 +120,7 @@ class BrowserActivity : AppActivity(), StatusAction, OnRefreshListener {
|
||||
}
|
||||
}
|
||||
|
||||
private inner class AppBrowserChromeClient constructor(view: BrowserView) :
|
||||
BrowserChromeClient(view) {
|
||||
private inner class AppBrowserChromeClient constructor(view: BrowserView) : BrowserChromeClient(view) {
|
||||
|
||||
override fun onReceivedTitle(view: WebView, title: String?) {
|
||||
if (title == null) {
|
@ -0,0 +1,171 @@
|
||||
package com.localee.mireo.app.ui.activity
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import androidx.activity.viewModels
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.localee.mireo.app.utils.MsMMKVUtils
|
||||
import com.gyf.immersionbar.ImmersionBar
|
||||
import com.hjq.base.FragmentPagerAdapter
|
||||
import com.hjq.http.EasyHttp
|
||||
import com.hjq.http.listener.HttpCallbackProxy
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.app.AppActivity
|
||||
import com.localee.mireo.app.app.AppFragment
|
||||
import com.localee.mireo.app.http.api.UserInfoApi
|
||||
import com.localee.mireo.app.http.api.UserInfoRes
|
||||
import com.localee.mireo.app.http.model.HttpData
|
||||
import com.localee.mireo.app.ui.adapter.NavigationAdapter
|
||||
import com.localee.mireo.app.ui.fragment.ExploreFragment
|
||||
import com.localee.mireo.app.ui.fragment.HomeFragment
|
||||
import com.localee.mireo.app.ui.fragment.MessageFragment
|
||||
import com.localee.mireo.app.ui.fragment.MineFragment
|
||||
import com.localee.mireo.app.ui.fragment.SharedViewModel
|
||||
|
||||
class HomeActivity : AppActivity(), NavigationAdapter.OnNavigationListener {
|
||||
|
||||
companion object {
|
||||
|
||||
private const val INTENT_KEY_IN_FRAGMENT_INDEX: String = "fragmentIndex"
|
||||
private const val INTENT_KEY_IN_FRAGMENT_CLASS: String = "fragmentClass"
|
||||
|
||||
@JvmOverloads
|
||||
fun start(
|
||||
context: Context,
|
||||
fragmentClass: Class<out AppFragment<*>?>? = HomeFragment::class.java
|
||||
) {
|
||||
val intent = Intent(context, HomeActivity::class.java)
|
||||
intent.putExtra(INTENT_KEY_IN_FRAGMENT_CLASS, fragmentClass)
|
||||
if (context !is Activity) {
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
||||
}
|
||||
context.startActivity(intent)
|
||||
}
|
||||
}
|
||||
|
||||
private val viewPager: ViewPager? by lazy { findViewById(R.id.vp_home_pager) }
|
||||
private val navigationView: RecyclerView? by lazy { findViewById(R.id.rv_home_navigation) }
|
||||
private var navigationAdapter: NavigationAdapter? = null
|
||||
private var pagerAdapter: FragmentPagerAdapter<AppFragment<*>>? = null
|
||||
|
||||
private val viewModel: SharedViewModel by viewModels()
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.home_activity
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
|
||||
navigationAdapter = NavigationAdapter(this).apply {
|
||||
addItem(
|
||||
NavigationAdapter.MenuItem(
|
||||
getString(R.string.home_nav_index),
|
||||
ContextCompat.getDrawable(this@HomeActivity, R.drawable.home_home_selector)
|
||||
)
|
||||
)
|
||||
addItem(
|
||||
NavigationAdapter.MenuItem(
|
||||
getString(R.string.home_nav_explore),
|
||||
ContextCompat.getDrawable(this@HomeActivity, R.drawable.home_explore_selector)
|
||||
)
|
||||
)
|
||||
addItem(
|
||||
NavigationAdapter.MenuItem(
|
||||
getString(R.string.home_nav_my_list),
|
||||
ContextCompat.getDrawable(this@HomeActivity, R.drawable.home_my_list_selector)
|
||||
)
|
||||
)
|
||||
addItem(
|
||||
NavigationAdapter.MenuItem(
|
||||
getString(R.string.home_nav_me),
|
||||
ContextCompat.getDrawable(this@HomeActivity, R.drawable.home_me_selector)
|
||||
)
|
||||
)
|
||||
setOnNavigationListener(this@HomeActivity)
|
||||
navigationView?.adapter = this
|
||||
}
|
||||
}
|
||||
|
||||
override fun initData() {
|
||||
// getCustomerUser()
|
||||
|
||||
pagerAdapter = FragmentPagerAdapter<AppFragment<*>>(this).apply {
|
||||
addFragment(HomeFragment.newInstance())
|
||||
addFragment(ExploreFragment.newInstance())
|
||||
addFragment(MessageFragment.newInstance())
|
||||
addFragment(MineFragment.newInstance())
|
||||
viewPager?.adapter = this
|
||||
}
|
||||
onNewIntent(intent)
|
||||
|
||||
viewModel.action.observe(this) { data ->
|
||||
switchFragment(data);
|
||||
}
|
||||
}
|
||||
|
||||
override fun onNewIntent(intent: Intent?) {
|
||||
super.onNewIntent(intent)
|
||||
pagerAdapter?.let {
|
||||
switchFragment(it.getFragmentIndex(getSerializable(INTENT_KEY_IN_FRAGMENT_CLASS)))
|
||||
}
|
||||
}
|
||||
|
||||
override fun onSaveInstanceState(outState: Bundle) {
|
||||
super.onSaveInstanceState(outState)
|
||||
viewPager?.let {
|
||||
outState.putInt(INTENT_KEY_IN_FRAGMENT_INDEX, it.currentItem)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onRestoreInstanceState(savedInstanceState: Bundle) {
|
||||
super.onRestoreInstanceState(savedInstanceState)
|
||||
switchFragment(savedInstanceState.getInt(INTENT_KEY_IN_FRAGMENT_INDEX))
|
||||
}
|
||||
|
||||
private fun switchFragment(fragmentIndex: Int) {
|
||||
if (fragmentIndex == -1) {
|
||||
return
|
||||
}
|
||||
when (fragmentIndex) {
|
||||
0, 1, 2, 3 -> {
|
||||
viewPager?.currentItem = fragmentIndex
|
||||
navigationAdapter?.setSelectedPosition(fragmentIndex)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [NavigationAdapter.OnNavigationListener]
|
||||
*/
|
||||
override fun onNavigationItemSelected(position: Int): Boolean {
|
||||
return when (position) {
|
||||
0, 1, 2, 3 -> {
|
||||
viewPager?.currentItem = position
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun createStatusBarConfig(): ImmersionBar {
|
||||
return super.createStatusBarConfig()
|
||||
.navigationBarColor(R.color.white)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
moveTaskToBack(false)
|
||||
}
|
||||
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
viewPager?.adapter = null
|
||||
navigationView?.adapter = null
|
||||
navigationAdapter?.setOnNavigationListener(null)
|
||||
}
|
||||
}
|
@ -0,0 +1,178 @@
|
||||
package com.localee.mireo.app.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import android.text.Editable
|
||||
import android.text.TextUtils
|
||||
import android.text.TextWatcher
|
||||
import android.view.KeyEvent
|
||||
import android.view.inputmethod.EditorInfo
|
||||
import android.widget.EditText
|
||||
import android.widget.ImageView
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.hjq.http.EasyHttp
|
||||
import com.hjq.http.config.IRequestApi
|
||||
import com.hjq.http.listener.HttpCallbackProxy
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.action.StatusAction
|
||||
import com.localee.mireo.app.app.AppActivity
|
||||
import com.localee.mireo.app.http.api.SearchHotApi
|
||||
import com.localee.mireo.app.http.api.SearchSearchApi
|
||||
import com.localee.mireo.app.http.model.HttpData
|
||||
import com.localee.mireo.app.other.MsConstants.CONSTANTS_short_play_id
|
||||
import com.localee.mireo.app.ui.adapter.SearchHotAdapter
|
||||
import com.localee.mireo.app.ui.adapter.SearchSearchAdapter
|
||||
import com.localee.mireo.app.widget.StatusLayout
|
||||
|
||||
|
||||
class SearchActivity : AppActivity(), StatusAction {
|
||||
|
||||
private val hintLayout: StatusLayout? by lazy { findViewById(R.id.hl_status_hint) }
|
||||
private val ivClose: ImageView? by lazy { findViewById(R.id.iv_close) }
|
||||
private val etSearch: EditText? by lazy { findViewById(R.id.et_search) }
|
||||
private val recycler: RecyclerView? by lazy { findViewById(R.id.recycler) }
|
||||
|
||||
private var mAdapter: SearchHotAdapter? = null
|
||||
private var mKeyAdapter: SearchSearchAdapter? = null
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.status_activity
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
|
||||
recycler?.layoutManager =
|
||||
LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false)
|
||||
|
||||
|
||||
mAdapter = SearchHotAdapter()
|
||||
mKeyAdapter = SearchSearchAdapter()
|
||||
recycler?.adapter = mAdapter
|
||||
|
||||
// getSearchHot()
|
||||
|
||||
}
|
||||
|
||||
override fun initData() {
|
||||
ivClose?.setOnClickListener {
|
||||
finish()
|
||||
}
|
||||
|
||||
etSearch?.addTextChangedListener(object : TextWatcher {
|
||||
override fun beforeTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) {
|
||||
}
|
||||
|
||||
override fun onTextChanged(charSequence: CharSequence, i: Int, i1: Int, i2: Int) {
|
||||
if (!TextUtils.isEmpty(charSequence.toString())) {
|
||||
recycler?.adapter = mKeyAdapter
|
||||
getSearchSearch(charSequence.toString())
|
||||
} else {
|
||||
recycler?.adapter = mAdapter
|
||||
}
|
||||
}
|
||||
|
||||
override fun afterTextChanged(editable: Editable) {
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
etSearch?.setOnEditorActionListener { v, actionId, event ->
|
||||
if (actionId == EditorInfo.IME_ACTION_DONE ||
|
||||
(event != null && event.action == KeyEvent.ACTION_DOWN &&
|
||||
event.keyCode == KeyEvent.KEYCODE_ENTER)
|
||||
) {
|
||||
hideKeyboard(v)
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
mAdapter?.setOnItemClickListener { adapter, view, position ->
|
||||
val searchHot: SearchHotApi.Bean.Data =
|
||||
adapter.items.get(position)
|
||||
startActivity(
|
||||
Intent(
|
||||
this,
|
||||
VideoPlayActivity::class.java
|
||||
).apply {
|
||||
searchHot.short_play_id.let {
|
||||
putExtra(CONSTANTS_short_play_id, it)
|
||||
}
|
||||
})
|
||||
}
|
||||
mKeyAdapter?.setOnItemClickListener { adapter, view, position ->
|
||||
val search: SearchSearchApi.Bean.Data =
|
||||
adapter.items.get(position)
|
||||
startActivity(
|
||||
Intent(
|
||||
this,
|
||||
VideoPlayActivity::class.java
|
||||
).apply {
|
||||
search.short_play_id.let {
|
||||
putExtra(CONSTANTS_short_play_id, it)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
fun getSearchHot() {
|
||||
EasyHttp.get(this)
|
||||
.api(SearchHotApi().apply {
|
||||
})
|
||||
.request(object : HttpCallbackProxy<HttpData<SearchHotApi.Bean>>(this) {
|
||||
override fun onHttpSuccess(result: HttpData<SearchHotApi.Bean>) {
|
||||
result.getData()?.let {
|
||||
if (it.list.isEmpty()) {
|
||||
hintLayout?.show()
|
||||
} else {
|
||||
hintLayout?.hide()
|
||||
}
|
||||
mAdapter?.submitList(it.list)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun onHttpFail(throwable: Throwable) {
|
||||
super.onHttpFail(throwable)
|
||||
hintLayout?.show()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun getSearchSearch(searchKey: String) {
|
||||
EasyHttp.get(this)
|
||||
.api(SearchSearchApi().apply {
|
||||
search = searchKey
|
||||
})
|
||||
.request(object : HttpCallbackProxy<HttpData<SearchSearchApi.Bean>>(this) {
|
||||
|
||||
override fun onHttpStart(api: IRequestApi) {
|
||||
|
||||
}
|
||||
|
||||
override fun onHttpSuccess(result: HttpData<SearchSearchApi.Bean>) {
|
||||
result.getData()?.let {
|
||||
if (it.list.isEmpty()) {
|
||||
hintLayout?.show()
|
||||
} else {
|
||||
hintLayout?.hide()
|
||||
}
|
||||
mKeyAdapter?.submitList(it.list)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onHttpFail(throwable: Throwable) {
|
||||
super.onHttpFail(throwable)
|
||||
hintLayout?.show()
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
override fun getStatusLayout(): StatusLayout? {
|
||||
return hintLayout
|
||||
}
|
||||
}
|
@ -1,26 +1,20 @@
|
||||
package com.localee.mireo.app.ui.activity
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.bumptech.glide.Glide
|
||||
import com.hjq.bar.TitleBar
|
||||
import com.hjq.widget.layout.SettingBar
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.app.AppActivity
|
||||
import com.localee.mireo.app.manager.CacheDataManager
|
||||
import com.localee.mireo.app.utils.MsMMKVUtils
|
||||
import com.localee.mireo.app.utils.TranslatesUtils
|
||||
import com.localee.mireo.app.utils.singleClick
|
||||
import com.localee.mireo.app.widget.layout.SettingBar
|
||||
import com.localee.mireo.shortapp.R
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
|
||||
|
||||
class SettingActivity : AppActivity() {
|
||||
class SettingActivity : AppActivity(){
|
||||
|
||||
private val title: TitleBar? by lazy { findViewById(R.id.title) }
|
||||
private val cleanCacheView: SettingBar? by lazy { findViewById(R.id.sb_setting_cache) }
|
||||
private val sbDeleteAccount: SettingBar? by lazy { findViewById(R.id.sb_delete_account) }
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.setting_activity
|
||||
@ -28,12 +22,6 @@ class SettingActivity : AppActivity() {
|
||||
|
||||
override fun initView() {
|
||||
|
||||
if (TranslatesUtils.translates() != null){
|
||||
title?.setTitle(TranslatesUtils.translates()?.mireo_settings)
|
||||
cleanCacheView?.setLeftText(TranslatesUtils.translates()?.mireo_clear_cache)
|
||||
sbDeleteAccount?.setLeftText(TranslatesUtils.translates()?.mireo_delete_account)
|
||||
}
|
||||
|
||||
cleanCacheView?.setOnClickListener {
|
||||
singleClick {
|
||||
// 清除内存缓存(必须在主线程)
|
||||
@ -49,27 +37,7 @@ class SettingActivity : AppActivity() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sbDeleteAccount?.setOnClickListener {
|
||||
if (!MsMMKVUtils.isTourist()) {
|
||||
singleClick {
|
||||
startActivity(
|
||||
Intent(
|
||||
this,
|
||||
AccountDeleteActivity::class.java
|
||||
)
|
||||
)
|
||||
}
|
||||
} else {
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
TranslatesUtils.translates()?.mireo_login_first?.let { it1 -> toast(it1) }
|
||||
} else {
|
||||
toast(getString(R.string.example_please_log_in_first))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
override fun initData() {
|
||||
// 获取应用缓存大小
|
@ -0,0 +1,31 @@
|
||||
package com.localee.mireo.app.ui.activity
|
||||
|
||||
import com.gyf.immersionbar.BarHide
|
||||
import com.gyf.immersionbar.ImmersionBar
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.app.AppActivity
|
||||
|
||||
|
||||
class SplashActivity : AppActivity() {
|
||||
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.splash_activity
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
postDelayed(Runnable {
|
||||
HomeActivity.start(this@SplashActivity)
|
||||
finish()
|
||||
}, 300)
|
||||
}
|
||||
|
||||
override fun initData() {
|
||||
}
|
||||
|
||||
override fun createStatusBarConfig(): ImmersionBar {
|
||||
return super.createStatusBarConfig()
|
||||
.hideBar(BarHide.FLAG_HIDE_BAR)
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,621 @@
|
||||
package com.localee.mireo.app.ui.activity
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.os.Bundle
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.view.WindowManager
|
||||
import android.widget.TextView
|
||||
import androidx.appcompat.widget.AppCompatImageView
|
||||
import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.blankj.utilcode.util.NetworkUtils
|
||||
import com.localee.mireo.app.utils.MsMMKVUtils
|
||||
import com.hjq.http.EasyHttp
|
||||
import com.hjq.http.config.IRequestApi
|
||||
import com.hjq.http.listener.HttpCallbackProxy
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.app.AppActivity
|
||||
import com.localee.mireo.app.app.BaseEventBus
|
||||
import com.localee.mireo.app.http.api.CreateHistoryApi
|
||||
import com.localee.mireo.app.http.api.VideoDetailsApi
|
||||
import com.localee.mireo.app.http.model.HttpData
|
||||
import com.localee.mireo.app.other.MsConstants
|
||||
import com.localee.mireo.app.other.MsConstants.CONSTANTS_activity_id
|
||||
import com.localee.mireo.app.other.MsConstants.CONSTANTS_quality
|
||||
import com.localee.mireo.app.other.MsConstants.CONSTANTS_quality_refresh
|
||||
import com.localee.mireo.app.other.MsConstants.CONSTANTS_short_play_id
|
||||
import com.localee.mireo.app.other.MsConstants.Constants_Episodes_Series_Data_currentPositionExample
|
||||
import com.localee.mireo.app.ui.videoPaly.ExamplePlayerDetailDataRes
|
||||
import com.localee.mireo.app.ui.videoPaly.ExampleSeriesDialogFragment
|
||||
import com.localee.mireo.app.ui.videoPaly.ExampleUnFavoriteDialog
|
||||
import com.localee.mireo.app.ui.videoPaly.VideoPlayAdapter
|
||||
import com.localee.mireo.app.ui.videoPaly.VideoPlayerView
|
||||
import com.localee.mireo.app.utils.DHStringUtils.getPublicRequest
|
||||
import com.localee.mireo.app.utils.TranslatesUtils
|
||||
import com.localee.mireo.app.utils.formatNumber
|
||||
import com.localee.mireo.app.utils.singleClick
|
||||
import com.scwang.smart.refresh.layout.SmartRefreshLayout
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
open class VideoPlayActivity : AppActivity(), VideoPlayAdapter.PlayerDetailCollection,
|
||||
ExampleSeriesDialogFragment.SeriesCallBack {
|
||||
|
||||
companion object {
|
||||
const val INTENT_KEY_PARAMETERS: String = "parameters"
|
||||
}
|
||||
|
||||
private var first: Boolean = true
|
||||
private var play: Boolean = true
|
||||
private var qualityRefresh: Boolean = false
|
||||
|
||||
// private val exampleRecommendViewModel by lazy { ViewModelProvider(this)[ExampleRecommendViewModel::class.java] }
|
||||
private var currentPage = 1
|
||||
private val currentSize = 10
|
||||
private var currentPosition = 0
|
||||
private var exampleRecommendAdapter: VideoPlayAdapter? = null
|
||||
private var data: com.localee.mireo.app.http.api.ExampleRecommendDataRes.Data? = null
|
||||
private var revolution =
|
||||
MsMMKVUtils.getMMKV().getInt(MsConstants.CONSTANTS_quality, 0).toString()
|
||||
|
||||
|
||||
private val srRecommend: SmartRefreshLayout? by lazy { findViewById(R.id.sr_recommend) }
|
||||
private val viewPagerExampleRecommend: ViewPager2? by lazy { findViewById(R.id.viewPager_example_recommend) }
|
||||
|
||||
private val exampleNetwork: ViewGroup? by lazy { findViewById(R.id.example_network) }
|
||||
private val exampleTvNoNetwork: TextView? by lazy { exampleNetwork?.findViewById(R.id.example_tv_no_network) }
|
||||
private val tvExampleRetry: TextView? by lazy { exampleNetwork?.findViewById(R.id.tv_example_retry) }
|
||||
|
||||
private val exampleEmpty: ViewGroup? by lazy { findViewById(R.id.example_empty) }
|
||||
private val exampleTvEmpty: TextView? by lazy { exampleEmpty?.findViewById(R.id.example_tv_empty) }
|
||||
|
||||
private var shortVideoId: Int? = null
|
||||
private var activityId: Int? = null
|
||||
private var shortVideo: VideoDetailsApi.Bean.ShortPlayInfo? = null
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.video_play_activity
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
shortVideoId = intent.getIntExtra(CONSTANTS_short_play_id, 0)
|
||||
activityId = intent.getIntExtra(CONSTANTS_activity_id, 0)
|
||||
EventBus.getDefault().register(this)
|
||||
this.window?.setFlags(
|
||||
WindowManager.LayoutParams.FLAG_SECURE,
|
||||
WindowManager.LayoutParams.FLAG_SECURE
|
||||
)
|
||||
this.window?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
|
||||
exampleTvNoNetwork?.text =
|
||||
TranslatesUtils.translates()?.no_network
|
||||
tvExampleRetry?.text = TranslatesUtils.translates()?.retry
|
||||
exampleTvEmpty?.text = TranslatesUtils.translates()?.s_no_content
|
||||
}
|
||||
|
||||
override fun initData() {
|
||||
initialization()
|
||||
MsConstants.ExampleIsCurrentPage = true
|
||||
if (!play) {
|
||||
qualityLogic()
|
||||
} else {
|
||||
play = false
|
||||
}
|
||||
}
|
||||
|
||||
fun initialization() {
|
||||
|
||||
if (NetworkUtils.isConnected()) {
|
||||
// avi?.start()
|
||||
getVideoDetails()
|
||||
|
||||
} else {
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
ToastUtils.show(TranslatesUtils.translates()?.no_network.toString())
|
||||
} else {
|
||||
ToastUtils.show(getString(R.string.example_no_network))
|
||||
}
|
||||
exampleNetwork?.visibility = View.VISIBLE
|
||||
}
|
||||
srRecommend?.setOnRefreshListener {
|
||||
if (NetworkUtils.isConnected()) {
|
||||
// avi?.start()
|
||||
currentPage = 1
|
||||
viewPagerExampleRecommend?.post {
|
||||
detailPlayerView()?.stop()
|
||||
detailPlayerView()?.release()
|
||||
}
|
||||
getVideoDetails()
|
||||
} else {
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
ToastUtils.show(TranslatesUtils.translates()?.no_network.toString())
|
||||
} else {
|
||||
ToastUtils.show(getString(R.string.example_no_network))
|
||||
}
|
||||
}
|
||||
}
|
||||
viewPagerExampleRecommend?.registerOnPageChangeCallback(object :
|
||||
ViewPager2.OnPageChangeCallback() {
|
||||
@SuppressLint("NotifyDataSetChanged")
|
||||
override fun onPageSelected(position: Int) {
|
||||
super.onPageSelected(position)
|
||||
currentPosition = position
|
||||
val previousPosition = exampleRecommendAdapter?.currentPlayingPosition
|
||||
if (previousPosition != position) {
|
||||
exampleRecommendAdapter?.recyclerView?.post { exampleRecommendAdapter?.notifyDataSetChanged() }
|
||||
}
|
||||
exampleRecommendAdapter?.currentPlayingPosition = position
|
||||
|
||||
previousPosition?.let {
|
||||
val recyclerView =
|
||||
viewPagerExampleRecommend?.getChildAt(0) as RecyclerView
|
||||
val exampleDetailPlayerView =
|
||||
recyclerView.layoutManager?.findViewByPosition(it) as VideoPlayerView?
|
||||
if (null != exampleDetailPlayerView) {
|
||||
val episode1 =
|
||||
exampleRecommendAdapter?.items?.get(it)
|
||||
episode1?.short_play_id?.let { it1 ->
|
||||
episode1?.short_play_video_id?.let { it2 ->
|
||||
createHistory(
|
||||
it1,
|
||||
it2
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
super.onPageScrollStateChanged(state)
|
||||
when (state) {
|
||||
ViewPager2.SCROLL_STATE_IDLE -> {
|
||||
if (viewPagerExampleRecommend?.currentItem == viewPagerExampleRecommend?.adapter?.itemCount?.minus(
|
||||
1
|
||||
)
|
||||
) {
|
||||
if (!first) {
|
||||
getVideoDetails()
|
||||
} else {
|
||||
first = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ViewPager2.SCROLL_STATE_DRAGGING -> {
|
||||
|
||||
}
|
||||
|
||||
ViewPager2.SCROLL_STATE_SETTLING -> {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
exampleTvEmpty?.setOnClickListener {
|
||||
singleClick {
|
||||
if (!NetworkUtils.isConnected()) {
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
ToastUtils.show(TranslatesUtils.translates()?.no_network.toString())
|
||||
} else {
|
||||
ToastUtils.show(getString(R.string.example_no_network))
|
||||
}
|
||||
return@singleClick
|
||||
}
|
||||
// avi?.start()
|
||||
currentPage = 1
|
||||
getVideoDetails()
|
||||
}
|
||||
}
|
||||
tvExampleRetry?.setOnClickListener {
|
||||
singleClick {
|
||||
if (!NetworkUtils.isConnected()) {
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
ToastUtils.show(TranslatesUtils.translates()?.no_network.toString())
|
||||
} else {
|
||||
ToastUtils.show(getString(R.string.example_no_network))
|
||||
}
|
||||
return@singleClick
|
||||
}
|
||||
// avi?.start()
|
||||
currentPage = 1
|
||||
getVideoDetails()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// override fun onHiddenChanged(hidden: Boolean) {
|
||||
// super.onHiddenChanged(hidden)
|
||||
// if (!hidden) {
|
||||
// activity?.window?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
// MsConstants.ExampleIsCurrentPage = true
|
||||
// qualityLogic()
|
||||
// } else {
|
||||
// activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
// MsConstants.ExampleIsCurrentPage = false
|
||||
// srRecommend?.postDelayed({ detailPlayerView()?.pause() }, 300)
|
||||
// }
|
||||
// }
|
||||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (!play) {
|
||||
detailPlayerView()?.play()
|
||||
} else {
|
||||
play = false
|
||||
}
|
||||
}
|
||||
|
||||
private fun qualityLogic() {
|
||||
if (qualityRefresh) {
|
||||
viewPagerExampleRecommend?.post {
|
||||
detailPlayerView()?.stop()
|
||||
detailPlayerView()?.release()
|
||||
}
|
||||
getVideoDetails()
|
||||
qualityRefresh = false
|
||||
} else {
|
||||
detailPlayerView()?.play()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
MsConstants.ExampleIsCurrentPage = false
|
||||
srRecommend?.postDelayed({ detailPlayerView()?.pause() }, 300)
|
||||
}
|
||||
|
||||
fun getVideoDetails() {
|
||||
EasyHttp.get(this)
|
||||
.api(VideoDetailsApi().apply {
|
||||
if (activityId!! != 0) {
|
||||
video_id = activityId;
|
||||
}
|
||||
short_play_id = shortVideoId;
|
||||
|
||||
})
|
||||
.request(object : HttpCallbackProxy<HttpData<VideoDetailsApi.Bean>>(this) {
|
||||
override fun onHttpSuccess(result: HttpData<VideoDetailsApi.Bean>) {
|
||||
result.getData()?.let {
|
||||
if (it.episodeList.isNotEmpty()) {
|
||||
shortVideo = it.shortPlayInfo
|
||||
exampleRecommendAdapter = VideoPlayAdapter()
|
||||
exampleRecommendAdapter?.shortVideo = it.shortPlayInfo
|
||||
viewPagerExampleRecommend?.adapter = exampleRecommendAdapter
|
||||
exampleRecommendAdapter?.submitList(it.episodeList)
|
||||
exampleRecommendAdapter?.playerDetailCollection =
|
||||
this@VideoPlayActivity
|
||||
createHistory(
|
||||
it.episodeList[0].short_play_id,
|
||||
it.episodeList[0].short_play_video_id
|
||||
);
|
||||
exampleNetwork?.visibility = View.INVISIBLE
|
||||
exampleEmpty?.visibility = View.INVISIBLE
|
||||
} else {
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
ToastUtils.show(TranslatesUtils.translates()?.no_more_data.toString())
|
||||
} else {
|
||||
ToastUtils.show(getString(R.string.example_there_s_no_more_data))
|
||||
}
|
||||
if (currentPage == 1) {
|
||||
exampleEmpty?.visibility = View.VISIBLE
|
||||
}
|
||||
}
|
||||
// avi?.stop()
|
||||
srRecommend?.finishRefresh()
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
// ExampleRecommendRequest.getVideoDetails(current_page, page_size, revolution)
|
||||
// .observeForever { result ->
|
||||
// recommendLiveData.value = result.getOrNull()
|
||||
// }
|
||||
}
|
||||
|
||||
fun createHistory(videoId: Int, shortPlayId: Int) {
|
||||
val sMap: MutableMap<String, String?> = LinkedHashMap()
|
||||
// StringMap = getSortMap(StringMap);
|
||||
sMap.put("short_play_id", videoId.toString())
|
||||
sMap.put("video_id", shortPlayId.toString())
|
||||
EasyHttp.post(this)
|
||||
.api(CreateHistoryApi())
|
||||
.body(getPublicRequest(sMap))
|
||||
.request(object : HttpCallbackProxy<HttpData<Any>>(this) {
|
||||
|
||||
override fun onHttpStart(api: IRequestApi) {
|
||||
}
|
||||
|
||||
override fun onHttpSuccess(result: HttpData<Any>) {
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun doCollect(shortPlayId: Int, videoId: Int) {
|
||||
val sMap: MutableMap<String, String?> = LinkedHashMap()
|
||||
// StringMap = getSortMap(StringMap);
|
||||
sMap.put("short_play_id", shortPlayId.toString())
|
||||
sMap.put("video_id", videoId.toString())
|
||||
|
||||
EasyHttp.post(this)
|
||||
.api(com.localee.mireo.app.http.api.DoCollectApi())
|
||||
.body(getPublicRequest(sMap))
|
||||
.request(object : HttpCallbackProxy<HttpData<Any>>(this) {
|
||||
override fun onHttpSuccess(result: HttpData<Any>) {
|
||||
result.getData()?.let {
|
||||
if (it != null) {
|
||||
val imageView =
|
||||
detailPlayerView()?.findViewById<AppCompatImageView>(R.id.example_iv_collection_controller)
|
||||
val textview =
|
||||
detailPlayerView()?.findViewById<AppCompatTextView>(R.id.example_tv_collection_num_controller)
|
||||
imageView?.setImageResource(R.mipmap.iv_example_collection_h)
|
||||
shortVideo?.collect_total = shortVideo?.collect_total?.plus(1)!!
|
||||
shortVideo?.is_collect = true
|
||||
textview?.text = formatNumber(shortVideo?.collect_total!!)
|
||||
textview?.setTextColor(resources.getColor(R.color.example_color_F56490))
|
||||
exampleRecommendAdapter?.shortVideo = shortVideo
|
||||
EventBus.getDefault().post(
|
||||
BaseEventBus(
|
||||
MsConstants.Constants_Episodes_Series_DataExample,
|
||||
shortVideo
|
||||
)
|
||||
)
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
toast(TranslatesUtils.translates()?.success.toString())
|
||||
}
|
||||
} else {
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
toast(TranslatesUtils.translates()?.network_error.toString())
|
||||
} else {
|
||||
toast(getString(R.string.example_service_exception_please_try_again))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun doCancelCollect(shortPlayId: Int, videoId: Int) {
|
||||
val sMap: MutableMap<String, String?> = LinkedHashMap()
|
||||
// StringMap = getSortMap(StringMap);
|
||||
sMap.put("short_play_id", shortPlayId.toString())
|
||||
sMap.put("video_id", videoId.toString())
|
||||
|
||||
EasyHttp.post(this)
|
||||
.api(com.localee.mireo.app.http.api.CancelCollectApi())
|
||||
.body(getPublicRequest(sMap))
|
||||
.request(object : HttpCallbackProxy<HttpData<Any>>(this) {
|
||||
override fun onHttpSuccess(result: HttpData<Any>) {
|
||||
result.getData()?.let {
|
||||
if (it != null) {
|
||||
val imageView =
|
||||
detailPlayerView()?.findViewById<AppCompatImageView>(R.id.example_iv_collection_controller)
|
||||
val textview =
|
||||
detailPlayerView()?.findViewById<AppCompatTextView>(R.id.example_tv_collection_num_controller)
|
||||
imageView?.setImageResource(R.mipmap.iv_example_collection_n)
|
||||
shortVideo?.collect_total = shortVideo?.collect_total?.minus(1)!!
|
||||
shortVideo?.is_collect = false
|
||||
textview?.text = formatNumber(shortVideo?.collect_total!!)
|
||||
textview?.setTextColor(resources.getColor(R.color.white))
|
||||
exampleRecommendAdapter?.shortVideo = shortVideo
|
||||
EventBus.getDefault().post(
|
||||
BaseEventBus(
|
||||
MsConstants.Constants_Episodes_Series_DataExample,
|
||||
shortVideo
|
||||
)
|
||||
)
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
toast(TranslatesUtils.translates()?.success.toString())
|
||||
}
|
||||
} else {
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
toast(TranslatesUtils.translates()?.network_error.toString())
|
||||
} else {
|
||||
toast(getString(R.string.example_service_exception_please_try_again))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
private fun detailPlayerView(): VideoPlayerView? {
|
||||
try {
|
||||
val recyclerView = viewPagerExampleRecommend?.getChildAt(0) as RecyclerView
|
||||
return recyclerView.layoutManager?.findViewByPosition(currentPosition) as VideoPlayerView?
|
||||
} catch (e: Exception) {
|
||||
e.printStackTrace()
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
viewPagerExampleRecommend?.post {
|
||||
detailPlayerView()?.stop()
|
||||
detailPlayerView()?.release()
|
||||
}
|
||||
super.onDestroy()
|
||||
EventBus.getDefault().unregister(this)
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEvent(event: String) {
|
||||
if (MsConstants.Constants_RecommendPlayerView_DramaSeriesExample == event) {
|
||||
if (exampleRecommendAdapter?.items?.isNotEmpty() == true) {
|
||||
val exampleSeriesDialogFragment = ExampleSeriesDialogFragment()
|
||||
val bundle = Bundle()
|
||||
bundle.putInt(
|
||||
Constants_Episodes_Series_Data_currentPositionExample,
|
||||
currentPosition
|
||||
)
|
||||
bundle.putParcelable(
|
||||
MsConstants.Constants_Episodes_Series_DataExample,
|
||||
shortVideo
|
||||
)
|
||||
bundle.putParcelableArrayList(
|
||||
MsConstants.Constants_Episodes_Series_Data_ListExample,
|
||||
exampleRecommendAdapter?.items?.let { ArrayList(it) }
|
||||
)
|
||||
exampleSeriesDialogFragment.seriesCallBack = this
|
||||
exampleSeriesDialogFragment.arguments = bundle
|
||||
exampleSeriesDialogFragment.show(
|
||||
supportFragmentManager,
|
||||
"ExampleSeriesDialogFragment"
|
||||
)
|
||||
}
|
||||
}
|
||||
if (MsConstants.Constants_DetailPlayerView_PLAYER_STATUS_FINISHExample == event) {
|
||||
currentPosition.plus(1)
|
||||
.let {
|
||||
exampleRecommendAdapter?.items?.get(it)?.let { it1 ->
|
||||
if (it1.coins > 0) {
|
||||
if (MsMMKVUtils.getMMKV().getString(
|
||||
CONSTANTS_short_play_id,
|
||||
""
|
||||
) == shortVideoId.toString()
|
||||
) {
|
||||
}
|
||||
}
|
||||
}
|
||||
detailPlayerView()?.stop()
|
||||
viewPagerExampleRecommend?.currentItem = it
|
||||
}
|
||||
}
|
||||
|
||||
if (CONSTANTS_quality_refresh == event) {
|
||||
revolution =
|
||||
MsMMKVUtils.getMMKV().getInt(MsConstants.CONSTANTS_quality, 0)
|
||||
.toString()
|
||||
qualityRefresh = true
|
||||
}
|
||||
|
||||
if (MsConstants.Constants_RecommendPlayerView_CLOSEExample == event) {
|
||||
finish()
|
||||
}
|
||||
if (CONSTANTS_quality == event) {
|
||||
startActivity(SearchActivity::class.java)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEvent(event: BaseEventBus<ExamplePlayerDetailDataRes.ShortPlayInfo>) {
|
||||
// if (MsConstants.Constants_Episodes_Series_DataExample == event.code) {
|
||||
// if (exampleRecommendAdapter?.items?.get(currentPosition)?.name == event.data.name) {
|
||||
// val imageView =
|
||||
// detailPlayerView()?.findViewById<AppCompatImageView>(R.id.example_iv_collection_controller)
|
||||
// val textview =
|
||||
// detailPlayerView()?.findViewById<AppCompatTextView>(R.id.example_tv_collection_num_controller)
|
||||
// imageView?.setImageResource(if (event.data.is_collect) R.mipmap.iv_example_collection_h else R.mipmap.iv_example_collection_n)
|
||||
// exampleRecommendAdapter?.items?.get(currentPosition)?.collect_total =
|
||||
// event.data.collect_total
|
||||
// exampleRecommendAdapter?.items?.get(currentPosition)?.is_collect =
|
||||
// event.data.is_collect
|
||||
// textview?.text = formatNumber(event.data.collect_total)
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
// override fun collection(dataRes: ExampleRecommendDataRes.Data) {
|
||||
// singleClick {
|
||||
// data = dataRes
|
||||
// if (dataRes.is_collect) {
|
||||
// val exampleUnFavoriteDialog = ExampleUnFavoriteDialog(this)
|
||||
// val tvThinkAgain =
|
||||
// exampleUnFavoriteDialog.findViewById<AppCompatTextView>(R.id.example_tv_think_again)
|
||||
// val tvUnfavorite =
|
||||
// exampleUnFavoriteDialog.findViewById<AppCompatTextView>(R.id.example_tv_unfavorite)
|
||||
// val tvTitle =
|
||||
// exampleUnFavoriteDialog.findViewById<AppCompatTextView>(R.id.example_tv_title)
|
||||
// val tvContent =
|
||||
// exampleUnFavoriteDialog.findViewById<AppCompatTextView>(R.id.example_tv_content)
|
||||
// if (TranslatesUtils.translates() != null) {
|
||||
// tvThinkAgain.text = TranslatesUtils.translates()?.try_again
|
||||
// tvUnfavorite.text = TranslatesUtils.translates()?.collection
|
||||
// tvTitle.text = TranslatesUtils.translates()?.collection
|
||||
// tvContent.text = TranslatesUtils.translates()?.not_collect_warning
|
||||
// }
|
||||
// tvThinkAgain.setOnClickListener { exampleUnFavoriteDialog.dismiss() }
|
||||
// tvUnfavorite.setOnClickListener {
|
||||
// dataRes.video_info?.short_play_id?.let {
|
||||
// dataRes.video_info.short_play_video_id.let { it1 ->
|
||||
// doCancelCollect(
|
||||
// it, it1
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// exampleUnFavoriteDialog.dismiss()
|
||||
// }
|
||||
// exampleUnFavoriteDialog.show()
|
||||
// } else {
|
||||
// dataRes.video_info?.short_play_id?.let {
|
||||
// dataRes.video_info.short_play_video_id.let { it1 ->
|
||||
// doCollect(
|
||||
// it, it1
|
||||
// )
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
override fun collection(episode: VideoDetailsApi.Bean.Episode) {
|
||||
singleClick {
|
||||
if (shortVideo?.is_collect == true) {
|
||||
val exampleUnFavoriteDialog = ExampleUnFavoriteDialog(this)
|
||||
val tvThinkAgain =
|
||||
exampleUnFavoriteDialog.findViewById<AppCompatTextView>(R.id.example_tv_think_again)
|
||||
val tvUnfavorite =
|
||||
exampleUnFavoriteDialog.findViewById<AppCompatTextView>(R.id.example_tv_unfavorite)
|
||||
val tvTitle =
|
||||
exampleUnFavoriteDialog.findViewById<AppCompatTextView>(R.id.example_tv_title)
|
||||
val tvContent =
|
||||
exampleUnFavoriteDialog.findViewById<AppCompatTextView>(R.id.example_tv_content)
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
tvThinkAgain.text = TranslatesUtils.translates()?.try_again
|
||||
tvUnfavorite.text = TranslatesUtils.translates()?.collection
|
||||
tvTitle.text = TranslatesUtils.translates()?.collection
|
||||
tvContent.text = TranslatesUtils.translates()?.not_collect_warning
|
||||
}
|
||||
tvThinkAgain.setOnClickListener { exampleUnFavoriteDialog.dismiss() }
|
||||
tvUnfavorite.setOnClickListener {
|
||||
episode.short_play_id.let {
|
||||
episode.short_play_video_id.let { it1 ->
|
||||
doCancelCollect(
|
||||
it, it1
|
||||
)
|
||||
}
|
||||
}
|
||||
exampleUnFavoriteDialog.dismiss()
|
||||
}
|
||||
exampleUnFavoriteDialog.show()
|
||||
} else {
|
||||
episode.short_play_id.let {
|
||||
episode.short_play_video_id.let { it1 ->
|
||||
doCollect(
|
||||
it, it1
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun chooseSeries(episode: VideoDetailsApi.Bean.Episode) {
|
||||
postDelayed({ detailPlayerView()?.pause() }, 300)
|
||||
episode.episode.minus(1)
|
||||
.let {
|
||||
viewPagerExampleRecommend?.currentItem = it
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -7,10 +7,9 @@ import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.app.AppApplication
|
||||
import com.localee.mireo.app.http.bean.RecommendBean
|
||||
import com.localee.mireo.app.utils.TranslatesUtils
|
||||
import com.localee.mireo.app.http.api.RecommendBean
|
||||
import com.youth.banner.adapter.BannerAdapter
|
||||
|
||||
class HomeBannerAdapter(mDatas: List<RecommendBean>) :
|
||||
@ -31,8 +30,6 @@ class HomeBannerAdapter(mDatas: List<RecommendBean>) :
|
||||
) {
|
||||
Glide.with(AppApplication.instance)
|
||||
.load(data.image_url)
|
||||
.placeholder(R.mipmap.ic_loading_h)
|
||||
.error(R.mipmap.ic_loading_h)
|
||||
.into(holder.imageView)
|
||||
|
||||
holder.tvName.setText(data.name)
|
||||
@ -44,10 +41,7 @@ class HomeBannerAdapter(mDatas: List<RecommendBean>) :
|
||||
holder.tvPlay.setOnClickListener {
|
||||
data.let { it1 -> homeBannerOnClick?.bannerPlay(it1) }
|
||||
}
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
holder.tvPlay.text = TranslatesUtils.translates()?.mireo_play
|
||||
holder.tvAdd.text = TranslatesUtils.translates()?.mireo_my_list
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
inner class BannerViewHolder(view: View) : RecyclerView.ViewHolder(view) {
|
@ -6,10 +6,9 @@ import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.chad.library.adapter4.BaseQuickAdapter
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.app.app.AppApplication
|
||||
import com.localee.mireo.shortapp.databinding.ItemListTabBinding
|
||||
import com.localee.mireo.app.http.bean.RecommendBean
|
||||
import com.localee.mireo.app.databinding.ItemListTabBinding
|
||||
import com.localee.mireo.app.http.api.RecommendBean
|
||||
|
||||
class HomeCategoriesTabAdapter : BaseQuickAdapter<RecommendBean, HomeCategoriesTabAdapter.VH>() {
|
||||
|
||||
@ -29,8 +28,6 @@ class HomeCategoriesTabAdapter : BaseQuickAdapter<RecommendBean, HomeCategoriesT
|
||||
holder.binding.tvName.text = item.name
|
||||
Glide.with(AppApplication.instance)
|
||||
.load(item.image_url)
|
||||
.placeholder(R.mipmap.ic_loading_v)
|
||||
.error(R.mipmap.ic_loading_v)
|
||||
.into(holder.binding.ivContent)
|
||||
|
||||
}
|
@ -8,10 +8,9 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.chad.library.adapter4.BaseQuickAdapter
|
||||
import com.localee.mireo.app.app.AppApplication
|
||||
import com.localee.mireo.app.http.bean.RecommendBean
|
||||
import com.localee.mireo.app.databinding.ItemHomeCriticallyBinding
|
||||
import com.localee.mireo.app.http.api.RecommendBean
|
||||
import com.localee.mireo.app.utils.formatNumber
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.shortapp.databinding.ItemHomeCriticallyBinding
|
||||
|
||||
class HomeCriticallyAdapter :
|
||||
BaseQuickAdapter<RecommendBean, HomeCriticallyAdapter.VH>() {
|
||||
@ -37,25 +36,16 @@ class HomeCriticallyAdapter :
|
||||
holder.binding.tvDescription.text = item.description
|
||||
holder.binding.tvScore.text = item.all_coins
|
||||
holder.binding.tvGood.text = item.watch_total?.let { formatNumber(it) }
|
||||
if (item.category?.isNotEmpty() == true && item.category[0].isNotEmpty()) {
|
||||
if (item.category.isEmpty()) {
|
||||
holder.binding.tvFavor.visibility = View.GONE
|
||||
} else {
|
||||
holder.binding.tvFavor.visibility = View.VISIBLE
|
||||
holder.binding.tvFavor.text = item.category[0]
|
||||
} else {
|
||||
holder.binding.tvFavor.visibility = View.GONE
|
||||
}
|
||||
Glide.with(AppApplication.instance)
|
||||
.load(item.image_url)
|
||||
.placeholder(R.mipmap.ic_loading_v)
|
||||
.error(R.mipmap.ic_loading_v)
|
||||
.into(holder.binding.ivContent)
|
||||
|
||||
if (position < 6) {
|
||||
holder.binding.tvScore.visibility = View.VISIBLE
|
||||
holder.binding.tvScore.text = (position + 1).toString()
|
||||
} else {
|
||||
holder.binding.tvScore.visibility = View.GONE
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -6,7 +6,7 @@ import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chad.library.adapter4.BaseQuickAdapter
|
||||
import com.hjq.shape.view.ShapeTextView
|
||||
import com.localee.mireo.shortapp.databinding.ItemHomeGenresBinding
|
||||
import com.localee.mireo.app.databinding.ItemHomeGenresBinding
|
||||
|
||||
class HomeGenresAdapter(var id: Int) : BaseQuickAdapter<String, HomeGenresAdapter.VH>() {
|
||||
|
@ -6,10 +6,9 @@ import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.chad.library.adapter4.BaseQuickAdapter
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.app.app.AppApplication
|
||||
import com.localee.mireo.shortapp.databinding.ItemHomeShortBinding
|
||||
import com.localee.mireo.app.http.bean.RecommendBean
|
||||
import com.localee.mireo.app.databinding.ItemHomeShortBinding
|
||||
import com.localee.mireo.app.http.api.RecommendBean
|
||||
|
||||
class HomeShortAdapter : BaseQuickAdapter<RecommendBean, HomeShortAdapter.VH>() {
|
||||
|
||||
@ -30,8 +29,6 @@ class HomeShortAdapter : BaseQuickAdapter<RecommendBean, HomeShortAdapter.VH>()
|
||||
holder.binding.tvDescription.text = item.description
|
||||
Glide.with(AppApplication.instance)
|
||||
.load(item.image_url)
|
||||
.placeholder(R.mipmap.ic_loading_v)
|
||||
.error(R.mipmap.ic_loading_v)
|
||||
.into(holder.binding.ivContent)
|
||||
|
||||
}
|
@ -6,9 +6,9 @@ import com.bumptech.glide.Glide
|
||||
import com.chad.library.adapter4.BaseQuickAdapter
|
||||
import com.chad.library.adapter4.viewholder.QuickViewHolder
|
||||
import com.hjq.shape.view.ShapeTextView
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.app.AppApplication
|
||||
import com.localee.mireo.app.http.bean.RecommendBean
|
||||
import com.localee.mireo.app.http.api.RecommendBean
|
||||
|
||||
class HomeTopAdapter(var type: Int) :
|
||||
BaseQuickAdapter<RecommendBean, QuickViewHolder>() {
|
||||
@ -28,8 +28,6 @@ class HomeTopAdapter(var type: Int) :
|
||||
) {
|
||||
Glide.with(AppApplication.instance)
|
||||
.load(item?.image_url)
|
||||
.placeholder(R.mipmap.ic_loading_v)
|
||||
.error(R.mipmap.ic_loading_v)
|
||||
.into(holder.getView(R.id.iv_content))
|
||||
|
||||
val text: ShapeTextView = holder.getView(R.id.tv_hot)
|
@ -8,10 +8,8 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.chad.library.adapter4.BaseQuickAdapter
|
||||
import com.localee.mireo.app.app.AppApplication
|
||||
import com.localee.mireo.app.http.bean.HistoryBean
|
||||
import com.localee.mireo.app.utils.TranslatesUtils
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.shortapp.databinding.ItemListTabBinding
|
||||
import com.localee.mireo.app.databinding.ItemListTabBinding
|
||||
import com.localee.mireo.app.http.api.HistoryBean
|
||||
|
||||
class LostTabAdapter(var tabPosition: Int) :
|
||||
BaseQuickAdapter<HistoryBean.Data, LostTabAdapter.VH>() {
|
||||
@ -35,14 +33,10 @@ class LostTabAdapter(var tabPosition: Int) :
|
||||
holder.binding.tvName.text = item.name
|
||||
Glide.with(AppApplication.instance)
|
||||
.load(item.image_url)
|
||||
.placeholder(R.mipmap.ic_loading_v)
|
||||
.error(R.mipmap.ic_loading_v)
|
||||
.into(holder.binding.ivContent)
|
||||
holder.binding.tvName2.text = item.name
|
||||
Glide.with(AppApplication.instance)
|
||||
.load(item.image_url)
|
||||
.placeholder(R.mipmap.ic_loading_v)
|
||||
.error(R.mipmap.ic_loading_v)
|
||||
.into(holder.binding.ivContent2)
|
||||
|
||||
if (type == 0) {
|
||||
@ -70,17 +64,13 @@ class LostTabAdapter(var tabPosition: Int) :
|
||||
|
||||
}
|
||||
|
||||
if (TranslatesUtils.translates() != null){
|
||||
holder.binding.tvPlay.text = TranslatesUtils.translates()?.mireo_play_now
|
||||
}
|
||||
|
||||
when (tabPosition) {
|
||||
0 -> {
|
||||
if (item.category != null && !item.category.isEmpty()) {
|
||||
holder.binding.tvFavor.text = item.category.get(0)
|
||||
if (item.categoryList?.isNotEmpty() == true) {
|
||||
holder.binding.tvFavor.text = item.categoryList.get(0).name
|
||||
holder.binding.tvFavor.visibility = View.VISIBLE
|
||||
if (item.category.size > 1) {
|
||||
holder.binding.tvLove.text = item.category.get(1)
|
||||
if (item.categoryList.size > 1) {
|
||||
holder.binding.tvLove.text = item.categoryList.get(1).name
|
||||
holder.binding.tvLove.visibility = View.VISIBLE
|
||||
} else {
|
||||
holder.binding.tvLove.visibility = View.GONE
|
||||
@ -92,7 +82,7 @@ class LostTabAdapter(var tabPosition: Int) :
|
||||
|
||||
1 -> {
|
||||
holder.binding.tvFavor.text =
|
||||
"EP." + item.current_episode + " / EP." + item.episode_total
|
||||
"EP" + item.current_episode + " / EP" + item.episode_total
|
||||
holder.binding.tvFavor.visibility = View.VISIBLE
|
||||
holder.binding.tvLove.visibility = View.GONE
|
||||
}
|
@ -6,10 +6,9 @@ import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.chad.library.adapter4.BaseQuickAdapter
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.app.app.AppApplication
|
||||
import com.localee.mireo.shortapp.databinding.ItemMeHistoryBinding
|
||||
import com.localee.mireo.app.http.bean.HistoryBean
|
||||
import com.localee.mireo.app.databinding.ItemMeHistoryBinding
|
||||
import com.localee.mireo.app.http.api.HistoryBean
|
||||
|
||||
class MeHistoryAdapter() :
|
||||
BaseQuickAdapter<HistoryBean.Data, MeHistoryAdapter.VH>() {
|
||||
@ -32,8 +31,6 @@ class MeHistoryAdapter() :
|
||||
if (null != item) {
|
||||
Glide.with(AppApplication.instance)
|
||||
.load(item.image_url)
|
||||
.placeholder(R.mipmap.ic_loading_v)
|
||||
.error(R.mipmap.ic_loading_v)
|
||||
.into(holder.binding.ivContent)
|
||||
}
|
||||
|
@ -6,8 +6,8 @@ import android.view.*
|
||||
import android.widget.*
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.localee.mireo.app.base.BaseAdapter
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.hjq.base.BaseAdapter
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.app.AppAdapter
|
||||
|
||||
class NavigationAdapter constructor(context: Context) :
|
@ -8,9 +8,8 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.bumptech.glide.Glide
|
||||
import com.chad.library.adapter4.BaseQuickAdapter
|
||||
import com.localee.mireo.app.app.AppApplication
|
||||
import com.localee.mireo.app.databinding.ItemSearchHotBinding
|
||||
import com.localee.mireo.app.http.api.SearchHotApi
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.shortapp.databinding.ItemSearchHotBinding
|
||||
|
||||
class SearchHotAdapter : BaseQuickAdapter<SearchHotApi.Bean.Data, SearchHotAdapter.VH>() {
|
||||
|
||||
@ -32,8 +31,6 @@ class SearchHotAdapter : BaseQuickAdapter<SearchHotApi.Bean.Data, SearchHotAdapt
|
||||
// 设置item数据
|
||||
Glide.with(AppApplication.instance)
|
||||
.load(item.image_url)
|
||||
.placeholder(R.mipmap.ic_loading_v)
|
||||
.error(R.mipmap.ic_loading_v)
|
||||
.into(holder.binding.ivContent)
|
||||
|
||||
if (item.categoryList?.isNotEmpty() == true) {
|
@ -5,13 +5,14 @@ import android.view.LayoutInflater
|
||||
import android.view.ViewGroup
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.chad.library.adapter4.BaseQuickAdapter
|
||||
import com.localee.mireo.shortapp.databinding.ItemSearchHistoryBinding
|
||||
import com.localee.mireo.app.databinding.ItemSearchSearchBinding
|
||||
import com.localee.mireo.app.http.api.SearchSearchApi
|
||||
|
||||
class SearchHistoryAdapter : BaseQuickAdapter<String, SearchHistoryAdapter.VH>() {
|
||||
class SearchSearchAdapter : BaseQuickAdapter<SearchSearchApi.Bean.Data, SearchSearchAdapter.VH>() {
|
||||
|
||||
class VH(
|
||||
parent: ViewGroup,
|
||||
val binding: ItemSearchHistoryBinding = ItemSearchHistoryBinding.inflate(
|
||||
val binding: ItemSearchSearchBinding = ItemSearchSearchBinding.inflate(
|
||||
LayoutInflater.from(parent.context), parent, false
|
||||
),
|
||||
) : RecyclerView.ViewHolder(binding.root)
|
||||
@ -20,18 +21,11 @@ class SearchHistoryAdapter : BaseQuickAdapter<String, SearchHistoryAdapter.VH>()
|
||||
return VH(parent)
|
||||
}
|
||||
|
||||
override fun onBindViewHolder(holder: VH, position: Int, item: String?) {
|
||||
override fun onBindViewHolder(holder: VH, position: Int, item: SearchSearchApi.Bean.Data?) {
|
||||
if (null != item) {
|
||||
holder.binding.tvHistory.text = item
|
||||
}
|
||||
holder.binding.tvKey.text = item.name
|
||||
|
||||
}
|
||||
|
||||
override fun getItemCount(items: List<String>): Int {
|
||||
if (items.size > 10){
|
||||
return 10
|
||||
}
|
||||
return super.getItemCount(items)
|
||||
}
|
||||
|
||||
}
|
@ -11,9 +11,9 @@ import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.recyclerview.widget.RecyclerView.AdapterDataObserver
|
||||
import com.localee.mireo.app.base.BaseAdapter
|
||||
import com.hjq.base.BaseAdapter
|
||||
import com.hjq.shape.view.ShapeTextView
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.app.AppAdapter
|
||||
|
||||
class TabAdapter @JvmOverloads constructor(
|
@ -5,9 +5,9 @@ import android.view.*
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.LayoutRes
|
||||
import androidx.annotation.StringRes
|
||||
import com.localee.mireo.app.base.BaseDialog
|
||||
import com.localee.mireo.app.base.action.AnimAction
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.hjq.base.BaseDialog
|
||||
import com.hjq.base.action.AnimAction
|
||||
import com.localee.mireo.app.R
|
||||
|
||||
class CommonDialog {
|
||||
|
@ -7,10 +7,10 @@ import android.view.inputmethod.EditorInfo
|
||||
import android.widget.TextView
|
||||
import android.widget.TextView.OnEditorActionListener
|
||||
import androidx.annotation.StringRes
|
||||
import com.localee.mireo.app.base.BaseDialog
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.app.widget.view.RegexEditText
|
||||
import com.localee.mireo.app.utils.singleClick
|
||||
import com.hjq.base.BaseDialog
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.aop.SingleClick
|
||||
import com.hjq.widget.view.RegexEditText
|
||||
|
||||
class InputDialog {
|
||||
|
||||
@ -65,8 +65,8 @@ class InputDialog {
|
||||
postDelayed({ showKeyboard(inputView) }, 500)
|
||||
}
|
||||
|
||||
@SingleClick
|
||||
override fun onClick(view: View) {
|
||||
singleClick {
|
||||
when (view.id) {
|
||||
R.id.tv_ui_confirm -> {
|
||||
autoDismiss()
|
||||
@ -77,8 +77,6 @@ class InputDialog {
|
||||
listener?.onCancel(getDialog())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
@ -4,9 +4,9 @@ import android.content.Context
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.StringRes
|
||||
import com.localee.mireo.app.base.BaseDialog
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.app.utils.singleClick
|
||||
import com.hjq.base.BaseDialog
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.aop.SingleClick
|
||||
|
||||
class MessageDialog {
|
||||
|
||||
@ -39,8 +39,8 @@ class MessageDialog {
|
||||
return super.create()
|
||||
}
|
||||
|
||||
@SingleClick
|
||||
override fun onClick(view: View) {
|
||||
singleClick {
|
||||
when (view.id) {
|
||||
R.id.tv_ui_confirm -> {
|
||||
autoDismiss()
|
||||
@ -51,8 +51,6 @@ class MessageDialog {
|
||||
listener?.onCancel(getDialog())
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,17 +6,16 @@ import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.annotation.StringRes
|
||||
import com.localee.mireo.app.base.BaseDialog
|
||||
import com.localee.mireo.app.base.action.AnimAction
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.hjq.base.BaseDialog
|
||||
import com.hjq.base.action.AnimAction
|
||||
import com.localee.mireo.app.R
|
||||
|
||||
class TipsDialog {
|
||||
|
||||
companion object {
|
||||
// const val ICON_FINISH: Int = R.drawable.tips_finish_ic
|
||||
// const val ICON_ERROR: Int = R.drawable.tips_error_ic
|
||||
// const val ICON_WARNING: Int = R.drawable.tips_warning_ic
|
||||
const val ICON_WARNING: Int = 0
|
||||
const val ICON_FINISH: Int = R.drawable.tips_finish_ic
|
||||
const val ICON_ERROR: Int = R.drawable.tips_error_ic
|
||||
const val ICON_WARNING: Int = R.drawable.tips_warning_ic
|
||||
}
|
||||
|
||||
class Builder(context: Context) : BaseDialog.Builder<Builder>(context),
|
@ -0,0 +1,33 @@
|
||||
package com.localee.mireo.app.ui.dialog
|
||||
|
||||
import android.content.*
|
||||
import android.view.*
|
||||
import android.widget.TextView
|
||||
import androidx.annotation.StringRes
|
||||
import com.hjq.base.BaseDialog
|
||||
import com.hjq.base.action.AnimAction
|
||||
import com.localee.mireo.app.R
|
||||
|
||||
class WaitDialog {
|
||||
|
||||
class Builder(context: Context) : BaseDialog.Builder<Builder>(context) {
|
||||
|
||||
private val messageView: TextView? by lazy { findViewById(R.id.tv_wait_message) }
|
||||
|
||||
init {
|
||||
setContentView(R.layout.wait_dialog)
|
||||
setAnimStyle(AnimAction.ANIM_TOAST)
|
||||
setBackgroundDimEnabled(false)
|
||||
setCancelable(false)
|
||||
}
|
||||
|
||||
fun setMessage(@StringRes id: Int): Builder = apply {
|
||||
setMessage(getString(id))
|
||||
}
|
||||
|
||||
fun setMessage(text: CharSequence?): Builder = apply {
|
||||
messageView?.text = text
|
||||
messageView?.visibility = if (text == null) View.GONE else View.VISIBLE
|
||||
}
|
||||
}
|
||||
}
|
@ -4,8 +4,10 @@ import android.graphics.Bitmap
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import android.webkit.WebView
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.action.StatusAction
|
||||
import com.localee.mireo.app.aop.CheckNet
|
||||
import com.localee.mireo.app.aop.Log
|
||||
import com.localee.mireo.app.app.AppActivity
|
||||
import com.localee.mireo.app.app.AppFragment
|
||||
import com.localee.mireo.app.ui.activity.BrowserActivity
|
||||
@ -17,7 +19,7 @@ import com.localee.mireo.app.widget.StatusLayout.OnRetryListener
|
||||
import com.scwang.smart.refresh.layout.SmartRefreshLayout
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import com.scwang.smart.refresh.layout.listener.OnRefreshListener
|
||||
import java.util.Locale
|
||||
import java.util.*
|
||||
|
||||
class BrowserFragment : AppFragment<AppActivity>(), StatusAction, OnRefreshListener {
|
||||
|
||||
@ -25,6 +27,7 @@ class BrowserFragment : AppFragment<AppActivity>(), StatusAction, OnRefreshListe
|
||||
|
||||
private const val INTENT_KEY_IN_URL: String = "url"
|
||||
|
||||
@Log
|
||||
fun newInstance(url: String): BrowserFragment {
|
||||
val fragment = BrowserFragment()
|
||||
val bundle = Bundle()
|
||||
@ -60,6 +63,7 @@ class BrowserFragment : AppFragment<AppActivity>(), StatusAction, OnRefreshListe
|
||||
return hintLayout!!
|
||||
}
|
||||
|
||||
@CheckNet
|
||||
private fun reload() {
|
||||
browserView?.reload()
|
||||
}
|
||||
@ -72,12 +76,7 @@ class BrowserFragment : AppFragment<AppActivity>(), StatusAction, OnRefreshListe
|
||||
}
|
||||
|
||||
private inner class AppBrowserViewClient : BrowserViewClient() {
|
||||
override fun onReceivedError(
|
||||
view: WebView,
|
||||
errorCode: Int,
|
||||
description: String,
|
||||
failingUrl: String
|
||||
) {
|
||||
override fun onReceivedError(view: WebView, errorCode: Int, description: String, failingUrl: String) {
|
||||
post {
|
||||
showError(object : OnRetryListener {
|
||||
override fun onRetry(layout: StatusLayout) {
|
@ -10,28 +10,27 @@ import androidx.appcompat.widget.AppCompatTextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager2.widget.ViewPager2
|
||||
import com.blankj.utilcode.util.NetworkUtils
|
||||
import com.hjq.http.EasyHttp
|
||||
import com.hjq.http.config.IRequestApi
|
||||
import com.hjq.http.listener.HttpCallbackProxy
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.localee.mireo.app.utils.MsMMKVUtils
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.app.BaseEventBus
|
||||
import com.localee.mireo.app.app.TitleBarFragment
|
||||
import com.localee.mireo.app.http.api.ExampleRecommendDataRes
|
||||
import com.localee.mireo.app.http.api.HomeRecommendApi
|
||||
import com.localee.mireo.app.http.api.VideoDetailsApi
|
||||
import com.localee.mireo.app.http.model.HttpData
|
||||
import com.localee.mireo.app.other.MsConstants
|
||||
import com.localee.mireo.app.other.MsConstants.CONSTANTS_quality_refresh
|
||||
import com.localee.mireo.app.ui.activity.HomeActivity
|
||||
import com.localee.mireo.app.ui.videoPaly.ExamplePlayerDetailDataRes
|
||||
import com.localee.mireo.app.ui.videoPaly.ExampleRecommendAdapter
|
||||
import com.localee.mireo.app.ui.videoPaly.ExampleRecommendPlayerView
|
||||
import com.localee.mireo.app.ui.videoPaly.ExampleUnFavoriteDialog
|
||||
import com.localee.mireo.app.utils.DHStringUtils.getPublicRequest
|
||||
import com.localee.mireo.app.utils.MsMMKVUtils
|
||||
import com.localee.mireo.app.utils.TranslatesUtils
|
||||
import com.localee.mireo.app.utils.formatNumber
|
||||
import com.localee.mireo.app.utils.singleClick
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.hjq.http.EasyHttp
|
||||
import com.hjq.http.listener.HttpCallbackProxy
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.scwang.smart.refresh.layout.SmartRefreshLayout
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
@ -59,7 +58,7 @@ class ExploreFragment : TitleBarFragment<HomeActivity>(),
|
||||
private var exampleRecommendAdapter: ExampleRecommendAdapter? = null
|
||||
private var data: com.localee.mireo.app.http.api.ExampleRecommendDataRes.Data? = null
|
||||
private var revolution =
|
||||
MsMMKVUtils.getMMKV().getInt(MsConstants.CONSTANTS_quality, 540).toString()
|
||||
MsMMKVUtils.getMMKV().getInt(MsConstants.CONSTANTS_quality, 0).toString()
|
||||
|
||||
|
||||
private val srRecommend: SmartRefreshLayout? by lazy { findViewById(R.id.sr_recommend) }
|
||||
@ -85,8 +84,10 @@ class ExploreFragment : TitleBarFragment<HomeActivity>(),
|
||||
)
|
||||
activity?.window?.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||
|
||||
tvExampleRetry?.text = TranslatesUtils.translates()?.mireo_retry
|
||||
|
||||
exampleTvNoNetwork?.text =
|
||||
TranslatesUtils.translates()?.no_network
|
||||
tvExampleRetry?.text = TranslatesUtils.translates()?.retry
|
||||
exampleTvEmpty?.text = TranslatesUtils.translates()?.s_no_content
|
||||
}
|
||||
|
||||
override fun initData() {
|
||||
@ -96,18 +97,19 @@ class ExploreFragment : TitleBarFragment<HomeActivity>(),
|
||||
fun initialization() {
|
||||
|
||||
if (NetworkUtils.isConnected()) {
|
||||
// avi?.start()
|
||||
getRecommands(currentPage, currentSize, revolution)
|
||||
} else {
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
ToastUtils.show(TranslatesUtils.translates()?.mireo_no_network.toString())
|
||||
ToastUtils.show(TranslatesUtils.translates()?.no_network.toString())
|
||||
} else {
|
||||
ToastUtils.show(getString(R.string.example_no_network))
|
||||
}
|
||||
exampleNetwork?.visibility = View.VISIBLE
|
||||
|
||||
}
|
||||
srRecommend?.setOnRefreshListener {
|
||||
if (NetworkUtils.isConnected()) {
|
||||
// avi?.start()
|
||||
currentPage = 1
|
||||
viewPagerExampleRecommend?.post {
|
||||
recommendPlayerView()?.stop()
|
||||
@ -119,11 +121,10 @@ class ExploreFragment : TitleBarFragment<HomeActivity>(),
|
||||
)
|
||||
} else {
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
ToastUtils.show(TranslatesUtils.translates()?.mireo_no_network.toString())
|
||||
ToastUtils.show(TranslatesUtils.translates()?.no_network.toString())
|
||||
} else {
|
||||
ToastUtils.show(getString(R.string.example_no_network))
|
||||
}
|
||||
srRecommend?.finishRefresh()
|
||||
}
|
||||
}
|
||||
viewPagerExampleRecommend?.registerOnPageChangeCallback(object :
|
||||
@ -174,7 +175,7 @@ class ExploreFragment : TitleBarFragment<HomeActivity>(),
|
||||
singleClick {
|
||||
if (!NetworkUtils.isConnected()) {
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
ToastUtils.show(TranslatesUtils.translates()?.mireo_no_network.toString())
|
||||
ToastUtils.show(TranslatesUtils.translates()?.no_network.toString())
|
||||
} else {
|
||||
ToastUtils.show(getString(R.string.example_no_network))
|
||||
}
|
||||
@ -192,7 +193,7 @@ class ExploreFragment : TitleBarFragment<HomeActivity>(),
|
||||
singleClick {
|
||||
if (!NetworkUtils.isConnected()) {
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
ToastUtils.show(TranslatesUtils.translates()?.mireo_no_network.toString())
|
||||
ToastUtils.show(TranslatesUtils.translates()?.no_network.toString())
|
||||
} else {
|
||||
ToastUtils.show(getString(R.string.example_no_network))
|
||||
}
|
||||
@ -288,7 +289,7 @@ class ExploreFragment : TitleBarFragment<HomeActivity>(),
|
||||
exampleEmpty?.visibility = View.INVISIBLE
|
||||
} else {
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
ToastUtils.show(TranslatesUtils.translates()?.mireo_no_more_data.toString())
|
||||
ToastUtils.show(TranslatesUtils.translates()?.no_more_data.toString())
|
||||
} else {
|
||||
ToastUtils.show(getString(R.string.example_there_s_no_more_data))
|
||||
}
|
||||
@ -302,7 +303,7 @@ class ExploreFragment : TitleBarFragment<HomeActivity>(),
|
||||
exampleEmpty?.visibility = View.VISIBLE
|
||||
}
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
ToastUtils.show(TranslatesUtils.translates()?.mireo_network_error.toString())
|
||||
ToastUtils.show(TranslatesUtils.translates()?.network_error.toString())
|
||||
} else {
|
||||
ToastUtils.show(getString(R.string.example_service_exception_please_try_again))
|
||||
}
|
||||
@ -311,14 +312,12 @@ class ExploreFragment : TitleBarFragment<HomeActivity>(),
|
||||
srRecommend?.finishRefresh()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onHttpEnd(api: IRequestApi) {
|
||||
super.onHttpEnd(api)
|
||||
srRecommend?.finishRefresh()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
// ExampleRecommendRequest.getRecommands(current_page, page_size, revolution)
|
||||
// .observeForever { result ->
|
||||
// recommendLiveData.value = result.getOrNull()
|
||||
// }
|
||||
}
|
||||
|
||||
fun doCollect(videoId: Int, shortPlayId: Int) {
|
||||
@ -346,11 +345,11 @@ class ExploreFragment : TitleBarFragment<HomeActivity>(),
|
||||
textview?.text = data?.collect_total?.let { it1 -> formatNumber(it1) }
|
||||
textview?.setTextColor(resources.getColor(R.color.example_color_F56490))
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
ToastUtils.show(TranslatesUtils.translates()?.mireo_success.toString())
|
||||
ToastUtils.show(TranslatesUtils.translates()?.success.toString())
|
||||
}
|
||||
} else {
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
ToastUtils.show(TranslatesUtils.translates()?.mireo_network_error.toString())
|
||||
ToastUtils.show(TranslatesUtils.translates()?.network_error.toString())
|
||||
} else {
|
||||
ToastUtils.show(getString(R.string.example_service_exception_please_try_again))
|
||||
}
|
||||
@ -385,11 +384,11 @@ class ExploreFragment : TitleBarFragment<HomeActivity>(),
|
||||
textview?.text = data?.collect_total?.let { it1 -> formatNumber(it1) }
|
||||
textview?.setTextColor(resources.getColor(R.color.white))
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
ToastUtils.show(TranslatesUtils.translates()?.mireo_success.toString())
|
||||
ToastUtils.show(TranslatesUtils.translates()?.success.toString())
|
||||
}
|
||||
} else {
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
ToastUtils.show(TranslatesUtils.translates()?.mireo_network_error.toString())
|
||||
ToastUtils.show(TranslatesUtils.translates()?.network_error.toString())
|
||||
} else {
|
||||
ToastUtils.show(getString(R.string.example_service_exception_please_try_again))
|
||||
}
|
||||
@ -435,11 +434,10 @@ class ExploreFragment : TitleBarFragment<HomeActivity>(),
|
||||
.toString()
|
||||
qualityRefresh = true
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEvent(event: BaseEventBus<VideoDetailsApi.Bean.ShortPlayInfo>) {
|
||||
fun onEvent(event: BaseEventBus<ExamplePlayerDetailDataRes.ShortPlayInfo>) {
|
||||
if (MsConstants.Constants_Episodes_Series_DataExample == event.code) {
|
||||
if (exampleRecommendAdapter?.items?.get(currentPosition)?.name == event.data.name) {
|
||||
val imageView =
|
||||
@ -452,11 +450,7 @@ class ExploreFragment : TitleBarFragment<HomeActivity>(),
|
||||
exampleRecommendAdapter?.items?.get(currentPosition)?.is_collect =
|
||||
event.data.is_collect
|
||||
textview?.text = formatNumber(event.data.collect_total)
|
||||
textview?.setTextColor(
|
||||
if (event.data.is_collect) resources.getColor(R.color.example_color_F56490) else resources.getColor(
|
||||
R.color.white
|
||||
)
|
||||
)
|
||||
textview?.setTextColor(if (event.data.is_collect) resources.getColor(R.color.example_color_F56490) else resources.getColor(R.color.white))
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -475,10 +469,10 @@ class ExploreFragment : TitleBarFragment<HomeActivity>(),
|
||||
val tvContent =
|
||||
exampleUnFavoriteDialog.findViewById<AppCompatTextView>(R.id.example_tv_content)
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
tvThinkAgain.text = TranslatesUtils.translates()?.mireo_try_again
|
||||
tvUnfavorite.text = TranslatesUtils.translates()?.mireo_unfavorite
|
||||
tvTitle.text = TranslatesUtils.translates()?.mireo_unfavorite
|
||||
tvContent.text = TranslatesUtils.translates()?.mireo_not_collect_warning
|
||||
tvThinkAgain.text = TranslatesUtils.translates()?.try_again
|
||||
tvUnfavorite.text = TranslatesUtils.translates()?.collection
|
||||
tvTitle.text = TranslatesUtils.translates()?.collection
|
||||
tvContent.text = TranslatesUtils.translates()?.not_collect_warning
|
||||
}
|
||||
tvThinkAgain.setOnClickListener { exampleUnFavoriteDialog.dismiss() }
|
||||
tvUnfavorite.setOnClickListener {
|
@ -10,11 +10,11 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import com.hjq.http.EasyHttp
|
||||
import com.hjq.http.config.IRequestApi
|
||||
import com.hjq.http.listener.HttpCallbackProxy
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.action.StatusAction
|
||||
import com.localee.mireo.app.app.TitleBarFragment
|
||||
import com.localee.mireo.app.http.api.HomeVideoListApi
|
||||
import com.localee.mireo.app.http.bean.RecommendBean
|
||||
import com.localee.mireo.app.http.api.RecommendBean
|
||||
import com.localee.mireo.app.http.model.HttpData
|
||||
import com.localee.mireo.app.other.MsConstants.CONSTANTS_short_play_id
|
||||
import com.localee.mireo.app.ui.activity.HomeActivity
|
@ -2,6 +2,7 @@ package com.localee.mireo.app.ui.fragment
|
||||
|
||||
import android.content.Intent
|
||||
import android.graphics.Rect
|
||||
import android.view.Display
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.ImageView
|
||||
@ -12,28 +13,28 @@ import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.hjq.base.FragmentPagerAdapter
|
||||
import com.hjq.http.EasyHttp
|
||||
import com.hjq.http.config.IRequestApi
|
||||
import com.hjq.http.listener.HttpCallbackProxy
|
||||
import com.hjq.toast.ToastUtils
|
||||
import com.localee.mireo.app.action.StatusAction
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.app.AppFragment
|
||||
import com.localee.mireo.app.app.TitleBarFragment
|
||||
import com.localee.mireo.app.http.api.CustomerRegisterApi
|
||||
import com.localee.mireo.app.http.api.HomeCategoriesApi
|
||||
import com.localee.mireo.app.http.api.HomeDayMaxRechargeShortPlayRankApi
|
||||
import com.localee.mireo.app.http.api.HomeModuleApi
|
||||
import com.localee.mireo.app.http.api.HomeVideoListApi
|
||||
import com.localee.mireo.app.http.api.RecommendBean
|
||||
import com.localee.mireo.app.http.api.UserInfoApi
|
||||
import com.localee.mireo.app.http.api.UserInfoRes
|
||||
import com.localee.mireo.app.http.bean.RecommendBean
|
||||
import com.localee.mireo.app.http.model.HttpData
|
||||
import com.localee.mireo.app.other.MsConstants
|
||||
import com.localee.mireo.app.other.MsConstants.CONSTANTS_quality
|
||||
import com.localee.mireo.app.other.MsConstants.CONSTANTS_short_play_id
|
||||
import com.localee.mireo.app.ui.activity.HomeActivity
|
||||
import com.localee.mireo.app.ui.activity.SearchActivity
|
||||
import com.localee.mireo.app.ui.activity.VideoPlayActivity
|
||||
import com.localee.mireo.app.ui.adapter.HomeBannerAdapter
|
||||
import com.localee.mireo.app.ui.adapter.HomeCategoriesTabAdapter
|
||||
import com.localee.mireo.app.ui.adapter.HomeCriticallyAdapter
|
||||
import com.localee.mireo.app.ui.adapter.HomeGenresAdapter
|
||||
import com.localee.mireo.app.ui.adapter.HomeShortAdapter
|
||||
@ -43,24 +44,13 @@ import com.localee.mireo.app.ui.adapter.TabAdapter.Companion.TAB_MODE_SLIDING
|
||||
import com.localee.mireo.app.utils.DHStringUtils.getPublicRequest
|
||||
import com.localee.mireo.app.utils.MsMMKVUtils
|
||||
import com.localee.mireo.app.utils.TranslatesUtils
|
||||
import com.localee.mireo.app.utils.singleClick
|
||||
import com.localee.mireo.app.widget.StatusLayout
|
||||
import com.localee.mireo.app.widget.StatusLayout.OnRetryListener
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.scwang.smart.refresh.layout.SmartRefreshLayout
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener
|
||||
import com.youth.banner.Banner
|
||||
import com.youth.banner.listener.OnBannerListener
|
||||
import org.greenrobot.eventbus.EventBus
|
||||
import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
|
||||
class HomeFragment : TitleBarFragment<HomeActivity>(), HomeBannerAdapter.HomeBannerOnClick,
|
||||
TabAdapter.OnTabListener,
|
||||
OnRefreshLoadMoreListener,
|
||||
StatusAction {
|
||||
ViewPager.OnPageChangeListener {
|
||||
|
||||
companion object {
|
||||
|
||||
@ -75,8 +65,7 @@ class HomeFragment : TitleBarFragment<HomeActivity>(), HomeBannerAdapter.HomeBan
|
||||
R.id.banner
|
||||
)
|
||||
}
|
||||
private val hintLayout: StatusLayout? by lazy { findViewById(R.id.hl_status_hint) }
|
||||
private val rlStatusRefresh: SmartRefreshLayout? by lazy { findViewById(R.id.rl_status_refresh) }
|
||||
|
||||
private val layoutTop: ViewGroup? by lazy { findViewById(R.id.layout_top) }
|
||||
private val tvTopOne: TextView? by lazy { layoutTop?.findViewById(R.id.tv_name) }
|
||||
private val ivTop: ImageView? by lazy { layoutTop?.findViewById(R.id.iv_img) }
|
||||
@ -106,25 +95,19 @@ class HomeFragment : TitleBarFragment<HomeActivity>(), HomeBannerAdapter.HomeBan
|
||||
private var criticallyAdapter: HomeCriticallyAdapter? = null
|
||||
|
||||
private val nestedScrollView: NestedScrollView? by lazy { findViewById(R.id.nestedScrollView) }
|
||||
private val recyclerGenresList: RecyclerView? by lazy { findViewById(R.id.recycler_genres) }
|
||||
private val statusGenres: StatusLayout? by lazy { findViewById(R.id.status_genres) }
|
||||
|
||||
private val viewPager: ViewPager? by lazy { findViewById(R.id.viewPager) }
|
||||
private var tabAdapter: TabAdapter? = null
|
||||
private var pagerAdapter: FragmentPagerAdapter<AppFragment<*>>? = null
|
||||
|
||||
private var mGenresListAdapter: HomeCategoriesTabAdapter? = null
|
||||
private var genresAdapter: HomeGenresAdapter? = null
|
||||
|
||||
private var category: List<HomeCategoriesApi.Bean.Data>? = null
|
||||
private var pageIndex = 1
|
||||
private var pageTotal = 1
|
||||
private var tabPosition = 0
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.home_fragment
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
EventBus.getDefault().register(this)
|
||||
recyclerOne?.layoutManager =
|
||||
LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
||||
recyclerNew?.layoutManager =
|
||||
@ -139,7 +122,7 @@ class HomeFragment : TitleBarFragment<HomeActivity>(), HomeBannerAdapter.HomeBan
|
||||
|
||||
recyclerGenres?.layoutManager =
|
||||
LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
||||
recyclerGenresList?.layoutManager = GridLayoutManager(context, 3)
|
||||
|
||||
|
||||
topAdapter = HomeTopAdapter(1)
|
||||
recyclerOne?.adapter = topAdapter
|
||||
@ -151,8 +134,7 @@ class HomeFragment : TitleBarFragment<HomeActivity>(), HomeBannerAdapter.HomeBan
|
||||
recyclerCritically?.adapter = criticallyAdapter
|
||||
genresAdapter = HomeGenresAdapter(0)
|
||||
recyclerGenres?.adapter = genresAdapter
|
||||
mGenresListAdapter = HomeCategoriesTabAdapter()
|
||||
recyclerGenresList?.adapter = mGenresListAdapter
|
||||
|
||||
|
||||
recyclerCritically?.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
||||
override fun getItemOffsets(
|
||||
@ -165,67 +147,37 @@ class HomeFragment : TitleBarFragment<HomeActivity>(), HomeBannerAdapter.HomeBan
|
||||
outRect.bottom = 28
|
||||
}
|
||||
})
|
||||
recyclerGenresList?.addItemDecoration(object : RecyclerView.ItemDecoration() {
|
||||
override fun getItemOffsets(
|
||||
outRect: Rect,
|
||||
view: View,
|
||||
parent: RecyclerView,
|
||||
state: RecyclerView.State
|
||||
) {
|
||||
outRect.right = 10
|
||||
outRect.left = 10
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
ivTop?.visibility = View.VISIBLE
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
tvTopOne?.setText(TranslatesUtils.translates()?.mireo_home_top)
|
||||
tvTopNew?.setText(TranslatesUtils.translates()?.mireo_home_new)
|
||||
tvTopShort?.setText(TranslatesUtils.translates()?.mireo_home_shorts)
|
||||
tvTopCritically?.setText(TranslatesUtils.translates()?.mireo_home_critically)
|
||||
tvTopGenres?.setText(TranslatesUtils.translates()?.mireo_home_genres)
|
||||
} else {
|
||||
tvTopOne?.setText("Top 10 Skits This Week")
|
||||
tvTopNew?.setText("New Releases")
|
||||
tvTopShort?.setText("Shorts for You")
|
||||
tvTopCritically?.setText("Critically Acclaimed")
|
||||
tvTopGenres?.setText("Genres to Explore")
|
||||
|
||||
}
|
||||
|
||||
// genresAdapter?.submitList(genersList)
|
||||
|
||||
searchView?.setOnClickListener {
|
||||
startActivity(SearchActivity::class.java)
|
||||
}
|
||||
|
||||
pagerAdapter = FragmentPagerAdapter(this)
|
||||
|
||||
tabAdapter = TabAdapter(getAttachActivity()!!, TAB_MODE_SLIDING, false)
|
||||
recyclerGenres?.adapter = tabAdapter
|
||||
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
tabAdapter?.addItem(TranslatesUtils.translates()?.mireo_all)
|
||||
} else {
|
||||
tabAdapter?.addItem("All")
|
||||
}
|
||||
pagerAdapter?.addFragment(HomeCategoriesTabFragment.newInstance("All", 0), "")
|
||||
tabAdapter?.setOnTabListener(this)
|
||||
|
||||
rlStatusRefresh?.setOnRefreshLoadMoreListener(this)
|
||||
rlStatusRefresh?.setEnableRefresh(true)
|
||||
rlStatusRefresh?.setEnableLoadMore(true)
|
||||
viewPager?.adapter = pagerAdapter
|
||||
viewPager?.addOnPageChangeListener(this@HomeFragment)
|
||||
|
||||
}
|
||||
|
||||
fun loadingData() {
|
||||
getCustomerUser()
|
||||
getHomeModuleData()
|
||||
getDayMaxRechargeShortPlayRank()
|
||||
getCategories()
|
||||
getHomeVideoListApi(0, pageIndex, 15)
|
||||
}
|
||||
|
||||
override fun initData() {
|
||||
loadingData()
|
||||
getCustomerRegister()
|
||||
|
||||
topAdapter?.setOnItemClickListener { adapter, view, position ->
|
||||
val data: RecommendBean = adapter.items.get(position)
|
||||
@ -275,18 +227,6 @@ class HomeFragment : TitleBarFragment<HomeActivity>(), HomeBannerAdapter.HomeBan
|
||||
}
|
||||
})
|
||||
}
|
||||
mGenresListAdapter?.setOnItemClickListener { adapter, view, position ->
|
||||
val data: RecommendBean = adapter.items.get(position)
|
||||
startActivity(
|
||||
Intent(
|
||||
context,
|
||||
VideoPlayActivity::class.java
|
||||
).apply {
|
||||
data.short_play_id.let {
|
||||
putExtra(CONSTANTS_short_play_id, it)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -294,6 +234,22 @@ class HomeFragment : TitleBarFragment<HomeActivity>(), HomeBannerAdapter.HomeBan
|
||||
return !super.isStatusBarEnabled()
|
||||
}
|
||||
|
||||
fun getCustomerRegister() {
|
||||
EasyHttp.post(this)
|
||||
.api(CustomerRegisterApi().apply {
|
||||
})
|
||||
.request(object : HttpCallbackProxy<HttpData<CustomerRegisterApi.Bean>>(this) {
|
||||
override fun onHttpSuccess(result: HttpData<CustomerRegisterApi.Bean>) {
|
||||
result.getData()?.token?.let {
|
||||
MsMMKVUtils.saveToken(it)
|
||||
getCustomerUser()
|
||||
getHomeModuleData()
|
||||
// getCategories()
|
||||
getDayMaxRechargeShortPlayRank();
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fun getHomeModuleData() {
|
||||
EasyHttp.get(this)
|
||||
@ -302,12 +258,6 @@ class HomeFragment : TitleBarFragment<HomeActivity>(), HomeBannerAdapter.HomeBan
|
||||
.request(object : HttpCallbackProxy<HttpData<HomeModuleApi.Bean>>(this) {
|
||||
override fun onHttpSuccess(result: HttpData<HomeModuleApi.Bean>) {
|
||||
result.getData()?.let {
|
||||
nestedScrollView?.visibility = View.VISIBLE
|
||||
showComplete()
|
||||
if (it.bannerData == null || it.bannerData!!.isEmpty()) {
|
||||
banner?.visibility = View.GONE
|
||||
} else {
|
||||
banner?.visibility = View.VISIBLE
|
||||
bannerAdapter = it.bannerData?.let { it1 -> HomeBannerAdapter(it1) }
|
||||
bannerAdapter?.homeBannerOnClick =
|
||||
this@HomeFragment
|
||||
@ -326,50 +276,27 @@ class HomeFragment : TitleBarFragment<HomeActivity>(), HomeBannerAdapter.HomeBan
|
||||
)
|
||||
})
|
||||
})
|
||||
}
|
||||
if (it.hotData == null || it.hotData!!.isEmpty()) {
|
||||
if (it.hotData == null) {
|
||||
layoutTop?.visibility = View.GONE
|
||||
} else {
|
||||
layoutTop?.visibility = View.VISIBLE
|
||||
topAdapter?.submitList(it.hotData)
|
||||
}
|
||||
if (it.manualNewestRecommand == null || it.manualNewestRecommand?.list == null || it.manualNewestRecommand!!.list!!.isEmpty()) {
|
||||
if (it.manualNewestRecommand == null) {
|
||||
layoutNew?.visibility = View.GONE
|
||||
} else {
|
||||
layoutNew?.visibility = View.VISIBLE
|
||||
newAdapter?.submitList(it.manualNewestRecommand?.list)
|
||||
}
|
||||
if (it.nineSquare == null || it.nineSquare?.list == null || it.nineSquare!!.list!!.isEmpty()) {
|
||||
if (it.recommandData == null || it.recommandData?.list == null) {
|
||||
layoutShort?.visibility = View.GONE
|
||||
} else {
|
||||
layoutShort?.visibility = View.VISIBLE
|
||||
shortAdapter?.submitList(it.nineSquare?.list)
|
||||
shortAdapter?.submitList(it.recommandData?.list)
|
||||
}
|
||||
// if (it.hottestPist == null || it.hottestPist!!.isEmpty()) {
|
||||
// layoutCritically?.visibility = View.GONE
|
||||
// } else {
|
||||
// layoutCritically?.visibility = View.VISIBLE
|
||||
// criticallyAdapter?.submitList(it.hottestPist)
|
||||
// }
|
||||
|
||||
} ?: run {
|
||||
nestedScrollView?.visibility = View.GONE
|
||||
showEmpty()
|
||||
// criticallyAdapter?.submitList(it.newTopThree)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onHttpFail(throwable: Throwable) {
|
||||
super.onHttpFail(throwable)
|
||||
nestedScrollView?.visibility = View.GONE
|
||||
showError(object : OnRetryListener {
|
||||
override fun onRetry(layout: StatusLayout) {
|
||||
singleClick {
|
||||
loadingData()
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
@ -377,8 +304,8 @@ class HomeFragment : TitleBarFragment<HomeActivity>(), HomeBannerAdapter.HomeBan
|
||||
|
||||
fun getDayMaxRechargeShortPlayRank() {
|
||||
val sMap: MutableMap<String, String?> = LinkedHashMap()
|
||||
sMap.put("type", "most_trending")
|
||||
// type:most_trending,top_searched,new_releases
|
||||
// StringMap = getSortMap(StringMap);
|
||||
sMap.put("type", "top_searched")
|
||||
EasyHttp.post(this)
|
||||
.api(HomeDayMaxRechargeShortPlayRankApi().apply {
|
||||
})
|
||||
@ -411,74 +338,30 @@ class HomeFragment : TitleBarFragment<HomeActivity>(), HomeBannerAdapter.HomeBan
|
||||
category = it.list
|
||||
for (cate in it.list) {
|
||||
tabAdapter?.addItem(cate.name)
|
||||
pagerAdapter?.addFragment(
|
||||
HomeCategoriesTabFragment.newInstance(
|
||||
cate.name,
|
||||
cate.id
|
||||
), ""
|
||||
)
|
||||
}
|
||||
pagerAdapter?.notifyDataSetChanged()
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
private fun getHomeVideoListApi(tabId: Int, currentPage: Int, pageSize: Int) {
|
||||
EasyHttp.get(this)
|
||||
.api(HomeVideoListApi().apply {
|
||||
category_id = tabId
|
||||
current_page = currentPage
|
||||
page_size = pageSize
|
||||
})
|
||||
.request(object : HttpCallbackProxy<HttpData<HomeVideoListApi.Bean>>(this) {
|
||||
override fun onHttpSuccess(result: HttpData<HomeVideoListApi.Bean>) {
|
||||
result.getData()?.let {
|
||||
if (pageIndex == 1) {
|
||||
if (it.list.isEmpty()) {
|
||||
statusGenres?.show()
|
||||
rlStatusRefresh?.setEnableLoadMore(false)
|
||||
} else {
|
||||
statusGenres?.hide()
|
||||
}
|
||||
mGenresListAdapter?.submitList(it.list)
|
||||
pageTotal = it.pagination.page_total
|
||||
} else {
|
||||
mGenresListAdapter?.addAll(it.list)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun onHttpFail(throwable: Throwable) {
|
||||
super.onHttpFail(throwable)
|
||||
if (pageIndex == 1) {
|
||||
statusGenres?.show()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onHttpEnd(api: IRequestApi) {
|
||||
super.onHttpEnd(api)
|
||||
if (pageIndex == 1) {
|
||||
rlStatusRefresh?.finishRefresh(200)
|
||||
} else {
|
||||
rlStatusRefresh?.finishLoadMore(200)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
fun getCustomerUser() {
|
||||
EasyHttp.get(this)
|
||||
.api(UserInfoApi().apply {
|
||||
})
|
||||
.request(object : HttpCallbackProxy<HttpData<UserInfoRes>>(this) {
|
||||
override fun onHttpStart(api: IRequestApi) {
|
||||
}
|
||||
|
||||
override fun onHttpSuccess(result: HttpData<UserInfoRes>) {
|
||||
result.getData()?.let {
|
||||
|
||||
MsMMKVUtils.saveUserInfo(it)
|
||||
var revolution =
|
||||
MsMMKVUtils.getMMKV().getInt(CONSTANTS_quality, 540).toString()
|
||||
if (revolution == "1080" && !MsMMKVUtils.isVip()) {
|
||||
EventBus.getDefault().post(MsConstants.CONSTANTS_quality_refresh)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
})
|
||||
@ -512,11 +395,11 @@ class HomeFragment : TitleBarFragment<HomeActivity>(), HomeBannerAdapter.HomeBan
|
||||
override fun onHttpSuccess(result: HttpData<Any>) {
|
||||
result.getData()?.let {
|
||||
if (it != null) {
|
||||
viewModel.triggerAction(3)
|
||||
viewModel.triggerAction(2)
|
||||
viewModel.meToHistoryAction(0)
|
||||
} else {
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
ToastUtils.show(TranslatesUtils.translates()?.mireo_network_error.toString())
|
||||
ToastUtils.show(TranslatesUtils.translates()?.network_error.toString())
|
||||
} else {
|
||||
ToastUtils.show(getString(R.string.example_service_exception_please_try_again))
|
||||
}
|
||||
@ -526,49 +409,21 @@ class HomeFragment : TitleBarFragment<HomeActivity>(), HomeBannerAdapter.HomeBan
|
||||
})
|
||||
}
|
||||
|
||||
@Subscribe(threadMode = ThreadMode.MAIN)
|
||||
fun onEvent(event: String) {
|
||||
if (MsConstants.CONSTANTS_refresh_home == event) {
|
||||
loadingData()
|
||||
}
|
||||
}
|
||||
|
||||
private val viewModel: SharedViewModel by activityViewModels()
|
||||
|
||||
override fun onTabSelected(recyclerView: RecyclerView?, position: Int): Boolean {
|
||||
tabPosition = position
|
||||
pageIndex = 1
|
||||
pageTotal = 1
|
||||
rlStatusRefresh?.setEnableLoadMore(true)
|
||||
|
||||
if (position == 0) {
|
||||
getHomeVideoListApi(0, pageIndex, 15)
|
||||
} else {
|
||||
category?.get(position - 1)?.id?.let { getHomeVideoListApi(it, 1, 15) }
|
||||
}
|
||||
viewPager?.currentItem = position
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onRefresh(refreshLayout: RefreshLayout) {
|
||||
loadingData()
|
||||
rlStatusRefresh?.finishRefresh(2000)
|
||||
override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
|
||||
}
|
||||
|
||||
override fun onLoadMore(refreshLayout: RefreshLayout) {
|
||||
if (pageIndex == pageTotal) {
|
||||
rlStatusRefresh?.finishLoadMore(1000)
|
||||
} else {
|
||||
pageIndex++
|
||||
if (tabPosition == 0) {
|
||||
getHomeVideoListApi(0, pageIndex, 15)
|
||||
} else {
|
||||
category?.get(tabPosition - 1)?.id?.let { getHomeVideoListApi(it, pageIndex, 15) }
|
||||
}
|
||||
}
|
||||
override fun onPageSelected(position: Int) {
|
||||
tabAdapter?.setSelectedPosition(position)
|
||||
}
|
||||
|
||||
override fun getStatusLayout(): StatusLayout? {
|
||||
return hintLayout
|
||||
override fun onPageScrollStateChanged(state: Int) {
|
||||
}
|
||||
|
||||
}
|
@ -15,11 +15,12 @@ import com.hjq.http.EasyHttp
|
||||
import com.hjq.http.config.IRequestApi
|
||||
import com.hjq.http.listener.HttpCallbackProxy
|
||||
import com.hjq.shape.layout.ShapeLinearLayout
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.action.StatusAction
|
||||
import com.localee.mireo.app.app.TitleBarFragment
|
||||
import com.localee.mireo.app.http.api.HistoryBean
|
||||
import com.localee.mireo.app.http.api.MyCollectionsApi
|
||||
import com.localee.mireo.app.http.api.MyHistoryApi
|
||||
import com.localee.mireo.app.http.bean.HistoryBean
|
||||
import com.localee.mireo.app.http.model.HttpData
|
||||
import com.localee.mireo.app.other.MsConstants.CONSTANTS_activity_id
|
||||
import com.localee.mireo.app.other.MsConstants.CONSTANTS_short_play_id
|
||||
@ -27,11 +28,7 @@ import com.localee.mireo.app.ui.activity.HomeActivity
|
||||
import com.localee.mireo.app.ui.activity.VideoPlayActivity
|
||||
import com.localee.mireo.app.ui.adapter.LostTabAdapter
|
||||
import com.localee.mireo.app.utils.DHStringUtils.getPublicRequest
|
||||
import com.localee.mireo.app.utils.TranslatesUtils
|
||||
import com.localee.mireo.app.utils.singleClick
|
||||
import com.localee.mireo.app.widget.StatusLayout
|
||||
import com.localee.mireo.app.widget.StatusLayout.OnRetryListener
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.scwang.smart.refresh.layout.SmartRefreshLayout
|
||||
import com.scwang.smart.refresh.layout.api.RefreshLayout
|
||||
import com.scwang.smart.refresh.layout.listener.OnRefreshLoadMoreListener
|
||||
@ -76,16 +73,6 @@ class ListTabFragment : TitleBarFragment<HomeActivity>(), OnRefreshLoadMoreListe
|
||||
|
||||
mAdapter = tabName?.let { LostTabAdapter(it) }
|
||||
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
tvDelete?.text =
|
||||
TranslatesUtils.translates()?.mireo_list_delete?.let {
|
||||
TranslatesUtils.replace(
|
||||
it,
|
||||
"0"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
val layoutManager = GridLayoutManager(context, 3)
|
||||
// 设置给 RecyclerView
|
||||
recyclerView!!.layoutManager = layoutManager
|
||||
@ -137,35 +124,14 @@ class ListTabFragment : TitleBarFragment<HomeActivity>(), OnRefreshLoadMoreListe
|
||||
?.intoBackground();
|
||||
context?.resources?.getColor(R.color.example_color_d9d9d9)
|
||||
?.let { tvDelete?.setTextColor(it) }
|
||||
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
tvDelete?.text =
|
||||
TranslatesUtils.translates()?.mireo_list_delete?.let {
|
||||
TranslatesUtils.replace(
|
||||
it,
|
||||
"0"
|
||||
)
|
||||
}
|
||||
} else {
|
||||
tvDelete?.text = "Delete (0)"
|
||||
}
|
||||
ivDelete?.setImageResource(R.mipmap.ic_list_detele_n)
|
||||
} else {
|
||||
llDelete?.shapeDrawableBuilder?.setStrokeColor(0xFFF56490.toInt())
|
||||
?.intoBackground();
|
||||
context?.resources?.getColor(R.color.example_color_F56490)
|
||||
?.let { tvDelete?.setTextColor(it) }
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
tvDelete?.text =
|
||||
TranslatesUtils.translates()?.mireo_list_delete?.let {
|
||||
TranslatesUtils.replace(
|
||||
it,
|
||||
detailList.size.toString()
|
||||
)
|
||||
}
|
||||
} else {
|
||||
tvDelete?.text = "Delete (" + detailList.size + ")"
|
||||
}
|
||||
ivDelete?.setImageResource(R.mipmap.ic_list_detele_y)
|
||||
}
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
@ -216,7 +182,6 @@ class ListTabFragment : TitleBarFragment<HomeActivity>(), OnRefreshLoadMoreListe
|
||||
}
|
||||
|
||||
fun setEdit() {
|
||||
rlStatusRefresh?.setEnableRefresh(false)
|
||||
mAdapter?.selectEdit = !mAdapter?.selectEdit!!
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
if (llDelete?.visibility == View.VISIBLE)
|
||||
@ -227,37 +192,22 @@ class ListTabFragment : TitleBarFragment<HomeActivity>(), OnRefreshLoadMoreListe
|
||||
}
|
||||
|
||||
fun setCancel() {
|
||||
rlStatusRefresh?.setEnableRefresh(true)
|
||||
llDelete?.visibility = View.GONE
|
||||
llDelete?.shapeDrawableBuilder?.setStrokeColor(0xFF9D9D9D.toInt())
|
||||
?.intoBackground();
|
||||
val allData = mAdapter?.items
|
||||
if (allData.isNullOrEmpty()) return
|
||||
for (i in allData.indices) {
|
||||
val allData: List<HistoryBean.Data>? = mAdapter?.items
|
||||
for (i in allData?.indices!!) {
|
||||
allData[i].is_check = false
|
||||
}
|
||||
detailList.clear()
|
||||
mAdapter?.selectEdit = false
|
||||
mAdapter?.selectEdit = !mAdapter?.selectEdit!!
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
context?.resources?.getColor(R.color.example_color_d9d9d9)
|
||||
?.let { tvDelete?.setTextColor(it) }
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
tvDelete?.text =
|
||||
TranslatesUtils.translates()?.mireo_list_delete?.let {
|
||||
TranslatesUtils.replace(
|
||||
it,
|
||||
"0"
|
||||
)
|
||||
}
|
||||
} else {
|
||||
tvDelete?.text = "Delete (0)"
|
||||
}
|
||||
ivDelete?.setImageResource(R.mipmap.ic_list_detele_n)
|
||||
if (llDelete?.visibility == View.VISIBLE)
|
||||
llDelete?.visibility = View.GONE
|
||||
else
|
||||
llDelete?.visibility = View.VISIBLE
|
||||
|
||||
}
|
||||
|
||||
fun setAllSelect(isSelect: Boolean) {
|
||||
val allData = mAdapter?.items
|
||||
if (allData.isNullOrEmpty()) return
|
||||
val allData: List<HistoryBean.Data>? = mAdapter?.items
|
||||
if (isSelect) {
|
||||
detailList.clear()
|
||||
for (i in allData?.indices!!) {
|
||||
@ -275,34 +225,14 @@ class ListTabFragment : TitleBarFragment<HomeActivity>(), OnRefreshLoadMoreListe
|
||||
?.intoBackground();
|
||||
context?.resources?.getColor(R.color.example_color_d9d9d9)
|
||||
?.let { tvDelete?.setTextColor(it) }
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
tvDelete?.text =
|
||||
TranslatesUtils.translates()?.mireo_list_delete?.let {
|
||||
TranslatesUtils.replace(
|
||||
it,
|
||||
"0"
|
||||
)
|
||||
}
|
||||
} else {
|
||||
tvDelete?.text = "Delete (0)"
|
||||
}
|
||||
ivDelete?.setImageResource(R.mipmap.ic_list_detele_n)
|
||||
} else {
|
||||
llDelete?.shapeDrawableBuilder?.setStrokeColor(0xFFF56490.toInt())
|
||||
?.intoBackground();
|
||||
context?.resources?.getColor(R.color.example_color_F56490)
|
||||
?.let { tvDelete?.setTextColor(it) }
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
tvDelete?.text =
|
||||
TranslatesUtils.translates()?.mireo_list_delete?.let {
|
||||
TranslatesUtils.replace(
|
||||
it,
|
||||
detailList.size.toString()
|
||||
)
|
||||
}
|
||||
} else {
|
||||
tvDelete?.text = "Delete (" + detailList.size + ")"
|
||||
}
|
||||
ivDelete?.setImageResource(R.mipmap.ic_list_detele_y)
|
||||
}
|
||||
mAdapter?.notifyDataSetChanged()
|
||||
@ -338,38 +268,24 @@ class ListTabFragment : TitleBarFragment<HomeActivity>(), OnRefreshLoadMoreListe
|
||||
.request(object : HttpCallbackProxy<HttpData<HistoryBean>>(this) {
|
||||
override fun onHttpSuccess(result: HttpData<HistoryBean>) {
|
||||
result.getData()?.let {
|
||||
recyclerView?.visibility = View.VISIBLE
|
||||
if (pageIndex == 1) {
|
||||
if (it.list.isEmpty()) {
|
||||
showEmpty()
|
||||
hintLayout?.show()
|
||||
} else {
|
||||
showComplete()
|
||||
hintLayout?.hide()
|
||||
}
|
||||
mAdapter?.submitList(it.list)
|
||||
it.pagination?.let { it1 ->
|
||||
pageTotal = it1.page_total
|
||||
}
|
||||
pageTotal = it.pagination.page_total
|
||||
} else {
|
||||
mAdapter?.addAll(it.list)
|
||||
}
|
||||
} ?: run {
|
||||
recyclerView?.visibility = View.GONE
|
||||
showEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
override fun onHttpFail(throwable: Throwable) {
|
||||
super.onHttpFail(throwable)
|
||||
if (pageIndex == 1) {
|
||||
recyclerView?.visibility = View.GONE
|
||||
showError(object : OnRetryListener {
|
||||
override fun onRetry(layout: StatusLayout) {
|
||||
singleClick {
|
||||
onRefreshData()
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
hintLayout?.show()
|
||||
}
|
||||
}
|
||||
|
||||
@ -393,23 +309,17 @@ class ListTabFragment : TitleBarFragment<HomeActivity>(), OnRefreshLoadMoreListe
|
||||
.request(object : HttpCallbackProxy<HttpData<HistoryBean>>(this) {
|
||||
override fun onHttpSuccess(result: HttpData<HistoryBean>) {
|
||||
result.getData()?.let {
|
||||
recyclerView?.visibility = View.VISIBLE
|
||||
if (pageIndex == 1) {
|
||||
if (it.list.isEmpty()) {
|
||||
showEmpty()
|
||||
hintLayout?.show()
|
||||
} else {
|
||||
showComplete()
|
||||
hintLayout?.hide()
|
||||
}
|
||||
mAdapter?.submitList(it.list)
|
||||
it.pagination?.let { it1 ->
|
||||
pageTotal = it1.page_total
|
||||
}
|
||||
pageTotal = it.pagination.page_total
|
||||
} else {
|
||||
mAdapter?.addAll(it.list)
|
||||
}
|
||||
} ?: run {
|
||||
recyclerView?.visibility = View.GONE
|
||||
showEmpty()
|
||||
}
|
||||
|
||||
}
|
||||
@ -417,15 +327,7 @@ class ListTabFragment : TitleBarFragment<HomeActivity>(), OnRefreshLoadMoreListe
|
||||
override fun onHttpFail(throwable: Throwable) {
|
||||
super.onHttpFail(throwable)
|
||||
if (pageIndex == 1) {
|
||||
recyclerView?.visibility = View.GONE
|
||||
showError(object : OnRetryListener {
|
||||
override fun onRetry(layout: StatusLayout) {
|
||||
singleClick {
|
||||
onRefreshData()
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
hintLayout?.show()
|
||||
}
|
||||
}
|
||||
|
||||
@ -451,9 +353,9 @@ class ListTabFragment : TitleBarFragment<HomeActivity>(), OnRefreshLoadMoreListe
|
||||
.body(getPublicRequest(sMap))
|
||||
.request(object : HttpCallbackProxy<HttpData<Any>>(this) {
|
||||
override fun onHttpSuccess(result: HttpData<Any>) {
|
||||
// result.getData()?.let {
|
||||
// viewModel.listTabAction(0)
|
||||
// }
|
||||
result.getData()?.let {
|
||||
viewModel.listTabAction(0)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onHttpEnd(api: IRequestApi) {
|
||||
@ -461,10 +363,10 @@ class ListTabFragment : TitleBarFragment<HomeActivity>(), OnRefreshLoadMoreListe
|
||||
detailPosition++
|
||||
if (detailPosition == detailList.size) {
|
||||
pageIndex = 1
|
||||
detailPosition = 0
|
||||
mAdapter?.selectEdit = false
|
||||
loadData()
|
||||
viewModel.listTabAction(0)
|
||||
setCancel()
|
||||
llDelete?.visibility = View.GONE
|
||||
detailList.clear()
|
||||
}
|
||||
}
|
||||
})
|
@ -8,16 +8,15 @@ import androidx.appcompat.widget.AppCompatCheckBox
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager.widget.ViewPager
|
||||
import com.hjq.base.FragmentPagerAdapter
|
||||
import com.lxj.xpopup.XPopup
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.app.AppFragment
|
||||
import com.localee.mireo.app.app.TitleBarFragment
|
||||
import com.localee.mireo.app.base.FragmentPagerAdapter
|
||||
import com.localee.mireo.app.ui.activity.HomeActivity
|
||||
import com.localee.mireo.app.ui.adapter.TabAdapter
|
||||
import com.localee.mireo.app.ui.popup.CustomBubbleAttachPopup
|
||||
import com.localee.mireo.app.ui.popup.CustomBubbleAttachPopup.CustomPopupOnclick
|
||||
import com.localee.mireo.app.utils.TranslatesUtils
|
||||
import com.localee.mireo.shortapp.R
|
||||
import com.lxj.xpopup.XPopup
|
||||
|
||||
|
||||
class MessageFragment : TitleBarFragment<HomeActivity>(), TabAdapter.OnTabListener,
|
||||
@ -54,10 +53,11 @@ class MessageFragment : TitleBarFragment<HomeActivity>(), TabAdapter.OnTabListen
|
||||
|
||||
ivMore?.setOnClickListener {
|
||||
XPopup.Builder(context)
|
||||
.isTouchThrough(false)
|
||||
.hasShadowBg(false)
|
||||
.isTouchThrough(true)
|
||||
.atView(ivMore)
|
||||
.hasShadowBg(true)
|
||||
.hasNavigationBar(true)
|
||||
.hasShadowBg(false)
|
||||
.hasNavigationBar(false)
|
||||
.asCustom(context?.let { it1 ->
|
||||
CustomBubbleAttachPopup(
|
||||
it1,
|
||||
@ -115,10 +115,10 @@ class MessageFragment : TitleBarFragment<HomeActivity>(), TabAdapter.OnTabListen
|
||||
}
|
||||
|
||||
flSelectCheck?.setOnClickListener {
|
||||
if (cbSelectCheck?.isChecked == true) {
|
||||
if (cbSelectCheck?.isChecked == true){
|
||||
cbSelectCheck?.isChecked = false
|
||||
listTabOneFragment.setAllSelect(false)
|
||||
} else {
|
||||
}else{
|
||||
cbSelectCheck?.isChecked = true
|
||||
listTabOneFragment.setAllSelect(true)
|
||||
}
|
||||
@ -144,11 +144,10 @@ class MessageFragment : TitleBarFragment<HomeActivity>(), TabAdapter.OnTabListen
|
||||
|
||||
viewModel.meToHistoryAction.observe(this) { data ->
|
||||
viewPager?.currentItem = data
|
||||
when (data) {
|
||||
when(data) {
|
||||
0 -> {
|
||||
listTabOneFragment.onRefreshData()
|
||||
}
|
||||
|
||||
1 -> {
|
||||
listTabTwoFragment.onRefreshData()
|
||||
}
|
||||
@ -161,6 +160,7 @@ class MessageFragment : TitleBarFragment<HomeActivity>(), TabAdapter.OnTabListen
|
||||
}
|
||||
|
||||
|
||||
|
||||
val listTabOneFragment: ListTabFragment = ListTabFragment.newInstance(0)
|
||||
val listTabTwoFragment: ListTabFragment = ListTabFragment.newInstance(1)
|
||||
|
||||
@ -175,15 +175,8 @@ class MessageFragment : TitleBarFragment<HomeActivity>(), TabAdapter.OnTabListen
|
||||
tabAdapter = TabAdapter(getAttachActivity()!!)
|
||||
tabView?.adapter = tabAdapter
|
||||
|
||||
if (TranslatesUtils.translates() != null) {
|
||||
cbSelectCheck?.text = " " + TranslatesUtils.translates()?.mireo_select_all
|
||||
tvCancel?.text = TranslatesUtils.translates()?.mireo_cancel
|
||||
tabAdapter?.addItem(TranslatesUtils.translates()?.mireo_follow_list)
|
||||
tabAdapter?.addItem(TranslatesUtils.translates()?.mireo_play_list)
|
||||
} else {
|
||||
tabAdapter?.addItem("Follow List")
|
||||
tabAdapter?.addItem("Play List")
|
||||
}
|
||||
tabAdapter?.setOnTabListener(this)
|
||||
|
||||
|
||||
@ -198,18 +191,6 @@ class MessageFragment : TitleBarFragment<HomeActivity>(), TabAdapter.OnTabListen
|
||||
}
|
||||
}
|
||||
|
||||
override fun onPause() {
|
||||
super.onPause()
|
||||
if (tabView?.visibility == View.VISIBLE) {
|
||||
tvCancel?.visibility = View.GONE
|
||||
ivMore?.visibility = View.VISIBLE
|
||||
tabView?.visibility = View.VISIBLE
|
||||
cbSelectCheck?.isChecked = false
|
||||
flSelectCheck?.visibility = View.GONE
|
||||
listTabOneFragment.setCancel()
|
||||
}
|
||||
}
|
||||
|
||||
override fun initData() {}
|
||||
|
||||
|
@ -0,0 +1,153 @@
|
||||
package com.localee.mireo.app.ui.fragment
|
||||
|
||||
import android.content.Intent
|
||||
import android.view.View
|
||||
import android.widget.TextView
|
||||
import androidx.fragment.app.activityViewModels
|
||||
import androidx.recyclerview.widget.LinearLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import com.hjq.http.EasyHttp
|
||||
import com.hjq.http.listener.HttpCallbackProxy
|
||||
import com.localee.mireo.app.R
|
||||
import com.localee.mireo.app.aop.SingleClick
|
||||
import com.localee.mireo.app.app.TitleBarFragment
|
||||
import com.localee.mireo.app.http.api.HistoryBean
|
||||
import com.localee.mireo.app.http.api.MyHistoryApi
|
||||
import com.localee.mireo.app.http.api.UserInfoApi
|
||||
import com.localee.mireo.app.http.api.UserInfoRes
|
||||
import com.localee.mireo.app.http.model.HttpData
|
||||
import com.localee.mireo.app.other.MsConstants
|
||||
import com.localee.mireo.app.other.MsConstants.CONSTANTS_short_play_id
|
||||
import com.localee.mireo.app.ui.activity.AboutActivity
|
||||
import com.localee.mireo.app.ui.activity.BrowserActivity
|
||||
import com.localee.mireo.app.ui.activity.HomeActivity
|
||||
import com.localee.mireo.app.ui.activity.SettingActivity
|
||||
import com.localee.mireo.app.ui.activity.VideoPlayActivity
|
||||
import com.localee.mireo.app.ui.adapter.MeHistoryAdapter
|
||||
import com.localee.mireo.app.utils.MsMMKVUtils
|
||||
|
||||
|
||||
class MineFragment : TitleBarFragment<HomeActivity>() {
|
||||
|
||||
private val tvId: TextView? by lazy { findViewById(R.id.tv_id) }
|
||||
private val recyclerView: RecyclerView? by lazy { findViewById(R.id.recyclerView) }
|
||||
|
||||
private var mAdapter: MeHistoryAdapter? = null
|
||||
|
||||
private val viewModel: SharedViewModel by activityViewModels()
|
||||
|
||||
companion object {
|
||||
|
||||
fun newInstance(): MineFragment {
|
||||
return MineFragment()
|
||||
}
|
||||
}
|
||||
|
||||
override fun getLayoutId(): Int {
|
||||
return R.layout.mine_fragment
|
||||
}
|
||||
|
||||
override fun initView() {
|
||||
setOnClickListener(
|
||||
R.id.sb_play_list,
|
||||
R.id.sb_setting,
|
||||
R.id.sb_privacy,
|
||||
R.id.sb_agreement,
|
||||
R.id.sb_about
|
||||
)
|
||||
|
||||
recyclerView?.layoutManager =
|
||||
LinearLayoutManager(context, LinearLayoutManager.HORIZONTAL, false)
|
||||
|
||||
mAdapter = MeHistoryAdapter()
|
||||
recyclerView?.adapter = mAdapter
|
||||
|
||||
mAdapter?.setOnItemClickListener { adapter, view, position ->
|
||||
val data: HistoryBean.Data = adapter.items[position]
|
||||
startActivity(
|
||||
Intent(
|
||||
context,
|
||||
VideoPlayActivity::class.java
|
||||
).apply {
|
||||
putExtra(CONSTANTS_short_play_id, data.short_play_id)
|
||||
})
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
override fun initData() {
|
||||
tvId?.text = "ID:".plus(MsMMKVUtils.getUserInfo()?.customer_id)
|
||||
}
|
||||
|
||||
private var isDataLoaded = false
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
if (isVisible && !isDataLoaded) {
|
||||
getCustomerUser()
|
||||
isDataLoaded = true
|
||||
}
|
||||
getMyHistory(1, 20)
|
||||
}
|
||||
|
||||
@SingleClick
|
||||
override fun onClick(view: View) {
|
||||
when (view.id) {
|
||||
R.id.sb_play_list -> {
|
||||
viewModel.triggerAction(2)
|
||||
viewModel.meToHistoryAction(1)
|
||||
}
|
||||
|
||||
R.id.sb_setting -> {
|
||||
startActivity(SettingActivity::class.java)
|
||||
}
|
||||
|
||||
R.id.sb_privacy -> {
|
||||
BrowserActivity.start(getAttachActivity()!!, MsConstants.Constants_privacy_policy)
|
||||
}
|
||||
|
||||
R.id.sb_agreement -> {
|
||||
BrowserActivity.start(getAttachActivity()!!, MsConstants.Constants_user_agreement)
|
||||
}
|
||||
|
||||
R.id.sb_about -> {
|
||||
startActivity(AboutActivity::class.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getCustomerUser() {
|
||||
EasyHttp.get(this)
|
||||
.api(UserInfoApi().apply {
|
||||
})
|
||||
.request(object : HttpCallbackProxy<HttpData<UserInfoRes>>(this) {
|
||||
override fun onHttpSuccess(result: HttpData<UserInfoRes>) {
|
||||
result.getData()?.let {
|
||||
|
||||
MsMMKVUtils.saveUserInfo(it)
|
||||
tvId?.text = "ID:".plus(MsMMKVUtils.getUserInfo()?.customer_id)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
private fun getMyHistory(currentPage: Int, pageSize: Int) {
|
||||
EasyHttp.get(this)
|
||||
.api(MyHistoryApi().apply {
|
||||
current_page = currentPage
|
||||
page_size = pageSize
|
||||
})
|
||||
.request(object : HttpCallbackProxy<HttpData<HistoryBean>>(this) {
|
||||
override fun onHttpSuccess(result: HttpData<HistoryBean>) {
|
||||
result.getData()?.let {
|
||||
mAdapter?.submitList(it.list)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
override fun isStatusBarEnabled(): Boolean {
|
||||
return !super.isStatusBarEnabled()
|
||||
}
|
||||
}
|
@ -32,11 +32,4 @@ class SharedViewModel : ViewModel() {
|
||||
fun meToHistoryCheckAction(data: Int) {
|
||||
_meToHistoryCheckAction.value = data
|
||||
}
|
||||
|
||||
private val _loginAction = MutableLiveData<Int>()
|
||||
val loginAction: LiveData<Int> get() = _loginAction
|
||||
|
||||
fun loginAction(data: Int) {
|
||||
_loginAction.value = data
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user