This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.zekierciyas.cache.model.satellite_list.SatelliteListItem | |
import java.util.* | |
class CachedBruteForceSearching(private val cacheSize: Int = 5) { | |
private var givenDataList: List<SatelliteListItem> = mutableListOf() | |
var cache: LinkedHashMap<String, List<SatelliteListItem>> = object : LinkedHashMap<String, List<SatelliteListItem>>(5, 0.75f, true) { | |
override fun removeEldestEntry(eldest: Map.Entry<String?, List<SatelliteListItem>>?): Boolean { | |
return size > cacheSize |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun Bitmap.resizeImage(image: Bitmap, maxWidth: Int, maxHeight: Int, onComplete: (bitmap: Bitmap?) -> Unit) { | |
val width = image.width | |
val height = image.height | |
val scaleWidth = maxWidth.toFloat() / width | |
val scaleHeight = maxHeight.toFloat() / height | |
val matrix = Matrix() | |
matrix.postScale(scaleWidth, scaleHeight) |