Android Open Source - SELP2013 Course Information Activity






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 w w  w . j  a v a 2 s .  com*/
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.ActionBarActivity;
import android.text.Html;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;

public class CourseInformationActivity extends ActionBarActivity {
  public final static String TAG = "CourseInformationActivity";
  public final static String COURSE_CODE = "course_code";

  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    
    // Set the appropriate content view
    setContentView(R.layout.activity_course_information);
    
    // Enable the back button in the action bar
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    TextView courseTitle = (TextView) findViewById(R.id.courseInfoTitle);
    TextView courseInfo = (TextView) findViewById(R.id.courseInfoText);

    // Double check that the course code passed to this activity is valid
    String course_code = this.getIntent().getExtras().getString(COURSE_CODE);
    Course course = null;
    if (course_code == null) {
      Log.e(TAG, "Course information activity wasn't passed a course code value!");

      return;
    } else {
      course = TimetableActivity.course_map.get(course_code);
    }

    if (course == null) {
      Log.e(TAG, "Course information activity was passed a code that doesn't exist!");

      return;
    }

    // Update UI with course information if it exists
    
    courseTitle.setText(course.getNamePlusAcronym());

    String course_info = "";

    if (!course.url.isEmpty()) {
      course_info += "<p><b>URL</b>: " + course.url + "</p>";
    }

    if (!course.drps.isEmpty()) {
      course_info += "<p><b>DRPS URL</b>: " + course.drps + "</p>";
    }

    if (!course.euclid.isEmpty()) {
      course_info += "<p><b>Euclid ID</b>: " + course.euclid + "</p>";
    }

    if (!course.types_string.isEmpty()) {
      course_info += "<p><b>Course types</b>: " + course.types_string + "</p>";
    }

    if (course.points >= 0) {
      course_info += "<p><b>Points</b>: " + Integer.toString(course.points) + "</p>";
    }

    if (!course.deliveryperiod.isEmpty()) {
      course_info += "<p><b>Delivery period</b>: " + course.deliveryperiod + "</p>";
    }

    if (course_info.isEmpty()) {
      course_info += "<p>No course information available</p>";
    }

    courseInfo.setText(Html.fromHtml(course_info));
  }

  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
    getMenuInflater().inflate(R.menu.main, menu);

    return super.onCreateOptionsMenu(menu);
  }

  @Override
  public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_home: {
      Intent i = new Intent(this, TimetableActivity.class);
      startActivity(i);
      return true;
    }
    case android.R.id.home: {
      // If the back button is pressed, end this activity
      finish();
      return true;
    }
    default:
      return super.onOptionsItemSelected(item);
    }
  }
}




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