Java Code Examples for com.yanzhenjie.album.Album#FUNCTION_CHOICE_ALBUM

The following examples show how to use com.yanzhenjie.album.Album#FUNCTION_CHOICE_ALBUM . 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: AlbumActivity.java    From Album with Apache License 2.0 6 votes vote down vote up
@Override
public void complete() {
    if (mCheckedList.isEmpty()) {
        int messageRes;
        switch (mFunction) {
            case Album.FUNCTION_CHOICE_IMAGE: {
                messageRes = R.string.album_check_image_little;
                break;
            }
            case Album.FUNCTION_CHOICE_VIDEO: {
                messageRes = R.string.album_check_video_little;
                break;
            }
            case Album.FUNCTION_CHOICE_ALBUM: {
                messageRes = R.string.album_check_album_little;
                break;
            }
            default: {
                throw new AssertionError("This should not be the case.");
            }
        }
        mView.toast(messageRes);
    } else {
        callbackResult();
    }
}
 
Example 2
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 3
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 4
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();
}
 
Example 5
Source File: GalleryActivity.java    From Album with Apache License 2.0 5 votes vote down vote up
@Override
public void complete() {
    if (sCheckedCount == 0) {
        int messageRes;
        switch (mFunction) {
            case Album.FUNCTION_CHOICE_IMAGE: {
                messageRes = R.string.album_check_image_little;
                break;
            }
            case Album.FUNCTION_CHOICE_VIDEO: {
                messageRes = R.string.album_check_video_little;
                break;
            }
            case Album.FUNCTION_CHOICE_ALBUM: {
                messageRes = R.string.album_check_album_little;
                break;
            }
            default: {
                throw new AssertionError("This should not be the case.");
            }
        }
        mView.toast(messageRes);
    } else {
        sCallback.onPreviewComplete();
        finish();
    }
}