stankocken / presentation Goto Github PK
View Code? Open in Web Editor NEWAn architecture for Android as a replacement of MVC.
An architecture for Android as a replacement of MVC.
If I use this lib on an Activity that switch presenter, (e.g an Activity with drawerLayout) I can't unsubscribe from ActivityLifeCycle.
If I use this code
private void goToMenu(int id) {
mActualMenuId = id;
replaceView();
replacePresenter(newPresenter());
}
private void replacePresenter(BasePresenter presenter) {
BasePresenter actualPresenter = getPresenter();
if (actualPresenter != null) {
actualPresenter.onPause();
actualPresenter.onStop();
actualPresenter.onDestroy();
}
setPresenter(presenter);
if (presenter != null) {
presenter.onCreate(null);
presenter.onStart();
presenter.onResume();
}
}
private void replaceView() {
if (mDrawerLayout.getChildCount() == 2) {
mDrawerLayout.removeViewAt(0);
}
int viewId = getViewId();
if (viewId != 0) {
View view = LayoutInflater.from(this).inflate(viewId, mDrawerLayout, false);
mDrawerLayout.addView(view, 0);
}
}
And then start a new Activity, when I close the new activity all presenter already shown will be onResumed. Even if it's not present on the screen and if it's view is remove from layout.
One solution to achieve that is to add a method isDestroyed
in com.skocken.presentation.util.ActivityLifeCycleListener
and a mDestroyed member in BaseProvider
class
com.skocken.presentation.util.ActivityLifecycleCallbackDelegate
will become:
@Override
public void onActivityResumed(Activity activity) {
if (!isForMe(activity) || mListener == null) {
return;
}
ActivityLifeCycleListener listener = mListener.get();
if (listener != null && !listener.isDestroyed()) {
listener.onResume();
}
}
And so on...
In my presenter, I don't receive call on onResume
, onPause
โฆ
This is due to the getActivity()
of BasePresenter
which is not working for ContextWrapper
context.
The fix is to replace getActivity()
from BasePresenter
to:
public Activity getActivity() {
Context context = getContext();
if (context instanceof ContextWrapper) {
context = ((ContextWrapper) context).getBaseContext();
}
if (context instanceof Activity) {
return (Activity) context;
} else {
return null;
}
}
https://github.com/EfficientAdapter/ yields 404
Its an amazing architecture but it make one class to five, I see the activity do nothing, Can I merge the activity and the viewProxy?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.