package views

import models.Image
import models.Thumbnail
import views.BaseView.baseUrl
import views.BaseView.uriEncode

/**
 * Created by allen on 3/30/17.
 */

object ImageView{
    fun urlForImageFull(image: Image?): String{
        if(image != null){
            return "http://photog.alaska.dev/media/images/" + uriEncode(image.path)
        }
        return ""
    }

    fun urlForThumbnailMini(thumbnail: Thumbnail?): String{
        if(thumbnail != null){
            return "http://photog.alaska.dev/media/thumbnails/" + uriEncode(thumbnail.miniThumbnailPath)
        }
        return ""
    }

    fun urlForThumbnail(thumbnail: Thumbnail?): String{
        if(thumbnail != null){
            return "http://photog.alaska.dev/media/thumbnails/" + uriEncode(thumbnail.thumbnailPath)
        }
        return ""
    }

    fun urlForImage(image: Image?): String{
        if(image != null){
            return  baseUrl() + "images/" + image.id
        }
        return ""
    }
}

package views

import models.Image
import models.Thumbnail
import views.BaseView.baseUrl
import views.BaseView.uriEncode

/**
 * Created by allen on 3/30/17.
 */

object ImageView{
    val ASSET_IMAGE_BASE_URL: String = "http://photog.alaska.dev/media/images/"
    val ASSET_THUMBNAIL_BASE_URL: String = "http://photog.alaska.dev/media/thumbnails/"

    fun urlForImageFull(image: Image?): String{
        if(image != null){
            return ASSET_IMAGE_BASE_URL + uriEncode(image.path)
        }
        return ""
    }

    fun urlForThumbnailMini(thumbnail: Thumbnail?): String{
        if(thumbnail != null){
            return ASSET_THUMBNAIL_BASE_URL + uriEncode(thumbnail.miniThumbnailPath)
        }
        return ""
    }

    fun urlForThumbnail(thumbnail: Thumbnail?): String{
        if(thumbnail != null){
            return ASSET_THUMBNAIL_BASE_URL + uriEncode(thumbnail.thumbnailPath)
        }
        return ""
    }

    fun urlForImage(image: Image?): String{
        if(image != null){
            return  baseUrl() + "images/" + image.id
        }
        return ""
    }
}

Refactor thumbnail and photo asset urls to use constants
Refactor thumbnail and photo asset urls to use constants

allen-garvey/photog-spark,allen-garvey/photog-spark,allen-garvey/photog-spark