Ejemplo n.º 1
0
  @Override
  protected void initViews() {
    setContentView(R.layout.course_list_activity);
    title = (TextView) findViewById(R.id.title_text);
    back = (TextView) findViewById(R.id.back_text);
    TouchUtil.createTouchDelegate(back, 30);
    title.setText(titleStr);

    listView = (XListView) findViewById(R.id.x_list_view);
    adapter = new CourseListAdapter(CourseListActivity.this, TAG);
    listView.setAdapter(adapter);
  }
Ejemplo n.º 2
0
    public void update(final VideoModel baseItemModel, final int positon) {
      model = baseItemModel;
      title.setText(model.getTitle());
      text.setText(
          changeMB(model.getDownloadedSize())
              + "/"
              + changeMB(model.getVideoSize())
              + "  ("
              + model.getDownloadPercent()
              + "%)");
      TouchUtil.createTouchDelegate(delete, 50);
      TouchUtil.createTouchDelegate(studyRecordBtn, 30);
      if (type == DISMISS_DELETE) {
        studyRecordBtn.setVisibility(View.VISIBLE);
        studyRecordBtn.setClickable(true);
        delete.setVisibility(View.GONE);
        deleteLayout.setVisibility(View.GONE);
        delete.setClickable(false);
        deleteLayout.setClickable(false);
        TouchUtil.createTouchDelegate(delete, 50);
        TouchUtil.createTouchDelegate(studyRecordBtn, 30);
        if (context.type == StudyRecordActivity.ALREADOVER_TYEP) {
          studyRecordBtn.setVisibility(View.GONE);
        } else {
          studyRecordBtn.setVisibility(View.VISIBLE);
          String currentVideoId = DownloadTaskManager.getInstance(context).downloadingId();
          if (currentVideoId != null && currentVideoId.equals(model.getId())) {
            studyRecordBtn.setText(context.getResources().getString(R.string.pause));
            studyRecordBtn.setOnClickListener(
                new OnClickListener() {

                  @Override
                  public void onClick(View v) {
                    // 暂停一个下载,并移除当前下载队列中。
                    DownloadTaskManager.getInstance(context).stopOneTask(model);
                  }
                });
          } else if (set.contains(model)) {
            studyRecordBtn.setText(context.getResources().getString(R.string.wait));
            studyRecordBtn.setOnClickListener(
                new OnClickListener() {

                  @Override
                  public void onClick(View v) {
                    // TODO
                  }
                });
          } else {
            studyRecordBtn.setText(context.getResources().getString(R.string.downlaod));
            studyRecordBtn.setOnClickListener(
                new OnClickListener() {

                  @Override
                  public void onClick(View v) {
                    // 将一个下载加载到下载队列中。
                    startTask(baseItemModel);
                  }
                });
          }
        }
      } else {
        studyRecordBtn.setVisibility(View.GONE);
        studyRecordBtn.setClickable(false);
        delete.setVisibility(View.VISIBLE);
        deleteLayout.setVisibility(View.VISIBLE);
        delete.setClickable(true);
        deleteLayout.setClickable(true);
        TouchUtil.createTouchDelegate(delete, 50);
        TouchUtil.createTouchDelegate(studyRecordBtn, 30);
      }
      deleteLayout.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              deleteDialog(baseItemModel);
            }
          });
      delete.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              deleteDialog(baseItemModel);
            }
          });
      if (positon == getCount() - 1) {
        line.setVisibility(View.INVISIBLE);
      } else {
        line.setVisibility(View.VISIBLE);
      }
    }