Giter Site home page Giter Site logo

presentation's People

Contributors

greysonp avatar stankocken avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

presentation's Issues

OnDestroy on a presenter should unsubscribe from ActivityLifeCycle

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...

Presenter not calling activity lifecycle methods

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;
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.