- [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)
/* | |
* Copyright (C) 2007-2008 OpenIntents.org | |
* | |
* 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 |
class CommentAdapter(private val fragment: SGFragment) : RecyclerView.Adapter<CommentViewHolder>() { | |
private val mCustomList = ArrayList<Comment>() | |
private val mListener = object : ListUpdateCallback { | |
override fun onChanged(position: Int, count: Int, payload: Any?) { | |
notifyItemRangeChanged(paged(position), count, payload) | |
} | |
override fun onMoved(fromPosition: Int, toPosition: Int) { |
import android.util.Log; | |
import com.google.gson.GsonBuilder; | |
import com.google.gson.JsonParser; | |
import com.google.gson.JsonSyntaxException; | |
import okhttp3.logging.HttpLoggingInterceptor; | |
public class CustomHttpLogger implements HttpLoggingInterceptor.Logger { | |
@Override |
import android.content.Context; | |
import android.content.res.Resources; | |
import android.content.res.TypedArray; | |
import android.graphics.Canvas; | |
import android.graphics.Color; | |
import android.graphics.PorterDuff; | |
import android.graphics.Rect; | |
import android.graphics.drawable.Drawable; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.RecyclerView; |
Introduction
AppCompat is an Android support library to provide backwards-compatible functionality for Material design patterns. It currently comes bundled with a set of styles in the Theme.AppCompat
and Widget.AppCompat
namespaces. However, there is a critical component missing which I would have thought essential to provide the a default from which we could inherit our styles: Widget.AppCompat.Button
. Sure, there's Widget.AppCompat.Light.ActionButton
, but that doesn't actually inherit from Widget.ActionButton
, which does not inherit from Widget.Button
, so we might get some unexpected behavior using that as our base button style, mainly because Widget.ActionButton
strictly belongs in the ActionBar
.
So, if we want to have a decently normal default button style related to AppCompat, we need to make it ourselves. Let's start by digging into the Android SDK to see how it's doing default styles.
Digging In
import android.annotation.SuppressLint; | |
import android.app.Activity; | |
import android.content.Context; | |
import android.provider.Settings; | |
import android.view.inputmethod.InputMethodManager; | |
public class AppUtils { | |
public static void hideKeyboard(Activity context) { | |
try { |
import android.arch.lifecycle.MediatorLiveData; | |
import android.arch.lifecycle.MutableLiveData; | |
import android.arch.lifecycle.Observer; | |
import com.abhinav.basemvvmsample.data.model.FailureResponse; | |
import java.net.SocketTimeoutException; | |
import java.net.UnknownHostException; | |
import retrofit2.Call; |
import android.support.v7.widget.GridLayoutManager; | |
import android.support.v7.widget.LinearLayoutManager; | |
import android.support.v7.widget.RecyclerView; | |
import android.support.v7.widget.StaggeredGridLayoutManager; | |
public abstract class EndlessRecyclerVScrollListener extends RecyclerView.OnScrollListener { | |
// The minimum amount of items to have below your current scroll position | |
// before loading more. | |
private int visibleThreshold = 5; | |
// The current offset index of data you have loaded |
import android.graphics.BitmapFactory; | |
//Not thread safe | |
public class SizeFromImage implements ISize { | |
private String path; | |
private int width; | |
private int height; | |
public SizeFromImage(String path) { | |
this.path = path; |