Skip to content

Instantly share code, notes, and snippets.

@mobiRic
mobiRic / Subtitle Text-To-Speech demo.java
Last active September 14, 2023 11:30
Android Text-To-Speech demo showing how to display subtitles as the words are being spoken.
/**
* Author : James Elsey Date : 26/Feb/2011 Title : TextToSpeechDemo URL :
* Http://www.JamesElsey.co.uk
*
* Adapted by Richard Le Mesurier from original code by James Elsey at
* https://github.com/jameselsey/TextToSpeechDemo.
*
* As referenced on Stack Overflow answer by Richard Le Mesurier at
* http://stackoverflow.com/a/23792562/383414
*
@mobiRic
mobiRic / EmptyRecyclerView.java
Last active April 25, 2023 18:35 — forked from henningta/EmptyRecyclerView.java
RecyclerView doesn't have an emptyView support, we gotta fix that
/*
* Copyright (C) 2015 Glowworm Software
* Copyright (C) 2014 Nizamutdinov Adel
*
* 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
*
@mobiRic
mobiRic / Boast.java
Last active January 25, 2022 07:23
Android Toast replacement allowing cancellation
/*
* Copyright (C) 2012 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 / 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 / Dbug.java
Last active September 13, 2018 06:37
Debug logging class that enables ProGuard to remove all logging artifacts from the code
/*
* Copyright (C) 2011 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 / 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;
/**
This is a collection of gradle tricks for the app's 'build.gradle' file.
@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
@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