Skip to content

Instantly share code, notes, and snippets.

View petitJAM's full-sized avatar
🤖
beep boop Androids

Alex Petitjean petitJAM

🤖
beep boop Androids
View GitHub Profile
@tfcporciuncula
tfcporciuncula / 1 - ci.yml
Last active June 11, 2024 11:06
Keeping a project dependency graph on the README up to date automatically by always generating it on CI with a GitHub Action
generate-dependency-graph:
name: Generate Dependency Graph
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Setup Graphviz
uses: ts-graphviz/setup-graphviz@v1
@discord-gists
discord-gists / CustomPanelGestureDetection.kt
Last active March 2, 2022 19:16
a simplified code example for how Discord's Android app supports custom panel gesture detection
class OverlappingPanelsLayout : FrameLayout {
private var scrollingSlopPx: Float = 0f
private var velocityTracker: VelocityTracker? = null
private var isScrollingHorizontally = false
private var xFromInterceptActionDown: Float = 0f
private var yFromInterceptActionDown: Float = 0f
... // initialize scrollingSlopPx and VelocityTracker
@patrickdappollonio
patrickdappollonio / install-tmux-ubuntu.sh
Last active July 24, 2021 08:54
Install tmux 3 from source in Ubuntu
#!/usr/bin/env bash
sudo apt update && sudo apt install -y git automake build-essential pkg-config libevent-dev libncurses5-dev byacc bison
rm -fr /tmp/tmux
git clone https://github.com/tmux/tmux.git /tmp/tmux
cd /tmp/tmux
git checkout 3.0
sh autogen.sh
./configure && make
sudo make install
@dlew
dlew / script.sh
Created November 9, 2018 16:36
Simple AndroidX Migration Script
#!/usr/bin/env bash
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very
# well, so I wrote my own script to do the simple job of converting package names.
#
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv
#
# It'll run faster on a clean build because then there are fewer files to scan over.
#
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`.
@NickHolcombe
NickHolcombe / ListAdapterWithHeader.kt
Last active October 18, 2023 00:16
Example of a RecyclerView Adapter based on ListAdapter with a header
package example
import android.support.v7.recyclerview.extensions.AsyncDifferConfig
import android.support.v7.recyclerview.extensions.AsyncListDiffer
import android.support.v7.util.DiffUtil
import android.support.v7.util.ListUpdateCallback
import android.support.v7.widget.RecyclerView
/**
* {@link RecyclerView.Adapter RecyclerView.Adapter} base class based on
@florina-muntenescu
florina-muntenescu / BaseDao.kt
Last active October 11, 2024 01:20
Use Dao inheritance to reduce the amount of boilerplate code - https://medium.com/google-developers/7-pro-tips-for-room-fbadea4bfbd1
/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@rharter
rharter / SharedPreferenceLiveData.kt
Last active March 19, 2023 08:15
Creates LiveData objects that observe a value in SharedPreferences while they have active listeners.
import android.arch.lifecycle.LiveData
import android.content.SharedPreferences
abstract class SharedPreferenceLiveData<T>(val sharedPrefs: SharedPreferences,
val key: String,
val defValue: T) : LiveData<T>() {
private val preferenceChangeListener = SharedPreferences.OnSharedPreferenceChangeListener { sharedPreferences, key ->
if (key == this.key) {
value = getValueFromPreferences(key, defValue)
@diegopacheco
diegopacheco / publish-maven-central-repo-sonatype.md
Last active December 11, 2021 00:57
How to publish a JAR into Sonatype Maven Central REPO?

How to publish a jar into Sonatype central repo

Order of Operations

  1. Create gpg key
  2. Export gpg key
  3. Publish gpg key to ubuntu server
  4. Create account at Sonatype JIRA
  5. Configure $HOME/.gradle/settings.gradle user and pass and keys settings
  6. Configure gradle plugins
@extralam
extralam / URLImageParser.java
Created April 12, 2017 02:53
URLImageParser - TextView show Image html , use Glide Image Library
import java.util.ArrayList;
import com.bumptech.glide.GenericRequestBuilder;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.animation.GlideAnimation;
import com.bumptech.glide.request.target.SimpleTarget;
import com.bumptech.glide.request.target.Target;
import android.content.Context;