From cf77623e9ce5187fab1d0716262d37e96712cbed Mon Sep 17 00:00:00 2001 From: Kacper Ziubryniewicz Date: Sun, 15 Dec 2019 00:42:28 +0100 Subject: [PATCH] [UI/Agenda] Add FAB to add events and make the dialog open with the selected date. --- .../ui/modules/agenda/AgendaFragment.java | 23 +++++++++++++++++-- .../ui/modules/homework/HomeworkFragment.kt | 17 +++++++++----- 2 files changed, 32 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/AgendaFragment.java b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/AgendaFragment.java index da0956f8..b5092603 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/AgendaFragment.java +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/agenda/AgendaFragment.java @@ -72,6 +72,7 @@ public class AgendaFragment extends Fragment { private FragmentAgendaDefaultBinding b_default = null; private FragmentAgendaCalendarBinding b_calendar = null; private int viewType = AGENDA_DEFAULT; + private Date actualDate = null; @Override public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { @@ -110,7 +111,7 @@ public class AgendaFragment extends Fragment { activity, App.profileId, null, - null, + actualDate, null, null, null, @@ -137,7 +138,24 @@ public class AgendaFragment extends Fragment { Toast.makeText(activity, R.string.main_menu_mark_as_read_success, Toast.LENGTH_SHORT).show(); }) ); + + activity.getNavView().bottomBar.setFabEnable(true); + activity.getNavView().bottomBar.setFabExtendedText(getString(R.string.add)); + activity.getNavView().bottomBar.setFabIcon(CommunityMaterial.Icon2.cmd_plus); + activity.getNavView().setFabOnClickListener(v -> new EventManualDialog( + activity, + App.profileId, + null, + actualDate, + null, + null, + null, + null, + null + )); + activity.gainAttention(); + activity.gainAttentionFAB(); if (viewType == AGENDA_DEFAULT) { createDefaultAgendaView(); @@ -303,7 +321,8 @@ public class AgendaFragment extends Fragment { @Override public void onScrollToDate(Calendar calendar) { - int scrolledDate = Date.fromCalendar(calendar).getValue(); + actualDate = Date.fromCalendar(calendar); + int scrolledDate = actualDate.getValue(); if (unreadEventDates.contains(scrolledDate)) { AsyncTask.execute(() -> app.db.eventDao().setSeenByDate(App.profileId, Date.fromYmd(intToStr(scrolledDate)), true)); unreadEventDates.remove((Integer) scrolledDate); diff --git a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkFragment.kt b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkFragment.kt index 01a2d705..90c1d12b 100644 --- a/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkFragment.kt +++ b/app/src/main/java/pl/szczodrzynski/edziennik/ui/modules/homework/HomeworkFragment.kt @@ -99,12 +99,17 @@ class HomeworkFragment : Fragment() { b.tabLayout.setupWithViewPager(b.viewPager) - activity.navView.bottomBar.fabEnable = true - activity.navView.bottomBar.fabExtendedText = getString(R.string.add) - activity.navView.bottomBar.fabIcon = CommunityMaterial.Icon2.cmd_plus - activity.navView.setFabOnClickListener(View.OnClickListener { - EventManualDialog(activity, App.profileId, defaultType = Event.TYPE_HOMEWORK) - }) + activity.navView.apply { + bottomBar.apply { + fabEnable = true + fabExtendedText = getString(R.string.add) + fabIcon = CommunityMaterial.Icon2.cmd_plus + } + + setFabOnClickListener(View.OnClickListener { + EventManualDialog(activity, App.profileId, defaultType = Event.TYPE_HOMEWORK) + }) + } activity.gainAttention() activity.gainAttentionFAB()