set MySquareImageView size depending on the thumbnail scrolling orientation

This commit is contained in:
tibbi 2017-06-18 20:36:37 +02:00
parent 561c81dd42
commit f740150d49
2 changed files with 4 additions and 2 deletions

View file

@ -23,7 +23,6 @@ import com.theartofdev.edmodo.cropper.CropImageView
import kotlinx.android.synthetic.main.view_crop_image.* import kotlinx.android.synthetic.main.view_crop_image.*
import java.io.* import java.io.*
class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener { class EditActivity : SimpleActivity(), CropImageView.OnCropImageCompleteListener {
val TAG = EditActivity::class.java.simpleName val TAG = EditActivity::class.java.simpleName
val ASPECT_X = "aspectX" val ASPECT_X = "aspectX"

View file

@ -1,10 +1,12 @@
package com.simplemobiletools.gallery.views package com.simplemobiletools.gallery.views
import android.content.Context import android.content.Context
import android.support.v7.widget.OrientationHelper
import android.util.AttributeSet import android.util.AttributeSet
import android.widget.ImageView import android.widget.ImageView
class MySquareImageView : ImageView { class MySquareImageView : ImageView {
var orientation = OrientationHelper.VERTICAL
constructor(context: Context) : super(context) constructor(context: Context) : super(context)
@ -14,6 +16,7 @@ class MySquareImageView : ImageView {
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) { override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec) super.onMeasure(widthMeasureSpec, heightMeasureSpec)
setMeasuredDimension(measuredWidth, measuredWidth) val spec = if (orientation == OrientationHelper.VERTICAL) measuredWidth else measuredHeight
setMeasuredDimension(spec, spec)
} }
} }