Java Code Examples for com.yanzhenjie.album.AlbumFile#setChecked()

The following examples show how to use com.yanzhenjie.album.AlbumFile#setChecked() . 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: PictureFileUtils.java    From smart-farmer-android with Apache License 2.0 5 votes vote down vote up
public static AlbumFile createAlbumFile(File file, boolean isVideo){
        AlbumFile albumFile = new AlbumFile();
        albumFile.setMediaType(isVideo ? AlbumFile.TYPE_VIDEO : AlbumFile.TYPE_IMAGE);
        albumFile.setPath(file.getAbsolutePath());
        String name = file.getName();
        albumFile.setName(name);
        int lastPoint = name.lastIndexOf(".");
        if (lastPoint != -1){
            albumFile.setTitle(name.substring(0, lastPoint));
        } else {
            albumFile.setTitle(name);
        }
        albumFile.setBucketName(file.getParent());
        if (lastPoint != -1 && lastPoint != name.length() - 1){
            albumFile.setMimeType(MimeTypeMap.getSingleton().getMimeTypeFromExtension(name.substring(lastPoint + 1)));
        }
        long date = System.currentTimeMillis();
        albumFile.setAddDate(date);
        albumFile.setModifyDate(date);
        albumFile.setLatitude(0);
        albumFile.setLongitude(0);
        albumFile.setSize(file.length());
        albumFile.setThumbPath(null);
        albumFile.setChecked(true);
        albumFile.setEnable(true);

//        if (!isVideo) {
//            int degree = PictureFileUtils.readPictureDegree(file.getAbsolutePath());
//            rotateImage(degree, file);
//        }

        if (isVideo) {
            int[] size = readVideoInfo(file.getPath());
            albumFile.setWidth(size[0]);
            albumFile.setHeight(size[1]);
            albumFile.setDuration(size[2]);
        }
        return albumFile;
    }
 
Example 2
Source File: GalleryAlbumActivity.java    From Album with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged() {
    AlbumFile albumFile = mAlbumFiles.get(mCurrentPosition);
    albumFile.setChecked(!albumFile.isChecked());

    setCheckedCount();
}
 
Example 3
Source File: AlbumActivity.java    From Album with Apache License 2.0 5 votes vote down vote up
@Override
public void onConvertCallback(AlbumFile albumFile) {
    albumFile.setChecked(!albumFile.isDisable());
    if (albumFile.isDisable()) {
        if (mFilterVisibility) addFileToList(albumFile);
        else mView.toast(getString(R.string.album_take_file_unavailable));
    } else {
        addFileToList(albumFile);
    }

    dismissLoadingDialog();
}
 
Example 4
Source File: AlbumActivity.java    From Album with Apache License 2.0 5 votes vote down vote up
@Override
public void tryCheckItem(CompoundButton button, int position) {
    AlbumFile albumFile = mAlbumFolders.get(mCurrentFolder).getAlbumFiles().get(position);
    if (button.isChecked()) {
        if (mCheckedList.size() >= mLimitCount) {
            int messageRes;
            switch (mFunction) {
                case Album.FUNCTION_CHOICE_IMAGE: {
                    messageRes = R.plurals.album_check_image_limit;
                    break;
                }
                case Album.FUNCTION_CHOICE_VIDEO: {
                    messageRes = R.plurals.album_check_video_limit;
                    break;
                }
                case Album.FUNCTION_CHOICE_ALBUM: {
                    messageRes = R.plurals.album_check_album_limit;
                    break;
                }
                default: {
                    throw new AssertionError("This should not be the case.");
                }
            }
            mView.toast(getResources().getQuantityString(messageRes, mLimitCount, mLimitCount));
            button.setChecked(false);
        } else {
            albumFile.setChecked(true);
            mCheckedList.add(albumFile);
            setCheckedCount();
        }
    } else {
        albumFile.setChecked(false);
        mCheckedList.remove(albumFile);
        setCheckedCount();
    }
}
 
Example 5
Source File: MediaReadTask.java    From Album with Apache License 2.0 5 votes vote down vote up
@Override
protected ResultWrapper doInBackground(Void... params) {
    ArrayList<AlbumFolder> albumFolders;
    switch (mFunction) {
        case Album.FUNCTION_CHOICE_IMAGE: {
            albumFolders = mMediaReader.getAllImage();
            break;
        }
        case Album.FUNCTION_CHOICE_VIDEO: {
            albumFolders = mMediaReader.getAllVideo();
            break;
        }
        case Album.FUNCTION_CHOICE_ALBUM: {
            albumFolders = mMediaReader.getAllMedia();
            break;
        }
        default: {
            throw new AssertionError("This should not be the case.");
        }
    }

    ArrayList<AlbumFile> checkedFiles = new ArrayList<>();

    if (mCheckedFiles != null && !mCheckedFiles.isEmpty()) {
        List<AlbumFile> albumFiles = albumFolders.get(0).getAlbumFiles();
        for (AlbumFile checkAlbumFile : mCheckedFiles) {
            for (int i = 0; i < albumFiles.size(); i++) {
                AlbumFile albumFile = albumFiles.get(i);
                if (checkAlbumFile.equals(albumFile)) {
                    albumFile.setChecked(true);
                    checkedFiles.add(albumFile);
                }
            }
        }
    }
    ResultWrapper wrapper = new ResultWrapper();
    wrapper.mAlbumFolders = albumFolders;
    wrapper.mAlbumFiles = checkedFiles;
    return wrapper;
}
 
Example 6
Source File: GalleryActivity.java    From Album with Apache License 2.0 5 votes vote down vote up
@Override
public void onCheckedChanged() {
    AlbumFile albumFile = sAlbumFiles.get(sCurrentPosition);
    if (albumFile.isChecked()) {
        albumFile.setChecked(false);
        sCallback.onPreviewChanged(albumFile);
        sCheckedCount--;
    } else {
        if (sCheckedCount >= mAllowSelectCount) {
            int messageRes;
            switch (mFunction) {
                case Album.FUNCTION_CHOICE_IMAGE: {
                    messageRes = R.plurals.album_check_image_limit;
                    break;
                }
                case Album.FUNCTION_CHOICE_VIDEO: {
                    messageRes = R.plurals.album_check_video_limit;
                    break;
                }
                case Album.FUNCTION_CHOICE_ALBUM: {
                    messageRes = R.plurals.album_check_album_limit;
                    break;
                }
                default: {
                    throw new AssertionError("This should not be the case.");
                }
            }
            mView.toast(getResources().getQuantityString(messageRes, mAllowSelectCount, mAllowSelectCount));
            mView.setChecked(false);
        } else {
            albumFile.setChecked(true);
            sCallback.onPreviewChanged(albumFile);
            sCheckedCount++;
        }
    }

    setCheckedCount();
}