java 按月分组_android日历选择按月分组并用recyclerview展示-程序员宅基地

技术标签: java 按月分组  

今天分享一个日历选择控件,可以定义日期可选、选择范围、按月分组展示。这个日历无非就是把每个日期的数据通过系统的日历查询出来,然后用recyclerview展示即可,数据模型里可以定义哪些可选以及选定状态等等。思路就是这样了,先看看效果:

bd21d8d9422f

日历效果

首先定义好数据来源,即从系统的calendar获取日期列表,这里因为是要按月分组,所以我选择用一个key为月份的时间戳value为对应月份的所有日期list的map来接收查询出来的日历,在展示的时候把map转为分组的list即可:

import android.annotation.SuppressLint;

import androidx.annotation.NonNull;

import java.text.ParseException;

import java.text.SimpleDateFormat;

import java.util.ArrayList;

import java.util.Calendar;

import java.util.Date;

import java.util.LinkedHashMap;

/**

* 日历工具类

* @author ly

* date 2020/4/24 9:52

*/

public class CalendarUtils {

public final static String YEAR = "yyyy";

public final static String YEAR_MONTH = "yyyy年MM月";

public final static String MONTH_DAY = "MM-dd";

public final static String DATE = "yyyy-MM-dd";

public final static String TIME = "HH:mm";

public final static String MONTH_DAY_TIME = "MM月dd日 hh:mm";

public final static String DATE_TIME_SECOND = "yyyy-MM-dd HH:mm:ss";

public final static String DATE_TIME = "yyyy-MM-dd HH:mm";

public final static String DATE1_TIME = "yyyy/MM/dd HH:mm";

public static @NonNull

LinkedHashMap> getMonthMap(Calendar initialCalendar, int monthNum) {

return getMonthMap(initialCalendar, monthNum, Integer.MAX_VALUE);

}

public static @NonNull

LinkedHashMap> getMonthByLimit(Calendar initialCalendar, int validSelNumLimit) {

return getMonthMap(initialCalendar, Integer.MAX_VALUE, validSelNumLimit);

}

/**

* 以月为单位,获取每个月的日期列表

*

* @param initialCalendar 初始选中的日期

* @param validSelNumLimit 最大有效选中数量

* @return 返回一个key为当前loop月的时间戳,value为当前月的所有日期list的有序map

* @author ly on 2020/4/25 11:37

*/

public static @NonNull

LinkedHashMap> getMonthMap(Calendar initialCalendar, int monthNum, int validSelNumLimit) {

//key:当前loop月的时间戳 value:当前月的所有日期list

LinkedHashMap> dateMap = new LinkedHashMap<>();

ArrayList dateInMonthList = new ArrayList<>();

if (initialCalendar == null)

initialCalendar = Calendar.getInstance();

Calendar c = Calendar.getInstance();

//设置开始遍历的date

//也可以不使用下面的set,直接c.setTime(initialCalendar.getTime()),只是第一个月的数据可能不足那个月的最大天数(ui不美观)

//告诉calendar从指定月的第一天开始,而不是精确到某一天

c.set(initialCalendar.get(Calendar.YEAR), initialCalendar.get(Calendar.MONTH), 1);

int loopMonthCount = 0;

int validDateNum = 0;//有效的可选日期数量

while (loopMonthCount < monthNum) {

// 获取当前月最大天数

int maxDayNum = c.getActualMaximum(Calendar.DATE);

int month = c.get(Calendar.MONTH);

DateInfo dateInfo = new DateInfo();

dateInfo.year = c.get(Calendar.YEAR);

dateInfo.month = month + 1;

dateInfo.day = c.get(Calendar.DAY_OF_MONTH);

dateInfo.timestamp = c.getTimeInMillis();

dateInfo.week = c.get(Calendar.DAY_OF_WEEK);

dateInfo.isSelected = initialCalendar.get(Calendar.MONTH) == c.get(Calendar.MONTH) && initialCalendar.get(Calendar.DATE) == c.get(Calendar.DATE);

//是否为可选的日期

boolean isAvailableDate = (dateInfo.isSelected || c.after(initialCalendar)) && dateInfo.week != Calendar.SUNDAY && dateInfo.week != Calendar.SATURDAY;

if (isAvailableDate)

validDateNum++;

dateInfo.canSelect = isAvailableDate && validDateNum <= validSelNumLimit;

if (dateInMonthList.isEmpty()) {//在每一月的第一周前面补空data

for (int j = 0; j < dateInfo.week - 1; j++) {

DateInfo d = new DateInfo();

dateInMonthList.add(0, d);

}

}

dateInMonthList.add(dateInfo);

if (maxDayNum == dateInfo.day) {//每loop到月底put一次

dateMap.put(dateInfo.timestamp, new ArrayList<>(dateInMonthList));

dateInMonthList.clear();

if (validDateNum < validSelNumLimit) {

loopMonthCount++;

} else {

break;//达到最大可选数后自动跳出looper

}

}

//条件满足时一直add天数即可

c.add(Calendar.DATE, 1);

}

return dateMap;

}

public static @NonNull

LinkedHashMap> getMonthMap(String startDate, String endDate) {

//key:当前loop月的时间戳 value:当前月的所有日期list

LinkedHashMap> dateMap = new LinkedHashMap<>();

ArrayList dateInMonthList = new ArrayList<>();

long startTimestamp = getMillisecondByFormat(startDate, DATE);

long endTimestamp = getMillisecondByFormat(endDate, DATE);

if (endTimestamp < startTimestamp || startTimestamp <= 0)

return dateMap;

Calendar start = Calendar.getInstance();

start.setTimeInMillis(startTimestamp);

Calendar end = Calendar.getInstance();

end.setTimeInMillis(endTimestamp);

Calendar c = Calendar.getInstance();

//设置开始遍历的date

//也可以不使用下面的set,直接c.setTime(initialCalendar.getTime()),只是第一个月的数据可能不足那个月的最大天数(ui不美观)

//告诉calendar从指定月的第一天开始,而不是精确到某一天

c.set(start.get(Calendar.YEAR), start.get(Calendar.MONTH), 1);

boolean needLoop = true;

while (needLoop) {

// 获取当前月最大天数

int maxDayNum = c.getActualMaximum(Calendar.DATE);

int month = c.get(Calendar.MONTH);

DateInfo dateInfo = new DateInfo();

dateInfo.year = c.get(Calendar.YEAR);

dateInfo.month = month;

dateInfo.day = c.get(Calendar.DAY_OF_MONTH);

dateInfo.timestamp = c.getTimeInMillis();

dateInfo.week = c.get(Calendar.DAY_OF_WEEK);

//此处理想条件应为 start.getTimeInMillis()==c.getTimeInMillis(),但开始时间戳和查询出来的时间戳不相等(就算是同一天)

//先用这个判断着

dateInfo.isSelected = start.get(Calendar.YEAR) == c.get(Calendar.YEAR) && start.get(Calendar.MONTH) == c.get(Calendar.MONTH) && start.get(Calendar.DATE) == c.get(Calendar.DATE);

boolean isEnd = end.get(Calendar.MONTH) == c.get(Calendar.MONTH) && end.get(Calendar.DATE) == c.get(Calendar.DATE);

dateInfo.canSelect = (dateInfo.isSelected || c.after(start)) && (c.before(end) || isEnd) && dateInfo.week != Calendar.SUNDAY && dateInfo.week != Calendar.SATURDAY;

if (dateInMonthList.isEmpty()) {//在每一月的第一周前面补空data

for (int j = 0; j < dateInfo.week - 1; j++) {

DateInfo d = new DateInfo();

dateInMonthList.add(0, d);

}

}

dateInMonthList.add(dateInfo);

if (maxDayNum == dateInfo.day) {//每loop到月底put一次

dateMap.put(dateInfo.timestamp, new ArrayList<>(dateInMonthList));

dateInMonthList.clear();

needLoop = c.before(end);//每到月底判断一下,是否还需继续loop

}

//条件满足时一直add天数即可

c.add(Calendar.DATE, 1);

}

return dateMap;

}

/**

* 获取当前日期一周的日期

*/

@SuppressLint("SimpleDateFormat")

public static ArrayList getWeek(String date) {

ArrayList result = new ArrayList<>();

Calendar c = Calendar.getInstance();

try {

c.setTime(new SimpleDateFormat("yyyy-MM-dd").parse(date));

} catch (ParseException e) {

e.printStackTrace();

}

c.set(Calendar.DAY_OF_WEEK, Calendar.SUNDAY); //获取本周一的日期

for (int i = 0; i < 7; i++) {

DateInfo entity = new DateInfo();

entity.timestamp = c.getTimeInMillis();

entity.day = c.get(Calendar.DATE);

entity.week = c.get(Calendar.DAY_OF_WEEK);

c.add(Calendar.DATE, 1);

result.add(entity);

}

return result;

}

/**

* 获取系统当前日期

*/

public static String getCurrDate(String format) {

@SuppressLint("SimpleDateFormat") SimpleDateFormat formatter = new SimpleDateFormat(format);

Date curDate = new Date(System.currentTimeMillis());//获取当前时间

return formatter.format(curDate);

}

/**

* String类型的日期时间转化为毫秒(1970-)类型.

*

* @param strDate String形式的日期时间

* @param format 格式化字符串,如:"yyyy-MM-dd HH:mm:ss"

* @author LY 2015-9-16 上午11:40:26

*/

public static long getMillisecondByFormat(String strDate, String format) {

@SuppressLint("SimpleDateFormat") SimpleDateFormat mSimpleDateFormat = new SimpleDateFormat(format);

Date date = null;

try {

date = mSimpleDateFormat.parse(strDate);

} catch (ParseException e) {

e.printStackTrace();

}

if (date == null) return 0;

return date.getTime();

}

/**

* 毫秒----> format格式的日期

*

* @author LY 2015-9-18 下午3:41:32

*/

public static String getDateByMillisecond(long milliseconds, String format) {

Date d = new Date(milliseconds);

@SuppressLint("SimpleDateFormat") SimpleDateFormat f = new SimpleDateFormat(format);

return f.format(d);

}

public static String getCurDateByFormat(String format) {

return getDateByMillisecond(System.currentTimeMillis(), format);

}

public static String getNextMonthByFormat(String format) {

Calendar c = Calendar.getInstance();

c.setTimeInMillis(System.currentTimeMillis());

c.add(Calendar.MONTH, 1);

Date d = c.getTime();

@SuppressLint("SimpleDateFormat") SimpleDateFormat f = new SimpleDateFormat(format);

return f.format(d);

}

}

日历的数据entity,注意一下canSelect我这里的业务需求是周末不可选,其他在范围内的日期可选,可以根据自己的需求来定制。DateInfo:

import com.robot.common.utils.CalendarUtils;

import java.util.Calendar;

/**

* @author ly

* date 2020/4/24 9:52

*/

public class DateInfo {

public long timestamp; //时间戳

public int year;

public int month;

public int day;

public int week;//一周中第几天,非中式

//是否选中

public boolean isSelected;

//日期是否可选

public boolean canSelect;

/**

* 根据美式周末到周一 返回

*/

public String getWeekName() {

String name = "";

switch (week) {

case Calendar.SUNDAY:

name = "周日";

break;

case Calendar.MONDAY:

name = "周一";

break;

case Calendar.TUESDAY:

name = "周二";

break;

case Calendar.WEDNESDAY:

name = "周三";

break;

case Calendar.THURSDAY:

name = "周四";

break;

case Calendar.FRIDAY:

name = "周五";

break;

case Calendar.SATURDAY:

name = "周六";

break;

default:

break;

}

return name;

}

public String getDay() {

if (day > 0) {

return String.valueOf(day);

} else {

return "";

}

}

public int getMonth() {

return month + 1;

}

public String getDate() {

return CalendarUtils.getDateByMillisecond(timestamp, CalendarUtils.DATE);

}

}

最后就是负责展示的类了,很简单。这里是dialog来实现的:

import android.app.Activity;

import android.view.Gravity;

import android.view.ViewGroup;

import android.widget.TextView;

import androidx.annotation.NonNull;

import androidx.recyclerview.widget.GridLayoutManager;

import androidx.recyclerview.widget.RecyclerView;

import com.chad.library.adapter.base.BaseSectionQuickAdapter;

import com.chad.library.adapter.base.BaseViewHolder;

import com.chad.library.adapter.base.entity.SectionEntity;

import java.util.ArrayList;

import java.util.LinkedHashMap;

import java.util.List;

/**

* @author ly

* date 2019/8/1 17:36

*/

public class SelDateDialog extends BaseDialog {

private SectionAdapter mAdapter;

private OnDateSelectedListener onDateSelectedListener;

private List dateList = new ArrayList<>();

private LinkedHashMap> monthMap;

private RecyclerView rv;

private int selPosition;

private DateInfo selDateInfo;

public SelDateDialog(@NonNull Activity activity, OnDateSelectedListener onDateSelectedListener) {

super(activity);

this.onDateSelectedListener = onDateSelectedListener;

mAdapter = new SectionAdapter(dateList);

mAdapter.setOnItemClickListener((adapter, view, position) -> {

SectionEntity item = mAdapter.getItem(position);

if (item == null || item.t == null)//item.t=null可能是点到了header 不做处理

return;

selPosition = position;

mAdapter.selectOne(position);

selDateInfo = item.t;

if (onDateSelectedListener != null) {

onDateSelectedListener.onDateSelect(selDateInfo);

}

// dismiss();

});

}

@Override

public int getLayoutResId() {

return R.layout.dialog_sel_date;

}

@Override

public void initViews() {

if (getWindow() != null) {

getWindow().getAttributes().width = ScreenUtil.getScreenWidth();

getWindow().getAttributes().height = (int) (ScreenUtil.getScreenHeight() * 0.7);

getWindow().setGravity(Gravity.BOTTOM);

getWindow().setWindowAnimations(com.robot.common.R.style.bottom_enter_anim);

}

setCanceledOnTouchOutside(true);

setCancelable(true);

findViewById(R.id.m_tv_dialog_sel_date_cancel).setOnClickListener(view -> {

dismiss();

});

rv = findViewById(R.id.m_rv_dialog_calendar);

rv.setLayoutManager(new GridLayoutManager(getContext(), 7));

mAdapter.bindToRecyclerView(rv);

rv.smoothScrollToPosition(selPosition);

}

public void setData(String startDate, String endDate) {

if (!dateList.isEmpty()) {

dateList.clear();

mAdapter.notifyDataSetChanged();

}

// LinkedHashMap> month = CalendarUtils.getMonthByLimit(selCalendar, 30);

monthMap = CalendarUtils.getMonthMap(startDate, endDate);

for (Long aLong : monthMap.keySet()) {

DateSection sectionTitle = new DateSection(true, CalendarUtils.getDateByMillisecond(aLong, CalendarUtils.YEAR_MONTH));

dateList.add(sectionTitle);

ArrayList monthDateList = monthMap.get(aLong);

if (monthDateList != null)

for (DateInfo dateInfo : monthDateList) {

dateList.add(new DateSection(dateInfo));

if (dateInfo.isSelected) {

selDateInfo = dateInfo;

if (onDateSelectedListener != null)

onDateSelectedListener.onDateSelect(selDateInfo);

}

}

}

DateSection sectionFooter = new DateSection(true, "后续日期暂不可订");

dateList.add(sectionFooter);

}

public LinkedHashMap> getMonthMap() {

return monthMap;

}

public DateInfo getSelDateInfo() {

return selDateInfo;

}

public void selectOne(DateInfo dateInfo) {

if (dateInfo != null && dateList != null) {

for (int i = 0; i < dateList.size(); i++) {

DateSection dateSection = dateList.get(i);

DateInfo info = dateSection.t;

if (info != null) {

info.isSelected = dateInfo.timestamp == info.timestamp;

if (info.isSelected)

selPosition = i;

}

}

mAdapter.notifyDataSetChanged();

if (rv != null)

rv.smoothScrollToPosition(selPosition);

}

}

static class SectionAdapter extends BaseSectionQuickAdapter {

private int itemW;

SectionAdapter(List data) {

super(R.layout.dialog_sel_date_item, R.layout.dialog_sel_date_title, data);

itemW = ScreenUtil.getScreenWidth() / 7;

}

void selectOne(int position) {

for (int i = 0; i < mData.size(); i++) {

SectionEntity entity = mData.get(i);

DateInfo dateInfo = entity.t;

if (dateInfo != null)

dateInfo.isSelected = position == i;

}

notifyDataSetChanged();

}

@Override

protected void convertHead(BaseViewHolder helper, final DateSection item) {

helper.setText(R.id.m_tv_dialog_sel_date_title, item.header);

}

@Override

protected void convert(BaseViewHolder helper, DateSection item) {

DateInfo dateInfo = item.t;

TextView tv = helper.getView(R.id.m_tv_dialog_sel_date);

tv.setText(dateInfo.getDay());

helper.itemView.setEnabled(dateInfo.canSelect);

tv.setBackgroundResource(dateInfo.isSelected ? R.mipmap.ic_date_item_sel : R.color.transparent);

if (dateInfo.canSelect) {

if (dateInfo.isSelected) {

tv.setTextColor(0xffffffff);

} else {

tv.setTextColor(mContext.getResources().getColor(R.color.black_text1));

}

} else {

tv.setTextColor(0xffC3C3DC);

}

ViewGroup.LayoutParams layoutParams = helper.itemView.getLayoutParams();

layoutParams.width = itemW;

layoutParams.height = itemW;

}

}

private static class DateSection extends SectionEntity {

DateSection(boolean isHeader, String header) {

super(isHeader, header);

}

DateSection(DateInfo dateInfo) {

super(dateInfo);

}

}

public interface OnDateSelectedListener {

void onDateSelect(@NonNull DateInfo dateInfo);

}

}

布局也贴一下,dialog_sel_date:

xmlns:tools="http://schemas.android.com/tools"

android:id="@+id/ll_dialog_share_confirm"

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:layout_gravity="bottom"

android:background="@drawable/shape_white_tr16b0"

android:gravity="bottom"

android:orientation="vertical">

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="horizontal">

android:id="@+id/m_tv_dialog_sel_date_cancel"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:padding="@dimen/list_lr_margin"

android:src="@mipmap/ic_close"

android:text="取消" />

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_centerInParent="true"

android:gravity="center"

android:text="选择日期"

android:textColor="#ff282832"

android:textSize="17sp" />

android:layout_width="match_parent"

android:layout_height="wrap_content"

android:orientation="horizontal"

android:paddingTop="8dp"

android:paddingBottom="15dp">

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_weight="1"

android:gravity="center"

android:text="日"

android:textColor="#fffa496a"

android:textSize="12sp" />

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_weight="1"

android:gravity="center"

android:text="一"

android:textColor="@color/black_text1"

android:textSize="12sp" />

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_weight="1"

android:gravity="center"

android:text="二"

android:textColor="@color/black_text1"

android:textSize="12sp" />

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_weight="1"

android:gravity="center"

android:text="三"

android:textColor="@color/black_text1"

android:textSize="12sp" />

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_weight="1"

android:gravity="center"

android:text="四"

android:textColor="@color/black_text1"

android:textSize="12sp" />

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_weight="1"

android:gravity="center"

android:text="五"

android:textColor="@color/black_text1"

android:textSize="12sp" />

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:layout_weight="1"

android:gravity="center"

android:text="六"

android:textColor="#fffa496a"

android:textSize="12sp" />

android:id="@+id/m_rv_dialog_calendar"

android:layout_width="match_parent"

android:layout_height="0dp"

android:layout_weight="1"

android:overScrollMode="never"

tools:listitem="@layout/m_dialog_item_sel_scenic" />

dialog_sel_date_item:

xmlns:tools="http://schemas.android.com/tools"

android:id="@+id/m_tv_dialog_sel_date"

style="@style/text_black"

android:layout_gravity="center"

android:gravity="center"

android:textSize="16sp"

tools:text="10" />

m_tv_dialog_sel_date_title:

xmlns:tools="http://schemas.android.com/tools"

android:id="@+id/m_tv_dialog_sel_date_title"

style="@style/text_black"

android:layout_width="match_parent"

android:background="#F3F3FA"

android:gravity="center"

android:paddingTop="6dp"

android:paddingBottom="6dp"

android:textSize="14sp"

tools:text="2020.3"/>

接着在需要用这个日历的地方创建上面的Dialog,传入开始及结束日期show即可:

SelDateDialog selDateDialog = new SelDateDialog(this, dateInfo -> showToast(dateInfo.getDate()));

selDateDialog.setData("2020-07-06", "2020-08-06");

selDateDialog.show();

最后,我想说一下,github上有很多的开源日历库,那些库大多功能繁多,如果app对日历依赖性强,需求稍微复杂那我还是建议用开源库的,毕竟不用花时间造轮子。但是简单的需求(就如本例)就没必要用那些库了,而且还要看文档学他的使用方式,还不如自己动手写了。所以视情况而定,不要动不动就接第三方库,不利于自己能力的提升。

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/weixin_39535283/article/details/114593586

智能推荐

使用nginx解决浏览器跨域问题_nginx不停的xhr-程序员宅基地

文章浏览阅读1k次。通过使用ajax方法跨域请求是浏览器所不允许的,浏览器出于安全考虑是禁止的。警告信息如下:不过jQuery对跨域问题也有解决方案,使用jsonp的方式解决,方法如下:$.ajax({ async:false, url: 'http://www.mysite.com/demo.do', // 跨域URL ty..._nginx不停的xhr

在 Oracle 中配置 extproc 以访问 ST_Geometry-程序员宅基地

文章浏览阅读2k次。关于在 Oracle 中配置 extproc 以访问 ST_Geometry,也就是我们所说的 使用空间SQL 的方法,官方文档链接如下。http://desktop.arcgis.com/zh-cn/arcmap/latest/manage-data/gdbs-in-oracle/configure-oracle-extproc.htm其实简单总结一下,主要就分为以下几个步骤。..._extproc

Linux C++ gbk转为utf-8_linux c++ gbk->utf8-程序员宅基地

文章浏览阅读1.5w次。linux下没有上面的两个函数,需要使用函数 mbstowcs和wcstombsmbstowcs将多字节编码转换为宽字节编码wcstombs将宽字节编码转换为多字节编码这两个函数,转换过程中受到系统编码类型的影响,需要通过设置来设定转换前和转换后的编码类型。通过函数setlocale进行系统编码的设置。linux下输入命名locale -a查看系统支持的编码_linux c++ gbk->utf8

IMP-00009: 导出文件异常结束-程序员宅基地

文章浏览阅读750次。今天准备从生产库向测试库进行数据导入,结果在imp导入的时候遇到“ IMP-00009:导出文件异常结束” 错误,google一下,发现可能有如下原因导致imp的数据太大,没有写buffer和commit两个数据库字符集不同从低版本exp的dmp文件,向高版本imp导出的dmp文件出错传输dmp文件时,文件损坏解决办法:imp时指定..._imp-00009导出文件异常结束

python程序员需要深入掌握的技能_Python用数据说明程序员需要掌握的技能-程序员宅基地

文章浏览阅读143次。当下是一个大数据的时代,各个行业都离不开数据的支持。因此,网络爬虫就应运而生。网络爬虫当下最为火热的是Python,Python开发爬虫相对简单,而且功能库相当完善,力压众多开发语言。本次教程我们爬取前程无忧的招聘信息来分析Python程序员需要掌握那些编程技术。首先在谷歌浏览器打开前程无忧的首页,按F12打开浏览器的开发者工具。浏览器开发者工具是用于捕捉网站的请求信息,通过分析请求信息可以了解请..._初级python程序员能力要求

Spring @Service生成bean名称的规则(当类的名字是以两个或以上的大写字母开头的话,bean的名字会与类名保持一致)_@service beanname-程序员宅基地

文章浏览阅读7.6k次,点赞2次,收藏6次。@Service标注的bean,类名:ABDemoService查看源码后发现,原来是经过一个特殊处理:当类的名字是以两个或以上的大写字母开头的话,bean的名字会与类名保持一致public class AnnotationBeanNameGenerator implements BeanNameGenerator { private static final String C..._@service beanname

随便推点

二叉树的各种创建方法_二叉树的建立-程序员宅基地

文章浏览阅读6.9w次,点赞73次,收藏463次。1.前序创建#include&lt;stdio.h&gt;#include&lt;string.h&gt;#include&lt;stdlib.h&gt;#include&lt;malloc.h&gt;#include&lt;iostream&gt;#include&lt;stack&gt;#include&lt;queue&gt;using namespace std;typed_二叉树的建立

解决asp.net导出excel时中文文件名乱码_asp.net utf8 导出中文字符乱码-程序员宅基地

文章浏览阅读7.1k次。在Asp.net上使用Excel导出功能,如果文件名出现中文,便会以乱码视之。 解决方法: fileName = HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8);_asp.net utf8 导出中文字符乱码

笔记-编译原理-实验一-词法分析器设计_对pl/0作以下修改扩充。增加单词-程序员宅基地

文章浏览阅读2.1k次,点赞4次,收藏23次。第一次实验 词法分析实验报告设计思想词法分析的主要任务是根据文法的词汇表以及对应约定的编码进行一定的识别,找出文件中所有的合法的单词,并给出一定的信息作为最后的结果,用于后续语法分析程序的使用;本实验针对 PL/0 语言 的文法、词汇表编写一个词法分析程序,对于每个单词根据词汇表输出: (单词种类, 单词的值) 二元对。词汇表:种别编码单词符号助记符0beginb..._对pl/0作以下修改扩充。增加单词

android adb shell 权限,android adb shell权限被拒绝-程序员宅基地

文章浏览阅读773次。我在使用adb.exe时遇到了麻烦.我想使用与bash相同的adb.exe shell提示符,所以我决定更改默认的bash二进制文件(当然二进制文件是交叉编译的,一切都很完美)更改bash二进制文件遵循以下顺序> adb remount> adb push bash / system / bin /> adb shell> cd / system / bin> chm..._adb shell mv 权限

投影仪-相机标定_相机-投影仪标定-程序员宅基地

文章浏览阅读6.8k次,点赞12次,收藏125次。1. 单目相机标定引言相机标定已经研究多年,标定的算法可以分为基于摄影测量的标定和自标定。其中,应用最为广泛的还是张正友标定法。这是一种简单灵活、高鲁棒性、低成本的相机标定算法。仅需要一台相机和一块平面标定板构建相机标定系统,在标定过程中,相机拍摄多个角度下(至少两个角度,推荐10~20个角度)的标定板图像(相机和标定板都可以移动),即可对相机的内外参数进行标定。下面介绍张氏标定法(以下也这么称呼)的原理。原理相机模型和单应矩阵相机标定,就是对相机的内外参数进行计算的过程,从而得到物体到图像的投影_相机-投影仪标定

Wayland架构、渲染、硬件支持-程序员宅基地

文章浏览阅读2.2k次。文章目录Wayland 架构Wayland 渲染Wayland的 硬件支持简 述: 翻译一篇关于和 wayland 有关的技术文章, 其英文标题为Wayland Architecture .Wayland 架构若是想要更好的理解 Wayland 架构及其与 X (X11 or X Window System) 结构;一种很好的方法是将事件从输入设备就开始跟踪, 查看期间所有的屏幕上出现的变化。这就是我们现在对 X 的理解。 内核是从一个输入设备中获取一个事件,并通过 evdev 输入_wayland

推荐文章

热门文章

相关标签