Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Marcel Schnelle mannodermaus

🏠
Working from home
View GitHub Profile
@mannodermaus
mannodermaus / GsonCompatAdapter.kt
Last active Jul 28, 2020
For when you're transitioning from Gson to Moshi, but those pesky JsonObject references still linger everywhere.
View GsonCompatAdapter.kt
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
View android-compliance-checker.sh
#!/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 / json-pretty.json
Created Feb 14, 2020
Effective Data Transfer with Protocol Buffers
View json-pretty.json
{
"id": 100,
"title": "Efficient Data Transfer with Protocol Buffers",
"type": "blog",
"content": "In the highly-connected environment of IoT technology..."
}
View build.gradle.kts
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 Aug 30, 2018
Custom TextView implementation to allow VectorDrawableCompat to work with compound Drawables
View CompatTextView.java
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 / MyActivity.java
Created Apr 6, 2016
Apply custom background color to Android Notification
View MyActivity.java
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 / CustomSSLSocketFactory.java
Last active Sep 19, 2018
Android SSLSocketFactory for use with custom CA
View CustomSSLSocketFactory.java
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 / BaseAdapter.java
Last active Jul 18, 2017
RecyclerView.ViewHolder and Adapter demonstration
View BaseAdapter.java
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);
@mannodermaus
mannodermaus / LoganSquareConverter.java
Last active Nov 14, 2018
LoganSquare Retrofit Converter
View LoganSquareConverter.java
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;