Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions tourguide/src/main/java/tourguide/tourguide/FrameLayoutWithHole.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package tourguide.tourguide
import android.animation.AnimatorSet
import android.app.Activity
import android.graphics.*
import android.os.Build
import android.support.v4.content.ContextCompat
import android.text.TextPaint
import android.util.AttributeSet
Expand Down Expand Up @@ -70,9 +71,10 @@ open class FrameLayoutWithHole @JvmOverloads constructor(private val mActivity:
textAlign = Paint.Align.LEFT
}

val size = Point()
size.x = mActivity.resources.displayMetrics.widthPixels
size.y = mActivity.resources.displayMetrics.heightPixels
val size = getDefaultResolution(mActivity)

// size.x = mActivity.resources.displayMetrics.widthPixels
// size.y = mActivity.resources.displayMetrics.heightPixels

mEraserBitmap = Bitmap.createBitmap(size.x, size.y, Bitmap.Config.ARGB_8888)
_eraserCanvas = Canvas(mEraserBitmap!!)
Expand All @@ -90,6 +92,16 @@ open class FrameLayoutWithHole @JvmOverloads constructor(private val mActivity:
}
}

fun getDefaultResolution(activity: Activity): Point {
val display = activity.windowManager.defaultDisplay
val size = Point()
when {
Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 -> display.getRealSize(size)
Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2 -> display.getSize(size)
}
return size
}

fun setViewHole(viewHole: View) {
this.mViewHole = viewHole
enforceMotionType()
Expand Down