Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
InstiApp
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
RAHUL SHARMA
InstiApp
Commits
3b193e43
Commit
3b193e43
authored
Feb 02, 2019
by
Varun Patil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix popping back stack to calendar
parent
721b01f0
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
33 deletions
+45
-33
app/src/main/java/app/insti/fragment/CalendarFragment.java
app/src/main/java/app/insti/fragment/CalendarFragment.java
+45
-33
No files found.
app/src/main/java/app/insti/fragment/CalendarFragment.java
View file @
3b193e43
...
@@ -64,6 +64,7 @@ public class CalendarFragment extends BaseFragment {
...
@@ -64,6 +64,7 @@ public class CalendarFragment extends BaseFragment {
private
FeedAdapter
feedAdapter
=
null
;
private
FeedAdapter
feedAdapter
=
null
;
private
List
<
Event
>
events
=
new
ArrayList
<>();
private
List
<
Event
>
events
=
new
ArrayList
<>();
private
HashSet
<
CalendarDay
>
haveMonths
=
new
HashSet
<>();
private
HashSet
<
CalendarDay
>
haveMonths
=
new
HashSet
<>();
private
boolean
initialized
=
false
;
public
CalendarFragment
()
{
public
CalendarFragment
()
{
...
@@ -178,7 +179,13 @@ public class CalendarFragment extends BaseFragment {
...
@@ -178,7 +179,13 @@ public class CalendarFragment extends BaseFragment {
private
void
updateEvents
(
CalendarDay
calendarDay
,
final
boolean
setToday
)
{
private
void
updateEvents
(
CalendarDay
calendarDay
,
final
boolean
setToday
)
{
// Do not make duplicate calls
// Do not make duplicate calls
if
(!
setToday
&&
haveMonths
.
contains
(
calendarDay
))
return
;
if
(
haveMonths
.
contains
(
calendarDay
))
{
if
(!
setToday
)
{
return
;
}
else
{
setupCalendar
(
true
);
}
}
haveMonths
.
add
(
calendarDay
);
haveMonths
.
add
(
calendarDay
);
// Parsers
// Parsers
...
@@ -187,9 +194,6 @@ public class CalendarFragment extends BaseFragment {
...
@@ -187,9 +194,6 @@ public class CalendarFragment extends BaseFragment {
final
SimpleDateFormat
isoFormatter
=
new
SimpleDateFormat
(
ISO_FORMAT
);
final
SimpleDateFormat
isoFormatter
=
new
SimpleDateFormat
(
ISO_FORMAT
);
isoFormatter
.
setTimeZone
(
utc
);
isoFormatter
.
setTimeZone
(
utc
);
// Get the date to start at
final
Date
today
=
new
Date
();
// Get the start date
// Get the start date
final
Date
startDate
;
final
Date
startDate
;
try
{
try
{
...
@@ -223,6 +227,20 @@ public class CalendarFragment extends BaseFragment {
...
@@ -223,6 +227,20 @@ public class CalendarFragment extends BaseFragment {
if
(!
events
.
contains
(
event
))
events
.
add
(
event
);
if
(!
events
.
contains
(
event
))
events
.
add
(
event
);
}
}
setupCalendar
(
setToday
);
}
}
@Override
public
void
onFailure
(
Call
<
NewsFeedResponse
>
call
,
Throwable
t
)
{
//Network Error
Toast
.
makeText
(
getContext
(),
"Failed to fetch events!"
,
Toast
.
LENGTH_SHORT
).
show
();
}
});
}
/** Show the calendar */
private
void
setupCalendar
(
boolean
setToday
)
{
// Make the calendar visible if it isn't
// Make the calendar visible if it isn't
final
LinearLayout
calendarLayout
=
getView
().
findViewById
(
R
.
id
.
calendar_layout
);
final
LinearLayout
calendarLayout
=
getView
().
findViewById
(
R
.
id
.
calendar_layout
);
if
(
calendarLayout
.
getVisibility
()
==
View
.
GONE
)
{
if
(
calendarLayout
.
getVisibility
()
==
View
.
GONE
)
{
...
@@ -234,34 +252,28 @@ public class CalendarFragment extends BaseFragment {
...
@@ -234,34 +252,28 @@ public class CalendarFragment extends BaseFragment {
}
}
// Initialize to show today's date
// Initialize to show today's date
final
MaterialCalendarView
matCalendarView
=
view
.
findViewById
(
R
.
id
.
simpleCalendarView
);
if
(
setToday
)
{
if
(
setToday
)
{
// Show today
try
{
DateFormat
formatter
=
new
SimpleDateFormat
(
"dd/MM/yyyy"
);
Date
todayWithZeroTime
=
formatter
.
parse
(
formatter
.
format
(
today
));
showEventsForDate
(
todayWithZeroTime
);
}
catch
(
ParseException
ignored
)
{}
// Select today's date
// Select today's date
final
MaterialCalendarView
matCalendarView
=
view
.
findViewById
(
R
.
id
.
simpleCalendarView
);
if
(!
initialized
)
{
initialized
=
true
;
matCalendarView
.
setSelectedDate
(
CalendarDay
.
today
());
matCalendarView
.
setSelectedDate
(
CalendarDay
.
today
());
}
// Show the fab
// Show the fab
showFab
();
showFab
();
}
}
// Show today
try
{
DateFormat
formatter
=
new
SimpleDateFormat
(
"dd/MM/yyyy"
);
Date
todayWithZeroTime
=
formatter
.
parse
(
formatter
.
format
(
toDate
(
matCalendarView
.
getSelectedDate
())));
showEventsForDate
(
todayWithZeroTime
);
}
catch
(
ParseException
ignored
)
{}
// Generate the decorators
// Generate the decorators
showHeatMap
(
events
);
showHeatMap
(
events
);
}
}
}
@Override
public
void
onFailure
(
Call
<
NewsFeedResponse
>
call
,
Throwable
t
)
{
//Network Error
Toast
.
makeText
(
getContext
(),
"Failed to fetch events!"
,
Toast
.
LENGTH_SHORT
).
show
();
}
});
}
/** Build and show the heat map from the list of events */
/** Build and show the heat map from the list of events */
private
void
showHeatMap
(
List
<
Event
>
eventList
)
{
private
void
showHeatMap
(
List
<
Event
>
eventList
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment