Java Code Examples for com.yanzhenjie.album.AlbumFile#TYPE_VIDEO

The following examples show how to use com.yanzhenjie.album.AlbumFile#TYPE_VIDEO . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GalleryAlbumActivity.java    From Album with Apache License 2.0 6 votes vote down vote up
@Override
public void onCurrentChanged(int position) {
    mCurrentPosition = position;
    mView.setSubTitle(position + 1 + " / " + mAlbumFiles.size());

    AlbumFile albumFile = mAlbumFiles.get(position);
    if (mCheckable) mView.setChecked(albumFile.isChecked());
    mView.setLayerDisplay(albumFile.isDisable());

    if (albumFile.getMediaType() == AlbumFile.TYPE_VIDEO) {
        if (!mCheckable) mView.setBottomDisplay(true);
        mView.setDuration(AlbumUtils.convertDuration(albumFile.getDuration()));
        mView.setDurationDisplay(true);
    } else {
        if (!mCheckable) mView.setBottomDisplay(false);
        mView.setDurationDisplay(false);
    }
}
 
Example 2
Source File: GalleryActivity.java    From Album with Apache License 2.0 6 votes vote down vote up
@Override
public void onCurrentChanged(int position) {
    sCurrentPosition = position;
    mView.setTitle(sCurrentPosition + 1 + " / " + sAlbumFiles.size());

    AlbumFile albumFile = sAlbumFiles.get(position);
    mView.setChecked(albumFile.isChecked());
    mView.setLayerDisplay(albumFile.isDisable());

    if (albumFile.getMediaType() == AlbumFile.TYPE_VIDEO) {
        mView.setDuration(AlbumUtils.convertDuration(albumFile.getDuration()));
        mView.setDurationDisplay(true);
    } else {
        mView.setDurationDisplay(false);
    }
}
 
Example 3
Source File: PostModelImpl.java    From smart-farmer-android with Apache License 2.0 5 votes vote down vote up
@NonNull
@Override
public Observable<JsonObject> onUpload(AlbumFile albumFile, Map<String, Object> params, IProgressListener<AlbumFile> listener) {
    if (albumFile.getMediaType() == AlbumFile.TYPE_VIDEO) {
        return uploadVideo(albumFile, params, listener);
    } else {
        return uploadPicture(albumFile, params, listener);
    }
}
 
Example 4
Source File: ThumbnailBuildTask.java    From Album with Apache License 2.0 5 votes vote down vote up
@Override
protected ArrayList<AlbumFile> doInBackground(Void... params) {
    for (AlbumFile albumFile : mAlbumFiles) {
        int mediaType = albumFile.getMediaType();
        if (mediaType == AlbumFile.TYPE_IMAGE) {
            albumFile.setThumbPath(mThumbnailBuilder.createThumbnailForImage(albumFile.getPath()));
        } else if (mediaType == AlbumFile.TYPE_VIDEO) {
            albumFile.setThumbPath(mThumbnailBuilder.createThumbnailForVideo(albumFile.getPath()));
        }
    }
    return mAlbumFiles;
}
 
Example 5
Source File: AlbumAdapter.java    From Album with Apache License 2.0 5 votes vote down vote up
@Override
public int getItemViewType(int position) {
    switch (position) {
        case 0: {
            return hasCamera ? TYPE_BUTTON : TYPE_IMAGE;
        }
        default: {
            position = hasCamera ? position - 1 : position;
            AlbumFile albumFile = mAlbumFiles.get(position);
            return albumFile.getMediaType() == AlbumFile.TYPE_VIDEO ? TYPE_VIDEO : TYPE_IMAGE;
        }
    }
}
 
Example 6
Source File: Adapter.java    From Album with Apache License 2.0 5 votes vote down vote up
@Override
public int getItemViewType(int position) {
    AlbumFile albumFile = mAlbumFiles.get(position);
    if (albumFile.getMediaType() == AlbumFile.TYPE_IMAGE) {
        return AlbumFile.TYPE_IMAGE;
    } else {
        return AlbumFile.TYPE_VIDEO;
    }
}
 
Example 7
Source File: Adapter.java    From Album with Apache License 2.0 5 votes vote down vote up
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
    switch (viewType) {
        case AlbumFile.TYPE_IMAGE: {
            return new ImageViewHolder(mInflater.inflate(R.layout.item_content_image, parent, false), mItemClickListener);
        }
        case AlbumFile.TYPE_VIDEO: {
            return new VideoViewHolder(mInflater.inflate(R.layout.item_content_video, parent, false), mItemClickListener);
        }
        default: {
            throw new AssertionError("This should not be the case.");
        }
    }
}
 
Example 8
Source File: Adapter.java    From Album with Apache License 2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
    int viewType = getItemViewType(position);
    switch (viewType) {
        case AlbumFile.TYPE_IMAGE: {
            ((ImageViewHolder) holder).setData(mAlbumFiles.get(position));
            break;
        }
        case AlbumFile.TYPE_VIDEO: {
            ((VideoViewHolder) holder).setData(mAlbumFiles.get(position));
            break;
        }
    }
}
 
Example 9
Source File: PathConversion.java    From Album with Apache License 2.0 4 votes vote down vote up
@WorkerThread
@NonNull
public AlbumFile convert(String filePath) {
    File file = new File(filePath);

    AlbumFile albumFile = new AlbumFile();
    albumFile.setPath(filePath);

    File parentFile = file.getParentFile();
    albumFile.setBucketName(parentFile.getName());

    String mimeType = AlbumUtils.getMimeType(filePath);
    albumFile.setMimeType(mimeType);
    long nowTime = System.currentTimeMillis();
    albumFile.setAddDate(nowTime);
    albumFile.setSize(file.length());
    int mediaType = 0;
    if (!TextUtils.isEmpty(mimeType)) {
        if (mimeType.contains("video"))
            mediaType = AlbumFile.TYPE_VIDEO;
        if (mimeType.contains("image"))
            mediaType = AlbumFile.TYPE_IMAGE;
    }
    albumFile.setMediaType(mediaType);

    if (mSizeFilter != null && mSizeFilter.filter(file.length())) {
        albumFile.setDisable(true);
    }
    if (mMimeFilter != null && mMimeFilter.filter(mimeType)) {
        albumFile.setDisable(true);
    }

    if (mediaType == AlbumFile.TYPE_VIDEO) {
        MediaPlayer player = new MediaPlayer();
        try {
            player.setDataSource(filePath);
            player.prepare();
            albumFile.setDuration(player.getDuration());
        } catch (Exception ignored) {
        } finally {
            player.release();
        }

        if (mDurationFilter != null && mDurationFilter.filter(albumFile.getDuration())) {
            albumFile.setDisable(true);
        }
    }
    return albumFile;
}