All Projects → samiuelson → Preservely

samiuelson / Preservely

Licence: Apache-2.0 license
Lightweight Android lib preserving objects instances during orientation changes

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Preservely

Moxy
Moxy is MVP library for Android with incremental annotation processor and ktx features
Stars: ✭ 234 (+963.64%)
Mutual labels:  mvp, android-architecture, mvp-android
Android Kotlin Mvp Clean Architecture
Clean architecture blueprint using Kotlin and MVP pattern.
Stars: ✭ 105 (+377.27%)
Mutual labels:  mvp, android-architecture, mvp-android
Mvparms
⚔️ A common architecture for Android applications developing based on MVP, integrates many open source projects, to make your developing quicker and easier (一个整合了大量主流开源项目高度可配置化的 Android MVP 快速集成框架).
Stars: ✭ 10,146 (+46018.18%)
Mutual labels:  mvp, android-architecture, mvp-android
Android Mvp Architecture
🏛 A basic sample android application to understand MVP in a very simple way. Just clone, build, run and understand MVP.
Stars: ✭ 203 (+822.73%)
Mutual labels:  mvp, android-architecture, mvp-android
Karchi
Repository that showcases 3 different Android app architectures, all with Java and Kotlin versions: "Standard Android", MVP and MVVM. The exact same app is built 6 times following the different patterns.
Stars: ✭ 20 (-9.09%)
Mutual labels:  mvp, android-architecture, mvp-android
Prevailer-orientation-support-library-for-Android
Prevailer is a simple android library that helps in preserving object instances across orientation change in android and is JAVA 8 and MVP ready.
Stars: ✭ 17 (-22.73%)
Mutual labels:  mvp, loader, orientation-changes
Armscomponent
📦 A complete android componentization solution, powered by MVPArms (MVPArms 官方快速组件化方案).
Stars: ✭ 1,664 (+7463.64%)
Mutual labels:  mvp, android-architecture, mvp-android
Mvpart
🎨 A new Android MVP architecture (此框架旨在解决传统 MVP 类和接口太多, 并且 Presenter 和 View 通过接口通信过于繁琐, 重用 Presenter 代价太大等问题).
Stars: ✭ 776 (+3427.27%)
Mutual labels:  mvp, android-architecture, mvp-android
Flair
This is powerful android framework
Stars: ✭ 31 (+40.91%)
Mutual labels:  mvp, android-architecture, mvp-android
Android tmdb clean architecture
Showcase of clean architecture concepts along with Continuous Integration and Development for modular Android applications. Includes test suits (functional and unit tests) along with code coverage.
Stars: ✭ 63 (+186.36%)
Mutual labels:  mvp, android-architecture, mvp-android
Rxviper
Android micro framework for developing apps based on clean VIPER architecture.
Stars: ✭ 112 (+409.09%)
Mutual labels:  mvp, android-architecture
Android Architecture
🌇该项目结合 MVP 与 Clean 架构思想,探索在 Android 项目上的最佳实践。
Stars: ✭ 112 (+409.09%)
Mutual labels:  mvp, android-architecture
Android Tech Frontier
【停止维护】一个定期翻译国外Android优质的技术、开源库、软件架构设计、测试等文章的开源项目
Stars: ✭ 10,334 (+46872.73%)
Mutual labels:  mvp, android-architecture
Android Mvp Basic Sample
Android MVP Basic Sample
Stars: ✭ 140 (+536.36%)
Mutual labels:  mvp, mvp-android
Mvp Architecture Components
This is a sample project, showing the connection between Android Architecture Components and MVP pattern.
Stars: ✭ 143 (+550%)
Mutual labels:  mvp, android-architecture
Mvpframes
整合大量主流开源项目并且可高度配置化的 Android MVP 快速集成框架,支持 AndroidX
Stars: ✭ 100 (+354.55%)
Mutual labels:  mvp, mvp-android
Android Clean Architecture Boilerplate
Apply clean architecture on Android
Stars: ✭ 141 (+540.91%)
Mutual labels:  mvp, mvp-android
Kotlinmvparchitecture
Clean MVP Architecture with Dagger2 + Retrofit2 + Mockito + Fresco + EasiestGenericRecyclerAdapter using Kotlin. Added Unit Tests(Kotlin Tests)!
Stars: ✭ 143 (+550%)
Mutual labels:  mvp, mvp-android
Android Spotify Mvp
Android Sample to explain Model View Presenter in android applications.
Stars: ✭ 184 (+736.36%)
Mutual labels:  mvp, android-architecture
Androidbasemvp
🚀一个快速搭建MVP+RxJava2+Retrofit 基础框架,主要是封装有Http网络请求、日志、缓存、加载等待、toast、页面状态布局管理、权限、RxBus、Glide图片加载等组件,方便快速开发新项目、减少开发成本。
Stars: ✭ 184 (+736.36%)
Mutual labels:  mvp, mvp-android

Preservely

Android library allowing to preserve instance of any object across orientation changes.

Note that the library should be considered depreceated now because Google deprecated Loaders API in favour to using ViewModel class instead. You can read more here: https://developer.android.com/guide/components/loaders.

Android Arsenal

Specs

  • Lightweight (5kB jar)
  • Clear & Flexible API (Using composition instead of forcing inheritance)
  • Java 8 ready...
Preserver.init(this, 23,
                (PreservedInstanceFactory<MyTypeToBePreserved>) () -> new MyTypeToBePreserved(),
                (Preserver.OnInstanceReloadedAction<MyTypeToBePreserved>) instance -> {
                    // do sth when instance is reloaded
                },
                (Preserver.OnInstanceDestroyedAction) () -> {
                    // do sth when instance is destroyed
                }
);

Usage

  • Add the JitPack repository to your build file:
	allprojects {
		repositories {
			// ...
			maven { url "https://jitpack.io" }
		}
	}
  • Add the dependency
	dependencies {
	        compile 'com.github.samiuelson:Preservely:0.0.4'
	}
  • In your Activity / Fragment onCreate call
Preserver.init(
		this, // activity instance
		23, // id of loader used
		new PreservedInstanceFactory<MyTypeToBePreserved>() { // factory for the instance that should be preserved
		    @Override
		    public MyTypeToBePreserved create() {
		        return new MyTypeToBePreserved();
		    }
		},
		new Preserver.OnInstanceReloadedAction<MyTypeToBePreserved>() {
		    @Override
		    public void performAction(MyTypeToBePreserved instance) {
		        // do sth when instance is reloaded
		    }
		},
		new Preserver.OnInstanceDestroyedAction() {
		    @Override
		    public void performAction() {
		        // do sth when instance is destroyed
		    }
		}
);

Purpose

The aim of Preservely lib creation is to provide simple and robust cache for presenters' instances in MVP architecture. In MVP approach, there often is a need to keep presenter instance from being destroyed during activity orientation change. You can check out the sample project to see how it's working in action.

The magic

Preservely uses Android Loader API under the hood. On Android platform, Loaders framework provides API for asynchronous data loading in Activity or Fragment. However, Loaders has special property of preserving instance of the handled object when it's reloaded. Preservely benefits from that to provide simple way of caching (preserving) instances of objects that mustn't be destroyed during orientation changes. Preserved instances are destroyed when the activity holding them is abandoned and no longer used.

License

Copyright Samuel Urbanowicz   

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.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].