apply the filters on thumbnail items

This commit is contained in:
tibbi 2018-07-20 11:07:25 +02:00
parent 5dc9f62c26
commit 8c116f6c16
3 changed files with 35 additions and 2 deletions

View file

@ -23,6 +23,7 @@ import com.simplemobiletools.gallery.dialogs.ResizeDialog
import com.simplemobiletools.gallery.dialogs.SaveAsDialog import com.simplemobiletools.gallery.dialogs.SaveAsDialog
import com.simplemobiletools.gallery.extensions.config import com.simplemobiletools.gallery.extensions.config
import com.simplemobiletools.gallery.extensions.openEditor import com.simplemobiletools.gallery.extensions.openEditor
import com.simplemobiletools.gallery.helpers.FilterThumbnailsManager
import com.simplemobiletools.gallery.models.FilterItem import com.simplemobiletools.gallery.models.FilterItem
import com.theartofdev.edmodo.cropper.CropImageView import com.theartofdev.edmodo.cropper.CropImageView
import com.zomato.photofilters.FilterPack 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 size = resources.getDimension(R.dimen.bottom_filters_thumbnail_height).toInt()
val bitmap = Glide.with(this).asBitmap().load(uri).submit(size, size).get() val bitmap = Glide.with(this).asBitmap().load(uri).submit(size, size).get()
runOnUiThread { 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) { val adapter = FiltersAdapter(filterItems) {
} }

View file

@ -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()
}
}

View file

@ -3,4 +3,4 @@ package com.simplemobiletools.gallery.models
import android.graphics.Bitmap import android.graphics.Bitmap
import com.zomato.photofilters.imageprocessors.Filter import com.zomato.photofilters.imageprocessors.Filter
data class FilterItem(val bitmap: Bitmap, val filter: Filter) data class FilterItem(var bitmap: Bitmap, val filter: Filter)