mirror of
https://github.com/FossifyOrg/Gallery.git
synced 2024-11-30 00:17:58 +01:00
apply the filters on thumbnail items
This commit is contained in:
parent
5dc9f62c26
commit
8c116f6c16
3 changed files with 35 additions and 2 deletions
|
@ -23,6 +23,7 @@ import com.simplemobiletools.gallery.dialogs.ResizeDialog
|
|||
import com.simplemobiletools.gallery.dialogs.SaveAsDialog
|
||||
import com.simplemobiletools.gallery.extensions.config
|
||||
import com.simplemobiletools.gallery.extensions.openEditor
|
||||
import com.simplemobiletools.gallery.helpers.FilterThumbnailsManager
|
||||
import com.simplemobiletools.gallery.models.FilterItem
|
||||
import com.theartofdev.edmodo.cropper.CropImageView
|
||||
import com.zomato.photofilters.FilterPack
|
||||
|
@ -253,8 +254,14 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener
|
|||
val size = resources.getDimension(R.dimen.bottom_filters_thumbnail_height).toInt()
|
||||
val bitmap = Glide.with(this).asBitmap().load(uri).submit(size, size).get()
|
||||
runOnUiThread {
|
||||
val filterItems = FilterPack.getFilterPack(this).map { FilterItem(bitmap, it) } as ArrayList<FilterItem>
|
||||
FilterThumbnailsManager.clearThumbs()
|
||||
|
||||
FilterPack.getFilterPack(this).forEach {
|
||||
val filterItem = FilterItem(bitmap, it)
|
||||
FilterThumbnailsManager.addThumb(filterItem)
|
||||
}
|
||||
|
||||
val filterItems = FilterThumbnailsManager.processThumbs()
|
||||
val adapter = FiltersAdapter(filterItems) {
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
package com.simplemobiletools.gallery.helpers
|
||||
|
||||
import com.simplemobiletools.gallery.models.FilterItem
|
||||
import java.util.*
|
||||
|
||||
object FilterThumbnailsManager {
|
||||
private var filterThumbnails = ArrayList<FilterItem>(10)
|
||||
private var processedThumbnails = ArrayList<FilterItem>(10)
|
||||
|
||||
fun addThumb(filterItem: FilterItem) {
|
||||
filterThumbnails.add(filterItem)
|
||||
}
|
||||
|
||||
fun processThumbs(): ArrayList<FilterItem> {
|
||||
for (filterItem in filterThumbnails) {
|
||||
filterItem.bitmap = filterItem.filter.processFilter(filterItem.bitmap)
|
||||
processedThumbnails.add(filterItem)
|
||||
}
|
||||
return processedThumbnails
|
||||
}
|
||||
|
||||
fun clearThumbs() {
|
||||
filterThumbnails = ArrayList()
|
||||
processedThumbnails = ArrayList()
|
||||
}
|
||||
}
|
|
@ -3,4 +3,4 @@ package com.simplemobiletools.gallery.models
|
|||
import android.graphics.Bitmap
|
||||
import com.zomato.photofilters.imageprocessors.Filter
|
||||
|
||||
data class FilterItem(val bitmap: Bitmap, val filter: Filter)
|
||||
data class FilterItem(var bitmap: Bitmap, val filter: Filter)
|
||||
|
|
Loading…
Reference in a new issue