@@ -57,9 +57,6 @@ public class HabitEventTimeLineActivity extends Fragment {
5757
5858 ArrayList <HabitEvent > events = new ArrayList <>();
5959
60- ArrayList <HabitEvent > filteredEvents = new ArrayList <>();
61- // TODO: Rename parameter arguments, choose names that match
62- // the fragment initialization parameters, e.g. ARG_ITEM_NUMBER
6360
6461 private HabitEventTimeLineActivity .OnFragmentInteractionListener mListener ;
6562
@@ -98,14 +95,38 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
9895
9996 }
10097
101-
102-
10398 //set up the TextView and ListView
10499 this .textView = (TextView ) view .findViewById (R .id .timelineHeadingTextView );
105100 this .listView = (ListView ) view .findViewById (R .id .timeLineListView );
106101 this .viewMap = (Button ) view .findViewById (R .id .viewMapButton );
107102
108- Button commentButton = (Button ) view .findViewById (R .id .filter_by_comment );
103+ Button reverseChronoButton = (Button ) view .findViewById (R .id .reverse_chronological_button );
104+ reverseChronoButton .setOnClickListener (new View .OnClickListener () {
105+ @ Override
106+ public void onClick (View v ) {
107+ events = new ArrayList <>();
108+ ElasticsearchController .GetEventsTask getEventsTask = new ElasticsearchController .GetEventsTask ();
109+ getEventsTask .execute (userName );
110+ try {
111+ ArrayList <HabitEvent > foundHabitEvents = getEventsTask .get ();
112+ if (!foundHabitEvents .isEmpty ()) {
113+
114+ events .addAll (foundHabitEvents );
115+ Log .i ("HabitEventTimeline: found events :" , events .toString ());
116+ } else {
117+ Log .i ("HabitEventTimeline" , "Did Not find habit events" + events .toString ());
118+
119+ }
120+ } catch (Exception e ) {
121+ Log .i ("HabitEventTimeline" , "Failed to get the Habit Events from the async object" );
122+
123+ }
124+ updateTextView (events .size ());
125+ updateListView (events );
126+ }
127+ });
128+
129+ Button commentButton = (Button ) view .findViewById (R .id .filter_by_comment );
109130
110131
111132 commentButton .setOnClickListener (new View .OnClickListener () {
0 commit comments