forked from huanghaibin-dev/CalendarView
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1f5c8a8
commit b55a31d
Showing
31 changed files
with
818 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
174 changes: 174 additions & 0 deletions
174
app/src/main/java/com/haibin/calendarviewproject/full/FullActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
package com.haibin.calendarviewproject.full; | ||
|
||
import android.annotation.SuppressLint; | ||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.util.Log; | ||
import android.view.View; | ||
import android.widget.TextView; | ||
|
||
import com.haibin.calendarview.Calendar; | ||
import com.haibin.calendarview.CalendarView; | ||
import com.haibin.calendarviewproject.R; | ||
import com.haibin.calendarviewproject.base.activity.BaseActivity; | ||
import com.haibin.calendarviewproject.colorful.ColorfulActivity; | ||
import com.haibin.calendarviewproject.custom.CustomActivity; | ||
import com.haibin.calendarviewproject.index.IndexActivity; | ||
import com.haibin.calendarviewproject.simple.SimpleActivity; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
/** | ||
* 全屏日历,因为月份大小不同的关系,需要 app:month_view_show_mode="mode_all", | ||
* 一般地,既然使用全屏日历,那也不必要 | ||
* Created by huanghaibin on 2019/3/7. | ||
*/ | ||
|
||
public class FullActivity extends BaseActivity implements | ||
CalendarView.OnCalendarSelectListener, | ||
CalendarView.OnYearChangeListener, | ||
View.OnClickListener { | ||
|
||
TextView mTextMonthDay; | ||
|
||
TextView mTextYear; | ||
|
||
TextView mTextLunar; | ||
|
||
TextView mTextCurrentDay; | ||
|
||
private int mYear; | ||
|
||
CalendarView mCalendarView; | ||
|
||
public static void show(Context context) { | ||
context.startActivity(new Intent(context, FullActivity.class)); | ||
} | ||
|
||
@Override | ||
protected int getLayoutId() { | ||
return R.layout.activity_full; | ||
} | ||
|
||
@SuppressLint("SetTextI18n") | ||
@Override | ||
protected void initView() { | ||
setStatusBarDarkMode(); | ||
mTextMonthDay = (TextView) findViewById(R.id.tv_month_day); | ||
mTextYear = (TextView) findViewById(R.id.tv_year); | ||
mTextLunar = (TextView) findViewById(R.id.tv_lunar); | ||
mTextCurrentDay = (TextView) findViewById(R.id.tv_current_day); | ||
mCalendarView = (CalendarView) findViewById(R.id.calendarView); | ||
mTextMonthDay.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
mCalendarView.showYearSelectLayout(mYear); | ||
mTextLunar.setVisibility(View.GONE); | ||
mTextYear.setVisibility(View.GONE); | ||
mTextMonthDay.setText(String.valueOf(mYear)); | ||
} | ||
}); | ||
findViewById(R.id.fl_current).setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
mCalendarView.scrollToCurrent(); | ||
} | ||
}); | ||
|
||
mCalendarView.setOnCalendarSelectListener(this); | ||
mCalendarView.setOnYearChangeListener(this); | ||
mTextYear.setText(String.valueOf(mCalendarView.getCurYear())); | ||
mYear = mCalendarView.getCurYear(); | ||
mTextMonthDay.setText(mCalendarView.getCurMonth() + "月" + mCalendarView.getCurDay() + "日"); | ||
mTextLunar.setText("今日"); | ||
mTextCurrentDay.setText(String.valueOf(mCalendarView.getCurDay())); | ||
} | ||
|
||
@Override | ||
protected void initData() { | ||
int year = mCalendarView.getCurYear(); | ||
int month = mCalendarView.getCurMonth(); | ||
|
||
Map<String, Calendar> map = new HashMap<>(); | ||
map.put(getSchemeCalendar(year, month, 3, 0xFF40db25, "假").toString(), | ||
getSchemeCalendar(year, month, 3, 0xFF40db25, "假")); | ||
map.put(getSchemeCalendar(year, month, 6, 0xFFe69138, "事").toString(), | ||
getSchemeCalendar(year, month, 6, 0xFFe69138, "事")); | ||
map.put(getSchemeCalendar(year, month, 9, 0xFFdf1356, "议").toString(), | ||
getSchemeCalendar(year, month, 9, 0xFFdf1356, "议")); | ||
map.put(getSchemeCalendar(year, month, 13, 0xFFedc56d, "记").toString(), | ||
getSchemeCalendar(year, month, 13, 0xFFedc56d, "记")); | ||
map.put(getSchemeCalendar(year, month, 14, 0xFFedc56d, "记").toString(), | ||
getSchemeCalendar(year, month, 14, 0xFFedc56d, "记")); | ||
map.put(getSchemeCalendar(year, month, 15, 0xFFaacc44, "假").toString(), | ||
getSchemeCalendar(year, month, 15, 0xFFaacc44, "假")); | ||
map.put(getSchemeCalendar(year, month, 18, 0xFFbc13f0, "记").toString(), | ||
getSchemeCalendar(year, month, 18, 0xFFbc13f0, "记")); | ||
map.put(getSchemeCalendar(year, month, 22, 0xFFdf1356, "议").toString(), | ||
getSchemeCalendar(year, month, 22, 0xFFdf1356, "议")); | ||
map.put(getSchemeCalendar(year, month, 25, 0xFF13acf0, "假").toString(), | ||
getSchemeCalendar(year, month, 25, 0xFF13acf0, "假")); | ||
map.put(getSchemeCalendar(year, month, 27, 0xFF13acf0, "多").toString(), | ||
getSchemeCalendar(year, month, 27, 0xFF13acf0, "多")); | ||
//此方法在巨大的数据量上不影响遍历性能,推荐使用 | ||
mCalendarView.setSchemeDate(map); | ||
} | ||
|
||
private Calendar getSchemeCalendar(int year, int month, int day, int color, String text) { | ||
Calendar calendar = new Calendar(); | ||
calendar.setYear(year); | ||
calendar.setMonth(month); | ||
calendar.setDay(day); | ||
calendar.setSchemeColor(color);//如果单独标记颜色、则会使用这个颜色 | ||
calendar.setScheme(text); | ||
calendar.addScheme(color, "假"); | ||
calendar.addScheme(day%2 == 0 ? 0xFF00CD00 : 0xFFD15FEE, "节"); | ||
calendar.addScheme(day%2 == 0 ? 0xFF660000 : 0xFF4169E1, "记"); | ||
return calendar; | ||
} | ||
|
||
@Override | ||
public void onClick(View v) { | ||
switch (v.getId()) { | ||
case R.id.ll_flyme: | ||
CustomActivity.show(this); | ||
break; | ||
case R.id.ll_simple: | ||
SimpleActivity.show(this); | ||
break; | ||
case R.id.ll_colorful: | ||
ColorfulActivity.show(this); | ||
break; | ||
case R.id.ll_index: | ||
IndexActivity.show(this); | ||
break; | ||
} | ||
} | ||
|
||
@Override | ||
public void onCalendarOutOfRange(Calendar calendar) { | ||
|
||
} | ||
|
||
@SuppressLint("SetTextI18n") | ||
@Override | ||
public void onCalendarSelect(Calendar calendar, boolean isClick) { | ||
mTextLunar.setVisibility(View.VISIBLE); | ||
mTextYear.setVisibility(View.VISIBLE); | ||
mTextMonthDay.setText(calendar.getMonth() + "月" + calendar.getDay() + "日"); | ||
mTextYear.setText(String.valueOf(calendar.getYear())); | ||
mTextLunar.setText(calendar.getLunar()); | ||
mYear = calendar.getYear(); | ||
|
||
Log.e("onDateSelected", " -- " + calendar.getYear() + | ||
" -- " + calendar.getMonth() + | ||
" -- " + calendar.getDay() + | ||
" -- " + isClick + " -- " + calendar.getScheme()); | ||
} | ||
|
||
@Override | ||
public void onYearChange(int year) { | ||
mTextMonthDay.setText(String.valueOf(year)); | ||
} | ||
} |
Oops, something went wrong.