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
Hide 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 {
private
FeedAdapter
feedAdapter
=
null
;
private
List
<
Event
>
events
=
new
ArrayList
<>();
private
HashSet
<
CalendarDay
>
haveMonths
=
new
HashSet
<>();
private
boolean
initialized
=
false
;
public
CalendarFragment
()
{
...
...
@@ -178,7 +179,13 @@ public class CalendarFragment extends BaseFragment {
private
void
updateEvents
(
CalendarDay
calendarDay
,
final
boolean
setToday
)
{
// Do not make duplicate calls
if
(!
setToday
&&
haveMonths
.
contains
(
calendarDay
))
return
;
if
(
haveMonths
.
contains
(
calendarDay
))
{
if
(!
setToday
)
{
return
;
}
else
{
setupCalendar
(
true
);
}
}
haveMonths
.
add
(
calendarDay
);
// Parsers
...
...
@@ -187,9 +194,6 @@ public class CalendarFragment extends BaseFragment {
final
SimpleDateFormat
isoFormatter
=
new
SimpleDateFormat
(
ISO_FORMAT
);
isoFormatter
.
setTimeZone
(
utc
);
// Get the date to start at
final
Date
today
=
new
Date
();
// Get the start date
final
Date
startDate
;
try
{
...
...
@@ -223,35 +227,7 @@ public class CalendarFragment extends BaseFragment {
if
(!
events
.
contains
(
event
))
events
.
add
(
event
);
}
// Make the calendar visible if it isn't
final
LinearLayout
calendarLayout
=
getView
().
findViewById
(
R
.
id
.
calendar_layout
);
if
(
calendarLayout
.
getVisibility
()
==
View
.
GONE
)
{
calendarLayout
.
setVisibility
(
VISIBLE
);
getView
().
findViewById
(
R
.
id
.
loadingPanel
).
setVisibility
(
View
.
GONE
);
AlphaAnimation
anim
=
new
AlphaAnimation
(
0.0f
,
1.0f
);
anim
.
setDuration
(
250
);
calendarLayout
.
startAnimation
(
anim
);
}
// Initialize to show today's date
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
final
MaterialCalendarView
matCalendarView
=
view
.
findViewById
(
R
.
id
.
simpleCalendarView
);
matCalendarView
.
setSelectedDate
(
CalendarDay
.
today
());
// Show the fab
showFab
();
}
// Generate the decorators
showHeatMap
(
events
);
setupCalendar
(
setToday
);
}
}
...
...
@@ -263,6 +239,42 @@ public class CalendarFragment extends BaseFragment {
});
}
/** Show the calendar */
private
void
setupCalendar
(
boolean
setToday
)
{
// Make the calendar visible if it isn't
final
LinearLayout
calendarLayout
=
getView
().
findViewById
(
R
.
id
.
calendar_layout
);
if
(
calendarLayout
.
getVisibility
()
==
View
.
GONE
)
{
calendarLayout
.
setVisibility
(
VISIBLE
);
getView
().
findViewById
(
R
.
id
.
loadingPanel
).
setVisibility
(
View
.
GONE
);
AlphaAnimation
anim
=
new
AlphaAnimation
(
0.0f
,
1.0f
);
anim
.
setDuration
(
250
);
calendarLayout
.
startAnimation
(
anim
);
}
// Initialize to show today's date
final
MaterialCalendarView
matCalendarView
=
view
.
findViewById
(
R
.
id
.
simpleCalendarView
);
if
(
setToday
)
{
// Select today's date
if
(!
initialized
)
{
initialized
=
true
;
matCalendarView
.
setSelectedDate
(
CalendarDay
.
today
());
}
// Show the fab
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
showHeatMap
(
events
);
}
/** Build and show the heat map from the list of events */
private
void
showHeatMap
(
List
<
Event
>
eventList
)
{
// Build strength map for each date
...
...
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