use of com.prolificinteractive.materialcalendarview.MaterialCalendarView in project GitTest by xiaoxige.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
materialCalendarView = (MaterialCalendarView) findViewById(R.id.materialCalendarView);
disableDecorator = new DisableDecorator(this);
broadDecorator = new BroadDecorator(this);
// 三年前
Calendar mixTime = Calendar.getInstance();
mixTime.add(Calendar.MONTH, -3 * 12);
// 二十年后
Calendar maxTime = Calendar.getInstance();
maxTime.add(Calendar.YEAR, 5);
maxTime.set(Calendar.DAY_OF_MONTH, maxTime.getActualMaximum(Calendar.DAY_OF_MONTH));
materialCalendarView.addDecorators(new DefaultDecorator(this), disableDecorator, broadDecorator, descDecorator, mSelectDecorator);
materialCalendarView.setTopbarVisible(true);
materialCalendarView.setDynamicHeightEnabled(true);
materialCalendarView.setSelectionMode(MaterialCalendarView.SELECTION_MODE_SINGLE);
materialCalendarView.state().edit().setCalendarDisplayMode(CalendarMode.MONTHS).setMinimumDate(mixTime.getTime()).setMaximumDate(maxTime.getTime()).commit();
materialCalendarView.setSelectedDate(CalendarDay.today());
materialCalendarView.invalidateDecorators();
materialCalendarView.setOnDateChangedListener(new OnDateSelectedListener() {
@Override
public void onDateSelected(@NonNull MaterialCalendarView widget, @NonNull CalendarDay date, boolean selected) {
List<CalendarDay> dates = new ArrayList<>();
dates.add(date);
mSelectDecorator.setDays(dates);
descDecorator.setDays(dates);
materialCalendarView.invalidateDecorators();
}
@Override
public void onDisableDateSelected(@NonNull MaterialCalendarView widget, @NonNull CalendarDay date, boolean selected) {
}
});
}
use of com.prolificinteractive.materialcalendarview.MaterialCalendarView in project Habba18 by chiragsastry1996.
the class TimeLineActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
overridePendingTransitionEnter();
setContentView(R.layout.activity_timeline);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
// in Activity's onCreate() for instance
Window w = getWindow();
w.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
getSupportActionBar().hide();
timestampsList = new ArrayList<>();
timelineList = new ArrayList();
if (getSupportActionBar() != null)
getSupportActionBar().setDisplayHomeAsUpEnabled(false);
calendarView = (MaterialCalendarView) findViewById(R.id.calendar);
// setTitle(mOrientation == Orientation.HORIZONTAL ? getResources().getString(R.string.horizontal_timeline) : getResources().getString(R.string.vertical_timeline));
mRecyclerView = (RecyclerView) findViewById(R.id.recyclerView);
mRecyclerView.setLayoutManager(getLinearLayoutManager());
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.setNestedScrollingEnabled(false);
calendarDays = new HashSet<CalendarDay>();
datespan();
calendarView.setDateSelected(CalendarDay.today(), true);
// calendarView.addDecorator(new EventDecorator(Color.RED, calendarDays));
calendarView.state().edit().setFirstDayOfWeek(Calendar.WEDNESDAY).setMinimumDate(CalendarDay.from(2018, 1, 1)).setMaximumDate(CalendarDay.from(2018, 2, 31)).commit();
calendarView.setOnDateChangedListener(new OnDateSelectedListener() {
@Override
public void onDateSelected(@NonNull MaterialCalendarView widget, @NonNull CalendarDay date, boolean selected) {
mDataList.clear();
timelineList.clear();
mRecyclerView.invalidate();
int curDate = date.getDay();
int months = date.getMonth() + 1;
String mon = "", dat = "";
if (months < 10)
mon = "0" + String.valueOf(months);
else
mon = String.valueOf(months);
if (curDate < 10)
dat = "0" + String.valueOf(curDate);
else
dat = String.valueOf(curDate);
String searchDate = date.getYear() + "-" + mon + "-" + dat;
for (int i = 0; i < Test.timeline.size(); i++) {
if (searchDate.equals(Test.timeline.get(i).get(1))) {
ArrayList<String> indexList = new ArrayList<String>();
indexList.add(Test.timeline.get(i).get(0));
String time = Test.timeline.get(i).get(2);
SimpleDateFormat date12Format = new SimpleDateFormat("hh:mm a");
SimpleDateFormat date24Format = new SimpleDateFormat("HH:mm");
try {
tmstmp = Test.timeline.get(i).get(1) + " " + date24Format.format(date12Format.parse(time));
indexList.add(tmstmp);
} catch (ParseException e) {
e.printStackTrace();
}
indexList.add(Test.timeline.get(i).get(3));
indexList.add(Test.timeline.get(i).get(4));
timelineList.add(indexList);
}
}
initView();
}
});
calendarView.setDateSelected(CalendarDay.today(), true);
int curDate = CalendarDay.today().getDay();
int months = CalendarDay.today().getMonth() + 1;
String mon = "", dat = "";
if (months < 10)
mon = "0" + String.valueOf(months);
else
mon = String.valueOf(months);
if (curDate < 10)
dat = "0" + String.valueOf(curDate);
else
dat = String.valueOf(curDate);
String search = CalendarDay.today().getYear() + "-" + mon + "-" + dat;
// toolbar.setTitle(search);
for (int i = 0; i < Test.timeline.size(); i++) {
if (search.equals(Test.timeline.get(i).get(1))) {
ArrayList<String> indexList = new ArrayList<String>();
indexList.add(Test.timeline.get(i).get(0));
String time = Test.timeline.get(i).get(2);
SimpleDateFormat date12Format = new SimpleDateFormat("hh:mm a");
SimpleDateFormat date24Format = new SimpleDateFormat("HH:mm");
try {
indexList.add(Test.timeline.get(i).get(1) + " " + date24Format.format(date12Format.parse(time)));
} catch (ParseException e) {
e.printStackTrace();
}
indexList.add(Test.timeline.get(i).get(3));
indexList.add(Test.timeline.get(i).get(4));
timelineList.add(indexList);
}
}
initView();
}
use of com.prolificinteractive.materialcalendarview.MaterialCalendarView in project GeekNews by codeestX.
the class CalendarActivity method initEventAndData.
@Override
protected void initEventAndData() {
setToolBar(mToolbar, "选择日期");
mCalender.state().edit().setFirstDayOfWeek(Calendar.WEDNESDAY).setMinimumDate(CalendarDay.from(2013, 5, 20)).setMaximumDate(CalendarDay.from(DateUtil.getCurrentYear(), DateUtil.getCurrentMonth(), DateUtil.getCurrentDay())).setCalendarDisplayMode(CalendarMode.MONTHS).commit();
mCalender.setOnDateChangedListener(new OnDateSelectedListener() {
@Override
public void onDateSelected(@NonNull MaterialCalendarView widget, @NonNull CalendarDay date, boolean selected) {
mDate = date;
}
});
}
use of com.prolificinteractive.materialcalendarview.MaterialCalendarView in project MyDiary by erttyy8821.
the class CalendarFragment method initCalendarMode.
private void initCalendarMode() {
RL_calendar_content.removeAllViews();
switch(currentMode) {
case MODE_DAY:
materialCalendarView = null;
pageEffectView = new PageEffectView(getActivity(), calendar);
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
pageEffectView.setLayoutParams(params);
RL_calendar_content.addView(pageEffectView);
break;
case MODE_MONTH:
pageEffectView = null;
materialCalendarView = new MaterialCalendarView(getActivity());
RelativeLayout.LayoutParams calendarViewParams = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT);
materialCalendarView.setLayoutParams(calendarViewParams);
materialCalendarView.setShowOtherDates(MaterialCalendarView.SHOW_ALL);
materialCalendarView.setSelectionColor(ThemeManager.getInstance().getThemeMainColor(getActivity()));
materialCalendarView.state().edit().setFirstDayOfWeek(Calendar.MONDAY).setCalendarDisplayMode(CalendarMode.MONTHS).commit();
materialCalendarView.setCurrentDate(calendar);
materialCalendarView.setDateSelected(calendar, true);
materialCalendarView.setOnDateChangedListener(this);
RL_calendar_content.addView(materialCalendarView);
// Add view first , then add Decorator
materialCalendarView.addDecorator(this);
break;
}
}
Aggregations