Clickdate Mac OS

broken image


TERMS OF SERVICE

INFORMATION

If you have questions or complaints regarding our terms of services, please contact us at info@ClickDate.com This privacy statement discloses the privacy practices of ClickDate Inc. and all websites owned or operated by ClickDate, Inc. and its subsidiaries and affiliates.

1971年東京都出身。雑誌やWeb媒体を中心にOSやネットワーク、サーバー関連の記事を数多く執筆するフリーライター。INTERNET Watchにてネットワーク関連の話題を扱う『イニシャルB』を連載中。著書に『できるWindows 10 改訂4版』(共著)など多数。. MEET YOUR LOVE TODAY AT A CLICK. Get started now with instantly generated matches based on your behavior, likes, patterns and psyche.

This is a legal agreement ('Agreement') between you and ClickDate, Inc., a Delaware corporation ('ClickDate'), which may be contacted at 2110 BONITA DR, GLENDALE, CA, 91208, USA. By accessing the ClickDate U.S. web site, currently located at www.clickdate.me and using any of the Services (as defined below) accessible through the Site, you become a user and agree to, and are bound by, the terms and conditions of this Agreement for as long as you continue to use the Site or Services. IF YOU DO NOT AGREE TO BE BOUND BY THIS AGREEMENT, DO NOT USE THE SITE OR THE SERVICES. Your use of, or participation in, certain Services may be subject to additional terms, and such terms will be either listed in this Agreement or will be presented to you for your acceptance when you sign up to use such Services.
The ClickDate services consist of the following, without limitation: a service for single people ('Singles Service'), any other services offered by or on behalf of ClickDate. ClickDate may offer additional services or revise any of the Services, at its discretion, and this Agreement will apply to all additional services or revised Services. ClickDate also reserves the right to cease offering any of the Services.
This Agreement is subject to change by ClickDate in its sole discretion at any time, and any such changes will be posted on the Site. Your continued use of this Site or the Services after the posting of revisions to this Agreement will constitute your acceptance of such revisions. Please consult the end of this Agreement to determine when the Agreement was last revised.

ELIGIBILITY.

We receive, store and process information that you make available to us when accessing or using our System. Examples include when you:

  1. Minimum Age. You must be at least 18 years old to use the Site or to register for the Services. By using the Singles Service, you represent and warrant that you are at least 18 years old.
  2. Marital Status. By requesting to use, registering to use, or using the Singles Service, you represent and warrant that you are not married. If you are separated, but not yet legally divorced, you may not request to use, register to use, or use the Singles Service.
  3. Criminal History. By requesting to use, registering to use, and/or using the Singles Service, you represent and warrant that you have never been convicted of a felony and/or are not required to register as a sex offender with any government entity. CLICKDATE DOES NOT CURRENTLY CONDUCT CRIMINAL BACKGROUND SCREENINGS ON ITS MEMBERS. However, ClickDate reserves the right to conduct any criminal background check, at any time and using available public records, to confirm your compliance with this subsection. BY AGREEING TO THESE TERMS AND CONDITIONS, YOU HEREBY AUTHORIZE ANY SUCH CHECK.

USE OF SITE AND SERVICE.

As a user of the Site or a user registered to use any of the Services (a 'Registered User'), you agree to the following:

  1. Exclusive Use. Your account is for your personal use only. You may not authorize others to use your account, and you may not assign or otherwise transfer your account to any other person or entity. You acknowledge that ClickDate is not responsible for third party access to your account that results from theft or misappropriation of your user names and passwords.
  2. Information Submitted. You are solely responsible for, and assume all liability regarding, (i) the information and content you contribute to the Service; (ii) the information and content you post, transmit, publish, or otherwise make available (hereinafter 'post') through the Services; and (iii) your interactions with other Registered Users through the Services. In addition to sharing your information with your matches, we may allow your matches to share your profile information with members of their social network(s).
  3. Risk Assumption and Precautions. You assume all risk when using the Services, including but not limited to all of the risks associated with any online or offline interactions with others, including dating. You agree to take all necessary precautions when meeting individuals through the Singles Service.
  4. No Guarantees. ClickDate may not be able to provide matches for everyone seeking to use its services. Further, ClickDate makes no guarantees as to the number or frequency of matches through the Singles Service, or to such matches' ability, desire or criteria to communicate with any user. You understand that ClickDate makes no guarantees, either express or implied, regarding your ultimate compatibility with individuals you meet through the Singles Service or as to the conduct of such individuals.
  5. Reporting of Violations. You will promptly report to ClickDate any violation of the Agreement by others, including but not limited to, Registered Users.
  6. Content Removal. ClickDate reserves the right, but has no obligation, to monitor the information or material you submit to the Services or post in the public areas of the Services. ClickDate will have the right to remove any such information or material that in its sole opinion violates, or may violate, any applicable law or either the letter or spirit of this Agreement or upon the request of any third party. ClickDate further reserves the right to remove matches previously delivered to you, in its reasonable discretion, in order to assure that you have a quality experience on the Site.
  7. Posting and Communication Restrictions. You will not post on the Services, transmit to other users, communicate any content (or links thereto), or otherwise engage in any activity on the Site or through the Services, that:
    • promotes racism, bigotry, hatred or physical harm of any kind against any group or individual;
    • is intended to or tends to harass, annoy, threaten or intimidate any other users of the Site or Services;
    • is defamatory, inaccurate, abusive, profane, offensive, sexually oriented, obscene or otherwise objectionable;
    • contains others' copyrighted content (e.g., music, movies, videos, photographs, images, software, etc.) without obtaining permission first;
    • contains video, audio, photographs, or images of another person without his or her permission (or in the case of a minor, the minor's legal guardian);
    • promotes or enables illegal or unlawful activities, such as instructions on how to make or buy illegal weapons or drugs, violate someone's privacy, harm or harass another person, obtain others' identity information, create or disseminate computer viruses, or circumvent copy-protect devices;
    • intended to defraud, swindle or deceive other users of the Services;
    • contains viruses, time bombs, trojan horses, cancelbots, worms or other harmful, or disruptive codes, components or devices;
    • promotes or solicits involvement in or support of a political platform, religion, cult, or sect;
    • disseminates another person's personal information without his or her permission, or collects or solicits another person's personal information for commercial or unlawful purposes;
    • is off-topic, meaningless, or otherwise intended to annoy or interfere with others' enjoyment of the Site;
    • impersonates, or otherwise misrepresents affiliation, connection or association with, any person or entity;
    • solicits gambling or engages in any gambling or similar activity;
    • uses scripts, bots or other automated technology to access the Site or Services;
    • uses the Site or Services for chain letter, junk mail or spam e-mails;
    • collects or solicits personal information about anyone under 18; or
    • is in any way used for or in connection with spamming, spimming, phishing, trolling, or similar activities.
  8. No False Information. You will not provide inaccurate, misleading or false information to ClickDate or to any other user. If information provided to ClickDate or another user subsequently becomes inaccurate, misleading or false, you will promptly notify ClickDate of such change.
  9. No Advertising or Commercial Solicitation. You will not advertise or solicit any user to buy or sell any products or services through the Site or Services. You may not transmit any chain letters, junk or spam e-mail to other users. Further, you will not use any information obtained from the Services in order to contact, advertise to, solicit, or sell to any user without their prior explicit consent. If you breach the terms of this subsection and send or post unsolicited bulk email, 'spam' or other unsolicited communications of any kind through the Services, you acknowledge that you will have caused substantial harm to ClickDate, but that the amount of such harm would be extremely difficult to ascertain. As a reasonable estimation of such harm, you agree to pay ClickDate $200 for each such unsolicited communication you send through the Services.
  10. Unique and Bona Fide Profile. As a Registered User of the Singles Service, you will create only one unique profile. In addition, your use of the Singles Service must be for bona fide relationship-seeking purposes in order to maintain the integrity of the Singles Service (for example, you may not become a Registered User solely to compile a report of compatible singles in your area, or to write a school research paper). Not all registered users are available for matching. From time to time, ClickDate may create test profiles in order to monitor the operation of the Services.

PROPRIETARY RIGHTS.

a. Ownership of Proprietary Information. You hereby acknowledge and agree that ClickDate is the owner of highly valuable proprietary information. ClickDate owns and hereby retains all proprietary rights in the Services and the Site, including but not limited to, all Confidential Information.
b. Other Users' Information. Other Registered Users may post copyrighted information, which has copyright protection whether or not it is identified as copyrighted. You agree that you will not copy, modify, publish, transmit, distribute, perform, display, commercially use, or sell any ClickDate or third party proprietary information available via the Services or the Site.
c. License to Posted or Accessed Content. By posting information or content to any profile pages or public area of the Services, or making it accessible to us by linking your ClickDate account to any of your social network accounts (e.g. via Facebook Connect), you automatically grant, and you represent and warrant that you have the right to grant, to ClickDate and its users, an irrevocable, perpetual, non-exclusive, fully-paid, worldwide license to use, reproduce, publicly perform, publicly display and distribute such information and content, and to prepare derivative works of, or incorporate into other works, such information and content, and to grant and authorize sub-licenses of the foregoing.

USER INFORMATION.

a. Privacy Statement. For information about the collection and possible use of information and material provided by you, please click on ClickDate's Privacy Statement located on the Site. By using the Site or the Services, you are consenting to the terms of ClickDate's Privacy Statement.
b. No Contact Information. You agree that you will not post any e-mail addresses, personal website address or profile page you may have on a third party website, or other contact information in the 'About Me' section of the Singles Service or in any other communications you may have with other users.
c. Disclosure by Law. You acknowledge and agree that ClickDate may disclose information you provide if required to do so by law, at the request of a third party, or if we, in our sole discretion, believe that disclosure is reasonable to (1) comply with the law, requests or orders from law enforcement, or any legal process (whether or not such disclosure is required by applicable law); (2) protect or defend ClickDate's, or a third party's, rights or property; or (3) protect someone's health or safety, such as when harm or violence against any person (including the user) is threatened.

CHANGES TO THIS PRIVACY POLICY

we may change this terms of services at any time. If we make material changes to the terms of services, we will notify you either by posting the changed Privacy Policy on the System or by sending an email to you. We will also update the 'Last Updated Date' at the top of this terms of services. If we let you know of changes through an email communication, then the date on which we send the email will be deemed to be the date of your receipt of that email. It's important that you review the changed terms of services. If you do not wish to agree to the changed terms of services, then we will not be able to continue providing the System to you, and your only option will be to stop accessing the System and deactivate your ClickDate account.

GOT FEEDBACK?

Your opinion matters to us! If you'd like to provide feedback to us about this Privacy Policy, please email us at info@ClickDate.com.

TERM AND TERMINATION.

This Agreement will become effective upon your registration and hence acceptance of the Agreement by your use of the Site or the Services and will remain in effect in perpetuity unless terminated hereunder. Either you or ClickDate may terminate your account at any time, for any reason or no reason, without explanation, effective upon sending written notice to the other party. ClickDate reserves the right to immediately suspend or terminate your access to any of the Services, without notice, for any reason or no reason. We also reserve the right to remove your account information or data from our Services and any other records at any time at our sole discretion. In the event your access to any of the Services is suspended due to the breach of this Agreement, you agree that all fees then paid to ClickDate by you will be nonrefundable and all outstanding or pending payments will immediately be due. You may terminate your account by 'Cancellations' entering to your account.
RENEWALS
In order to provide continuous service, ClickDate automatically renews all paid subscriptions, in the countries where the payable service is available, for the Services on the date such subscriptions expire. We always communicate renewal periods to you in the subscription plan page, before you finalize the purchase of your subscription, upon confirmation of purchase, and in the body of any special promotions sent to our users. By entering into this Agreement, you acknowledge that your account will be subject to the above-described automatic renewals. In all cases, if you do not wish your account to renew automatically, you should disable that feature from your settings.
DIGITAL MILLENNIUM COPYRIGHT ACT NOTICE.

If you believe that your copyrighted work has been copied in a way that constitutes copyright infringement and is accessible on this Site, please notify ClickDate's copyright agent, as set forth in the Digital Millennium Copyright Act of 1998 (DMCA). For your complaint to be valid under the DMCA, you must provide the following information in writing:

  1. An electronic or physical signature of a person authorized to act on behalf of the copyright owner;
  2. Identification of the copyrighted work that you claim is being infringed;
  3. Identification of the material that is claimed to be infringing and where it is located on the Site
  4. Information reasonably sufficient to permit ClickDate to contact you, such as your address, telephone number, and e-mail address;
  5. A statement that you have a good faith belief that use of the material in the manner complained of is not authorized by the copyright owner, its agent, or law; and
  6. A statement, made under penalty of perjury, that the above information is accurate, and that you are the copyright owner or are authorized to act on behalf of the owner.

The above information must be submitted to the following DMCA Agent: copyright@ClickDate.com (only DMCA notices will be accepted at this email address. All other inquiries or requests will be discarded)

EFFECTIVE DATE
This Terms Agreement was last revised on May 1, 2017.
Copyright © 2017 ClickDate Inc. All Rights Reserved.

自定义日历并且具备设置今天以前的时间不可点选,以前的颜色和当前的颜色不同,以及获取两次点击日期之间间隔的天数所以说细节比较多

个人习惯,先上图

靠,笔记本不知道怎么回事,禁用到触摸板之后 再次唤醒屏幕触摸板又恢复正常了,而且快捷键可能被占用还是怎么着,找不到关闭快捷键的图标,关闭的话 需要重启才行,懒得管了 蛋疼,瘪犊子玩意!

项目中用到日历控件,需求大致是这样:

有两处用到日历控件: 一个是显示每个月份全部的天数,实现滑动跳到下一月份,以前月份的天数不可点选,点击今天及以后的天数的时候刷新页面显示日期,获取两次点击的间隔数以及相关的计算(android这方面用原生的话肯定不行,而且后台和ios商量用ios风格,android仿ios这方面的轮子就更少了,没办法,遇到不会的就查呗,查不到就问呗,问不到的只能'靠'了);

第二个需求是显示每周的天数实现多选,这个很简单。

重点来了:::》》》

所以说要完全自定义日历并且具备设置以前或者以后时间不可点选,以前的颜色和当前的颜色不同,以及获取两次点击日期之间间隔的天数所以说细节比较多,,,

Calendar大家都清楚,获取时间:

不断刷新秒,简单的时钟就出来了,

package com.example.mydemo;

import java.util.Calendar;

import android.app.Activity;
import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;

public class MainActivity extends Activity implements OnClickListener{

/**
* 获取时间
*/
private int mHour;
private int mMinute;
private int mYear;
private int mMonth;
private int mDay;
private TextView text;
private int second;
private int ampm;
private Handler mHandler=new Handler(){};
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

text = (TextView) findViewById(R.id.text);
button = (Button) findViewById(R.id.button);
button.setOnClickListener(this);

init();

mHandler.postDelayed(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
mHandler.postDelayed(this, 1000);
init();
text.setText('年:'+mYear+',月:'+mMonth+',日:'+mDay+','+mHour+':'+mMinute+':秒'+second);
}
}, 1000);
}
private void init(){
Calendar c = Calendar.getInstance();
mYear = c.get(Calendar.YEAR); //获取当前年份
mMonth = c.get(Calendar.MONTH)+1;//获取当前月份
mDay = c.get(Calendar.DAY_OF_MONTH);//获取当前月份的日期号码
mHour = c.get(Calendar.HOUR_OF_DAY);//获取当前的小时数
mMinute = c.get(Calendar.MINUTE);//获取当前的分钟数
second = c.get(Calendar.SECOND);//获取当前的秒数
ampm = c.get(Calendar.AM_PM); //0-上午;1-下午
//当前年的第几周 这个需求感觉没什么用
int week_of_year = c.get(Calendar.WEEK_OF_YEAR);
//当前月的第几周
int week_of_month = c.get(Calendar.WEEK_OF_MONTH);
//当前年的第几天
int day_of_year = c.get(Calendar.DAY_OF_YEAR);

mHandler.sendEmptyMessage(0);
}

/**
* 点击出现日历弹框
*/
private PickDialog dialog;
private Button button;
private void getData(){
dialog = new PickDialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.show();
}
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.button:
getData();

break;

default:
break;
}
}
}

-------------------------------

由此,封装出工具类,这种工具类 轮子比较多,

package com.example.mydemo.util;

import java.io.Serializable;

/**
* 自定义日期类
* @author kcw001
*/
public class CustomDate implements Serializable{

private static final long serialVersionUID = 1L;
public int year;
public int month;
public int day;
public int week;

public CustomDate(int year,int month,int day){
if(month > 12){
month = 1;
year++;
}else if(month <1){
month = 12;
year--;
}
this.year = year;
this.month = month;
this.day = day;
}

public CustomDate(){

this.year = DateUtils.getYear();
this.month = DateUtils.getMonth();
this.day = DateUtils.getCurrentMonthDay();
}

public static CustomDate modifiDayForObject(CustomDate date,int day){
CustomDate modifiDate = new CustomDate(date.year,date.month,day);
return modifiDate;
}
@Override
public String toString() {
return year+'-'+month+'-'+day;
}

public int getYear() {
return year;
}

public void setYear(int year) {
this.year = year;
}

public int getMonth() {
return month;
}

public void setMonth(int month) {
this.month = month;
}

public int getDay() {
return day;
}

 public void setDay(int day) {
this.day = day;
}

public int getWeek() {
return week;
}

public void setWeek(int week) {
this.week = week;
}

}

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import android.annotation.SuppressLint;

public class DateUtils {

public static String[] weekName = { '周日', '周一', '周二', '周三', '周四', '周五','周六' };

public static int getMonthDays(int year, int month) {
if (month > 12) {
month = 1;
year += 1;
} else if (month < 1) {
month = 12;
year -= 1;
}
int[] arr = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int days = 0;

if ((year % 4 0 && year % 100 != 0) || year % 400 0) {
arr[1] = 29; // 闰年2月29天
}

try {
days = arr[month - 1];
} catch (Exception e) {
e.getStackTrace();
}

return days;
}

public static int getYear() {
return Calendar.getInstance().get(Calendar.YEAR);
}

public static int getMonth() {
return Calendar.getInstance().get(Calendar.MONTH) + 1;
}

public static int getCurrentMonthDay() {
return Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
}

public static int getWeekDay() {
return Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
}

public static int getHour() {
return Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
}
public static int getMinute() {
return Calendar.getInstance().get(Calendar.MINUTE);
}

public static CustomDate getNextSunday() {

Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, 7 - getWeekDay()+1);
CustomDate date = new CustomDate(c.get(Calendar.YEAR),
c.get(Calendar.MONTH)+1, c.get(Calendar.DAY_OF_MONTH));
return date;
}

public static int[] getWeekSunday(int year, int month, int day, int pervious) {
int[] time = new int[3];
Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR, year);
c.set(Calendar.MONTH, month);
c.set(Calendar.DAY_OF_MONTH, day);
c.add(Calendar.DAY_OF_MONTH, pervious);
time[0] = c.get(Calendar.YEAR);
time[1] = c.get(Calendar.MONTH )+1;
time[2] = c.get(Calendar.DAY_OF_MONTH);
return time;

} Prototype: airwaves mac os.

public static int getWeekDayFromDate(int year, int month) {
Calendar cal = Calendar.getInstance();
cal.setTime(getDateFromString(year, month));
int week_index = cal.get(Calendar.DAY_OF_WEEK) - 1;
if (week_index < 0) {
week_index = 0;
}
return week_index;
}

@SuppressLint('SimpleDateFormat')
public static Date getDateFromString(int year, int month) {
String dateString = year + '-' + (month > 9 ? month : ('0' + month))
+ '-01';
Date date = null;
try {
SimpleDateFormat sdf = new SimpleDateFormat('yyyy-MM-dd');
date = sdf.parse(dateString);
} catch (ParseException e) {
System.out.println(e.getMessage());
}
return date;
}

public static boolean isToday(CustomDate date){
return(date.year DateUtils.getYear() &&
date.month DateUtils.getMonth()
&& date.day DateUtils.getCurrentMonthDay());
}

public static boolean isCurrentMonth(CustomDate date){
return(date.year DateUtils.getYear() &&
date.month DateUtils.getMonth());
}

/**
* 返回当天日期
* String 格式: 'yyyy-MM-dd' 'yyyy-MM-dd HH:mm:ss:SS'等
*/
public static String getNowData(Date data,String dateformat) {
// Date data = new Date();
SimpleDateFormat format = new SimpleDateFormat(dateformat);// 可以方便地修改日期格式
String now = format.format(data);
return now;
}
/**
* 传入字符串
* @param point1 起始日期
* @param point2 终止日期
* @return
*/
public static String getDays(String point1, String point2,boolean flag) {
SimpleDateFormat myFormatter = new SimpleDateFormat('yyyy-MM-dd');
long day = 0;
try {
java.util.Date date = myFormatter.parse(point1);
java.util.Date mydate = myFormatter.parse(point2);
day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
if(flag)
day = Math.abs(day);
} catch (Exception e) {
return ';
}
return day + ';
}
public static Calendar getDate(int day,int month,int year) {
Calendar calDate = Calendar.getInstance();
calDate.clear();
calDate.set(Calendar.YEAR, year);
calDate.set(Calendar.MONTH, month);
calDate.set(Calendar.DAY_OF_MONTH, day);
return calDate;
}

/**
* 传入Date对象计算相隔天数
*/
public static int getDays(Calendar fromCalendar,Calendar toCalendar){
return (int) ((toCalendar.getTime().getTime() - fromCalendar.getTime().getTime()) / (1000 * 60 * 60 * 24));
}
public Calendar getDate2(Date date,int day,int month,int year) {
Calendar calDate = Calendar.getInstance();
calDate.setTime(date);
calDate.set(Calendar.YEAR, year);
calDate.set(Calendar.MONTH, month);
calDate.set(Calendar.DAY_OF_MONTH, day);
return calDate;
}

}

DateUtil工具类

package com.example.mydemo.util;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

import android.annotation.SuppressLint;
import android.provider.ContactsContract.Data;

public class DateUtils {

public static String[] weekName = { '周日', '周一', '周二', '周三', '周四', '周五','周六' };

public static int getMonthDays(int year, int month) {
if (month > 12) {
month = 1;
year += 1;
} else if (month < 1) {
month = 12;
year -= 1;
}
int[] arr = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
int days = 0;

if ((year % 4 0 && year % 100 != 0) || year % 400 0) {
arr[1] = 29; // 闰年2月29天
}

try {
days = arr[month - 1];
} catch (Exception e) {
e.getStackTrace();
}

return days;
}

public static int getYear() {
return Calendar.getInstance().get(Calendar.YEAR);
}

public static int getMonth() {
return Calendar.getInstance().get(Calendar.MONTH) + 1;
}

public static int getCurrentMonthDay() {
return Calendar.getInstance().get(Calendar.DAY_OF_MONTH);
}

public static int getWeekDay() {
return Calendar.getInstance().get(Calendar.DAY_OF_WEEK);
}

public static int getHour() {
return Calendar.getInstance().get(Calendar.HOUR_OF_DAY);
}
public static int getMinute() {
return Calendar.getInstance().get(Calendar.MINUTE);
}

public static CustomDate getNextSunday() {

Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, 7 - getWeekDay()+1);
CustomDate date = new CustomDate(c.get(Calendar.YEAR),
c.get(Calendar.MONTH)+1, c.get(Calendar.DAY_OF_MONTH));
return date;
}

public static int[] getWeekSunday(int year, int month, int day, int pervious) {
int[] time = new int[3];
Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR, year);
c.set(Calendar.MONTH, month);
c.set(Calendar.DAY_OF_MONTH, day);
c.add(Calendar.DAY_OF_MONTH, pervious);
time[0] = c.get(Calendar.YEAR);
time[1] = c.get(Calendar.MONTH )+1;
time[2] = c.get(Calendar.DAY_OF_MONTH);
return time;

}

public static int getWeekDayFromDate(int year, int month) {
Calendar cal = Calendar.getInstance();
cal.setTime(getDateFromString(year, month));
int week_index = cal.get(Calendar.DAY_OF_WEEK) - 1;
if (week_index < 0) {
week_index = 0;
}
return week_index;
}

@SuppressLint('SimpleDateFormat')
public static Date getDateFromString(int year, int month) {
String dateString = year + '-' + (month > 9 ? month : ('0' + month))
+ '-01';
Date date = null;
try {
SimpleDateFormat sdf = new SimpleDateFormat('yyyy-MM-dd');
date = sdf.parse(dateString);
} catch (ParseException e) {
System.out.println(e.getMessage());
}
return date;
}
public static boolean isToday(CustomDate date){
return(date.year DateUtils.getYear() &&
date.month DateUtils.getMonth()
&& date.day DateUtils.getCurrentMonthDay());
}

public static boolean isCurrentMonth(CustomDate date){
return(date.year DateUtils.getYear() &&
date.month DateUtils.getMonth());
}

/**
* 返回当天日期
* String 格式: 'yyyy-MM-dd' 'yyyy-MM-dd HH:mm:ss:SS'等
*/
public static String getNowData(Date data,String dateformat) {
// Date data = new Date();
SimpleDateFormat format = new SimpleDateFormat(dateformat);// 可以方便地修改日期格式
String now = format.format(data);
return now;
}
/**
* 传入字符串
* @param point1 起始日期
* @param point2 终止日期
* @return
*/
public static String getDays(String point1, String point2,boolean flag) {
SimpleDateFormat myFormatter = new SimpleDateFormat('yyyy-MM-dd');
long day = 0;
try {
java.util.Date date = myFormatter.parse(point1);
java.util.Date mydate = myFormatter.parse(point2);
day = (date.getTime() - mydate.getTime()) / (24 * 60 * 60 * 1000);
if(flag)
day = Math.abs(day);
} catch (Exception e) {
return ';
}
return day + ';
}
public static Calendar getDate(int day,int month,int year) {
Calendar calDate = Calendar.getInstance();
calDate.clear();
calDate.set(Calendar.YEAR, year);
calDate.set(Calendar.MONTH, month);
calDate.set(Calendar.DAY_OF_MONTH, day);
return calDate;
}

/**
* 传入Date对象计算相隔天数
*/
public static int getDays(Calendar fromCalendar,Calendar toCalendar){
return (int) ((toCalendar.getTime().getTime() - fromCalendar.getTime().getTime()) / (1000 * 60 * 60 * 24));
}
public Calendar getDate2(Date date,int day,int month,int year) {
Calendar calDate = Calendar.getInstance();
calDate.setTime(date);
calDate.set(Calendar.YEAR, year);
calDate.set(Calendar.MONTH, month);
calDate.set(Calendar.DAY_OF_MONTH, day);
return calDate;
}

}

package com.example.mydemo;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewConfiguration;

import com.example.mydemo.util.CustomDate;
import com.example.mydemo.util.DateUtils;

public class CalendarView extends View{
private static final String TAG = 'CalendarView';
/**
* 两种模式 (月份和星期)
*/
public static final int MONTH_STYLE = 0;
public static final int WEEK_STYLE = 1;

private static final int TOTAL_COL = 7;
private static final int TOTAL_ROW = 6;

private Paint mCirclePaint;
private Paint mTextPaint;
private int mViewWidth;
private int mViewHight;
private int mCellSpace;
private Row rows[] = new Row[TOTAL_ROW];
private static CustomDate mShowDate;//自定义的日期 包括year month day
public static int style = MONTH_STYLE;
private static final int WEEK = 7;
private CallBack mCallBack;//回调
private int touchSlop;
private boolean callBackCellSpace;

public interface CallBack {

void clickDate(CustomDate date);//回调点击的日期

void onMesureCellHeight(int cellSpace);//回调cell的高度确定slidingDrawer高度

void changeDate(CustomDate date);//回调滑动viewPager改变的日期

void onClickOnDate();//设置日期点击item事件
}

public CalendarView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init(context);

}

public CalendarView(Context context, AttributeSet attrs) {
super(context, attrs);
init(context);

}

public CalendarView(Context context) {
super(context);
init(context);
}

public CalendarView(Context context, int style, CallBack mCallBack) {
super(context);
CalendarView.style = style;
this.mCallBack = mCallBack;
init(context);
}

@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
for (int i = 0; i < TOTAL_ROW; i++) {
if (rows[i] != null)
rows[i].drawCells(canvas);
}
}

private void init(Context context) {
mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
mCirclePaint.setStyle(Paint.Style.FILL);
mCirclePaint.setColor(Color.parseColor('#F24949'));
touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
initDate();

}

private void initDate() {
if (style MONTH_STYLE) {
mShowDate = new CustomDate();
} else if(style WEEK_STYLE ) {
mShowDate = DateUtils.getNextSunday();
}
fillDate();
}

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mViewWidth = w;
mViewHight = h;
mCellSpace = Math.min(mViewHight / TOTAL_ROW, mViewWidth / TOTAL_COL);
if (!callBackCellSpace) {
mCallBack.onMesureCellHeight(mCellSpace);
callBackCellSpace = true;
}
mTextPaint.setTextSize(mCellSpace / 3);

}

private Cell mClickCell;
private float mDownX;
private float mDownY;
/*
*
* 触摸事件为了确定点击的位置日期
*/
@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
mDownX = event.getX();
mDownY = event.getY();
break;
case MotionEvent.ACTION_UP:
float disX = event.getX() - mDownX;
float disY = event.getY() - mDownY;
if (Math.abs(disX) < touchSlop && Math.abs(disY) < touchSlop) {
int col = (int) (mDownX / mCellSpace);
int row = (int) (mDownY / mCellSpace);

//执行点击事件
mCallBack.onClickOnDate();
measureClickCell(col, row);

}
break;
}
return true;
}

private void measureClickCell(int col, int row) {
if (col >= TOTAL_COL || row >= TOTAL_ROW)
return;
if (mClickCell != null) {
rows[mClickCell.j].cells[mClickCell.i] = mClickCell;
}
if (rows[row] != null) {
mClickCell = new Cell(rows[row].cells[col].date,
rows[row].cells[col].state, rows[row].cells[col].i,
rows[row].cells[col].j);
rows[row].cells[col].state = State.CLICK_DAY;
CustomDate date = rows[row].cells[col].date;
date.week = col;
mCallBack.clickDate(date);
invalidate();
}
}

// 组
class Row {
public int j;

Row(int j) {
this.j = j;
}

public Cell[] cells = new Cell[TOTAL_COL];

public void drawCells(Canvas canvas) {
for (int i = 0; i < cells.length; i++) {
if (cells[i] != null)
cells[i].drawSelf(canvas);
}

Click Date Mac Os Download

}
}

// 单元格
class Cell {
public CustomDate date;
public State state;
public int i;
public int j;

public Cell(CustomDate date, State state, int i, int j) {
super();
this.date = date;
this.state = state;
this.i = i;
this.j = j;
}

// 绘制一个单元格 如果颜色需要自定义可以修改
public void drawSelf(Canvas canvas) {
switch (state) {
case CURRENT_MONTH_DAY:
mTextPaint.setColor(Color.parseColor('#80000000'));//偏红
break;
case NEXT_MONTH_DAY:
case PAST_MONTH_DAY:
mTextPaint.setColor(Color.parseColor('#40000000'));//暗色
break;
case TODAY:
mTextPaint.setColor(Color.parseColor('#F24949'));//红色
break;
case BEFORE_DAY:
mTextPaint.setColor(Color.parseColor('#F24949'));//红色
break;

case CLICK_DAY:
mTextPaint.setColor(Color.parseColor('#fffffe'));//白色
canvas.drawCircle((float) (mCellSpace * (i + 0.5)),
(float) ((j + 0.5) * mCellSpace), mCellSpace / 2,
mCirclePaint);
break;
}
// 绘制文字
String content = date.day+';
canvas.drawText(content,
(float) ((i+0.5) * mCellSpace - mTextPaint.measureText(content)/2),
(float) ((j + 0.7) * mCellSpace - mTextPaint.measureText(
content, 0, 1) / 2), mTextPaint);
}
}
/**
*
* @author huang
* cell的state
*当前月日期,过去的月的日期,下个月的日期,今天,点击的日期
*
*/
enum State {
CURRENT_MONTH_DAY, PAST_MONTH_DAY, NEXT_MONTH_DAY, TODAY, CLICK_DAY,BEFORE_DAY;
}

/**
* 填充日期的数据
*/
private void fillDate() {
if (style MONTH_STYLE) {
fillMonthDate();
} else if(style WEEK_STYLE) {
fillWeekDate();
}
mCallBack.changeDate(mShowDate);
}

/**
* 填充星期模式下的数据 默认通过当前日期得到所在星期天的日期,然后依次填充日期
*/
private void fillWeekDate() {
int lastMonthDays = DateUtils.getMonthDays(mShowDate.year, mShowDate.month-1);
rows[0] = new Row(0);
int day = mShowDate.day;
for (int i = TOTAL_COL -1; i >= 0 ; i--) {
day -= 1;
if (day < 1) {
day = lastMonthDays;
}
CustomDate date = CustomDate.modifiDayForObject(mShowDate, day);
if (DateUtils.isToday(date)) {
mClickCell = new Cell(date, State.TODAY, i, 0);
date.week = i;
mCallBack.clickDate(date);
rows[0].cells[i] = new Cell(date, State.CLICK_DAY, i, 0);
continue;
}
rows[0].cells[i] = new Cell(date, State.CURRENT_MONTH_DAY,i, 0);
}
}

/**
* 填充月份模式下数据 通过getWeekDayFromDate得到一个月第一天是星期几就可以算出所有的日期的位置 然后依次填充
* 重构一下
*/
private void fillMonthDate() {
int monthDay = DateUtils.getCurrentMonthDay();
int lastMonthDays = DateUtils.getMonthDays(mShowDate.year, mShowDate.month - 1);
int currentMonthDays = DateUtils.getMonthDays(mShowDate.year, mShowDate.month);
int firstDayWeek = DateUtils.getWeekDayFromDate(mShowDate.year, mShowDate.month);
boolean isCurrentMonth = false;
if (DateUtils.isCurrentMonth(mShowDate)) {
isCurrentMonth = true;
}
int day = 0;
for (int j = 0; j < TOTAL_ROW; j++) {
rows[j] = new Row(j);
for (int i = 0; i < TOTAL_COL; i++) {
int postion = i + j * TOTAL_COL;
if (postion >= firstDayWeek
&& postion < firstDayWeek + currentMonthDays) {
day++;// 这个月的
if (isCurrentMonth && day monthDay) {//今天
CustomDate date = CustomDate.modifiDayForObject(mShowDate, day);
mClickCell = new Cell(date,State.TODAY, i,j);
date.week = i;
mCallBack.clickDate(date);
rows[j].cells[i] = new Cell(date,State.CLICK_DAY, i,j);
continue;
}if (isCurrentMonth && day < monthDay) { // 如果比这个月的今天要XIAO,表示还没到
rows[j].cells[i] = new Cell(
CustomDate.modifiDayForObject(mShowDate, day),
State.BEFORE_DAY, i, j);
continue;
}

rows[j].cells[i] = new Cell(CustomDate.modifiDayForObject(mShowDate, day),
State.CURRENT_MONTH_DAY, i, j);
} else if (postion < firstDayWeek) {
rows[j].cells[i] = new Cell(new CustomDate(mShowDate.year, mShowDate.month-1, lastMonthDays - (firstDayWeek- postion - 1)), State.PAST_MONTH_DAY, i, j);
} else if (postion >= firstDayWeek + currentMonthDays) {
rows[j].cells[i] = new Cell((new CustomDate(mShowDate.year, mShowDate.month+1, postion - firstDayWeek - currentMonthDays + 1)), State.NEXT_MONTH_DAY, i, j);
}
}
}
}

public void update() {
fillDate();
invalidate();
}

public void backToday(){
initDate();
invalidate();
}

//切换style
public void switchStyle(int style) {
CalendarView.style = style;
if (style MONTH_STYLE) {
update();
} else if (style WEEK_STYLE) {
int firstDayWeek = DateUtils.getWeekDayFromDate(mShowDate.year,
mShowDate.month);
int day = 1 + WEEK - firstDayWeek;
mShowDate.day = day;

update();
}

}
//向右滑动
public void rightSilde() {
if (style MONTH_STYLE) {

if (mShowDate.month 12) {
mShowDate.month = 1;
mShowDate.year += 1;
} else {
mShowDate.month += 1;
}

} else if (style WEEK_STYLE) {
int currentMonthDays = DateUtils.getMonthDays(mShowDate.year, mShowDate.month);
if (mShowDate.day + WEEK > currentMonthDays) {
if (mShowDate.month 12) {
mShowDate.month = 1;
mShowDate.year += 1;
} else {
mShowDate.month += 1;
}
mShowDate.day = WEEK - currentMonthDays + mShowDate.day;
}else{
mShowDate.day += WEEK;

}
}
update();
}
//向左滑动
public void leftSilde() {

if (style MONTH_STYLE) {
if (mShowDate.month 1) {
mShowDate.month = 12;
mShowDate.year -= 1;
} else {
mShowDate.month -= 1;
}

} else if (style WEEK_STYLE) {
int lastMonthDays = DateUtils.getMonthDays(mShowDate.year, mShowDate.month);
if (mShowDate.day - WEEK < 1) {
if (mShowDate.month 1) {
mShowDate.month = 12;
mShowDate.year -= 1;
} else {
mShowDate.month -= 1;
}
mShowDate.day = lastMonthDays - WEEK + mShowDate.day;

}else{
mShowDate.day -= WEEK;
}
Log.i(TAG, 'leftSilde'+mShowDate.toString());
}
update();
}
}

package com.example.mydemo;

import android.content.Context;

import com.example.mydemo.CalendarView.CallBack;

/**
* calendview辅助类 在这里 完成回调今天等功能
* @author kcw001
*
*/
public class CalendarViewBuilder {

private CalendarView[] calendarViews;

/**
* create 多个calendarviews
* @param context
* @param count
* @param style
* @param callBack
* @return
*/
public CalendarView[] createMassCalendarViews(Context context,int count,int style,CallBack callBack){
calendarViews = new CalendarView[count];
for(int i = 0; i < count;i++){
calendarViews[i] = new CalendarView(context, style,callBack);
}
return calendarViews;
}

public CalendarView[] createMassCalendarViews(Context context,int count,CallBack callBack){

return createMassCalendarViews(context, count, CalendarView.MONTH_STYLE,callBack);
}

/**
* 切换CandlendarView的样式
* @param style
*/
public void swtichCalendarViewsStyle(int style){
if(calendarViews != null)
for(int i = 0 ;i < calendarViews.length;i++){
calendarViews[i].switchStyle(style);
}
}

/**
* CandlendarView回到当前日期
*/

public void backTodayCalendarViews(){
if(calendarViews != null)
for(int i = 0 ;i < calendarViews.length;i++){
calendarViews[i].backToday();
}
}
}

package com.example.mydemo;

import android.support.v4.view.ViewPager.OnPageChangeListener;

public class CalendarViewPagerLisenter implements OnPageChangeListener{

private SildeDirection mDirection = SildeDirection.NO_SILDE;
int mCurrIndex = 498;
private CalendarView[] mShowViews;

public CalendarViewPagerLisenter(CustomViewPagerAdapter viewAdapter) {
super();
this.mShowViews = viewAdapter.getAllItems();
}

@Override
public void onPageSelected(int arg0) {
measureDirection(arg0);
updateCalendarView(arg0);
}

private void updateCalendarView(int arg0) {
if(mDirection SildeDirection.RIGHT){
mShowViews[arg0 % mShowViews.length].rightSilde();
}else if(mDirection SildeDirection.LEFT){
mShowViews[arg0 % mShowViews.length].leftSilde();
}
mDirection = SildeDirection.NO_SILDE;
}

/**
* 判断滑动方向
* @param arg0
*/
private void measureDirection(int arg0) {

if (arg0 > mCurrIndex) {
mDirection = SildeDirection.RIGHT;

} else if (arg0 < mCurrIndex) {
mDirection = SildeDirection.LEFT;
}
mCurrIndex = arg0;
}

@Override
public void onPageScrolled(int arg0, float arg1, int arg2) {
}

@Override
public void onPageScrollStateChanged(int arg0) {
}

//反射
enum SildeDirection {
RIGHT, LEFT, NO_SILDE;
}
}

----------------------------------------------------------------------------------

package com.example.mydemo;

Mac Os Download

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.util.AttributeSet;
import android.view.MotionEvent;
import android.view.View;

/**
* 自定义布局 绘制文字和园
* @author kcw001
*/
public class CircleTextView extends View {

private String mText = '订';
private OnClickListener onClickListener;
private Paint mCirclePaint;
private Paint mTextPaint;
private int mViewWidth;
private int mViewHight;

public CircleTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
// TODO Auto-generated constructor stub
init();
}

public CircleTextView(Context context) {
super(context);
// TODO Auto-generated constructor stub
init();
}

public CircleTextView(Context context, AttributeSet attrs) {
super(context, attrs);
// TODO Auto-generated constructor stub
TypedArray t = context.obtainStyledAttributes(attrs,
R.styleable.CircleTextView);
mText = t.getString(R.styleable.CircleTextView_text);
t.recycle();

init();
}

@Override
public void setOnClickListener(OnClickListener l) {
super.setOnClickListener(l);
this.onClickListener = l;
}

public void setmText(String mText) {
this.mText = mText;
}

@Override
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
canvas.drawCircle(mViewWidth / 2, mViewWidth / 2, mViewWidth / 2,
mCirclePaint);
canvas.drawText(mText,
(mViewWidth - mTextPaint.measureText(mText)) / 2,
(mViewHight + mTextPaint.measureText(mText) / 2) / 2,
mTextPaint);
}

public void init() {
mTextPaint = new Paint(Paint.ANTI_ALIAS_FLAG);

mCirclePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
initPaint(false);
}

@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
mViewWidth = w;
mViewHight = h;
mTextPaint.setTextSize(mViewWidth / 3);
}

@Override
public boolean onTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
initPaint(true);
break;

case MotionEvent.ACTION_UP:
case MotionEvent.ACTION_CANCEL:
if (onClickListener != null)
onClickListener.onClick(this);
initPaint(false);
break;
}
invalidate();
return true;
}

private void initPaint(boolean isPress) {
if (!isPress) {
mCirclePaint.setStyle(Paint.Style.STROKE);
mCirclePaint.setColor(Color.parseColor('#40000000'));
mTextPaint.setColor(Color.parseColor('#80000000'));
} else {
mCirclePaint.setStyle(Paint.Style.FILL);
mCirclePaint.setColor(Color.parseColor('#F24949'));
mTextPaint.setColor(Color.parseColor('#fffffe'));
}
}
}

package com.example.mydemo;

import android.os.Parcelable;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.View;

/**
* 日历适配器
* @author kcw001
*
*/
public class CustomViewPagerAdapter extends PagerAdapter {

private V[] views;

public CustomViewPagerAdapter(V[] views) {
super();
this.views = views;
}

@Override
public void finishUpdate(View arg0) {
}

@Override
public void notifyDataSetChanged() {
super.notifyDataSetChanged();
}

@Override
public int getCount() {
return Integer.MAX_VALUE;
}

@Override
public Object instantiateItem(View arg0, int arg1) {
if (((ViewPager) arg0).getChildCount() views.length) {
((ViewPager) arg0).removeView(views[arg1 % views.length]);
}

((ViewPager) arg0).addView(views[arg1 % views.length], 0);

return views[arg1 % views.length];
}

@Override
public boolean isViewFromObject(View arg0, Object arg1) {
return arg0 (arg1);
}

@Override
public Parcelable saveState() {
return null;
}

@Override
public void destroyItem(View arg0, int arg1, Object arg2) {
// TODO Auto-generated method stub

}

@Override
public void startUpdate(View arg0) {
}

public V[] getAllItems() {
return views;
}
}

package com.example.mydemo;

import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Bundle;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.LinearLayout;
import android.widget.SlidingDrawer;
import android.widget.SlidingDrawer.OnDrawerOpenListener;
import android.widget.SlidingDrawer.OnDrawerScrollListener;
import android.widget.TextView;

import com.example.mydemo.CalendarView.CallBack;
import com.example.mydemo.util.CustomDate;
import com.example.mydemo.util.DateUtils;

public class PickDialog extends Dialog implements OnClickListener,CallBack{

private Context context;
private PickDialogListener pickDialogListener;
private LinearLayout dialog_data;

private CalendarViewBuilder builder = new CalendarViewBuilder();//创建view的辅助类

Clickdate Mac Os Catalina

private TextView monthCalendarView;
private TextView weekCalendarView;

private CircleTextView mSubscibeCircleView;
private CircleTextView mNowCircleView;
private CircleTextView mAddCircleView;
private LinearLayout layout;
//年月周
private TextView showYearView;
private TextView showMonthView;
private TextView showWeekView;
private ViewPager viewPager;
private CalendarView[] views;
private LayoutInflater inflater;

private View mContentPager;
private SlidingDrawer mSlidingDrawer;
private CustomDate mClickDate;

public PickDialog(Context context) {
super(context);
// TODO Auto-generated constructor stub
this.context=context;
}

public PickDialog(Context context, int theme, PickDialogListener pickDialogListener) {
super(context);
// TODO Auto-generated constructor stub
this.context=context;
this.pickDialogListener=pickDialogListener;
}

//如何调用接口里面的
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);

inflater = LayoutInflater.from(context);
layout = (LinearLayout) inflater.inflate(
R.layout.dialog_data, null);

this.setCanceledOnTouchOutside(true);
this.setOnCancelListener(new DialogInterface.OnCancelListener() {

@Override
public void onCancel(DialogInterface dialog) {
// TODO Auto-generated method stub
dismiss();
}
});
init();

this.setContentView(layout);

}

private void init(){

viewPager = (ViewPager) layout.findViewById(R.id.viewpager);
showMonthView = (TextView)layout.findViewById(R.id.show_month_view);
showYearView = (TextView)layout.findViewById(R.id.show_year_view);
showWeekView = (TextView)layout.findViewById(R.id.show_week_view);
views = builder.createMassCalendarViews(getContext(), 5, this);
monthCalendarView = (TextView) layout.findViewById(R.id.month_calendar_button);
weekCalendarView = (TextView) layout.findViewById(R.id.week_calendar_button);
mContentPager = layout.findViewById(R.id.contentPager);
mSlidingDrawer = (SlidingDrawer)layout.findViewById(R.id.sildingDrawer);

mSubscibeCircleView = (CircleTextView)layout.findViewById(R.id.subscibe_circle_view);
mNowCircleView = (CircleTextView)layout.findViewById(R.id.now_circle_view);//点击今天回到今天
mAddCircleView = (CircleTextView)layout.findViewById(R.id.add_circle_view);
monthCalendarView.setOnClickListener(this);
weekCalendarView.setOnClickListener(this);
mSubscibeCircleView.setOnClickListener(this);
mNowCircleView.setOnClickListener(this);
mAddCircleView.setOnClickListener(this);

setViewPager();
setOnDrawListener();
}

@Override
public void onClick(View v) {
// TODO Auto-generated method stub
switch (v.getId()) {
case R.id.month_calendar_button://月份
swtichBackgroundForButton(true);
builder.swtichCalendarViewsStyle(CalendarView.MONTH_STYLE);
mSlidingDrawer.close();
break;
case R.id.week_calendar_button://周
swtichBackgroundForButton(false);
mSlidingDrawer.open();

break;
case R.id.now_circle_view://点击今天会到今天
builder.backTodayCalendarViews();
break;
case R.id.add_circle_view://加号 点击进入编辑

break;
case R.id.subscibe_circle_view:

dismiss();
}
}

private void swtichBackgroundForButton(boolean isMonth){
if(isMonth){
monthCalendarView.setBackgroundResource(R.drawable.press_left_text_bg);
weekCalendarView.setBackgroundColor(Color.TRANSPARENT);
}else{
weekCalendarView.setBackgroundResource(R.drawable.press_right_text_bg);
monthCalendarView.setBackgroundColor(Color.TRANSPARENT);
}
}

private void setViewPager() {
CustomViewPagerAdapter viewPagerAdapter = new CustomViewPagerAdapter(views);
viewPager.setAdapter(viewPagerAdapter);
viewPager.setCurrentItem(498);
viewPager.setOnPageChangeListener(new CalendarViewPagerLisenter(viewPagerAdapter));
}

@SuppressWarnings('deprecation')
private void setOnDrawListener() {

mSlidingDrawer.setOnDrawerOpenListener(new OnDrawerOpenListener() {

@Override
public void onDrawerOpened() {
builder.swtichCalendarViewsStyle(CalendarView.WEEK_STYLE);
}
});

mSlidingDrawer.setOnDrawerScrollListener(new OnDrawerScrollListener() {

The dot mac os. @Override
public void onScrollStarted() {
builder.swtichCalendarViewsStyle(CalendarView.MONTH_STYLE);
}

@Override
public void onScrollEnded() {
}
});
}

//------------------------------------------------callback
@Override
public void clickDate(CustomDate date) {
// TODO Auto-generated method stub
mClickDate = date;
}

@Override
public void onMesureCellHeight(int cellSpace) {
// TODO Auto-generated method stub
mSlidingDrawer.getLayoutParams().height = mContentPager.getHeight() - cellSpace;
}

@Override
public void changeDate(CustomDate date) {
// TODO Auto-generated method stub
setShowDateViewText(date.year,date.month);
}

private void setShowDateViewText(int year, int month) {
// TODO Auto-generated method stub
showYearView.setText(year+');
showMonthView.setText(month+'月');
showWeekView.setText(DateUtils.weekName[DateUtils.getWeekDay()-1]);
}

@Override
public void onDetachedFromWindow() {
// TODO Auto-generated method stub
super.onDetachedFromWindow();
}

/**
* 获取到日历天数 点击功能的实现
*/
boolean flag=true;
@Override
public void onClickOnDate() {
int day = mClickDate.getDay();
int month = mClickDate.getMonth();
int year = mClickDate.getYear();

//获取当前日期
//Date data=new Date();
//String nowData = DateUtils.getNowData(data,'yyyy-MM-dd');

//获取点击日期
/* Calendar date2 = DateUtils.getDate(day, month, year);
Date time = date2.getTime();
SimpleDateFormat format = new SimpleDateFormat('yyyy-MM-dd');
String nowData = DateUtils.getNowData(time, 'yyyy-MM-dd');
Toast.makeText(getContext(), nowData, 0).show();*/

//计算相邻天数相差
/*String days = DateUtils.getDays('2016-1-12', '2016-1-18');
Toast.makeText(context, days, 0).show();*/

/**
* 设置以前的时间不可点选
*/
/*String days = DateUtils.getDays('2016-1-12', '2016-1-18',false);
int num = Integer.parseInt(days);
if(num<0)
Toast.makeText(context, '不可点击', 0).show();
else
Toast.makeText(context, days, 0).show();*/

}

}

package com.example.mydemo;

public interface PickDialogListener {
public void onLeftBtnClick();
public void onRightBtnClick();
public void onListItemClick(int position, String string);
public void onListItemLongClick(int position, String string);
public void onCancel();
}

主页的布局文件

xmlns:tools='http://schemas.android.com/tools'
android:layout_width='match_parent'
android:layout_height='match_parent'
tools:context='.MainActivity' >

android:id='@+id/text'
android:layout_width='wrap_content'
android:layout_height='wrap_content'
android:text='@string/hello_world' /> Graveyard of the void egg mac os.

android:id='@+id/button'
android:layout_width='wrap_content'
android:layout_height='wrap_content'
android:layout_centerInParent='true'
android:text='点我'
/>

dialog页的布局文件

xmlns:tools='http://schemas.android.com/tools'
xmlns:demo='http://schemas.android.com/apk/res/com.example.mydemo'
android:layout_width='wrap_content'
android:layout_height='wrap_content'
android:orientation='vertical' >

android:layout_width='fill_parent'
android:layout_height='50dip'
android:background='@drawable/action_bar_bg'
android:orientation='horizontal' >

android:id='@+id/show_month_view'
android:layout_width='wrap_content'
android:layout_height='fill_parent'
android:layout_marginLeft='15dip'
android:layout_marginRight='10dip'
android:layout_alignParentLeft='true'
android:gravity='center'
android:text='11月'
android:textColor='#fffffe'
android:textSize='24sp' />

android:layout_width='wrap_content'
android:layout_height='fill_parent'
android:layout_toRightOf='@id/show_month_view'
android:orientation='vertical' >

android:id='@+id/show_week_view'
android:layout_width='wrap_content'
android:layout_height='fill_parent'
android:layout_weight='1'
android:gravity='bottom|left'
android:paddingBottom='1dip'
android:text='周六'
android:textColor='#80ffffff'
android:textSize='12sp' />

android:id='@+id/show_year_view'
android:layout_width='wrap_content'
android:layout_height='fill_parent'
android:layout_weight='1'
android:gravity='top|left'
android:paddingTop='1dip'
android:text='2015'
android:textColor='#80ffffff'
android:textSize='12sp' />

android:layout_width='80dip'
android:layout_height='25dip'
android:layout_alignParentRight='true'
android:layout_centerVertical='true'
android:background='@drawable/select_view_bg'
android:layout_marginRight='20dip'
android:orientation='horizontal'
>
android:id='@+id/month_calendar_button'
android:layout_width='wrap_content'
android:layout_height='fill_parent'
android:layout_weight='1'
android:text='月'
android:gravity='center'
android:textColor='#ffffff'
android:clickable='@drawable/press_left_text_bg'
/>
android:layout_width='1px'
android:layout_height='fill_parent'
android:background='#80ffffff'
android:textColor='#ffffff'
/>
android:id='@+id/week_calendar_button'
android:layout_width='wrap_content'
android:layout_height='fill_parent'
android:layout_weight='1'
android:text='周'
android:gravity='center'
android:textColor='#ffffff'
android:clickable='@drawable/press_right_text_bg'
/>

android:layout_width='fill_parent'
android:layout_height='wrap_content'
android:paddingLeft='10dip'
android:paddingRight='10dip'
android:background='#fffffe'
android:orientation='vertical' >

android:layout_width='fill_parent'
android:layout_height='1px'
android:layout_alignParentTop='true'
android:background='#20000000' >

android:layout_width='fill_parent'
android:layout_height='20dip'
android:layout_marginBottom='2dip'
android:layout_marginTop='2dip' >

android:text='日'
android:textColor='@color/date_1' />

android:text='一'
android:textColor='@color/date_2' />

android:text='二'
android:textColor='@color/date_2' />

android:text='三'
android:textColor='@color/date_2' />

android:text='四'
android:textColor='@color/date_2' />

android:text='五'
android:textColor='@color/date_2' />

android:text='六'
android:textColor='@color/date_1' />

Update

android:layout_width='fill_parent'
android:layout_height='1px'
android:layout_alignParentTop='true'
android:background='#20000000' >

android:id='@+id/contentPager'
android:layout_width='fill_parent'
android:layout_height='fill_parent'
android:layout_weight='1'
android:background='#fffffe'
>
android:id='@+id/viewpager'
android:layout_width='fill_parent'
android:layout_height='300dp'
android:layout_gravity='center'
android:paddingLeft='15dip'
android:paddingRight='10dip'
android:background='#F7F7F7' >

android:id='@+id/sildingDrawer'
android:layout_width='fill_parent'
android:layout_height='100dip'
android:orientation='vertical'
android:layout_alignBottom='@+id/viewpager'
android:handle='@+id/handlerText'
android:content='@+id/contentText'
>
android:id='@+id/handlerText'
android:layout_height='wrap_content'
android:minHeight='100dip'
android:background='#fffffe'
android:layout_width='fill_parent'
android:orientation='vertical'>
android:layout_width='fill_parent'
android:layout_height='1px'
android:background='#30000000' >

android:layout_width='fill_parent'
android:layout_height='50dip'
android:paddingLeft='5dip'
android:text='一座城池2012'
android:textSize='16sp'
android:textColor='#90000000'
android:gravity='center_vertical'
/>
android:layout_width='fill_parent'
android:layout_height='1px'
android:background='#20000000' >


android:id='@+id/contentText'
android:background='#fffffe'
android:layout_width='fill_parent'
android:layout_height='wrap_content'>


android:layout_width='fill_parent'
android:layout_height='60dip'
android:background='@drawable/bottom_bar_bg' >

android:layout_width='fill_parent'
android:layout_height='1px'
android:layout_alignParentTop='true'
android:background='#20000000' >

android:id='@+id/now_circle_view'
android:layout_width='50dip'
android:layout_height='50dip'
android:layout_centerInParent='true'
android:layout_marginLeft='10dip'
android:layout_marginRight='10dip'
demo:text='今' />

android:id='@+id/subscibe_circle_view'
android:layout_width='50dip'
android:layout_height='50dip'
android:layout_centerInParent='true'
android:layout_toLeftOf='@id/now_circle_view'
demo:text='帅' />

android:id='@+id/add_circle_view'
android:layout_width='50dip'
android:layout_height='50dip'
android:layout_centerInParent='true'
android:layout_toRightOf='@id/now_circle_view'
demo:text='+' />

action_bar_bg.xml




bottom_bar_bg.xml




press_left_text_bg.xml




press_right_text_bg.xml




select_view_bg.xml





value 目录下

attrs.xml




colors.xml




#F24949
#40000000

styles.xml中添加:


<br> <item name='android:layout_width'>fill_parent</item><br> <item name='android:layout_height'>fill_parent</item><br> <item name='android:layout_weight'>1</item><br> <item name='android:gravity'>center</item><br> <item name='android:textSize'>12sp</item><br>

ok,就是这么多了,还有几个细节没处理,明天整理好后

继续

完整demo下载:

http://download.csdn.net/detail/onebelowzero2012/9352913

另附:欢迎加入群一块学习交流,谢谢大家!Android&Go,Let's go! 521039620

有几个地方,后面会更新修改,

android日历控件(一)的更多相关文章

  1. Android 日历控件PickTime

    最近做项目,需要设置用户的生日,所以做这样一个功能. 开始发觉自带的 DatePicker 很是不好用. 上代码:

broken image