Android Open Source - SELP2013 Timetable Fragment






From Project

Back to project page SELP2013.

License

The source code is released under:

License ======= This work is licensed under the BSD 2-clause license as follows. # BSD 2-clause license Copyright (c) 2013, Sky Welch All rights reserved. Redistribution and use in source and ...

If you think the Android project SELP2013 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 uk.co.skywelch.selp2013;
/*from ww  w.  ja v  a2  s  .  c o m*/
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ListView;

public class TimetableFragment extends Fragment {
  public static final String TAG = "TimeFragment";
  public ListView list = null;
  private OnTimetableItemSelected mListener;

  public interface OnTimetableItemSelected {
    public void onItemLongClicked(Lecture lecture);
  }

  @Override
  public void onAttach(Activity activity) {
    // Set up the listener to pass events back to the parent of this fragment
    super.onAttach(activity);
    try {
      mListener = (OnTimetableItemSelected) activity;
    } catch (ClassCastException e) {
      throw new ClassCastException(activity.toString()
          + " must implement OnTimetableItemSelected interface");
    }
  }

  @Override
  public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_timetable, container, false);
    list = (ListView) view.findViewById(R.id.timeListView);

    // Grab filtering settings from the bundle that should be passed to us
    //  Validate them just in case something bad was passed
    Bundle bundle = this.getArguments();
    int semester = bundle.getInt("semester", -1);
    Boolean filter_checked = bundle.getBoolean("filter_checked", false);

    // Make the list use the appropriate adapter based on the filtering options
    if (semester == 1) {
      if (filter_checked) {
        list.setAdapter(TimetableActivity.checked_semesterone_adapter);
      } else {
        list.setAdapter(TimetableActivity.all_semesterone_adapter);
      }
    } else if (semester == 2) {
      if (filter_checked) {
        list.setAdapter(TimetableActivity.checked_semestertwo_adapter);
      } else {
        list.setAdapter(TimetableActivity.all_semestertwo_adapter);
      }
    } else {
      Log.e(TAG, "Unknown semester passed to timetable fragment. List will be empty!");
    }

    list.setEmptyView(view.findViewById(R.id.timetableLoadingLayout));

    // Pass long press events to the parent of this fragment,
    //  but only if the item was valid
    list.setOnItemLongClickListener(new AdapterView.OnItemLongClickListener() {
      @Override
      public boolean onItemLongClick(AdapterView<?> list, View v, int position, long id) {
        TimetableListAdapter adapter = (TimetableListAdapter) list.getAdapter();
        ListItem list_item = (ListItem) adapter.getItem(position);
        if (!list_item.isSection()) {
          Lecture lecture = (Lecture) list_item;
          if (lecture != null) {
            mListener.onItemLongClicked(lecture);
            return true;
          }
        }

        return false;
      }
    });

    return view;
  }
}




Java Source Code List

uk.co.skywelch.selp2013.AboutActivity.java
uk.co.skywelch.selp2013.CourseInformationActivity.java
uk.co.skywelch.selp2013.CourseListActivity.java
uk.co.skywelch.selp2013.CourseListAdapter.java
uk.co.skywelch.selp2013.Course.java
uk.co.skywelch.selp2013.CoursesParseTask.java
uk.co.skywelch.selp2013.CoursesXmlParser.java
uk.co.skywelch.selp2013.DrawerListAdapter.java
uk.co.skywelch.selp2013.FileDownloader.java
uk.co.skywelch.selp2013.HourMinute.java
uk.co.skywelch.selp2013.Lecture.java
uk.co.skywelch.selp2013.ListItem.java
uk.co.skywelch.selp2013.ListSection.java
uk.co.skywelch.selp2013.StringListItem.java
uk.co.skywelch.selp2013.TimetableActivity.java
uk.co.skywelch.selp2013.TimetableFragment.java
uk.co.skywelch.selp2013.TimetableListAdapter.java
uk.co.skywelch.selp2013.TimetableParseTask.java
uk.co.skywelch.selp2013.TimetableXmlParser.java
uk.co.skywelch.selp2013.VenueInformationActivity.java
uk.co.skywelch.selp2013.Venue.java
uk.co.skywelch.selp2013.VenuesParseTask.java
uk.co.skywelch.selp2013.VenuesXmlParser.java
uk.co.skywelch.selp2013.XMLUtilities.java