fix:切换播放问题

This commit is contained in:
zengyi 2025-09-24 11:37:15 +08:00
parent 7120208013
commit 96d6ef8f75
4 changed files with 275 additions and 226 deletions

View File

@ -6,6 +6,11 @@ plugins {
// The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins.
id("dev.flutter.flutter-gradle-plugin") id("dev.flutter.flutter-gradle-plugin")
} }
val signingProperties =
project.rootProject.file("key.properties").takeIf { it.exists() }
?.reader()
?.use { Properties().apply { load(it) } }
?: Properties()
android { android {
namespace = "com.kinetra.adehok.app" namespace = "com.kinetra.adehok.app"
@ -31,13 +36,44 @@ android {
targetSdk = flutter.targetSdkVersion targetSdk = flutter.targetSdkVersion
versionCode = flutter.versionCode versionCode = flutter.versionCode
versionName = flutter.versionName versionName = flutter.versionName
ndk {
abiFilters.clear()
abiFilters.add("armeabi-v7a")
abiFilters.add("arm64-v8a")
}
} }
signingConfigs {
create("release") {
storeFile = file(signingProperties["storeFile"].toString())
storePassword = signingProperties["storePassword"].toString()
keyAlias = signingProperties["keyAlias"].toString()
keyPassword = signingProperties["keyPassword"].toString()
}
}
splits {
abi {
isEnable = false
}
}
buildTypes { buildTypes {
release { release {
// TODO: Add your own signing config for the release build. isMinifyEnabled = true
// Signing with the debug keys for now, so `flutter run --release` works. isShrinkResources = true
signingConfig = signingConfigs.getByName("debug") proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
// 签名配置
signingConfig = signingConfigs.getByName("release")
}
debug {
signingConfig = signingConfigs.getByName("release")
} }
} }
} }

View File

@ -11,6 +11,7 @@ import '../../dio_cilent/kt_request.dart';
import '../../kt_model/kt_short_video_bean.dart'; import '../../kt_model/kt_short_video_bean.dart';
import '../../kt_utils/kt_device_info_utils.dart'; import '../../kt_utils/kt_device_info_utils.dart';
import '../../kt_widgets/kt_status_widget.dart'; import '../../kt_widgets/kt_status_widget.dart';
import '../kt_main_page/view.dart';
class KtExploreLogic extends GetxController { class KtExploreLogic extends GetxController {
final state = KtExploreState(); final state = KtExploreState();
@ -165,7 +166,8 @@ class KtExploreLogic extends GetxController {
try { try {
await controller.initialize(); await controller.initialize();
if (index == state.currentPage) { if (index == state.currentPage) {
controller.play(); final mainLogic = Get.find<KtMainLogic>();
if(mainLogic.curIndex == 1) controller.play();
update(); update();
} }
controller.addListener(() { controller.addListener(() {

View File

@ -1,4 +1,5 @@
import 'package:easy_refresh/easy_refresh.dart'; import 'package:easy_refresh/easy_refresh.dart';
import 'package:flutter/material.dart';
import 'package:flutter_kinetra/kt_model/kt_home_category_bean.dart'; import 'package:flutter_kinetra/kt_model/kt_home_category_bean.dart';
import 'package:flutter_kinetra/kt_pages/kt_home/state.dart'; import 'package:flutter_kinetra/kt_pages/kt_home/state.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';

View File

@ -5,7 +5,6 @@ import 'package:flutter_kinetra/kt_utils/kt_string_extend.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart'; import 'package:get/get.dart';
import '../../kt_utils/kt_keys.dart';
import '../kt_explore/view.dart'; import '../kt_explore/view.dart';
import '../kt_home/view.dart'; import '../kt_home/view.dart';
import '../kt_mine/view.dart'; import '../kt_mine/view.dart';
@ -21,11 +20,12 @@ class KtMainPage extends StatefulWidget {
class _KtMainPageState extends State<KtMainPage> class _KtMainPageState extends State<KtMainPage>
with RouteAware, WidgetsBindingObserver { with RouteAware, WidgetsBindingObserver {
final logic = Get.put(KtMainLogic());
final PageController _controller = PageController(); final PageController _controller = PageController();
static const List _tabsTitle = [ static const List _tabsTitle = [
{'icon': 'home', 'title': 'Home'}, {'icon': 'home', 'title': 'Home'},
{'icon': 'explore', 'title': 'Explore'}, {'icon': 'explore', 'title': 'Explore'},
{'icon': 'actor', 'title': 'Actor'}, {'icon': 'actor', 'title': 'Actors'},
{'icon': 'favorite', 'title': 'My List'}, {'icon': 'favorite', 'title': 'My List'},
{'icon': 'mine', 'title': 'Profile'}, {'icon': 'mine', 'title': 'Profile'},
]; ];
@ -79,12 +79,15 @@ class _KtMainPageState extends State<KtMainPage>
} }
} }
}, },
child: Scaffold( child: GetBuilder<KtMainLogic>(
builder: (ctrl) {
return Scaffold(
body: PageView.builder( body: PageView.builder(
controller: _controller, controller: _controller,
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
onPageChanged: (index) { onPageChanged: (index) {
_currentIndex = index; _currentIndex = index;
logic.curIndex = index;
setState(() {}); setState(() {});
}, },
itemBuilder: (context, index) => _getTab(index), itemBuilder: (context, index) => _getTab(index),
@ -105,6 +108,7 @@ class _KtMainPageState extends State<KtMainPage>
currentIndex: _currentIndex, currentIndex: _currentIndex,
onTap: (index) { onTap: (index) {
_currentIndex = index; _currentIndex = index;
logic.curIndex = index;
_controller.jumpToPage(index); _controller.jumpToPage(index);
final myListLogic = Get.put(MyListLogic()); final myListLogic = Get.put(MyListLogic());
myListLogic.initData(); myListLogic.initData();
@ -134,6 +138,8 @@ class _KtMainPageState extends State<KtMainPage>
), ),
], ],
), ),
);
}
), ),
); );
} }
@ -332,3 +338,7 @@ class _KtMainPageState extends State<KtMainPage>
// EasyThrottle.throttle('restore', Duration(minutes: 5), () => BuyUtils.restorePay(showTips: false)); // EasyThrottle.throttle('restore', Duration(minutes: 5), () => BuyUtils.restorePay(showTips: false));
// } // }
} }
class KtMainLogic extends GetxController{
int curIndex = 0;
}