本文整理匯總了Java中nucleus.factory.PresenterStorage類的典型用法代碼示例。如果您正苦於以下問題:Java PresenterStorage類的具體用法?Java PresenterStorage怎麽用?Java PresenterStorage使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
PresenterStorage類屬於nucleus.factory包,在下文中一共展示了PresenterStorage類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getPresenter
import nucleus.factory.PresenterStorage; //導入依賴的package包/類
/**
* {@link ViewWithPresenter#getPresenter()}
*/
@SuppressWarnings("all")
public P getPresenter() {
if (presenterFactory != null && presenter == null) {
if (bundle != null)
presenter = PresenterStorage.INSTANCE.getPresenter(bundle.getString(PRESENTER_ID_KEY));
if (presenter == null) {
presenter = presenterFactory.createPresenter();
// 添加到PresenterStorage中,已添加OnDestroyListener,當銷毀時從Storage內移除,注意調用就是了
PresenterStorage.INSTANCE.add(presenter);
presenter.create(bundle == null ? null : bundle.getBundle(PRESENTER_KEY));
}else{
presenter.restore();
}
bundle = null;
}
return presenter;
}
示例2: onSaveInstanceState
import nucleus.factory.PresenterStorage; //導入依賴的package包/類
/**
* {@link android.app.Activity#onSaveInstanceState(Bundle)}, {@link android.app.Fragment#onSaveInstanceState(Bundle)}, {@link android.view.View#onSaveInstanceState()}.
*/
public Bundle onSaveInstanceState() {
Bundle bundle = new Bundle();
getPresenter();
// 有可能不需要presenter
if (presenter != null) {
// 保存presenter內需要保存的值
Bundle presenterBundle = new Bundle();
presenter.save(presenterBundle);
bundle.putBundle(PRESENTER_KEY, presenterBundle);
// 保存presenter在storage的key
bundle.putString(PRESENTER_ID_KEY, PresenterStorage.INSTANCE.getId(presenter));
}
return bundle;
}
示例3: getPresenter
import nucleus.factory.PresenterStorage; //導入依賴的package包/類
/**
* {@link ViewWithPresenter#getPresenter()}
*/
public P getPresenter() {
if (presenterFactory != null) {
if (presenter == null && bundle != null)
presenter = PresenterStorage.INSTANCE.getPresenter(bundle.getString(PRESENTER_ID_KEY));
if (presenter == null) {
presenter = presenterFactory.createPresenter();
PresenterStorage.INSTANCE.add(presenter);
presenter.create(bundle == null ? null : bundle.getBundle(PRESENTER_KEY));
}
bundle = null;
}
return presenter;
}
示例4: onSaveInstanceState
import nucleus.factory.PresenterStorage; //導入依賴的package包/類
/**
* {@link android.app.Activity#onSaveInstanceState(Bundle)}, {@link android.app.Fragment#onSaveInstanceState(Bundle)}, {@link android.view.View#onSaveInstanceState()}.
*/
public Bundle onSaveInstanceState() {
Bundle bundle = new Bundle();
getPresenter();
if (presenter != null) {
Bundle presenterBundle = new Bundle();
presenter.save(presenterBundle);
bundle.putBundle(PRESENTER_KEY, presenterBundle);
bundle.putString(PRESENTER_ID_KEY, PresenterStorage.INSTANCE.getId(presenter));
}
return bundle;
}