Skip to content

Instantly share code, notes, and snippets.

View mohanmanu484's full-sized avatar

Mohan mohanmanu484

  • Banglore
View GitHub Profile
@marcelpinto
marcelpinto / ApiManager.java
Last active May 18, 2018 13:41
Cache RxJava observables on Android approach to reuse and avoid multiple calls.
private ObservableManager obsManager = new ObservableManager(EventBus.getDefault());
@Override
public Subscription getStores() {
// Get the observable if exists and is not too old
Observable<StoresList> observable = obsManager.get(ObservableManager.Types.STORES);
if (observable == null) {
// If is null create it and us cache to keep it in memeroy
observable = api.getStoresList()
.compose(applySchedulers(api.getStoresList()))
@mohanmanu484
mohanmanu484 / GenericAdapter.kt
Created December 13, 2017 07:41
Generic adapter with kotlin
abstract class GenericAdapter<T> : RecyclerView.Adapter<RecyclerView.ViewHolder> {
var listItems: List<T>
constructor(listItems: List<T>) {
this.listItems = listItems
}
constructor() {