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.example.components; | |
import android.content.Context; | |
import android.content.res.Resources; | |
import android.graphics.Bitmap; | |
import android.graphics.Canvas; | |
import android.graphics.drawable.BitmapDrawable; | |
import android.graphics.drawable.Drawable; | |
import android.text.Html; | |
import android.view.View; |
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
Bitmap batmapBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.batman); | |
RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), batmapBitmap); | |
// option 1 h/t [Chris Banes](https://chris.banes.me/) | |
circularBitmapDrawable.setCornerRadius(batmapBitmap.getWidth()); | |
// option 2 h/t @csorgod in the comments | |
circularBitmapDrawable.setCircular(true); | |
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
public class RealPathUtil { | |
public static String getRealPath(Context context, Uri fileUri) { | |
String realPath; | |
// SDK < API11 | |
if (Build.VERSION.SDK_INT < 11) { | |
realPath = RealPathUtil.getRealPathFromURI_BelowAPI11(context, fileUri); | |
} | |
// SDK >= 11 && SDK < 19 | |
else if (Build.VERSION.SDK_INT < 19) { |
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 View.visible() { | |
visibility = View.VISIBLE | |
} | |
fun View.invisible() { | |
visibility = View.INVISIBLE | |
} | |
fun View.gone() { | |
visibility = View.GONE |