Android Open Source - iEtueri Schedule Fragment

From Project

Back to project page iEtueri.


The source code is released under:

GNU General Public License

If you think the Android project iEtueri listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package schedule;
/*w  w  w .  j  a v a 2  s  .c o m*/
import java.util.ArrayList;
import java.util.Calendar;

import navigationdrawer.MainActivity;
import navigationdrawer.NavigationDrawerController;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CalendarView;
import android.widget.CalendarView.OnDateChangeListener;
import android.widget.ListView;
import android.widget.Toast;

import com.javils.ietueri.R;

public class ScheduleFragment extends Fragment implements OnDateChangeListener {

  /** Views */
  private CalendarView calendar;
  private static ListView listEvents;

  /** Variables to check the actual day */
  private int actualDay;
  private int actualMonth;
  private int actualYear;

  private static boolean iAmActive = false;

  public static Handler updaterHandler = new Handler() {
    public void handleMessage(Message msg) {
      switch (msg.what) {
      case RefreshScheduleEventsData.CALENDAR_DATA_CHANGE:
        // Update adapter of the ListView
        ((ScheduleTodayAdapter) listEvents.getAdapter()).notifyDataSetChanged();

  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_schedule, container, false);

    calendar = (CalendarView) view.findViewById(;
    listEvents = (ListView) view.findViewById(;

    actualDay = 0;
    actualMonth = 0;
    actualYear = 0;

    Calendar now = Calendar.getInstance();
    int year = now.get(Calendar.YEAR);
    int month = now.get(Calendar.MONTH);
    int day = now.get(Calendar.DAY_OF_MONTH);

    Toast.makeText(getActivity(), "Cargando Eventos...", Toast.LENGTH_LONG).show();


    ScheduleTodayAdapter adapter = new ScheduleTodayAdapter(view.getContext(), R.layout.schedule_list_item,
        new ArrayList<Event>());


    ArrayList<Event> events = new ArrayList<Event>();


    new Thread(new FindEvents(getActivity(), EventsManager.getAdapter(), events, year, month, day, false)).start();

    return view;

  public void onDestroyView() {

  public void onSelectedDayChange(CalendarView view, int year, int month, int dayOfMonth) {
    /** Don't refresh if is the same day */
    if (actualDay == dayOfMonth && actualMonth == month && actualYear == year)

    actualDay = dayOfMonth;
    actualMonth = month;
    actualYear = year;

    new Thread(new FindEvents(getActivity(), EventsManager.getAdapter(), EventsManager.getEvents(), year, month,
        dayOfMonth, false)).start();

  public void onAttach(Activity activity) {
    ((MainActivity) activity).onSectionAttached(getArguments()

  public static boolean isiAmActive() {
    return iAmActive;

  public static void setiAmActive(boolean iAmActive) {
    ScheduleFragment.iAmActive = iAmActive;

Java Source Code List