Skip to content

Instantly share code, notes, and snippets.

View ForceTower's full-sized avatar
😋
Legendary nice meme

João Sena ForceTower

😋
Legendary nice meme
  • Feira de Santana
  • 02:36 (UTC -03:00)
View GitHub Profile
import android.os.Bundle
import androidx.annotation.IdRes
import androidx.navigation.NavController
import androidx.navigation.NavDestination
import androidx.navigation.NavDirections
import androidx.navigation.NavOptions
import androidx.navigation.Navigator
/**
* Navigate via the given [NavDirections]
import android.graphics.Typeface
import android.text.SpannableString
import android.text.Spanned
import android.text.style.StrikethroughSpan
import android.text.style.StyleSpan
import android.text.style.UnderlineSpan
private val BOLD_REGEX = Regex("\\*([^*]+)\\*")
private val ITALIC_REGEX = Regex("_([^_]+)_")
private val STRIKE_REGEX = Regex("~([^~]+)~")
import SwiftUI
import AVKit
struct ContentView: View {
@State var audioPlayer: AVAudioPlayer!
@State var progress: CGFloat = 0.0
@State private var playing: Bool = false
@State var duration: Double = 0.0
@State var formattedDuration: String = ""
@State var formattedProgress: String = "00:00"
private const val ERROR_EMPTY_VALUE = "Mask cannot be empty"
private const val ERROR_INVALID_CHARACTER = "Mask does not contain specified character"
data class Mask(
val value: String,
val character: Char = value.mostOccurred()
) {
init {
require(value.isNotEmpty()) { ERROR_EMPTY_VALUE }
require(value.contains(character)) { ERROR_INVALID_CHARACTER }
@ForceTower
ForceTower / SimpleRecyclerView.java
Created December 23, 2022 18:50 — forked from saber-solooki/SimpleRecyclerView.java
Sticky Header RecyclerView
package com.saber.customstickyheader;
import android.graphics.Color;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
function ig_media_preview(base64data) {
var jpegtpl = "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEABsaGikdKUEmJkFCLy8vQkc/Pj4/R0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0cBHSkpNCY0PygoP0c/NT9HR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR0dHR//AABEIABQAKgMBIgACEQEDEQH/xAGiAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgsQAAIBAwMCBAMFBQQEAAABfQECAwAEEQUSITFBBhNRYQcicRQygZGhCCNCscEVUtHwJDNicoIJChYXGBkaJSYnKCkqNDU2Nzg5OkNERUZHSElKU1RVVldYWVpjZGVmZ2hpanN0dXZ3eHl6g4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2drh4uPk5ebn6Onq8fLz9PX29/j5+gEAAwEBAQEBAQEBAQAAAAAAAAECAwQFBgcICQoLEQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2gAMAwEAAhEDEQA/AA==",
t = atob(base64data),
p = t.slice(3).split(""),
o = t.substring(0, 3).split("").map(function(e) {
return e.charCodeAt(0)
}),
c = atob(jpegtp
@ForceTower
ForceTower / Dialog.kt
Created July 30, 2021 13:35
Always rounded corners
override fun onCreateDialog(savedInstanceState: Bundle?): Dialog {
val dialog = super.onCreateDialog(savedInstanceState) as BottomSheetDialog
dialog.behavior.addBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() {
override fun onStateChanged(bottomSheet: View, newState: Int) {
Timber.d("State changed $newState")
if (newState == BottomSheetBehavior.STATE_EXPANDED) {
Timber.d("State is expanded :D")
val shape = createShape(bottomSheet)
ViewCompat.setBackground(bottomSheet, shape)
}
package dev.forcetower.hilt.android.dynamic.processor.internal.dynamicentrypoint
import com.google.auto.common.MoreElements
import com.squareup.javapoet.ClassName
import com.squareup.javapoet.CodeBlock
import com.squareup.javapoet.FieldSpec
import com.squareup.javapoet.JavaFile
import com.squareup.javapoet.MethodSpec
import com.squareup.javapoet.ParameterizedTypeName
import com.squareup.javapoet.TypeName
package dev.forcetower.playtime.auth.hilt;
import javax.inject.Singleton;
import dagger.Binds;
import dagger.Component;
import dagger.Module;
import dagger.Subcomponent;
import dagger.hilt.android.components.ActivityComponent;
import dagger.hilt.android.components.ActivityRetainedComponent;
@ForceTower
ForceTower / BuildNode.kt
Created June 25, 2021 00:09
Navigation deep link emulation
fun NavDestination.buildExplicitly(): IntArray {
val hierarchy = ArrayDeque<NavDestination>()
var current: NavDestination? = this
do {
val parent = current!!.parent
if (parent == null || parent.startDestination != current.id) {
hierarchy.addFirst(current)
}
current = parent
} while (current != null)