SimpleDroidRx


Source link: https://github.com/PhilippeBoisney/SimpleDroidRx

[![Android Arsenal]( https://img.shields.io/badge/Android%20Arsenal-SimpleDroidRx-green.svg?style=true)](https://android-arsenal.com/details/3/3998) # SimpleDroidRx An application that helps you learn and understand better ReactiveX on Android.

Introduction

I've created this project because, as everyone knows, learn ReactiveX from scratch is a tremendous challenge, and it has a pretty steep learning curve. So I tried to bring together all the samples I found useful to appreciate ReactiveX and how to use it on an Android app.

How does it works ?

With SimpleDroidRx app, you have several fragments. Each one contains some examples of ReactiveX. Each example is performed using those Rx libraries :

  • RxJava : RxJava is a Java VM implementation of Reactive Extensions: a library for composing asynchronous and event-based programs by using observable sequences.
  • RxAndroid : Android specific bindings for RxJava.
  • RxBroadcast : Reactive Broadcast and LocalBroadcast for Android.
  • RxBinding : RxJava binding APIs for Android UI widgets from the platform and support libraries.

It also uses these massive libraries:

  • ButterKnife : Bind Android views and callbacks to fields and methods.
  • Retrofit :A type-safe HTTP client for Android and Java
  • Dagger2 : Dagger is a fully static, compile-time dependency injection framework for both Java and Android. It is an adaptation of an earlier version created by Square and now maintained by Google.

Mini Screenshots

Demo

You can test this app with appetize: https://appetize.io/app/g57uqpd3m4nn8w45v0r8awfq9w

List of Samples

Each sample is on a fragment and set up in the navigation drawer. It's sorted by level of complexity (from top to bottom). Also, on each sample, an explanatory TextView is here to briefly explain what's happening:

  • Hello World : In this fragment, you'll learn how to use an Observable and Observer. Also, you'll create your first stream and use your first operator : map( ).

Explanation: When you click on the button "Map( ) my words", you'll subscribe to an observable on TextView Text. The relative stream (myStream) replaces the words "Massive View Controller" by "MVVM", "Hell Callback" by "ReactiveX" and "AsyncTask" by "RxJava". Finally it adds at the end of TextView "<3 <3 <3".

  • Famous Operator : In this fragment, you'll learn the most commons operators and will get used to them : flatMap( ), filter( ), take( ), doOnNext( )

Explanation: When you click on "Play Happy !" or use the SeekBar, you'll subscribe to an observable on a string array. The relative stream (myStream) observes each item of string array, and apply to it some functions (setSmileyToItem, setCarriotReturnToItem & filterVersionAndroidThatSucks). It also takes only the number of item set by take( ).Finally, each item is shown in the TextView.

  • Error Handling : In this fragment, you'll learn how to handle error properly. You'll use map( ) and onError ().

Explanation: When you press button, you'll subscribe to an observable to relative TextView text. The relative stream (myStreamThatHandleError) executes a function that will test String. If it contains "callback" AND "hell" then it will throw an error.

  • Background Tasks : In this fragment, you'll learn how to run one and multiple tasks in the background.

Explanation: When you press the simple "SIMPLE TASK" button, you'll subscribe to an observable that execute a single task running in background (During 4sec) and stop. When you press the "DOUBLE TASKS" button, you'll subscribe to another one observable that executes a first long task to the background (During 8sec) and when over, a second single task will start (During 4 sec).

  • Android Simple Sample : In this fragment, you'll learn how to set an observer to a button using RxView.clicks( ), and intercept network changes.

Explanation: When you start fragment, you subscribe to an observable on a network changes. When you disable Wifi or mobile connection, you'll get notified by a Snackbar. When you press the "SHOW" button, it subscribes to an observable. It will show a Snackbar.

  • Android REST Sample With Dagger2 : In this fragment, you'll learn how to make multiple http requests with only single stream. Also, you will learn how to use RxJava with Dagger2 injection.

Explanation: When you press "REFRESH" button, it will subscribe to an observable that gets Github followers of each person you've defined (In a String array), and after processing of requests, update the TextView.

Contribute

It will be awesome if you contribute to this project adding your own sample(s). Just follow this checklist :

  • 1 Create a Fragment and name it with the name of your sample. Put it on "Fragments" package. Also, create it's layout. You could use the other fragment as a model.

- 2 Add your fragment in MainActivity on "displayView" function.

- 3 Add the title of your sample in string.xml on related array (nav_drawer_labels)

- 4 You can also modify the icon menu of your sample in NavigationDrawerAdapter on "getRessource" function.

- 5 Update this README.md with your own infos. - 6 Make a pull request !

License

Copyright (C) 2016 Philippe Boisney  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 or implied. See the License for the specific language governing permissions and limitations under the License. 

Resources

SlideDayTimePicker is an Android library that displays a single DialogFragment in which the user can select a day of week and a time. The user can swipe between the day picker and time picker, and the tab underline will gradually animate as the user swipes. The colors of the tab indicator and divider lines are customizable to fit your project's theme.

Routable is an in-app native URL router, for Android.

AndroidTwitter is a small android library to let you connect to Twitter and access all it's public API (tweet status, retweet, etc).

AutoCompleteBubbleText allows you to add and remove items from an EditText using a drawable as a background.

The benefit of AutoCompleteBubbleText is that you can position the ListView anywhere in the layout instead of just under the EditText. You can also use the autocomplete filtering function of the EditText to filter items in the list.

Gradle plugin to use Android AAR libraries on Eclipse.

You can manage dependencies with Gradle and build app on Eclipse.

subsampling-scale-image-view is a custom image views for Android, designed for photo galleries and displaying huge images (e.g. maps and building plans) without OutOfMemoryErrors. Includes pinch to zoom, panning, rotation and animation support, and allows easy extension so you can add your own overlays and touch event detection.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes