This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context | |
import android.graphics.* | |
import android.graphics.drawable.Drawable | |
import android.os.Handler | |
import android.os.Looper | |
import android.util.DisplayMetrics | |
import androidx.annotation.ColorInt | |
import kotlin.math.PI | |
import kotlin.math.cos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.comunitee.ui.widgets.media_view | |
import android.content.Context | |
import android.graphics.Color | |
import android.util.AttributeSet | |
import android.util.Log | |
import android.view.View | |
import android.widget.FrameLayout | |
import android.widget.ImageView | |
import android.widget.LinearLayout |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"emoji": "☺️️", | |
"aliases": [ | |
":‑)", | |
":)", | |
":-]", | |
":]", | |
":-3", | |
":3", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun drawTextToBitmapOrGetCache(context: Context, text: String, @ColorRes textColor: Int, @ColorRes backgroundColor: Int, textSize: Float = 33f): Bitmap? { | |
val name = "${text}_image" | |
val file = File(context.cacheDir, name) | |
Log.d("CACHE_IMAGE", "${file.exists()} $name ${file.absolutePath}") | |
return if (file.exists()) { | |
getNamePlaceholderFromCache(file) | |
} else { | |
val namePlaceholderBitmap = drawTextToBitmap(context, text, textColor, backgroundColor, textSize) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun RecyclerView.attachScrollToFade(view: View? = null) { | |
addOnScrollListener(object : RecyclerView.OnScrollListener() { | |
override fun onScrolled(recyclerView: RecyclerView, dx: Int, dy: Int) { | |
super.onScrolled(recyclerView, dx, dy) | |
val linearLayoutManager = layoutManager as LinearLayoutManager | |
if (linearLayoutManager.findFirstVisibleItemPosition() == 0) { | |
val firstVisible = linearLayoutManager.findViewByPosition(linearLayoutManager.findFirstVisibleItemPosition()) | |
if (firstVisible != null) { | |
val distanceTop = firstVisible.top |