mirror of
https://github.com/bggRGjQaUbCoE/PiliPlus.git
synced 2026-05-30 23:58:13 +08:00
mod: pop back
This commit is contained in:
@@ -4,6 +4,7 @@ import io.flutter.embedding.android.FlutterActivity
|
|||||||
import io.flutter.embedding.engine.FlutterEngine
|
import io.flutter.embedding.engine.FlutterEngine
|
||||||
import io.flutter.plugin.common.MethodChannel
|
import io.flutter.plugin.common.MethodChannel
|
||||||
import com.ryanheise.audioservice.AudioServiceActivity
|
import com.ryanheise.audioservice.AudioServiceActivity
|
||||||
|
import android.content.Intent
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.WindowManager.LayoutParams
|
import android.view.WindowManager.LayoutParams
|
||||||
@@ -14,6 +15,21 @@ class MainActivity : AudioServiceActivity() {
|
|||||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||||
super.configureFlutterEngine(flutterEngine)
|
super.configureFlutterEngine(flutterEngine)
|
||||||
methodChannel = MethodChannel(flutterEngine!!.getDartExecutor()!!.getBinaryMessenger(), CHANNEL)
|
methodChannel = MethodChannel(flutterEngine!!.getDartExecutor()!!.getBinaryMessenger(), CHANNEL)
|
||||||
|
methodChannel.setMethodCallHandler { call, result ->
|
||||||
|
if (call.method == "back") {
|
||||||
|
back()
|
||||||
|
} else {
|
||||||
|
result.notImplemented()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun back() {
|
||||||
|
val intent = Intent(Intent.ACTION_MAIN).apply {
|
||||||
|
addCategory(Intent.CATEGORY_HOME)
|
||||||
|
flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
|
}
|
||||||
|
startActivity(intent)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onCreate(savedInstanceState: Bundle?) {
|
override fun onCreate(savedInstanceState: Bundle?) {
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import 'dart:async';
|
import 'dart:async';
|
||||||
|
import 'dart:io';
|
||||||
|
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
|
||||||
@@ -55,18 +56,24 @@ class MainController extends GetxController {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onBackPressed(BuildContext context) {
|
void onBackPressed(BuildContext context) {
|
||||||
if (_lastPressedAt == null ||
|
// if (_lastPressedAt == null ||
|
||||||
DateTime.now().difference(_lastPressedAt!) >
|
// DateTime.now().difference(_lastPressedAt!) >
|
||||||
const Duration(seconds: 2)) {
|
// const Duration(seconds: 2)) {
|
||||||
// 两次点击时间间隔超过2秒,重新记录时间戳
|
// 两次点击时间间隔超过2秒,重新记录时间戳
|
||||||
_lastPressedAt = DateTime.now();
|
// _lastPressedAt = DateTime.now();
|
||||||
if (selectedIndex != 0) {
|
if (selectedIndex != 0) {
|
||||||
pageController.jumpTo(0);
|
pageController.jumpTo(0);
|
||||||
|
} else {
|
||||||
|
if (Platform.isAndroid) {
|
||||||
|
const MethodChannel("onUserLeaveHint").invokeMethod('back');
|
||||||
|
} else {
|
||||||
|
SystemNavigator.pop(); // 退出应用
|
||||||
}
|
}
|
||||||
SmartDialog.showToast("再按一次退出PiliPalaX");
|
|
||||||
return; // 不退出应用
|
|
||||||
}
|
}
|
||||||
SystemNavigator.pop(); // 退出应用
|
// SmartDialog.showToast("再按一次退出PiliPalaX");
|
||||||
|
// return; // 不退出应用
|
||||||
|
// }
|
||||||
|
// SystemNavigator.pop(); // 退出应用
|
||||||
}
|
}
|
||||||
|
|
||||||
void getUnreadDynamic() async {
|
void getUnreadDynamic() async {
|
||||||
|
|||||||
Reference in New Issue
Block a user