Skip to content

Instantly share code, notes, and snippets.

View mannodermaus's full-sized avatar
🏠
Working from home

Marcel Schnelle mannodermaus

🏠
Working from home
View GitHub Profile
@mannodermaus
mannodermaus / build.gradle.kts
Last active January 28, 2018 02:14
Using android-junit5 with gradle/kotlin-dsl. https://github.com/mannodermaus/android-junit5
import de.mannodermaus.gradle.plugins.junit5.*
import org.junit.platform.console.options.Details
plugins {
// 1. Declare plugin
id("de.mannodermaus.android-junit5") version "1.0.30"
// More plugins here (Kotlin, Android)
}
@mannodermaus
mannodermaus / CompatTextView.java
Last active August 30, 2018 09:59
Custom TextView implementation to allow VectorDrawableCompat to work with compound Drawables
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.AppCompatDrawableManager;
import android.support.v7.widget.AppCompatTextView;
import android.util.AttributeSet;
@mannodermaus
mannodermaus / json-pretty.json
Created February 14, 2020 08:47
Effective Data Transfer with Protocol Buffers
{
"id": 100,
"title": "Efficient Data Transfer with Protocol Buffers",
"type": "blog",
"content": "In the highly-connected environment of IoT technology..."
}
@mannodermaus
mannodermaus / android-compliance-checker.sh
Last active May 20, 2020 14:03
Runs the JAPI Compliance Checker on two AAR files. (https://github.com/lvc/japi-compliance-checker)
#!/bin/sh
# Performs the JAPI compliance checker on two Android Archive files.
# https://github.com/lvc/japi-compliance-checker
AAR1="$1"
AAR2="$2"
function usage {
echo "Usage:"
@mannodermaus
mannodermaus / GsonCompatAdapter.kt
Last active July 28, 2020 10:37
For when you're transitioning from Gson to Moshi, but those pesky JsonObject references still linger everywhere.
import com.google.gson.Gson
import com.google.gson.JsonArray
import com.google.gson.JsonElement
import com.google.gson.JsonNull
import com.google.gson.JsonObject
import com.google.gson.JsonPrimitive
import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter
import com.squareup.moshi.Moshi
@mannodermaus
mannodermaus / LoganSquareConverter.java
Last active September 16, 2021 12:28
LoganSquare Retrofit Converter
package retrofit.converter;
import com.bluelinelabs.logansquare.LoganSquare;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.util.List;
import retrofit.converter.ConversionException;
import retrofit.converter.Converter;
@mannodermaus
mannodermaus / CustomSSLSocketFactory.java
Last active June 7, 2022 18:20
Android SSLSocketFactory for use with custom CA
package com.github.aurae.ssl;
import android.content.Context;
import android.support.annotation.RawRes;
import java.io.IOException;
import java.io.InputStream;
import java.security.KeyStore;
import java.security.SecureRandom;
import java.security.cert.Certificate;
@mannodermaus
mannodermaus / MyActivity.java
Created April 6, 2016 22:12
Apply custom background color to Android Notification
package com.github.aurae.notifications;
import android.app.Notification;
import android.os.Bundle;
import android.support.v4.app.NotificationManagerCompat;
import android.support.v7.app.AppCompatActivity;
public class MyActivity extends AppCompatActivity {
@Override protected void onCreate(Bundle savedInstanceState) {
@mannodermaus
mannodermaus / BaseAdapter.java
Last active June 14, 2023 14:24
RecyclerView.ViewHolder and Adapter demonstration
public abstract class BaseAdapter<T, VH extends BaseViewHolder<T>> extends RecyclerView.Adapter<VH> {
private List<T> items;
// Missing: setItems(), addItem(), removeItem(), ...
@Override
public final void onBindViewHolder(VH vh, int position) {
T item = items.get(position);
vh.performBind(item, position);