/*
 * Copyright 2017 Yan Zhenjie.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.sobot.album.api;

import android.content.Context;
import android.content.Intent;

import com.sobot.album.AlbumFile;
import com.sobot.album.Filter;
import com.sobot.album.SobotAlbum;
import com.sobot.album.app.album.AlbumActivity;

import java.util.ArrayList;


public final class VideoSingleWrapper extends BasicChoiceVideoWrapper<VideoSingleWrapper, ArrayList<AlbumFile>, String, AlbumFile> {

    private Filter<Long> mDurationFilter;

    public VideoSingleWrapper(Context context) {
        super(context);
    }

    /**
     * Filter video duration.
     *
     * @param filter filter.
     */
    public VideoSingleWrapper filterDuration(Filter<Long> filter) {
        this.mDurationFilter = filter;
        return this;
    }

    @Override
    public void start() {
        AlbumActivity.sSizeFilter = mSizeFilter;
        AlbumActivity.sMimeFilter = mMimeTypeFilter;
        AlbumActivity.sDurationFilter = mDurationFilter;
        AlbumActivity.sResult = mResult;
        AlbumActivity.sCancel = mCancel;
        Intent intent = new Intent(mContext, AlbumActivity.class);
        intent.putExtra(SobotAlbum.KEY_INPUT_WIDGET, mWidget);

        intent.putExtra(SobotAlbum.KEY_INPUT_FUNCTION, SobotAlbum.FUNCTION_CHOICE_VIDEO);
        intent.putExtra(SobotAlbum.KEY_INPUT_CHOICE_MODE, SobotAlbum.MODE_SINGLE);
        intent.putExtra(SobotAlbum.KEY_INPUT_COLUMN_COUNT, mColumnCount);
        intent.putExtra(SobotAlbum.KEY_INPUT_ALLOW_CAMERA, mHasCamera);
        intent.putExtra(SobotAlbum.KEY_INPUT_LIMIT_COUNT, 1);
        intent.putExtra(SobotAlbum.KEY_INPUT_FILTER_VISIBILITY, mFilterVisibility);
        intent.putExtra(SobotAlbum.KEY_INPUT_CAMERA_QUALITY, mQuality);
        intent.putExtra(SobotAlbum.KEY_INPUT_CAMERA_DURATION, mLimitDuration);
        intent.putExtra(SobotAlbum.KEY_INPUT_CAMERA_BYTES, mLimitBytes);
        mContext.startActivity(intent);
    }
}