Skip to content

Instantly share code, notes, and snippets.

View Mercandj's full-sized avatar
😀
Working on Android Apps

Jonathan Mercandalli Mercandj

😀
Working on Android Apps
View GitHub Profile
@Mercandj
Mercandj / android_drawing_stylus_performance.md
Last active November 23, 2022 12:57
How to improve stylus performances on Android using AndroidX

Android drawing stylus performance

Goal, increase stylus performances on Android: mobile, tablet, Chromebooks...

AndroidX.graphics

Requirements: OpenGL architecture must let you draw "incrementally" (delta) or "fully"

Dependency

buildscript {
repositories {
jcenter()
}
dependencies {
classpath(kotlin("gradle-plugin", version = "1.6.21"))
}
}
allprojects {
package com.medium
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.material.Text
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

Android: Memory leak

Java and the JVM may leak objects.

Leaking an object on Java (or Kotlin) is done when a reference direct or indirect (via transitivity) is kept so that the Garbage Collector cannot release the memory.

What Meaning in this snippet
live Means, cannot be garbage collected
died Means, is garbage collected

Fail fast

One goal of mobile apps or any dev project, is to not have crash or wrong behavior.

I. Example and "safe" implementation

Imagine a car with a car.setAccelerationPercent(Float).

For example, the client using the car can

  • shut off the acceleration with car.setAccelerationPercent(0f)
@Mercandj
Mercandj / programmation_test.md
Last active March 11, 2022 08:10
[Dev] Tests from a Mobile Developer point of view

Tests from a Mobile Developer point of view

Hi 👋, I'm Jonathan, Android Lead at MWM. "You should write tests", that something we can hear on the mobile / tech industry. But the question is Why?. Let's find out if writing tests is something you should invest on.


"Be sure you test the tests written" 🙃. Romain Guy and Chet Haase.

Android developer: Principles

Description

Please, first, checkout Developer: Principles. These Android developer principles are the "implementation details" of developer principles on the Android world.

The following advices are very opinionated. Before saying "bullshit", please read the why below in the Details section. One of the main ability of developer is to understand the why. (This advice apply to myself of course. Every tool I'm criticising exist because of a why that I consider less important than the alternative. But for sure, you can disagree).

The goal of this document is more to start a reflection than make you think twice of your code.

Screen recorder - Android

  • Basic code to record screen on Android.
  • Record your app and other apps
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
    intent ?: return super.onStartCommand(intent, flags, startId)
    val extras = intent.extras
        ?: return super.onStartCommand(intent, flags, startId)

Manager: Principles

Imagine you are a tech manager, as a tech manager here some principles:

Principles

# 5 Principles
1 Promote your CTO principles about code
2 Lead by example
@Mercandj
Mercandj / android_image_folders.sh
Last active November 2, 2020 12:59
Derivation of images into Android drawable folders
#!/bin/sh
# GOAL
# Convert images png or jpg into Android drawable folder and convert into webp
# HOW TO USE IT
# · Setup: "brew install imagemagick" // https://formulae.brew.sh/formula/imagemagick
# · Place your images in the same folder of this script
# · Run the script