Skip to content

Instantly share code, notes, and snippets.

View chizoba's full-sized avatar

Chizoba Ogbonna chizoba

View GitHub Profile
@chizoba
chizoba / question.txt
Last active April 10, 2020 07:44
Technical(Android) Question Format
- [ ] Summary of your question in a sentence or two.
- [ ] Detailed explanation:
[ ] Provide context i.e. what are you building and what functionality are you trying to achieve?
[ ] Your current approach. (that is probably not working or you feel can be optimised)
- [ ] Your code snippets.
- [ ] Screenshots, if any. (optional)
- [ ] Link to your entire codebase. (optional)
@chizoba
chizoba / proguard-rules.pro
Created June 20, 2019 20:58 — forked from nisrulz/proguard-rules.pro
Android : Proguard Rules for a Library Module
#
# This ProGuard configuration file illustrates how to process a program
# library, such that it remains usable as a library.
# Usage:
# java -jar proguard.jar @library.pro
#
# Save the obfuscation mapping to a file, so we can de-obfuscate any stack
# traces later on. Keep a fixed source file attribute and all line number
# tables to get line numbers in the stack traces.
@chizoba
chizoba / EndlessRecyclerOnScrollListener.java
Created February 23, 2019 17:31 — forked from ssinss/EndlessRecyclerOnScrollListener.java
Endless RecyclerView OnScrollListener
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
public abstract class EndlessRecyclerOnScrollListener extends RecyclerView.OnScrollListener {
public static String TAG = EndlessRecyclerOnScrollListener.class.getSimpleName();
private int previousTotal = 0; // The total number of items in the dataset after the last load
private boolean loading = true; // True if we are still waiting for the last set of data to load.
private int visibleThreshold = 5; // The minimum amount of items to have below your current scroll position before loading more.
int firstVisibleItem, visibleItemCount, totalItemCount;
@chizoba
chizoba / PULL_REQUEST_TEMPLATE
Created February 3, 2019 14:58 — forked from riggaroo/PULL_REQUEST_TEMPLATE
Pull request template format. Add this file to your .github folder
<!--- Provide a general summary of your changes in the Title above -->
<!--- If there is no changelog entry, label this PR as trivial to bypass the Danger warning -->
## Description
<!--- Describe your changes in detail -->
## Motivation and Context
<!--- Why is this change required? What problem does it solve? -->
@chizoba
chizoba / AndroidManifest.xml
Last active February 2, 2019 11:28
Having multiple APKs on a single device - SnippetB
<application
...
android:label="${app_name}"
...>
</application>
@chizoba
chizoba / build.gradle
Last active February 2, 2019 11:28
Having multiple APKs on a single device - SnippetA
defaultConfig {
applicationId "com.github.chizoba"
}
buildTypes {
release {
...
}
staging {
@chizoba
chizoba / HashTable.java
Created December 12, 2018 21:44 — forked from amadamala/HashTable.java
HashTable implementation in Java
public class HashTable {
private static int INITIAL_SIZE = 16;
private HashEntry[] entries = new HashEntry[INITIAL_SIZE];
public void put(String key, String value) {
int hash = getHash(key);
final HashEntry hashEntry = new HashEntry(key, value);
if(entries[hash] == null) {
entries[hash] = hashEntry;
}
// If there is already an entry at current hash
@chizoba
chizoba / LICENSE
Created November 12, 2018 14:47 — forked from nickbutcher/LICENSE
Fun with gradients and AnimatedVectorDrawables. Illustration by the wonderful https://twitter.com/VPoltrack
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
@chizoba
chizoba / MainActivity.kt
Created August 6, 2018 08:24
Kobserver's onException() implementation
GitHubRequest(name).doRequest().observe(this, object : Kobserver<ResponseModel>() {
override fun onException(exception: Exception) {
// handle exception here
when(exception){
is GitHubErrorHandler.ErrorConfig.NetworkException -> {
Toast.makeText(this@MainActivity, exception.message, Toast.LENGTH_LONG).show()
}
is GitHubErrorHandler.ErrorConfig.GitHubException -> {
Toast.makeText(this@MainActivity, exception.message, Toast.LENGTH_LONG).show()
}
@chizoba
chizoba / MainActivity.kt
Created August 6, 2018 08:17
Ketro's Kobserver class using to observe changes to your LiveData
GitHubRequest(name).doRequest().observe(this, object : Kobserver<ResponseModel>() {
override fun onException(exception: Exception) {
// handle exception here
}
override fun onSuccess(data: ResponseModel) {
// update UI
}
})