コード例 #1
0
  /**
   * 加载皮肤
   *
   * @param position
   * @param downloadTask
   * @param itemViewHolder
   */
  protected void loadSkin(int position, DownloadTask downloadTask, ItemViewHolder itemViewHolder) {
    selectedIndex = findOldSelectedIndex();
    if (selectedIndex != -1) {
      reshPICStatusUI(selectedIndex);
    }
    // 设置当前皮肤主题的id和保存,并通知各个页面去加载新的皮肤
    Constants.skinID = downloadTask.getTid();
    DataUtil.saveValue(context, Constants.skinID_KEY, Constants.skinID);

    SkinThemeApp skinTheme = SkinThemeDB.getSkinThemeDB(context).getSkinThemeInfo(Constants.skinID);
    if (skinTheme != null) {
      DataUtil.loadSkin(context);
      ObserverManage.getObserver().setMessage(skinTheme);
    }
    selectedIndex = position;
    reshPICStatusUI(selectedIndex);
  }
コード例 #2
0
  /**
   * 刷新ui
   *
   * @param position
   * @param itemViewHolder
   * @param downloadTask
   */
  private void reshViewHolder(
      final int position, final ItemViewHolder itemViewHolder, final DownloadTask downloadTask) {
    if (SkinThemeDB.getSkinThemeDB(context).skinThemeIsExists(downloadTask.getTid())) {
      // itemViewHolder.getDownloadstatusRelativeLayout().setVisibility(
      // View.INVISIBLE);
      // itemViewHolder.getSkinProgressBar().setVisibility(View.INVISIBLE);
      if (!downloadTask.getTid().equals(Constants.skinID)) {
        itemViewHolder.getselectImageView().setVisibility(View.INVISIBLE);

        itemViewHolder
            .getItembg()
            .setOnClickListener(
                new OnClickListener() {

                  @Override
                  public void onClick(View arg0) {

                    // 加载皮肤数据
                    loadSkin(position, downloadTask, itemViewHolder);
                  }
                });

      } else {
        itemViewHolder.getItembg().setOnClickListener(null);
        // selectedIndex = position;
        itemViewHolder.getselectImageView().setVisibility(View.VISIBLE);
      }
      itemViewHolder.getSkinProgressBar().setVisibility(View.INVISIBLE);
      itemViewHolder.getDownloadstatusRelativeLayout().setVisibility(View.INVISIBLE);
    } else {
      itemViewHolder.getselectImageView().setVisibility(View.INVISIBLE);
      if (downloadTask.getStatus() == DownloadTask.DOWNLOAD_FINISH) {
        itemViewHolder.getSkinProgressBar().setVisibility(View.INVISIBLE);
        itemViewHolder.getDownloadstatusRelativeLayout().setVisibility(View.INVISIBLE);

        itemViewHolder
            .getItembg()
            .setOnClickListener(
                new OnClickListener() {

                  @Override
                  public void onClick(View arg0) {
                    // 加载皮肤数据
                    loadSkin(position, downloadTask, itemViewHolder);
                  }
                });

      } else if (downloadTask.getStatus() == DownloadTask.DOWNLOING
          || downloadTask.getStatus() == DownloadTask.WAITING) {
        itemViewHolder.getSkinProgressBar().setVisibility(View.VISIBLE);
        itemViewHolder.getDownloadstatusRelativeLayout().setVisibility(View.INVISIBLE);
        itemViewHolder.getItembg().setOnClickListener(null);
      } else {
        itemViewHolder.getSkinProgressBar().setVisibility(View.INVISIBLE);
        itemViewHolder.getDownloadstatusRelativeLayout().setVisibility(View.VISIBLE);

        itemViewHolder
            .getItembg()
            .setOnClickListener(
                new OnClickListener() {

                  @Override
                  public void onClick(View arg0) {
                    // 下载皮肤
                    downloadSkin(position, downloadTask);
                  }
                });
      }
    }
  }