
com.arellomobile.mvp.PresenterStore Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of moxy Show documentation
Show all versions of moxy Show documentation
Arello-Mobile MVP library for Android
package com.arellomobile.mvp;
import java.util.HashMap;
import java.util.Map;
import android.util.Log;
/**
* Date: 17-Dec-15
* Time: 16:05
*
* @author Yuri Shmakov
* @author Alexander Blinov
*/
@SuppressWarnings("WeakerAccess")
public class PresenterStore {
private Map mPresenters = new HashMap<>();
/**
* Add presenter to storage
*
* @param tag Tag of presenter. Local presenters contains also delegate's tag as prefix
* @param instance Instance of MvpPresenter implementation to store
* @param Type of presenter
*/
public void add(String tag, T instance) {
mPresenters.put(tag, instance);
}
/**
* Get presenter on existing params
*
* @param tag Tag of presenter. Local presenters contains also delegate's tag as prefix
* @return Presenter if it's exists. Null otherwise (if it's no exists)
*/
public MvpPresenter get(String tag) {
return mPresenters.get(tag);
}
/**
* Remove presenter from store.
*
* @param tag Tag of presenter. Local presenters contains also delegate's tag as prefix
* @return Presenter which was removed
*/
public MvpPresenter remove(String tag) {
return mPresenters.remove(tag);
}
public void logPresenters() {
for (Map.Entry currentEntry : mPresenters.entrySet()) {
Log.d("PresenterStore", currentEntry.getKey() + " -> " +
currentEntry.getValue());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy