diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt index 3697a9f31..129655165 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -9,6 +9,7 @@ import android.graphics.Point import android.net.Uri import android.os.Bundle import android.provider.MediaStore +import android.support.v7.widget.LinearLayoutManager import android.view.Menu import android.view.MenuItem import android.widget.RelativeLayout @@ -353,8 +354,8 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener if (currPrimaryAction == PRIMARY_ACTION_FILTER && bottom_actions_filter_list.adapter == null) { Thread { - val size = resources.getDimension(R.dimen.bottom_filters_thumbnail_height).toInt() - val bitmap = Glide.with(this).asBitmap().load(uri).submit(size, size).get() + val thumbnailSize = resources.getDimension(R.dimen.bottom_filters_thumbnail_size).toInt() + val bitmap = Glide.with(this).asBitmap().load(uri).submit(thumbnailSize, thumbnailSize).get() runOnUiThread { val filterThumbnailsManager = FilterThumbnailsManager() filterThumbnailsManager.clearThumbs() @@ -369,7 +370,14 @@ class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener val filterItems = filterThumbnailsManager.processThumbs() val adapter = FiltersAdapter(applicationContext, filterItems) { - applyFilter(it) + val layoutManager = bottom_actions_filter_list.layoutManager as LinearLayoutManager + applyFilter(filterItems[it]) + + if (it == layoutManager.findLastCompletelyVisibleItemPosition() || it == layoutManager.findLastVisibleItemPosition()) { + bottom_actions_filter_list.smoothScrollBy(thumbnailSize, 0) + } else if (it == layoutManager.findFirstCompletelyVisibleItemPosition() || it == layoutManager.findFirstVisibleItemPosition()) { + bottom_actions_filter_list.smoothScrollBy(-thumbnailSize, 0) + } } bottom_actions_filter_list.adapter = adapter diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/FiltersAdapter.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/FiltersAdapter.kt index e8dfd83ef..782412a94 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/FiltersAdapter.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/adapters/FiltersAdapter.kt @@ -12,7 +12,7 @@ import com.simplemobiletools.gallery.models.FilterItem import kotlinx.android.synthetic.main.editor_filter_item.view.* import java.util.* -class FiltersAdapter(val context: Context, val filterItems: ArrayList, val itemClick: (FilterItem) -> Unit) : RecyclerView.Adapter(), +class FiltersAdapter(val context: Context, val filterItems: ArrayList, val itemClick: (Int) -> Unit) : RecyclerView.Adapter(), FilterAdapterListener { private var currentSelection = filterItems.first() @@ -31,11 +31,12 @@ class FiltersAdapter(val context: Context, val filterItems: ArrayList + android:layout_marginBottom="@dimen/bottom_filters_thumbnail_size"/> diff --git a/app/src/main/res/layout/editor_filter_item.xml b/app/src/main/res/layout/editor_filter_item.xml index ff20581f1..31f6bb51d 100644 --- a/app/src/main/res/layout/editor_filter_item.xml +++ b/app/src/main/res/layout/editor_filter_item.xml @@ -8,8 +8,8 @@ diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 14367ad1f..b671eac3e 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -11,6 +11,6 @@ 30dp 72dp 64dp - 76dp + 76dp 90dp