Fragnums


Source link: https://github.com/pyricau/fragnums

Fragnums

An enum based library to replace fragments, because #perfmatters.

“Frag your app complexity today!” - Zach K.

We all know that Fragments suck, and that #enumsmatter. What if we could replace Fragments with Enums?

What's Fragnums?

Fragnums is the smallest, simplest and most performant Android backstack library:

  • No reflection, unlike Fragments which are recreated through reflection.
  • Each enum value is both a screen and a presenter. This means only one instance of each value is created, ever. No useless garbage collection!
  • Synchronous transitions coz ain't nobody got time for Async Fragment Transactions.
  • Handles configuration changes, for all the landscape nut lovers out there.

Show me the code

Creating a new screen is as simple as adding an enum value:

  MY_SCREEN(R.layout.my_screen_layout, R.string.my_screen_title) {

  @Override protected void onBind() {

 View button = findViewById(R.id.button);

 button.setOnClickListener(new View.OnClickListener() {

@Override public void onClick(View view) {

  // Do something.

}

 
}
);

  
}

}
,

Then you can just do goTo(MY_SCREEN).

Getting started

  • Copy the three classes from the example.
  • You're good to go! You can now focus on writing new screens and features, just by adding new enum values.

Why should I use Fragnums?

  • Ultra small footprint: no dependency. In fact, it's not even a library, just three classes to copy.
  • It's really hard to test, so test zealots can't force you to write tests. You can therefore focus on writing more features.
  • All your business logic is in one place, so it's really easy to have a 30,000 feet picture of your code. We suggest you start using a smaller font size in your IDE.

How does it work?

Is this serious?

No. The core principles are good, but this is a satire library. Read the code and see for yourself.

More details

  • The suggestion that we should stop using enums because #perfmatters is a fallacy. An enum is essentially a class. Every new class makes our binary a bit bigger and our runtime a bit slower. Should we stop using classes? Or should we instead focus on the perf problems that actually matter?
  • This library shows how to implement a very basic backstack. You don't need enums for that, you could have a Screen class instead.
  • It's cool to know that one could make an enum centric app. However just because you can, doesn't mean you should.
  • If you're into trolling at conferences, you can get the #enumsmatter T-Shirt here. I am not affiliated with this T-Shirt campaign.

Resources

Library for securing your SharedPreferences information.

Android dex file extractor,anti-bangcle.

Sharedsqlite is a simple thread-safe database with a single table with a key-value schema where you can save your primitive data types that suites nowhere else excluding the headache of messing around with committing and reading from the SharedPreferences.

A sample of the new percent support library.

SerializableParcelableGeneratorPlugin for IntelliJ IDEA & Android Studio to generator SerializableParcelable code.

MaterialDialogBottomSheet is a custom dialog implementation to use BottomSheet MaterialView feature of Lollipop in older versions

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