From f740150d49263e8ca275e58150382215a76f0cec Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 18 Jun 2017 20:36:37 +0200 Subject: [PATCH] set MySquareImageView size depending on the thumbnail scrolling orientation --- .../com/simplemobiletools/gallery/activities/EditActivity.kt | 1 - .../com/simplemobiletools/gallery/views/MySquareImageView.kt | 5 ++++- 2 files changed, 4 insertions(+), 2 deletions(-) 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 ac8cdb4dc..ca9cf9bf6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/activities/EditActivity.kt @@ -23,7 +23,6 @@ import com.theartofdev.edmodo.cropper.CropImageView import kotlinx.android.synthetic.main.view_crop_image.* import java.io.* - class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener { val TAG = EditActivity::class.java.simpleName val ASPECT_X = "aspectX" diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/views/MySquareImageView.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/views/MySquareImageView.kt index 54c26947c..c7b40e61f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/views/MySquareImageView.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/views/MySquareImageView.kt @@ -1,10 +1,12 @@ package com.simplemobiletools.gallery.views import android.content.Context +import android.support.v7.widget.OrientationHelper import android.util.AttributeSet import android.widget.ImageView class MySquareImageView : ImageView { + var orientation = OrientationHelper.VERTICAL constructor(context: Context) : super(context) @@ -14,6 +16,7 @@ class MySquareImageView : ImageView { override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { super.onMeasure(widthMeasureSpec, heightMeasureSpec) - setMeasuredDimension(measuredWidth, measuredWidth) + val spec = if (orientation == OrientationHelper.VERTICAL) measuredWidth else measuredHeight + setMeasuredDimension(spec, spec) } }