protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == COURSE_SELECT_REQUEST_CODE) {
      if (resultCode == RESULT_OK) {
        user = (User) data.getParcelableExtra("userObject");
        if (user != null && user.getSelectedCourseId() != 99999) {
          Course course = user.getCourse(user.getSelectedCourseId());
          footerCourseHdr.setText(course.getShortName());

          getCourseAssignments();
        }
      }
    }
  }
  /** Called when the activity is first created. */
  @Override
  public void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.course_assignment);

    try {
      Intent i = getIntent();
      user = (User) i.getParcelableExtra("userObject");

      footerCourseHdr = (TextView) findViewById(R.id.course_ftr_view);

      home = (Button) findViewById(R.id.coursework_home_view);
      courseSelect = (Button) findViewById(R.id.select_course);
      setting = (Button) findViewById(R.id.settings_view);
      upload = (Button) findViewById(R.id.upload_view);

      if (user != null && user.getCourses().size() == 1) {
        user.setSelectedCourseId(user.getCourses().get(0).getId());
        courseSelect.setEnabled(false);
      } else courseSelect.setEnabled(true);

      if (user != null && user.getSelectedCourseId() == 99999) {
        i = new Intent(this, CourseSelect.class);
        i.putExtra("userObject", user);
        startActivityForResult(i, COURSE_SELECT_REQUEST_CODE);
      }

      if (user != null && user.getSelectedCourseId() != 99999)
        footerCourseHdr.setText(user.getCourse(user.getSelectedCourseId()).getShortName());

      getCourseAssignments();

      home.setOnClickListener(this);
      if (courseSelect.isEnabled()) courseSelect.setOnClickListener(this);
      setting.setOnClickListener(this);
      upload.setOnClickListener(this);
    } catch (Exception e) {
      Log.e("Error 1", e.toString() + "Error within CourseAssignmentView Class");
    }
  }
  private void getCourseAssignments() {
    emptyLayout = (LinearLayout) findViewById(R.id.coursework_assignitem_empty);
    emptyLayout.setVisibility(View.INVISIBLE);
    courseworkLayout = (FrameLayout) findViewById(R.id.assignlistView);
    courseworkLayout.setVisibility(View.VISIBLE);

    ArrayList<CourseContent> coursecontent = new ArrayList<CourseContent>();
    if (user != null && user.getCourse(user.getSelectedCourseId()) != null) {
      coursecontent = user.getCourse(user.getSelectedCourseId()).getCourseContent();
    }

    assignArray =
        CourseContentsListHelper.getInstance(this).populateCourseAssignments(coursecontent);

    if (assignArray != null && assignArray.length > 0) {
      arrayAdapter = new StandardArrayAdapter(this, assignArray);
      sectionAdapter = new SectionListAdapter(getLayoutInflater(), arrayAdapter);
      listView =
          (SectionListView)
              findViewById(
                  getResources()
                      .getIdentifier(
                          "assign_section_list_view",
                          "id",
                          this.getClass().getPackage().getName()));
      listView.setAdapter(sectionAdapter);

      listView.setOnItemClickListener(
          new OnItemClickListener() {

            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {

              Object obj = sectionAdapter.getItem(position);
              if (obj instanceof SectionListItem) {

                SectionListItem selectedMap = (SectionListItem) obj;
                @SuppressWarnings("unchecked")
                // String value = ((HashMap<String, String>)selectedMap.item).get("id");
                String url = ((HashMap<String, String>) selectedMap.item).get("url");

                if (!url.startsWith("http://") && !url.startsWith("https://"))
                  url = "http://" + url;

                Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));

                try {
                  // Start the activity
                  startActivity(browserIntent);
                } catch (ActivityNotFoundException e) {
                  // Raise on activity not found
                  Toast.makeText(getApplicationContext(), "Browser not found.", Toast.LENGTH_SHORT)
                      .show();
                }
              }
            }
          });
    } else {
      emptyLayout.setVisibility(View.VISIBLE);
      courseworkLayout.setVisibility(View.INVISIBLE);
    }
  }