package com.kfzs.duanduan.datashare.provider.downloadtask;

// @formatter:off
import android.net.Uri;
import android.provider.BaseColumns;

import com.kfzs.duanduan.datashare.provider.KFZSDDProvider;
import com.kfzs.duanduan.datashare.provider.base.AbstractSelection;
import com.kfzs.duanduan.datashare.provider.downloadtask.DownloadtaskColumns;
import com.kfzs.duanduan.datashare.provider.records.RecordsColumns;
import com.kfzs.duanduan.datashare.provider.session.SessionColumns;

/**
 * A download_task info which is part of a team.
 */
@SuppressWarnings("unused")
public class DownloadtaskColumns implements BaseColumns {
    public static final String TABLE_NAME = "downloadtask";
    public static final Uri CONTENT_URI = Uri.parse(KFZSDDProvider.CONTENT_URI_BASE + "/" + TABLE_NAME);

    /**
     * Primary key.
     */
    public static final String _ID = BaseColumns._ID;

    /**
     * update create_time of this download_task.
     */
    public static final String CREATE_TIME = "create_time";

    /**
     * download_task_id of this download_task.
     */
    public static final String DOWNLOAD_TASK_ID = "download_task_id";

    /**
     * game_name of this download_task.
     */
    public static final String GAME_NAME = "game_name";
    /**
     * game_id of this download_task.
     */
    public static final String GAME_ID = "game_id";

    /**
     * icon_url of this download_task.
     */
    public static final String ICON_URL = "icon_url";

    /**
     * percent of this download_task.
     */
    public static final String PERCENT = "percent";

    /**
     * downloaded_size of this download_task.
     */
    public static final String DOWNLOADED_SIZE = "downloaded_size";

    /**
     * total_size of this download_task.
     */
    public static final String TOTAL_SIZE = "total_size";

    /**
     * status of this download_task.
     */
    public static final String STATUS = "status";

    /**
     * download_url of this download_task.
     */
    public static final String DOWNLOAD_URL = "download_url";

    /**
     * package_name of this download_task.
     */
    public static final String PACKAGE_NAME = "package_name";

    /**
     * version_code of this download_task.
     */
    public static final String VERSION_CODE = "version_code";

    /**
     * apk_path of this download_task.
     */
    public static final String APK_PATH = "apk_path";


    public static final String DEFAULT_ORDER = TABLE_NAME + "." + CREATE_TIME + AbstractSelection.DESC;

    public static final String[] ALL_COLUMNS = new String[] {
            _ID,
            CREATE_TIME,
            DOWNLOAD_TASK_ID,
            GAME_NAME,
            GAME_ID,
            ICON_URL,
            PERCENT,
            DOWNLOADED_SIZE,
            TOTAL_SIZE,
            STATUS,
            DOWNLOAD_URL,
            PACKAGE_NAME,
            VERSION_CODE,
            APK_PATH
    };

    public static boolean hasColumns(String[] projection) {
        if (projection == null) return true;
        for (String c : projection) {
            if (c.equals(CREATE_TIME) || c.contains("." + CREATE_TIME)) return true;
            if (c.equals(DOWNLOAD_TASK_ID) || c.contains("." + DOWNLOAD_TASK_ID)) return true;
            if (c.equals(GAME_NAME) || c.contains("." + GAME_NAME)) return true;
            if (c.equals(ICON_URL) || c.contains("." + ICON_URL)) return true;
            if (c.equals(PERCENT) || c.contains("." + PERCENT)) return true;
            if (c.equals(DOWNLOADED_SIZE) || c.contains("." + DOWNLOADED_SIZE)) return true;
            if (c.equals(TOTAL_SIZE) || c.contains("." + TOTAL_SIZE)) return true;
            if (c.equals(STATUS) || c.contains("." + STATUS)) return true;
            if (c.equals(DOWNLOAD_URL) || c.contains("." + DOWNLOAD_URL)) return true;
            if (c.equals(PACKAGE_NAME) || c.contains("." + PACKAGE_NAME)) return true;
            if (c.equals(VERSION_CODE) || c.contains("." + VERSION_CODE)) return true;
            if (c.equals(APK_PATH) || c.contains("." + APK_PATH)) return true;
        }
        return false;
    }

}
