Commit ec8fa297 authored by Varun Patil's avatar Varun Patil

Show fab after load on calendar

parent 33caa649
...@@ -105,16 +105,18 @@ public class CalendarFragment extends BaseFragment { ...@@ -105,16 +105,18 @@ public class CalendarFragment extends BaseFragment {
} }
}); });
// Handle fab click return view;
fab.setOnClickListener(new View.OnClickListener() { }
@Override
public void onClick(View v) {
AddEventFragment addEventFragment = new AddEventFragment();
((MainActivity) getActivity()).updateFragment(addEventFragment);
}
});
// Show the fab if we can make events @Override
public void onStart() {
super.onStart();
updateEvents(CalendarDay.today(), true);
}
/** Show the fab if we can make events */
private void showFab() {
if (((MainActivity) getActivity()).createEventAccess()) { if (((MainActivity) getActivity()).createEventAccess()) {
fab.show(); fab.show();
NestedScrollView nsv = view.findViewById(R.id.calendar_nsv); NestedScrollView nsv = view.findViewById(R.id.calendar_nsv);
...@@ -125,27 +127,28 @@ public class CalendarFragment extends BaseFragment { ...@@ -125,27 +127,28 @@ public class CalendarFragment extends BaseFragment {
else fab.show(); else fab.show();
} }
}); });
}
return view; // Handle fab click
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AddEventFragment addEventFragment = new AddEventFragment();
((MainActivity) getActivity()).updateFragment(addEventFragment);
}
});
}
} }
@Override
public void onStart() {
super.onStart();
updateEvents(CalendarDay.today(), true);
}
/** Convert CalendarDay to Date */ /** Convert CalendarDay to Date */
public Date toDate(CalendarDay date) throws ParseException { private Date toDate(CalendarDay date) throws ParseException {
String sdate = date.getDay() + "/" + date.getMonth() + "/" + date.getYear(); String sdate = date.getDay() + "/" + date.getMonth() + "/" + date.getYear();
Date showDate = new SimpleDateFormat("dd/M/yyyy").parse(sdate); Date showDate = new SimpleDateFormat("dd/M/yyyy").parse(sdate);
return showDate; return showDate;
} }
/** Decorator for Calendar */ /** Decorator for Calendar */
public class EventDecorator implements DayViewDecorator { private class EventDecorator implements DayViewDecorator {
private final int color = getResources().getColor(R.color.colorAccent); private final int color = getResources().getColor(R.color.colorAccent);
private final int white = getResources().getColor(R.color.primaryTextColor); private final int white = getResources().getColor(R.color.primaryTextColor);
private final HashSet<CalendarDay> dates; private final HashSet<CalendarDay> dates;
...@@ -234,6 +237,9 @@ public class CalendarFragment extends BaseFragment { ...@@ -234,6 +237,9 @@ public class CalendarFragment extends BaseFragment {
// Select today's date // Select today's date
final MaterialCalendarView matCalendarView = view.findViewById(R.id.simpleCalendarView); final MaterialCalendarView matCalendarView = view.findViewById(R.id.simpleCalendarView);
matCalendarView.setSelectedDate(CalendarDay.today()); matCalendarView.setSelectedDate(CalendarDay.today());
// Show the fab
showFab();
} }
// Generate the decorators // Generate the decorators
......
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
android:layout_margin="16dp" android:layout_margin="16dp"
android:src="@drawable/ic_add_black_24dp" android:src="@drawable/ic_add_black_24dp"
android:tint="@android:color/black" android:tint="@android:color/black"
android:visibility="gone" /> android:visibility="invisible" />
<include layout="@layout/loading_panel" /> <include layout="@layout/loading_panel" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment