コード例 #1
0
  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    if (courseData == null || !isCoursewareAccessible) return;

    final String headerImageUrl = courseData.getCourse().getCourse_image(environment.getConfig());
    Glide.with(CourseDashboardFragment.this)
        .load(headerImageUrl)
        .placeholder(R.drawable.edx_map_login)
        .transform(new TopAnchorFillWidthTransformation(getActivity()))
        .into(headerImageView);

    courseTextName.setText(courseData.getCourse().getName());
    CourseEntry course = courseData.getCourse();
    courseTextDetails.setText(course.getDescription(getActivity(), true));

    if (environment.getConfig().isShareCourseEnabled()) {
      shareButton.setVisibility(headerImageView.VISIBLE);
      shareButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              openShareMenu();
            }
          });
    }
  }
コード例 #2
0
  @Override
  public void onViewCreated(View view, Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);

    if (isCoursewareAccessible) {
      final LayoutInflater inflater = LayoutInflater.from(getActivity());

      if (courseData.isCertificateEarned()
          && environment.getConfig().areCertificateLinksEnabled()) {
        final View child = inflater.inflate(R.layout.row_course_dashboard_cert, parent, false);
        child
            .findViewById(R.id.get_certificate)
            .setOnClickListener(
                new View.OnClickListener() {
                  @Override
                  public void onClick(View v) {
                    environment.getRouter().showCertificate(getActivity(), courseData);
                  }
                });
        parent.addView(child);
      }

      // Implementation Note: - we can create a list view and populate the list.
      // but as number of rows are fixed and each row is different. the only common
      // thing is UI layout. so we reuse the same UI layout programmatically here.
      ViewHolder holder = createViewHolder(inflater, parent);

      holder.typeView.setIcon(Iconify.IconValue.fa_list_alt);
      holder.titleView.setText(R.string.courseware_title);
      holder.subtitleView.setText(R.string.courseware_subtitle);
      holder.rowView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              environment.getRouter().showCourseContainerOutline(getActivity(), courseData);
            }
          });

      if (courseData != null
          && !TextUtils.isEmpty(courseData.getCourse().getDiscussionUrl())
          && environment.getConfig().isDiscussionsEnabled()) {
        holder = createViewHolder(inflater, parent);

        holder.typeView.setIcon(Iconify.IconValue.fa_comments_o);
        holder.titleView.setText(R.string.discussion_title);
        holder.subtitleView.setText(R.string.discussion_subtitle);
        holder.rowView.setOnClickListener(
            new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                environment.getRouter().showCourseDiscussionTopics(getActivity(), courseData);
              }
            });
      }

      holder = createViewHolder(inflater, parent);

      holder.typeView.setIcon(Iconify.IconValue.fa_file_text_o);
      holder.titleView.setText(R.string.handouts_title);
      holder.subtitleView.setText(R.string.handouts_subtitle);
      holder.rowView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (courseData != null)
                environment.getRouter().showHandouts(getActivity(), courseData);
            }
          });

      holder = createViewHolder(inflater, parent);

      holder.typeView.setIcon(Iconify.IconValue.fa_bullhorn);
      holder.titleView.setText(R.string.announcement_title);
      holder.subtitleView.setText(R.string.announcement_subtitle);
      holder.rowView.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              if (courseData != null)
                environment.getRouter().showCourseAnnouncement(getActivity(), courseData);
            }
          });
    } else {
      errorText.setText(R.string.course_not_started);
    }
  }