- [Data Structures] (https://gist.github.com/lawloretienne/6f7d7d92f72986f5ebd60f226d9044ee#data-structures)
- [Linked Lists] (https://gist.github.com/lawloretienne/6f7d7d92f72986f5ebd60f226d9044ee#linked-lists)
- [Trees] (https://gist.github.com/lawloretienne/6f7d7d92f72986f5ebd60f226d9044ee#trees)
- [Binary Trees] (https://gist.github.com/lawloretienne/6f7d7d92f72986f5ebd60f226d9044ee#binary-trees)
- [Binary Search Tree] (https://gist.github.com/lawloretienne/6f7d7d92f72986f5ebd60f226d9044ee#binary-search-tree)
- [Red-Black Tree] (https://gist.github.com/lawloretienne/6f7d7d92f72986f5ebd60f226d9044ee#red-black-tree)
- [AVL Tree] (https://gist.github.com/lawloretienne/6f7d7d92f72986f5ebd60f226d9044ee#avl-tree)
- [Tries] (https://gist.github.com/lawloretienne/6f7d7d92f72986f5ebd60f226d9044ee#tries)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@NonNull private static Action1<Throwable> handleError(@NonNull final Context context, | |
final boolean isExpected, int stackLevel) { | |
final StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); | |
final StackTraceElement stackTraceElement = stackTrace[stackLevel]; | |
final String identifyingString = | |
String.format(Locale.getDefault(), "%s : %s (%d)", stackTraceElement.getClassName(), | |
stackTraceElement.getMethodName(), stackTraceElement.getLineNumber()); | |
return new Action1<Throwable>() { | |
@Override public void call(Throwable throwable) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Utility class for fonts manipulations. | |
*/ | |
public final class FontFaceUtils { | |
public static final LruCache<String, Typeface> sCache = new LruCache<>(6); | |
private FontFaceUtils() { | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Utils for I/O operations. | |
* <p/> | |
* Created by Tomek on 09/06/15. | |
*/ | |
public class IoUtils { | |
/** | |
* Reads file and returns a String. | |
* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onDraw(Canvas canvas) { | |
super.onDraw(canvas); | |
mPaint.setStyle(Paint.Style.STROKE); | |
mPaint.setStrokeWidth(50); | |
// Setting the color of the circle | |
mPaint.setColor(Color.BLUE); | |
// Draw the circle at (x,y) with radius 250 |
New projects should follow the Android Gradle project structure that is defined on the Android Gradle plugin user guide. The ribot Boilerplate project is a good reference to start from.
Class names are written in UpperCamelCase.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Copyright (C) 2016 Jeff Gilfelt. | |
* | |
* 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.text.SpannableStringBuilder; | |
import java.util.ArrayDeque; | |
import java.util.Deque; | |
import static android.text.Spanned.SPAN_INCLUSIVE_EXCLUSIVE; | |
/** A {@link SpannableStringBuilder} wrapper whose API doesn't make me want to stab my eyes out. */ | |
public class Truss { | |
private final SpannableStringBuilder builder; | |
private final Deque<Span> stack; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import android.content.Context; | |
import com.squareup.okhttp.internal.io.FileSystem; | |
import java.io.File; | |
import java.io.IOException; | |
import java.io.InputStream; | |
import okio.BufferedSource; | |
import okio.Okio; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Returns response cached by OkHttp. | |
* | |
* @param url URL used to make original request | |
*/ | |
@Nullable | |
private List<PostModel> getCachedDataIfExist(final String url) { | |
// OkHttpClient saves cache using DiskLruCache, the cached data is stored in the cache dir in the files | |
// which names are created by md5 hash function, e.g. for | |
// http://www.yourserver.com/posts?filter[posts_per_page]=10&page=1 |