Source link: https://github.com/MaksTuev/ferro


Simple and powerful MVP library for Android

Ferro elegantly solves two age-old problems of Android Framework related to configuration changes:

  • restore screen's data
  • managing background tasks

First problem is solved using permanent presenter, second - using freezing rx events (Observable doesn't unsubscribe). Also new feature was added - Ferro can freeze rx event when screen becomes invisible, and defreeze it when screen goes to foreground.

The schematic work of ferro:

Ferro is divided into 3 layers, each of one adds behavior to the previous. So you can use only part of Ferro, if you want.

The first layer:


This library contains base classes for Activity and Fragment ( PSSActivity, PSSFragmentV4, PSS - persistent screen scope). For each activity and fragment, based on this classes, will be created PersistentScreenScope. You can get it by calling the method PSSActivity#getPersistentScreenScope or PSSFragmentV4#getPersistentScreenScope. This object isn't destroyed when configuration changed, it is only destroyed when screen is finally destroyed (e.g. after call Activity#finish()). You can add listener, which will be called when PersistentScreenScope destroyed. It has methods for storing and getting objects. In reality, PersistentScreenScope is actually a retained Fragment without view.

This mechanism is perfect for storing a presenter, that is done in the next extention:


This library contains base classes for view, presenter and screen component. For each screen you need to extend ScreenComponent, MvpPresenter and MvpActivityView or MvpFragmentV4View.

The ScreenComponent will be saved in PersistentScreenScope and reused when view recreated. In method ScreenComponent#inject(view) you need to insert presenter to the view. The easiest way to do it is to use dagger component as ScreenComponent. Due to this mechanism presenter is reused after configuration change.

Method MvpPresenter#onLoad(viewRecreated) will be called, when view is ready. Boolean parameter viewRecreated means that view is recreated after configuration change. You should show previously loaded data via this method, it data exists.

In MvpActivityView you should override method #onCreate() with parameter viewRecreated instead of default method #onCreate(). Same for MvpFragmentV4View and onActivityCreated method.

If you use Dagger, this library contains two scope annotations @PerApplication and @PerScreen. It also contains ActivityProvider and FragmentProvider, which can be used for getting access to Activity or Fragment inside objects, provided by Dagger screen component (e.g. inside Navigator class).

It's lifecycle of screen's objects:

The next extention adds freeze logic for Rx events:


Class MvpRxPesenter contains freeze logic, scematic work of which shown in gif above. This class should be extended instead of MvpPresenter.

If you subscribe to Observable via one of MvpRxPesenter#subscribe() methods, all rx events (onNext, onError, onComplete) would be frozen when view destroyed and unfrozen when view recreated. If option freezeEventOnPause is enabled (it is enabled by default), all Rx events would be also frozen when screen is paused and unfrozen when screen is resumed.

When screen is finally destroyed, all subscriptions would be automatically unsubscribed.


This library contains rx operators ( ObservableOperatorFreeze, MaybeOperatorFreeze, SingleOperatorFreeze, CompletableOperatorFreeze, FlowableOperatorFreeze for RxJava2 and OperatorFreeze for RxJava1), which contains freeze logic. To apply it, you should pass this operator in method Observable#lift().


Nobody likes to do the basic logic of the project dependent on third-party libraries. So, the Ferro is, generally speaking, set of simple ideas, and you can create you own base classes by using this ideas.


repositories {

dependencies {

 //for use the full ferro (still not support RxJava2)

 compile 'com.agna.ferro:ferro-mvp-rx:1.1.2'

 //for use the part of ferro

 compile 'com.agna.ferro:ferro-core:1.1.2'

 compile 'com.agna.ferro:ferro-mvp:1.1.2'

 compile 'com.agna.ferro:ferro-rx:1.0.2'

  //or if you use RxJava2

 compile 'com.agna.ferro:ferro-rx:2.0.0'


Copyright 2016 Maxim Tuev
  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

  Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 See the License for the specific language governing permissions and
 limitations under the License. 


Example app to use Protobuf in Android using Square's Wire library.

Espresso's consistency makes it really easy to learn.

Want to match a view with a specific id? Use withId(R.id.some_id). Need to match with a piece of text? Use withText(R.id.some_text) or withText("some text). Awesome, consistent and it's very clear what it is you are doing.


After a few hours writing test code you'll find your code being a little bit too verbose. Not anymore.

Why should you need to explicitly specify that you are matching with some text if you are passing in some text as a parameter? Some for the view id, you can already see that it is a view id.

Ristretto allows you to write the same test code as you already write, but less verbose.

Complete abstraction from the Spannable API. Forget about all the boiler plate code and all the Object what nonsense that you have to deal with when working with Spannable.

  • Eliminate setSpan calls by using all the provided methods trough the StyleEZ interface.
  • Chain multiple spans with a fluent style
  • By using both the ContentEZ and StyleEZ interface it removes unnecessary methods from the autocomplete form, and thus it removes clutter.
  • Allows different ways of adding content (String, String Resource and Formatted String)
  • By default it does INCLUSIVE_INCLUSIVE to all the spans
  • After calling any of the inclusive/exclusive methods, all the next methods will be using that flag until apply is called or another flag is used
  • You can create your own locator by extending the Locator interface

FadingTextView is a TextView that changes its content automatically every few seconds.

An example android application to set dynamic span size on GridLayoutManager, RecyclerView.

Android Library for custom views to control brightness , volume and seek through swipable gestures . These views could easily replace the conventional volume / brightness / seek controls that we have in music player ,video player or gallery apps.


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