Search in sources :

Example 1 with ExternalLinkType

use of com.owncloud.android.lib.common.ExternalLinkType in project android by nextcloud.

the class ExternalLinksProvider method createExternalLinkFromCursor.

/**
 * cursor to externalLink
 *
 * @param cursor db cursor
 * @return externalLink, null if cursor is null
 */
private ExternalLink createExternalLinkFromCursor(Cursor cursor) {
    ExternalLink externalLink = null;
    if (cursor != null) {
        int id = cursor.getInt(cursor.getColumnIndex(ProviderMeta.ProviderTableMeta._ID));
        String iconUrl = cursor.getString(cursor.getColumnIndex(ProviderMeta.ProviderTableMeta.EXTERNAL_LINKS_ICON_URL));
        String language = cursor.getString(cursor.getColumnIndex(ProviderMeta.ProviderTableMeta.EXTERNAL_LINKS_LANGUAGE));
        ExternalLinkType type;
        switch(cursor.getString(cursor.getColumnIndex(ProviderMeta.ProviderTableMeta.EXTERNAL_LINKS_TYPE))) {
            case "link":
                type = ExternalLinkType.LINK;
                break;
            case "settings":
                type = ExternalLinkType.SETTINGS;
                break;
            case "quota":
                type = ExternalLinkType.QUOTA;
                break;
            default:
                type = ExternalLinkType.UNKNOWN;
                break;
        }
        String name = cursor.getString(cursor.getColumnIndex(ProviderMeta.ProviderTableMeta.EXTERNAL_LINKS_NAME));
        String url = cursor.getString(cursor.getColumnIndex(ProviderMeta.ProviderTableMeta.EXTERNAL_LINKS_URL));
        externalLink = new ExternalLink(id, iconUrl, language, type, name, url);
    }
    return externalLink;
}
Also used : ExternalLinkType(com.owncloud.android.lib.common.ExternalLinkType) ExternalLink(com.owncloud.android.lib.common.ExternalLink)

Aggregations

ExternalLink (com.owncloud.android.lib.common.ExternalLink)1 ExternalLinkType (com.owncloud.android.lib.common.ExternalLinkType)1