Search in sources :

Example 1 with AccountMediaModel

use of com.chute.sdk.v2.model.AccountMediaModel in project photo-picker-plus-android by chute.

the class AssetUtil method filterFiles.

/**
	 * Filters the media items that should be displayed according to the options
	 * retrieved from the configuration regarding if the application should
	 * support images, videos or both.
	 * 
	 * @param accountBaseModel
	 *            {@link AccountBaseModel}
	 * @param supportImages
	 *            boolean value indicating whether the application supports
	 *            images.
	 * @param supportVideos
	 *            boolean value indicating whether the application supports
	 *            videos.
	 * @return {@link AccountBaseModel} containing filtered media files.
	 */
public static AccountBaseModel filterFiles(AccountBaseModel accountBaseModel, boolean supportImages, boolean supportVideos) {
    AccountBaseModel model = new AccountBaseModel();
    List<AccountAlbumModel> folders = accountBaseModel.getFolders();
    List<AccountMediaModel> files = new ArrayList<AccountMediaModel>();
    List<AccountMediaModel> videos = new ArrayList<AccountMediaModel>();
    List<AccountMediaModel> images = new ArrayList<AccountMediaModel>();
    if (accountBaseModel.getFiles() != null) {
        for (AccountMediaModel file : accountBaseModel.getFiles()) {
            if (file.getVideoUrl() != null && supportVideos == true) {
                videos.add(file);
            }
            if (file.getVideoUrl() == null && supportImages == true) {
                images.add(file);
            }
        }
    }
    files.addAll(images);
    files.addAll(videos);
    model.setFiles(files);
    model.setFolders(folders);
    return model;
}
Also used : ArrayList(java.util.ArrayList) AccountBaseModel(com.chute.sdk.v2.model.AccountBaseModel) AccountMediaModel(com.chute.sdk.v2.model.AccountMediaModel) AccountAlbumModel(com.chute.sdk.v2.model.AccountAlbumModel)

Example 2 with AccountMediaModel

use of com.chute.sdk.v2.model.AccountMediaModel in project photo-picker-plus-android by chute.

the class ImageDataResponseLoader method postImageData.

public static void postImageData(Context context, ArrayList<AccountMediaModel> selectedImages, ListenerFilesAccount accountListener, AccountModel accountModel) {
    String token = TokenAuthenticationProvider.getInstance().getToken();
    AuthConstants authConstants = AuthenticationFactory.getInstance().getAuthConstants();
    String clientId = authConstants.clientId;
    String clientSecret = authConstants.clientSecret;
    Chute.init(context, new AuthConstants(clientId, clientSecret), token);
    ArrayList<MediaDataModel> mediaModelList = new ArrayList<MediaDataModel>();
    for (AccountMediaModel accountMediaModel : selectedImages) {
        MediaDataModel mediaModel = new MediaDataModel();
        if (accountMediaModel.getVideoUrl() != null) {
            mediaModel.setFileType(MediaType.VIDEO.name().toLowerCase());
        } else {
            mediaModel.setFileType(MediaType.IMAGE.name().toLowerCase());
        }
        mediaModel.setVideoUrl(accountMediaModel.getVideoUrl());
        mediaModel.setImageUrl(accountMediaModel.getImageUrl());
        mediaModel.setThumbnail(accountMediaModel.getThumbnail());
        mediaModelList.add(mediaModel);
    }
    OptionsModel options = new OptionsModel();
    options.setCliendId(clientId);
    MediaModel imageDataModel = new MediaModel();
    imageDataModel.setOptions(options);
    imageDataModel.setMedia(mediaModelList);
    getImageData(imageDataModel, new ImageDataCallback(context, accountListener, accountModel)).executeAsync();
}
Also used : MediaModel(com.getchute.android.photopickerplus.models.MediaModel) AccountMediaModel(com.chute.sdk.v2.model.AccountMediaModel) AuthConstants(com.chute.sdk.v2.api.authentication.AuthConstants) ArrayList(java.util.ArrayList) AccountMediaModel(com.chute.sdk.v2.model.AccountMediaModel) OptionsModel(com.getchute.android.photopickerplus.models.OptionsModel) MediaDataModel(com.getchute.android.photopickerplus.models.MediaDataModel)

Aggregations

AccountMediaModel (com.chute.sdk.v2.model.AccountMediaModel)2 ArrayList (java.util.ArrayList)2 AuthConstants (com.chute.sdk.v2.api.authentication.AuthConstants)1 AccountAlbumModel (com.chute.sdk.v2.model.AccountAlbumModel)1 AccountBaseModel (com.chute.sdk.v2.model.AccountBaseModel)1 MediaDataModel (com.getchute.android.photopickerplus.models.MediaDataModel)1 MediaModel (com.getchute.android.photopickerplus.models.MediaModel)1 OptionsModel (com.getchute.android.photopickerplus.models.OptionsModel)1