コード例 #1
0
 public void release() {
   for (CoursePreviewInfo coursePreviewInfo : mCoursePreviewInfos) {
     if (coursePreviewInfo == null) {
       continue;
     }
     coursePreviewInfo.release();
   }
 }
コード例 #2
0
  @Override
  public void onBindViewHolder(CoursePreviewViewHolder holder, int position) {

    if (holder == null) {
      return;
    }

    if (position >= mCoursePreviewInfos.size()) {
      return;
    }

    final CoursePreviewInfo coursePreviewInfo = mCoursePreviewInfos.get(position);
    if (coursePreviewInfo == null) {
      return;
    }

    // course cover
    if (TextUtils.isEmpty(coursePreviewInfo.getCourseCoverUrl())) {
      holder.mIvCourseCover.setImageResource(R.mipmap.ic_launcher);
    } else {
      ImageLoader.getInstance()
          .displayImage(coursePreviewInfo.getCourseCoverUrl(), holder.mIvCourseCover);
    }
    // course name
    holder.mTvCourseName.setText(coursePreviewInfo.getCourseName());

    holder.mIvDownloadCourse.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            // download course
            if (TextUtils.isEmpty(coursePreviewInfo.getCourseUrl())) {
              ToastUtil.showToast(
                  v.getContext(),
                  v.getContext()
                      .getString(R.string.advanced_use__course_preview_url_is_empty_note));
              return;
            }

            ToastUtil.showToast(
                v.getContext(),
                v.getContext().getString(R.string.advanced_use__course_preview_add_download)
                    + coursePreviewInfo.getCourseName());
            // use FileDownloader to download
            FileDownloader.start(coursePreviewInfo.getCourseUrl());
          }
        });

    holder.itemView.setOnClickListener(
        new OnClickListener() {
          @Override
          public void onClick(View v) {
            // go to play course
            ToastUtil.showToast(v.getContext(), "watch " + coursePreviewInfo.getCourseName());
          }
        });
  }