Skip to content

Instantly share code, notes, and snippets.

View axiel7's full-sized avatar
🐢
Take your time

Axel axiel7

🐢
Take your time
View GitHub Profile
@axiel7
axiel7 / build.gradle.kt
Created January 4, 2024 00:28
Enable compose metricts and reports
kotlinOptions {
freeCompilerArgs += listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + project.buildDir.absolutePath + "/compose_metrics")
freeCompilerArgs += listOf(
"-P",
"plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + project.buildDir.absolutePath + "/compose_metrics")
}
@axiel7
axiel7 / Navigation.kt
Last active November 5, 2023 13:07
Simple Compose Navigation Wrapper
import androidx.navigation.NavBackStackEntry
import androidx.navigation.NavType
import androidx.navigation.navArgument
enum class ArgumentType {
String, Int, Boolean, BooleanOptional;
fun toNavType() = when (this) {
String -> NavType.StringType
Int -> NavType.IntType
@axiel7
axiel7 / ComposeView.kt
Last active October 15, 2023 01:41
Compose View Android Studio code template
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}
#end
#parse("File Header.java")
import androidx.compose.runtime.Composable
import androidx.compose.ui.tooling.preview.Preview
@Composable
fun ${NAME}() {
}
@axiel7
axiel7 / TopAppBarWithContent.kt
Last active May 27, 2023 03:31
Custom implementation of Material3 TopAppBar with custom content
import androidx.compose.animation.animateColorAsState
import androidx.compose.animation.core.FastOutLinearInEasing
import androidx.compose.animation.core.Spring
import androidx.compose.animation.core.spring
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.windowInsetsPadding
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
@axiel7
axiel7 / KtorClient.kt
Last active August 12, 2021 07:55
Ktor HttpClient for Android
import android.util.Log
import io.ktor.client.*
import io.ktor.client.engine.okhttp.*
import io.ktor.client.features.logging.*
import java.util.concurrent.TimeUnit
object KtorClient {
private const val TIME_OUT = 60_000L
val ktorHttpClient = HttpClient(OkHttp) {
@axiel7
axiel7 / BaseAdapter.kt
Last active February 3, 2023 12:47
Android BaseAdapter for RecyclerView with ViewBinding
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import androidx.viewbinding.ViewBinding
abstract class BaseAdapter<VB: ViewBinding, T> : RecyclerView.Adapter<BaseAdapter<VB, T>.ViewHolder>() {
protected abstract val bindingInflater: (LayoutInflater, ViewGroup?, Boolean) -> VB
protected var _list: List<T>? = listOf()
@axiel7
axiel7 / BaseFragment.kt
Last active February 3, 2023 12:48
Android BaseFragment with ViewBinding
import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.viewbinding.ViewBinding
abstract class BaseFragment<VB: ViewBinding> : Fragment() {
@axiel7
axiel7 / BaseActivity.kt
Last active February 3, 2023 12:48
Android BaseActivity with ViewBinding
import android.os.Bundle
import android.view.LayoutInflater
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.WindowCompat
import androidx.viewbinding.ViewBinding
abstract class BaseActivity<VB: ViewBinding> : AppCompatActivity() {
private var _binding: VB? = null
protected val binding get() = _binding!!

Keybase proof

I hereby claim:

  • I am axiel7 on github.
  • I am axiel7 (https://keybase.io/axiel7) on keybase.
  • I have a public key ASBE5Stz91-O0s5vU7DSLtH-yh1mZv5-Fd9ssKloCiTEIAo

To claim this, I am signing this object: