make the variables in MainActivity and FocusRectView non-static
This commit is contained in:
parent
a016f514f8
commit
eeb1077fc2
|
@ -16,13 +16,14 @@ import com.bumptech.glide.Glide
|
|||
import com.bumptech.glide.load.engine.DiskCacheStrategy
|
||||
import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions
|
||||
import com.bumptech.glide.request.RequestOptions
|
||||
import com.simplemobiletools.camera.*
|
||||
import com.simplemobiletools.camera.views.Preview.PreviewListener
|
||||
import com.simplemobiletools.camera.BuildConfig
|
||||
import com.simplemobiletools.camera.R
|
||||
import com.simplemobiletools.camera.extensions.config
|
||||
import com.simplemobiletools.camera.extensions.navBarHeight
|
||||
import com.simplemobiletools.camera.helpers.*
|
||||
import com.simplemobiletools.camera.views.FocusRectView
|
||||
import com.simplemobiletools.camera.views.Preview
|
||||
import com.simplemobiletools.camera.views.Preview.PreviewListener
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_CAMERA
|
||||
import com.simplemobiletools.commons.helpers.PERMISSION_RECORD_AUDIO
|
||||
|
@ -31,25 +32,23 @@ import com.simplemobiletools.commons.models.Release
|
|||
import kotlinx.android.synthetic.main.activity_main.*
|
||||
|
||||
class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSavedListener {
|
||||
companion object {
|
||||
private val FADE_DELAY = 5000
|
||||
private val FADE_DELAY = 5000
|
||||
|
||||
lateinit var mFocusRectView: FocusRectView
|
||||
lateinit var mTimerHandler: Handler
|
||||
lateinit var mFadeHandler: Handler
|
||||
lateinit var mRes: Resources
|
||||
lateinit var mFocusRectView: FocusRectView
|
||||
lateinit var mTimerHandler: Handler
|
||||
lateinit var mFadeHandler: Handler
|
||||
lateinit var mRes: Resources
|
||||
|
||||
private var mPreview: Preview? = null
|
||||
private var mPreviewUri: Uri? = null
|
||||
private var mFlashlightState = FLASH_OFF
|
||||
private var mIsInPhotoMode = false
|
||||
private var mIsCameraAvailable = false
|
||||
private var mIsVideoCaptureIntent = false
|
||||
private var mIsHardwareShutterHandled = false
|
||||
private var mCurrVideoRecTimer = 0
|
||||
private var mCurrCameraId = 0
|
||||
var mLastHandledOrientation = 0
|
||||
}
|
||||
private var mPreview: Preview? = null
|
||||
private var mPreviewUri: Uri? = null
|
||||
private var mFlashlightState = FLASH_OFF
|
||||
private var mIsInPhotoMode = false
|
||||
private var mIsCameraAvailable = false
|
||||
private var mIsVideoCaptureIntent = false
|
||||
private var mIsHardwareShutterHandled = false
|
||||
private var mCurrVideoRecTimer = 0
|
||||
private var mCurrCameraId = 0
|
||||
var mLastHandledOrientation = 0
|
||||
|
||||
lateinit var mOrientationEventListener: OrientationEventListener
|
||||
|
||||
|
|
|
@ -9,16 +9,14 @@ import android.view.ViewGroup
|
|||
import com.simplemobiletools.camera.extensions.config
|
||||
|
||||
class FocusRectView(context: Context) : ViewGroup(context) {
|
||||
companion object {
|
||||
private val RECT_SIZE = 50
|
||||
private val RECT_DURATION = 500
|
||||
private val RECT_SIZE = 50
|
||||
private val RECT_DURATION = 500
|
||||
|
||||
private var mDrawRect = false
|
||||
private var mDrawRect = false
|
||||
private var mHandler: Handler
|
||||
|
||||
lateinit var mPaint: Paint
|
||||
lateinit var mHandler: Handler
|
||||
lateinit var mRect: Rect
|
||||
}
|
||||
lateinit var mPaint: Paint
|
||||
lateinit var mRect: Rect
|
||||
|
||||
init {
|
||||
setWillNotDraw(false)
|
||||
|
@ -53,9 +51,7 @@ class FocusRectView(context: Context) : ViewGroup(context) {
|
|||
invalidate()
|
||||
}
|
||||
|
||||
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
|
||||
|
||||
}
|
||||
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {}
|
||||
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
super.onDraw(canvas)
|
||||
|
|
|
@ -13,12 +13,12 @@ import android.view.ScaleGestureDetector
|
|||
import android.view.SurfaceHolder
|
||||
import android.view.SurfaceView
|
||||
import android.view.ViewGroup
|
||||
import com.simplemobiletools.camera.helpers.PhotoProcessor
|
||||
import com.simplemobiletools.camera.R
|
||||
import com.simplemobiletools.camera.activities.MainActivity
|
||||
import com.simplemobiletools.camera.dialogs.ChangeResolutionDialog
|
||||
import com.simplemobiletools.camera.extensions.*
|
||||
import com.simplemobiletools.camera.helpers.Config
|
||||
import com.simplemobiletools.camera.helpers.PhotoProcessor
|
||||
import com.simplemobiletools.commons.extensions.*
|
||||
import java.io.File
|
||||
import java.io.IOException
|
||||
|
@ -290,7 +290,8 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
|||
mCamera!!.enableShutterSound(false)
|
||||
}
|
||||
|
||||
mRotationAtCapture = MainActivity.mLastHandledOrientation
|
||||
|
||||
mRotationAtCapture = mActivity!!.mLastHandledOrientation
|
||||
mCamera!!.parameters = mParameters
|
||||
isWaitingForTakePictureCallback = true
|
||||
mIsPreviewShown = true
|
||||
|
@ -692,7 +693,7 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
|
|||
}
|
||||
|
||||
private fun getVideoRotation(): Int {
|
||||
val deviceRot = MainActivity.mLastHandledOrientation.compensateDeviceRotation(mCurrCameraId)
|
||||
val deviceRot = mActivity!!.mLastHandledOrientation.compensateDeviceRotation(mCurrCameraId)
|
||||
val previewRot = mActivity!!.getPreviewRotation(mCurrCameraId)
|
||||
return (deviceRot + previewRot) % 360
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue