Skip to content

Instantly share code, notes, and snippets.

@Airsaid
Created July 30, 2019 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Airsaid/dbb7d6080d55ad1ce6f67abfe633af1e to your computer and use it in GitHub Desktop.
Save Airsaid/dbb7d6080d55ad1ce6f67abfe633af1e to your computer and use it in GitHub Desktop.
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