예제 #1
0
 /**
  * Returns whether this music file is one of the root music folders.
  *
  * @return Whether this music file is one of the root music folders.
  */
 public boolean isRoot() {
   MediaFolderService mediaFolderSettings = ServiceLocator.getMediaFolderService();
   List<MediaFolder> folders = mediaFolderSettings.getAllMediaFolders();
   for (MediaFolder folder : folders) {
     if (file.equals(folder.getPath())) {
       return true;
     }
   }
   return false;
 }
예제 #2
0
  @Override
  public View getView(int position, View convertView, ViewGroup parent) {
    int type = getItemViewType(position);
    if (convertView == null) {
      if (type == 0) {
        convertView = mInflater.inflate(R.layout.item_op, null);
      } else if (type == MediaEntity.IMAGE) {
        convertView = mInflater.inflate(R.layout.item_grid, null);
      } else if (type == MediaEntity.AUDIO) {
        convertView = mInflater.inflate(R.layout.item_grid, null);
      } else if (type == MediaEntity.VIDEO) {
        convertView = mInflater.inflate(R.layout.item_grid_video, null);
      } else {
        throw new IllegalArgumentException("no this kind of viewType");
      }
    }

    int folderType = mDataFolder.getType();
    if (position == 0) {
      ImageView img = (ImageView) convertView;
      if (folderType == MediaEntity.IMAGE) {
        img.setImageResource(R.mipmap.img_op_camera);
        img.setOnClickListener(v -> mActivity.toTakePhoto());
      } else if (type == MediaEntity.VIDEO) {
        img.setImageResource(R.mipmap.img_op_video);
        img.setOnClickListener(v -> mActivity.toMakeVideo());
      }
    } else {
      ImageView imgCover = (ImageView) convertView.findViewById(R.id.img);
      ImageView imgCheck = (ImageView) convertView.findViewById(R.id.img_check_box);
      int realPosition = position - 1;
      MediaEntity en = mDada.get(realPosition);
      imgCheck.setSelected(mediaManager.isSelected(en));
      imgCheck.setOnClickListener(v1 -> mediaManager.toggle(en));

      Glide.with(mActivity).load(en.getPath()).crossFade().into(imgCover);
      if (type == MediaEntity.IMAGE) {
        imgCover.setOnClickListener(
            v -> {
              if (mOnMediaClickListener == null) {
                ActivityImageShower.startActivity(mActivity, mDataFolder, realPosition);
              } else {
                mOnMediaClickListener.onMediaClick(en, realPosition);
              }
            });
      } else if (type == MediaEntity.VIDEO) {
        TextView txtTime = (TextView) convertView.findViewById(R.id.txt_time);
        txtTime.setText(getSecond(en.getDuration()));
        imgCover.setOnClickListener(
            v -> {
              if (mOnMediaClickListener == null) {
                ActivityVideoShower.startActivity(mActivity, en);
              } else {
                mOnMediaClickListener.onMediaClick(en, realPosition);
              }
            });
      }
    }
    return convertView;
  }
예제 #3
0
  public void setMediaFolder(MediaFolder folder) {
    mDataFolder = folder;
    mDada.clear();
    mDada.addAll(folder.getChildren());

    notifyDataSetChanged();
  }