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 'package:flutter/widgets.dart'; | |
/// Conditionally wrap a subtree with a parent widget. | |
/// | |
/// [isParentWidgetNeeded]: the condition depending on which the subtree [child] is wrapped with the parent. | |
/// [child]: The subtree that should always be build. | |
/// [conditionalBuilder]: builds the parent wrapping the subtree [child]. | |
/// | |
/// ___________ | |
/// Usage: |
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
version: 2 | |
updates: | |
- package-ecosystem: gradle | |
directory: "/" | |
schedule: | |
interval: daily | |
open-pull-requests-limit: 10 |
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
version: 2 | |
updates: | |
# Updates for Github Actions used in the repo | |
- package-ecosystem: "github-actions" | |
directory: "/" | |
schedule: | |
interval: "weekly" | |
# Updates for Gradle dependencies used in the app | |
- package-ecosystem: gradle | |
directory: "/" |
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 var currentAzimuth = TRUE_NORTH | |
private fun animateArrow(newDegreesValue: Float) { | |
var from = currentAzimuth | |
var to = newDegreesValue | |
val min = from.coerceAtMost(to) | |
if (abs(to - from) > HALF_CIRCLE) { | |
if (min == from) { |
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
// It is better to use dialogs with detailed description of error, but for clarity of this gist I decided to use Toasts here | |
fun Context.startIntentOrShowError(intent: Intent, | |
errorDialogDescription: String, | |
errorDialogTitle: String = "No app found!") { | |
if (intent.resolveActivity(this.packageManager) != null) { | |
when (intent.resolveActivityInfo(this.packageManager, intent.flags).exported) { | |
true -> startActivity(intent) | |
else -> Toast.makeText(this, errorDialogTitle, Toast.LENGHT_SHORT).show() | |
} | |
} else { |
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
@Throws(IOException::class) | |
private fun restoreBitmapRotation(bitmapFile: File): Bitmap { | |
val exif = ExifInterface(Uri.fromFile(bitmapFile).path) | |
val orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL) | |
val rotationAngle = when (orientation) { | |
ExifInterface.ORIENTATION_ROTATE_90 -> 90f | |
ExifInterface.ORIENTATION_ROTATE_180 -> 180f | |
ExifInterface.ORIENTATION_ROTATE_270 -> 270f | |
else -> 0f |
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.graphics.* | |
import android.graphics.drawable.Drawable | |
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool | |
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation | |
import java.io.UnsupportedEncodingException | |
import java.security.MessageDigest | |
class MaskImageTransformation(private val mask: Drawable) : BitmapTransformation() { | |
override fun transform(pool: BitmapPool, toTransform: Bitmap, outWidth: Int, outHeight: Int): 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
import android.content.Context; | |
import android.graphics.Bitmap; | |
import android.graphics.BitmapShader; | |
import android.graphics.Canvas; | |
import android.graphics.Paint; | |
import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; | |
import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; | |
public class CircleTransform extends BitmapTransformation { |
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 Bitmap restoreRotation(File originalFile) throws IOException { | |
int rotationAngle; | |
ExifInterface ei = new ExifInterface(Uri.fromFile(originalFile).getPath()); | |
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION, ExifInterface.ORIENTATION_NORMAL); | |
switch (orientation) { | |
case ExifInterface.ORIENTATION_ROTATE_90: | |
rotationAngle = 90; | |
break; | |
case ExifInterface.ORIENTATION_ROTATE_180: |