Skip to content

Instantly share code, notes, and snippets.

@mobiRic
mobiRic / CountingLiveData.java
Created August 17, 2020 08:51
LiveData class that counts how many times it has delivered updated values to Observers.
/*
* Copyright (C) 2020 Glowworm Software
*
* 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
@mobiRic
mobiRic / CrashLog.java
Created September 5, 2018 07:51
Basic wrapper for Crashlytics
package mobi.glowworm.lib.utils.debug;
import android.content.Context;
import android.support.annotation.NonNull;
import com.crashlytics.android.Crashlytics;
import io.fabric.sdk.android.Fabric;
/**
@mobiRic
mobiRic / Composition
Last active June 15, 2018 17:24
Some thoughts and sample code I have put together to try and explain concepts during the Google Africa ALC v2.0 Udacity course.
Here's the followup, which is called *composition*. This pattern is favoured in React Native and Flutter, and seems to be gaining popularity. Instead of extending from one class, we wrap one class in another. Some people say it is much better - I leave that up to the team to read up on.
Here I'm going to have an immutable `message` in some `HandWriting`. Anyone can look at the message by calling `HandWriting.readMe()` which is my fun example of a "getter" type method. We could rename it to `getMessage()` if you really want.
I also have a `Letter` that I'm writing to a friend.
It doesn't really make sense to `extend HandWriting` because a letter is a slightly different concept to the writing inside it.
But the `Letter` does contain some writing. Also has a friend's name that we are sending it to.
Of course, to say that you are reading the Letter, also means you are reading the HandWriting on the letter, right? So the "getter" on the Letter should call into the getter on the HandWriting.
@mobiRic
mobiRic / SimpleTextWatcher
Last active June 1, 2018 08:47
A simple concrete implementation of the TextWatcher interface that provides no-op implementations of required methods.
/*
* Copyright (C) 2018 Glowworm Software
*
* 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 distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
This is a collection of gradle tricks for the app's 'build.gradle' file.
@mobiRic
mobiRic / CircleImageView.java
Created January 29, 2018 12:21
Yet another circle ImageView for Android
/*
* Copyright (C) 2018 Glowworm Software
*
* 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 distributed under the License
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
@mobiRic
mobiRic / DelayFilter.java
Created October 5, 2016 15:17
This is a direct copy of the {@link android.widget.Filter} class from API 23, with the hidden delay functionality made available.
/*
* Copyright (C) 2007 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
@mobiRic
mobiRic / DummyContent.java
Last active September 16, 2016 11:04
Timeline Adapter
package mobi.glowworm.demo.timeline.dummy;
import android.support.annotation.Nullable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import mobi.glowworm.demo.timeline.TimelineItem;
@mobiRic
mobiRic / DividerItemDecoration.java
Created March 14, 2016 12:53 — forked from zokipirlo/DividerItemDecoration.java
DividerItemDecoration. RecyclerView.ItemDecoration simple implementation
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
@mobiRic
mobiRic / MyCrypto.java
Last active October 12, 2015 09:28 — forked from upsuper/LICENSE
A Java implementation of SHA-224 message digest algorithm with Provider
/*
* Copyright (c) 2012 Xidorn Quan
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* <p/>