flutter 手写日历组件

先看效果

 直接上代码

calendar_popup_view.dart

import 'package:flutter/material.dart';
import 'package:intl/intl.dart';import 'custom_calendar.dart';
import 'hotel_app_theme.dart';class CalendarPopupView extends StatefulWidget {const CalendarPopupView({required this.initialStartDate,required this.initialEndDate,required this.onApplyClick,required this.onCancelClick,required this.state,this.minimumDate,this.maximumDate,this.barrierDismissible = true,super.key,});final DateTime? minimumDate;final DateTime? maximumDate;final bool barrierDismissible;final DateTime initialStartDate;final DateTime initialEndDate;final Function(DateTime, DateTime) onApplyClick;final Function onCancelClick;final Function state;@overrideState<CalendarPopupView> createState() => _CalendarPopupViewState();
}class _CalendarPopupViewState extends State<CalendarPopupView>with TickerProviderStateMixin {late DateTime startDate;late DateTime endDate;late final AnimationController animationController;late DateTime curSelectStartData;late DateTime curSelectEndData;@overridevoid initState() {super.initState();animationController = AnimationController(duration: const Duration(milliseconds: 400), vsync: this);startDate = widget.initialStartDate;endDate = widget.initialEndDate;curSelectStartData = startDate;curSelectEndData = endDate;animationController.forward();}@overridevoid dispose() {animationController.dispose();super.dispose();}@overrideWidget build(BuildContext context) {return AnimatedBuilder(animation: animationController,builder: (BuildContext context, _) {return AnimatedOpacity(duration: const Duration(milliseconds: 100),opacity: animationController.value,child: InkWell(splashColor: Colors.transparent,focusColor: Colors.transparent,highlightColor: Colors.transparent,hoverColor: Colors.transparent,onTap: () {if (widget.barrierDismissible) {Navigator.pop(context);}},child: Container(decoration: BoxDecoration(color: HotelAppTheme.buildLightTheme().colorScheme.background,borderRadius: const BorderRadius.all(Radius.circular(24.0)),boxShadow: <BoxShadow>[BoxShadow(color: Colors.grey.withOpacity(0.2),offset: const Offset(4, 4),blurRadius: 8.0),],),child: Column(mainAxisAlignment: MainAxisAlignment.center,crossAxisAlignment: CrossAxisAlignment.start,mainAxisSize: MainAxisSize.min,children: <Widget>[Row(children: <Widget>[Expanded(child: Column(mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[Text('From',textAlign: TextAlign.left,style: grayTitle(),),const SizedBox(height: 4,),Text(DateFormat('EEE, dd MMM').format(curSelectStartData),style:curSelectStartData == widget.initialStartDate? grayTime(): primaryTime(),),],),),Container(height: 74,width: 1,color: HotelAppTheme.buildLightTheme().dividerColor,),Expanded(child: Column(mainAxisAlignment: MainAxisAlignment.center,children: <Widget>[Text('To',style: grayTitle(),),const SizedBox(height: 4),Text(DateFormat('EEE, dd MMM').format(curSelectEndData),style: curSelectEndData == widget.initialEndDate? grayTime(): primaryTime(),),],),)],),const Divider(height: 1),CustomCalendarView(minimumDate: widget.minimumDate,maximumDate: widget.maximumDate,initialEndDate: widget.initialEndDate,initialStartDate: widget.initialStartDate,startEndDateChange:(DateTime startDateData, DateTime endDateData) {if (mounted) {setState(() {startDate = startDateData;endDate = endDateData;curSelectStartData = startDateData;curSelectEndData = endDateData;});toUpdateState();}},endDateChange: (DateTime endData) {print("endDateChange");setState(() {endDate = endData;curSelectEndData = endData;});toUpdateState();},startDateChange: (DateTime startData) {print("startDateChange");setState(() {startDate = startData;curSelectStartData = startData;});toUpdateState();}),Padding(padding: const EdgeInsets.only(left: 16, right: 16, bottom: 16, top: 8),child: Container(height: 48,decoration: BoxDecoration(color: HotelAppTheme.buildLightTheme().primaryColor,borderRadius:const BorderRadius.all(Radius.circular(24.0)),boxShadow: <BoxShadow>[BoxShadow(color: Colors.grey.withOpacity(0.6),blurRadius: 8,offset: const Offset(4, 4),),],),child: Material(color: Colors.transparent,child: InkWell(borderRadius:const BorderRadius.all(Radius.circular(24.0)),highlightColor: Colors.transparent,onTap: () {try {// animationController?.reverse().then((f) {// });widget.onApplyClick(startDate, endDate);Navigator.pop(context);} catch (_) {}},child: const Center(child: Text('Apply',style: TextStyle(fontWeight: FontWeight.w500,fontSize: 18,color: Colors.white),),),),),),)],),),),);},);}toUpdateState() {widget.state(() {});}TextStyle grayTitle() {return const TextStyle(fontWeight: FontWeight.w100,fontSize: 16,color: Color(0xff676970),);}TextStyle grayTime() {return const TextStyle(fontWeight: FontWeight.bold,fontSize: 16,color: Color(0xff45474D),);}TextStyle primaryTime() {return TextStyle(fontWeight: FontWeight.bold,fontSize: 16,color: HotelAppTheme.buildLightTheme().primaryColorDark,);}
}

custom_calendar.dart

import 'package:app/common/util/k_date_util.dart';
import 'package:app/common/util/k_log_util.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:intl/intl.dart';import 'hotel_app_theme.dart';class CustomCalendarView extends StatefulWidget {const CustomCalendarView({required this.initialStartDate,required this.initialEndDate,required this.startEndDateChange,required this.startDateChange,required this.endDateChange,this.minimumDate,this.maximumDate,super.key,});final DateTime? minimumDate;final DateTime? maximumDate;final DateTime initialStartDate;final DateTime initialEndDate;final Function(DateTime, DateTime) startEndDateChange;final Function(DateTime) startDateChange;final Function(DateTime) endDateChange;@overrideState<CustomCalendarView> createState() => _CustomCalendarViewState();
}class _CustomCalendarViewState extends State<CustomCalendarView> {List<DateTime> dateList = <DateTime>[];DateTime currentMonthDate = DateTime.now();DateTime? startDate;DateTime? endDate;@overridevoid initState() {super.initState();setListOfDate(currentMonthDate);startDate = widget.initialStartDate;endDate = widget.initialEndDate;}@overridevoid dispose() {super.dispose();}void setListOfDate(DateTime monthDate) {dateList.clear();final DateTime newDate = DateTime(monthDate.year, monthDate.month, 0);int previousMothDay = 0;if (newDate.weekday < 7) {previousMothDay = newDate.weekday;for (int i = 1; i <= previousMothDay; i++) {dateList.add(newDate.subtract(Duration(days: previousMothDay - i)));}}for (int i = 0; i < (42 - previousMothDay); i++) {dateList.add(newDate.add(Duration(days: i + 1)));}// if (dateList[dateList.length - 7].month != monthDate.month) {//   dateList.removeRange(dateList.length - 7, dateList.length);// }}@overrideWidget build(BuildContext context) {return Container(child: Column(children: <Widget>[Padding(padding:const EdgeInsets.only(left: 8.0, right: 8.0, top: 4, bottom: 4),child: Row(children: <Widget>[Padding(padding: const EdgeInsets.all(8.0),child: Container(height: 38,width: 38,decoration: BoxDecoration(borderRadius:const BorderRadius.all(Radius.circular(24.0)),border: Border.all(color: HotelAppTheme.buildLightTheme().dividerColor,),),child: InkWell(borderRadius:const BorderRadius.all(Radius.circular(24.0)),onTap: () {if (mounted) {setState(() {if (getCurMonthIsInMinMaxRange(DateTime(currentMonthDate.year,currentMonthDate.month,0))) {currentMonthDate = DateTime(currentMonthDate.year,currentMonthDate.month, 0);setListOfDate(currentMonthDate);}});}},child: const Icon(Icons.keyboard_arrow_left,color: Colors.grey,),),),),Expanded(child: Center(child: Text(DateFormat('MMMM, yyyy').format(currentMonthDate),style: TextStyle(fontWeight: FontWeight.w500,fontSize: 15.sp,color: Colors.white,),),),),Padding(padding: const EdgeInsets.all(8.0),child: Container(height: 38,width: 38,decoration: BoxDecoration(borderRadius:const BorderRadius.all(Radius.circular(24.0)),border: Border.all(color: HotelAppTheme.buildLightTheme().dividerColor,),),child: InkWell(borderRadius:const BorderRadius.all(Radius.circular(24.0)),onTap: () {if (mounted) {setState(() {if (getCurMonthIsInMinMaxRange(DateTime(currentMonthDate.year,currentMonthDate.month + 2,0))) {currentMonthDate = DateTime(currentMonthDate.year,currentMonthDate.month + 2, 0);setListOfDate(currentMonthDate);}});}},child: const Icon(Icons.keyboard_arrow_right,color: Colors.grey,),),),),],),),Padding(padding: const EdgeInsets.only(right: 8, left: 8, bottom: 8),child: Row(children: getDaysNameUI(),),),Padding(padding: const EdgeInsets.only(right: 8, left: 8),child: Column(children: getDaysNoUI(),),),],),);}List<Widget> getDaysNameUI() {final List<Widget> listUI = <Widget>[];final weekendList = [5, 6];for (int i = 0; i < 7; i++) {listUI.add(Expanded(child: Center(child: Text(DateFormat('EEE').format(dateList[i]),style: TextStyle(fontSize: 14.sp,fontWeight: FontWeight.w500,color: weekendList.contains(i)? HotelAppTheme.buildLightTheme().primaryColorDark: Colors.white,),),),),);}return listUI;}List<Widget> getDaysNoUI() {final List<Widget> noList = <Widget>[];int count = 0;for (int i = 0; i < dateList.length / 7; i++) {final List<Widget> listUI = <Widget>[];for (int i = 0; i < 7; i++) {final DateTime date = dateList[count];listUI.add(Expanded(child: AspectRatio(aspectRatio: 1.0,child: Stack(children: <Widget>[Padding(padding: const EdgeInsets.only(top: 3, bottom: 3),child: Padding(padding: EdgeInsets.only(top: 0,bottom: 0,left: isStartDateRadius(date) ? 4 : 0,right: isEndDateRadius(date) ? 4 : 0),child: Container(decoration: BoxDecoration(color: startDate != null && endDate != null? getIsItStartAndEndDate(date) ||getIsInRange(date)? HotelAppTheme.buildLightTheme().primaryColorDark.withOpacity(0.1): Colors.transparent: Colors.transparent,borderRadius: BorderRadius.only(bottomLeft: isStartDateRadius(date)? Radius.circular(15.r): const Radius.circular(0.0),topLeft: isStartDateRadius(date)? Radius.circular(15.r): const Radius.circular(0.0),topRight: isEndDateRadius(date)? Radius.circular(15.r): const Radius.circular(0.0),bottomRight: isEndDateRadius(date)? Radius.circular(15.r): const Radius.circular(0.0),),),),),),InkWell(borderRadius: const BorderRadius.all(Radius.circular(32.0)),onTap: () {if (currentMonthDate.month == date.month) {final DateTime? minimumDate = widget.minimumDate;final DateTime? maximumDate = widget.maximumDate;if (minimumDate != null && maximumDate != null) {final DateTime newminimumDate = DateTime(minimumDate.year,minimumDate.month,minimumDate.day - 1);final DateTime newmaximumDate = DateTime(maximumDate.year,maximumDate.month,maximumDate.day + 1);if (date.isAfter(newminimumDate) &&date.isBefore(newmaximumDate)) {onDateClick(date);}} else if (minimumDate != null) {final DateTime newminimumDate = DateTime(minimumDate.year,minimumDate.month,minimumDate.day - 1);if (date.isAfter(newminimumDate)) {onDateClick(date);}} else if (maximumDate != null) {final DateTime newmaximumDate = DateTime(maximumDate.year,maximumDate.month,maximumDate.day + 1);if (date.isBefore(newmaximumDate)) {onDateClick(date);}} else {onDateClick(date);}}},child: Padding(padding: const EdgeInsets.all(2),child: Container(decoration: BoxDecoration(color: getIsItStartAndEndDate(date)? HotelAppTheme.buildLightTheme().primaryColorDark: Colors.transparent,borderRadius: getStartOrEndPoint(date),// border: Border.all(//   color: getIsItStartAndEndDate(date)//       ? Colors.white//       : Colors.transparent,//   width: 2,// ),// boxShadow: getIsItStartAndEndDate(date)//     ? <BoxShadow>[//         BoxShadow(//             color: Colors.grey.withOpacity(0.6),//             blurRadius: 4),//       ]//     : null,),child: Center(child: Text('${date.day}',style: ceilStyle(date),),),),),),Positioned(bottom: 9,right: 0,left: 0,child: Container(height: 6,width: 6,decoration: BoxDecoration(color: DateTime.now().day == date.day &&DateTime.now().month == date.month &&DateTime.now().year == date.year? getIsInRange(date)? Colors.white: HotelAppTheme.buildLightTheme().primaryColorDark: Colors.transparent,shape: BoxShape.circle),),),],),),),);count += 1;}noList.add(Row(mainAxisAlignment: MainAxisAlignment.center,mainAxisSize: MainAxisSize.min,children: listUI,));}return noList;}BorderRadius getStartOrEndPoint(DateTime date) {KLogUtil.log([startDate, endDate, KDateUtils.isSome(startDate, endDate)]);if (startDate.toString() == endDate.toString()) {return BorderRadius.all(Radius.circular(15.r),);} else if (getIsItStart(date)) {return BorderRadius.only(topLeft: Radius.circular(15.r),bottomLeft: Radius.circular(15.r),);} else {return BorderRadius.only(topRight: Radius.circular(15.r),bottomRight: Radius.circular(15.r),);}}// 日期每一格的样式TextStyle ceilStyle(DateTime date) {// 不能选择日期的样式if (!getIsInMinMaxRange(date)) {return TextStyle(color: Colors.grey.withOpacity(0.6),fontSize: MediaQuery.of(context).size.width > 360 ? 14.sp : 16.sp,fontWeight:getIsItStartAndEndDate(date) ? FontWeight.bold : FontWeight.normal,);}return TextStyle(color: getIsItStartAndEndDate(date) || getIsInRange(date)? Colors.white: currentMonthDate.month == date.month? Colors.white: Colors.grey.withOpacity(0.6),fontSize: MediaQuery.of(context).size.width > 360 ? 14.sp : 16.sp,fontWeight:getIsItStartAndEndDate(date) ? FontWeight.bold : FontWeight.normal);}bool getIsInMinMaxRange(DateTime date) {if (widget.minimumDate != null && widget.maximumDate != null) {if (date.isAfter(widget.minimumDate!) &&date.isBefore(widget.maximumDate!)) {return true;}}return false;}// 当前月份是否在bool getCurMonthIsInMinMaxRange(DateTime tgtMonth) {if (widget.minimumDate != null && widget.maximumDate != null) {if (tgtMonth.isAfter(DateTime(widget.minimumDate!.year, widget.minimumDate!.month, 0)) &&tgtMonth.isBefore(DateTime(widget.maximumDate!.year, widget.maximumDate!.month + 2, 0))) {return true;}}return false;}bool getIsInRange(DateTime date) {if (startDate != null && endDate != null) {if (date.isAfter(startDate!) && date.isBefore(endDate!)) {return true;}}return false;}bool getIsItStartAndEndDate(DateTime date) {if ((startDate != null &&startDate!.day == date.day &&startDate!.month == date.month &&startDate!.year == date.year) ||(endDate != null &&endDate!.day == date.day &&endDate!.month == date.month &&endDate!.year == date.year)) return true;return false;}bool getIsItStart(DateTime date) {if (startDate != null &&startDate!.day == date.day &&startDate!.month == date.month &&startDate!.year == date.year) return true;return false;}bool isStartDateRadius(DateTime date) {if (startDate != null &&startDate!.day == date.day &&startDate!.month == date.month) {return true;} else if (date.weekday == 1) {return true;} else {return false;}}bool isEndDateRadius(DateTime date) {if (endDate != null &&endDate!.day == date.day &&endDate!.month == date.month) {return true;} else if (date.weekday == 7) {return true;} else {return false;}}void onDateClick(DateTime date) {if (startDate == null) {startDate = date;} else if (startDate != date && endDate == null) {endDate = date;} else if (startDate!.day == date.day && startDate!.month == date.month) {// startDate = null;endDate = startDate;} else if (endDate != null &&endDate!.day == date.day &&endDate!.month == date.month) {if (endDate != null) {startDate = endDate;} else {endDate = null;}}if (startDate == null && endDate != null) {startDate = endDate;endDate = null;}if (startDate != null && endDate != null) {if (!endDate!.isAfter(startDate!)) {final DateTime d = startDate!;startDate = endDate;endDate = d;}if (date.isBefore(startDate!)) {startDate = date;} else if (date.isAfter(endDate!)) {endDate = date;} else {final int daysToStartDate = startDate!.difference(date).inDays.abs();final int daysToEndDate = endDate!.difference(date).inDays.abs();daysToStartDate > daysToEndDate ? endDate = date : startDate = date;}}if (mounted) {setState(() {if (startDate != null && endDate != null) {try {widget.startEndDateChange(startDate!, endDate!);} catch (_) {}}if (startDate != null) {try {widget.startDateChange(startDate!);} catch (_) {}}if (endDate != null) {try {widget.endDateChange(endDate!);} catch (_) {}}},);}}
}

hotel_app_theme.dart

import 'package:flutter/material.dart';class HotelAppTheme {static TextTheme _buildTextTheme(TextTheme base) {const String fontName = 'WorkSans';return base.copyWith(displayLarge: base.displayLarge?.copyWith(fontFamily: fontName),displayMedium: base.displayMedium?.copyWith(fontFamily: fontName),displaySmall: base.displaySmall?.copyWith(fontFamily: fontName),headlineMedium: base.headlineMedium?.copyWith(fontFamily: fontName),headlineSmall: base.headlineSmall?.copyWith(fontFamily: fontName),titleLarge: base.titleLarge?.copyWith(fontFamily: fontName),labelLarge: base.labelLarge?.copyWith(fontFamily: fontName),bodySmall: base.bodySmall?.copyWith(fontFamily: fontName),bodyLarge: base.bodyLarge?.copyWith(fontFamily: fontName),bodyMedium: base.bodyMedium?.copyWith(fontFamily: fontName),titleMedium: base.titleMedium?.copyWith(fontFamily: fontName),titleSmall: base.titleSmall?.copyWith(fontFamily: fontName),labelSmall: base.labelSmall?.copyWith(fontFamily: fontName),);}static ThemeData buildLightTheme() {// #54D3C2// #54D3C2// #4677FFconst Color primaryColor = Color(0xff1C1D1F);const Color secondaryColor = Color(0xff1C1D1F);const Color primaryColorDark = Color(0xff4677FF);final ColorScheme colorScheme = const ColorScheme.light().copyWith(primary: primaryColor,secondary: secondaryColor,);final ThemeData base = ThemeData.light();return base.copyWith(primaryColor: primaryColor,primaryColorDark: primaryColorDark,indicatorColor: Colors.white,splashColor: Colors.white24,splashFactory: InkRipple.splashFactory,canvasColor: Colors.white,// #F6F6F6scaffoldBackgroundColor: const Color(0xFFF6F6F6),buttonTheme: ButtonThemeData(colorScheme: colorScheme,textTheme: ButtonTextTheme.primary,),textTheme: _buildTextTheme(base.textTheme),primaryTextTheme: _buildTextTheme(base.primaryTextTheme),platform: TargetPlatform.iOS,colorScheme: colorScheme.copyWith(background: const Color(0xff1C1D1F))// #B00020.copyWith(error: const Color(0xFFB00020)),);}
}

RangePicker.dart  这个文件是使用的地方 这里还使用到了  getx 的组件 从底部弹出

// ignore_for_file: file_namesimport 'package:app/gen/assets.gen.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
import 'package:intl/intl.dart';import 'calendar_popup_view.dart';class RangePicker extends StatefulWidget {RangePicker({super.key, required this.apply});final Function(DateTime, DateTime) apply;@overrideState<RangePicker> createState() => _RangePickerState();
}class _RangePickerState extends State<RangePicker> {DateTime startDate = DateTime.now().subtract(const Duration(days: 90));DateTime endDate = DateTime.now();@overrideWidget build(BuildContext context) {return GestureDetector(onTap: () {openCalendarPopupView(context);},child: Row(children: [Text("${DateFormat('MM/dd').format(startDate)} - ${DateFormat('MM/dd').format(endDate)}",style: TextStyle(color: const Color(0xff676970),fontWeight: FontWeight.w500,fontSize: 12.sp,),),SizedBox(width: 4.w,),Assets.icon.botomArrowhead.image(width: 17.w),],),);}void openCalendarPopupView(BuildContext context) {Get.bottomSheet(isScrollControlled: true,StatefulBuilder(builder: (context, state) {return CalendarPopupView(state: state,minimumDate: DateTime.now().subtract(const Duration(days: 365)),maximumDate: DateTime.now(),initialEndDate: endDate,initialStartDate: startDate,onApplyClick: (DateTime startData, DateTime endData) {if (mounted) {setState(() {startDate = startData;endDate = endData;});state(() {startDate = startData;endDate = endData;});widget.apply(startDate, endDate);}},onCancelClick: () {},);}),);}
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/30000.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【【萌新的STM32 学习-6】】

萌新的STM32 学习-6 BSP 文件夹&#xff0c;用于存放正点原子提供的板级支持包驱动代码&#xff0c;如&#xff1a;LED、蜂鸣器、按键等。 本章我们暂时用不到该文件夹&#xff0c;不过可以先建好备用。 CMSIS 文件夹&#xff0c;用于存放 CMSIS 底层代码&#xff08;ARM 和 ST…

深度学习之用PyTorch实现逻辑回归

0.1 学习视频源于&#xff1a;b站&#xff1a;刘二大人《PyTorch深度学习实践》 0.2 本章内容为自主学习总结内容&#xff0c;若有错误欢迎指正&#xff01; 代码&#xff08;类比线性回归&#xff09;&#xff1a; # 调用库 import torch import torch.nn.functional as F#…

HDFS小文件解决方案---archive归档文件命令

小文件解决方案 背景Archive概述创建archive查看归档文件查看归档之后的样子查看归档文件之前的样子 提取archivearchive注意事项 背景 hdfs并不擅长存储小文件&#xff0c;因为每个文件最少一个block&#xff0c;每个block的元数据都会在namenode占用内存&#xff0c;如果存在…

Linux驱动之设备树添加蜂鸣器驱动

目录 一、蜂鸣器简介 二、硬件原理分析 三、蜂鸣器驱动原理 四、开发环境 五、修改设备树文件 1、添加 pinctrl 节点 2、添加 BEEP 设备节点 3、检查 PIN 是否被其他外设使用 六、蜂鸣器驱动程序编写 七、测试程序编写 八、运行验证 在 I.MX6U-ALPHA 开发板上有一个有源…

一种水文水利行业满管非满管双声道流量计安装调试

供电电源 用户应该特别注意&#xff1a;若是交流&#xff08;AC220V&#xff09;供电的主机插入直流电源&#xff0c;或者直流&#xff08;DC24V&#xff09;供电的主机接入AC220V电源&#xff0c;就会把流量计烧毁。 普通主机&#xff08;包括固定式主机、盘装式主机&#x…

前沿分享-无创检测血糖RF波

非侵入性血糖仪&#xff0c;利用射频 (RF) 波连续测量血液中的葡萄糖水平。利用射频波技术连续实时监测血液中的葡萄糖水平&#xff0c;使用的辐射要比手机少得多。 大概原理是血液中的葡萄糖是具有介电特性&#xff0c;一般来说就是介电常数。 电磁波波幅的衰减反映了介质对电…

火车头采集器AI伪原创【php源码】

大家好&#xff0c;本文将围绕python作业提交什么文件展开说明&#xff0c;python123怎么提交作业是一个很多人都想弄明白的事情&#xff0c;想搞清楚python期末作业程序需要先了解以下几个事情。 火车头采集ai伪原创插件截图&#xff1a; I have a python project, whose fold…

FFmpeg常见命令行(二):FFmpeg转封装

前言 在Android音视频开发中&#xff0c;网上知识点过于零碎&#xff0c;自学起来难度非常大&#xff0c;不过音视频大牛Jhuster提出了《Android 音视频从入门到提高 - 任务列表》。本文是Android音视频任务列表的其中一个&#xff0c; 对应的要学习的内容是&#xff1a;如何使…

C# 2048小游戏核心算法

文章目录 01.程序结构划分02.去零03.合并04.上移05.下移/左移/右移&#xff0c;只是取数据的方向不同06.提高可读性 01.程序结构划分 02.去零 有序向量“唯一化”的思路。 /// <summary>/// 去零/// </summary>/// <param name"row">对于一行或一…

Clash 意外退出后 chrome / google 谷歌 浏览器无法连接互联网

解决方案&#xff1a; 以管理员模式打开命令行&#xff0c;输入&#xff1a;netsh winsock reset &#xff0c;然后重启电脑 如果还不行的话&#xff0c; 在 chromevs中选中 设置>隐私和安全>安全>使用安全 dns> 使用您当前的服务提供商 即可

数据结构和算法——哈希查找冲突处理方法(开放地址法-线性探测、平方探测、双散列探测、再散列,分离链接法)

目录 开放地址法&#xff08;Open Addressing&#xff09; 线性探测&#xff08;Linear Probing&#xff09; 散列表查找性能分析 平方探测&#xff08;Quadratic Probing&#xff09; 定理 平方探测法的查找与插入 双散列探测法&#xff08;Double Hashing&#xff09…

分布式 - 消息队列Kafka:Kafka生产者发送消息的3种方式

文章目录 1. Kafka 生产者2. kafaka 命令行操作3. Kafka 生产者发送消息流程4. Kafka 生产者发送消息的3种方式1. 发送即忘记2. 同步发送3. 异步发送 5. Kafka 消息对象 ProducerRecord 1. Kafka 生产者 Kafka 生产者是指使用 Apache Kafka 消息系统的应用程序&#xff0c;它们…

Pytorch深度学习-----神经网络模型的保存与加载(VGG16模型)

系列文章目录 PyTorch深度学习——Anaconda和PyTorch安装 Pytorch深度学习-----数据模块Dataset类 Pytorch深度学习------TensorBoard的使用 Pytorch深度学习------Torchvision中Transforms的使用&#xff08;ToTensor&#xff0c;Normalize&#xff0c;Resize &#xff0c;Co…

Git介绍及常用命令详解

一、Git的概述 Git是一个分布式版本控制工具&#xff0c;通常用来对软件开发过程中的源代码文件进行管理。 Git 会跟踪我们对文件所做的更改&#xff0c;因此我们可以记录已完成的工作&#xff0c;并且可以在需要时恢复到特定或以前的版本。Git 还使多人协作变得更加容易&…

Linux系统中的自旋锁(两幅图清晰说明)

总结&#xff1a; 多CPU下的自旋锁采取的是忙等待&#xff08;原地打转&#xff09;机制&#xff0c;虽然忙等待的线程占用了它所在的cpu&#xff0c;但其他线程仍可放到其他CPU上执行。所以自旋锁上锁和解锁之间的临界区代码要尽量的短&#xff0c;最好不要超过5行&#xff0c…

jenkins流水线

1.拉取代码 https://gitee.com/Wjc_project/yygh-parent.git2、项目编译 mvn clean package -Dmaven.test.skiptrue ls hospital-manage/target3、构建镜像 ls hospital-manage/target docker build -t hospital-manage:latest -f hospital-manage/Dockerfile ./hospital-ma…

AWD攻防学习总结(草稿状态,待陆续补充)

AWD攻防学习总结 防守端1、修改密码2、备份网站3、备份数据库4、部署WAF5、部署文件监控脚本6、部署流量监控脚本/工具7、D盾扫描&#xff0c;删除预留webshell8、代码审计&#xff0c;seay/fortify扫描&#xff0c;漏洞修复及利用9、时刻关注流量和积分信息&#xff0c;掉分时…

业绩难言乐观,皓泽电子撤回上市申请,小米等为其关联方

撰稿|行星 来源|贝多财经 8月8日&#xff0c;深圳证券交易所披露的信息显示&#xff0c;由于河南皓泽电子股份有限公司&#xff08;下称“皓泽电子”&#xff09;及其保荐人主动要求撤回申请文件&#xff0c;深交所终止了皓泽电子的发行注册程序。 据此前招股书披露&#xff…

python爬虫实战(1)--爬取新闻数据

想要每天看到新闻数据又不想占用太多时间去整理&#xff0c;萌生自己抓取新闻网站的想法。 1. 准备工作 使用python语言可以快速实现&#xff0c;调用BeautifulSoup包里面的方法 安装BeautifulSoup pip install BeautifulSoup完成以后引入项目 2. 开发 定义请求头&#xf…

Fast Tone Mapping for High Dynamic Range Images

Abstract 我们提出了一种快速、有效、灵活的色调再现方法&#xff0c;在低动态范围再现设备中保留了高动态范围场景的可视性和对比度印象。 一个单一的参数控制能见度和对比度在一个简单和优雅的方式和互动速度。 新方法使用简单&#xff0c;计算效率高。 实验表明&#xff0c…