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 ImageSaver { | |
public static void saveImage( Context context, String FILE_NAME, Bitmap bitmap){ | |
String savedImagePath = null; | |
final File path = Environment.getExternalStoragePublicDirectory (Environment.DIRECTORY_DCIM + "/YOUR_DIRECTORY_NAME/"); | |
savedImagePath = path.getAbsolutePath(); | |
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
class ShareScreenshot { | |
fun getBitmapFromView(view: View): Bitmap? { | |
val bitmap = Bitmap.createBitmap(view.width, view.height, Bitmap.Config.ARGB_8888) | |
val canvas = Canvas(bitmap) | |
view.draw(canvas) | |
return bitmap | |
} | |
} |
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
@Composable | |
fun Instagram() { | |
// gradient color for the icon | |
val gradientColor = listOf(Color.Yellow, Color.Red, Color.Magenta) | |
Canvas( | |
modifier = Modifier | |
.size(100.dp) | |
.padding(16.dp) |
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
private inline fun <T1: Any, T2: Any, R: Any> safeLet(p1: T1?, p2: T2?, block: (T1, T2)->R?): R? { | |
return if (p1 != null && p2 != null) block(p1, p2) else null | |
} |