Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Custom CircularRevealWidget for ImageView.
package com.airsaid.revealeffectview
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Canvas
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatImageView
import com.google.android.material.circularreveal.CircularRevealHelper
import com.google.android.material.circularreveal.CircularRevealWidget
/**
* @author airsaid
*/
class CircularRevealImageView @JvmOverloads constructor(
context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0) : AppCompatImageView(context, attrs, defStyleAttr)
, CircularRevealWidget {
private val helper: CircularRevealHelper = CircularRevealHelper(this)
override fun buildCircularRevealCache() {
this.helper.buildCircularRevealCache()
}
override fun destroyCircularRevealCache() {
this.helper.destroyCircularRevealCache()
}
override fun getRevealInfo(): CircularRevealWidget.RevealInfo? {
return this.helper.revealInfo
}
override fun setRevealInfo(revealInfo: CircularRevealWidget.RevealInfo?) {
this.helper.revealInfo = revealInfo
}
override fun getCircularRevealScrimColor(): Int {
return this.helper.circularRevealScrimColor
}
override fun setCircularRevealScrimColor(color: Int) {
this.helper.circularRevealScrimColor = color
}
override fun getCircularRevealOverlayDrawable(): Drawable? {
return this.helper.circularRevealOverlayDrawable
}
override fun setCircularRevealOverlayDrawable(drawable: Drawable?) {
this.helper.circularRevealOverlayDrawable = drawable
}
@SuppressLint("MissingSuperCall")
override fun draw(canvas: Canvas) {
this.helper.draw(canvas)
}
override fun actualDraw(canvas: Canvas) {
super.draw(canvas)
}
override fun isOpaque(): Boolean {
return this.helper.isOpaque
}
override fun actualIsOpaque(): Boolean {
return super.isOpaque()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.