(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
| def toCamelCase(String string) { | |
| String result = "" | |
| string.findAll("[^\\W]+") { String word -> | |
| result += word.capitalize() | |
| } | |
| return result | |
| } | |
| afterEvaluate { project -> | |
| Configuration runtimeConfiguration = project.configurations.getByName('compile') |
| /* put this in your application's build.gradle after the android {} block | |
| * output is in this format: "<projectName>-<buildType>-v<versionName>-<versionCode>.apk" | |
| * e.g. "materiyolo-debug-v5.0.0-12345.apk" | |
| * also, supports injecting jenkins ci's build number into apk, if available | |
| * e.g. "materiyolo-debug-v5.0.0-12345-b6789.apk" | |
| * you must specify your versionName and versionCode in your build.gradle for this to work | |
| * see: http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Manifest-entries */ | |
| // change this to whatever your app's name is... | |
| project.archivesBaseName = 'materiyolo' |
| <!-- You can change the parent around to whatever you normally use --> | |
| <style name="DebugColors" parent="Theme.AppCompat"> | |
| <!-- System colors --> | |
| <item name="android:windowBackground">@color/__debugWindowBackground</item> | |
| <item name="android:colorPressedHighlight">#FF4400</item> | |
| <item name="android:colorLongPressedHighlight">#FF0044</item> | |
| <item name="android:colorFocusedHighlight">#44FF00</item> | |
| <item name="android:colorActivatedHighlight">#00FF44</item> |
| Unless specified otherwise, all of the below tinting applies to both Lollipop and pre-Lollipop using AppCompat v21. To use the support version of these attributes, remove the android namespace. For instance, "android:colorControlNormal" becomes "colorControlNormal". These attributes will be propagated to their corresponding attributes within the android namespace for devices running Lollipop. Any exceptions to this will be noted by including the "android:" prefix. | |
| All Clickable Views: | |
| ----------- | |
| * ripple effect (Lollipop only) -- "colorControlHighlight" | |
| Status Bar: | |
| ------------ | |
| * background (Lollipop only) - "colorPrimaryDark" |
| import android.graphics.Color; | |
| import android.os.Bundle; | |
| import android.support.annotation.Nullable; | |
| import android.support.v4.app.Fragment; | |
| import android.view.LayoutInflater; | |
| import android.view.View; | |
| import android.view.ViewGroup; | |
| import android.view.ViewTreeObserver; | |
| import android.view.animation.AccelerateInterpolator; |
| public class MyFragment { | |
| boolean loaded; | |
| private void maybeLoad() { | |
| if (!loaded && getUserVisibleHint()) { | |
| loaded = true; | |
| loadMyData(); | |
| } | |
| } | |
| @Override |
| // Dagger 1 example | |
| @Module( | |
| complete = false, | |
| library = true | |
| ) | |
| public final class ApiModule { | |
| @Provides | |
| @Singleton | |
| Retrofit provideRetrofit(Gson gson, Application app) { | |
| return new Retrofit.Builder() |
| /** | |
| * 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 |
| import android.animation.Animator; | |
| import android.animation.TimeInterpolator; | |
| import android.annotation.TargetApi; | |
| import android.graphics.Color; | |
| import android.os.Build; | |
| import android.support.annotation.NonNull; | |
| import android.util.Log; | |
| import android.view.MotionEvent; | |
| import android.view.View; | |
| import android.view.ViewAnimationUtils; |