Git Product home page Git Product logo

Comments (3)

SpecialCyCi avatar SpecialCyCi commented on June 15, 2024

Hello, @csava . I have a simple solution to handle configuration changes. And I have pushed it to the dev branch.

1 For AndroidResideMenu, I added two overload methods. They provide a same parameter named withAnimations, you can open/close menu without animations by passing it false.

public void openMenu(int direction, boolean withAnimations);
public void closeMenu(boolean withAnimations);

2 For activity, I suggest to use onSaveInstanceState() to save the current opening state and direction of menu. Then, it will pass saved instance state to onCreate() after configurations changed.

    @Override
    protected void onSaveInstanceState(Bundle outState) {
        super.onSaveInstanceState(outState);
        if (resideMenu != null) {
            outState.putBoolean(MENU_STATE, resideMenu.isOpened());
            outState.putInt(MENU_DIRECTION, resideMenu.getCurrentDirection());
        }
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ....
        // Restore the menu state by savedInstanceState.
        if ( savedInstanceState != null && savedInstanceState.getBoolean(MENU_STATE) == true ) {
            resideMenu.openMenu(savedInstanceState.getInt(MENU_DIRECTION));
        }
   }

If it works, please comment on here and I will merge code into master. Thanks.

from androidresidemenu.

csava avatar csava commented on June 15, 2024

Hi ,

Thanks for your answer.

Your answer should work when the developer does not require manually handling of the configuration changes.

Unfortunately, my issue is that I need to manually handle the configuration changes by overriding
“onConfigurationChanged” and by putting in the manifest “android:configChanges="keyboard|keyboardHidden|orientation”.

I don't see this issue as a bug but would be a nice enhancement to have it. In many cases android force you to handle the configuration changes manually.

For this case I think residemenu needs an interface like "detachOnCfgChange()"
to be used like

@OverRide
public void onConfigurationChanged(Configuration newConfig)
{

ResideMenu.detachOnCfgChange()

super.onConfigurationChanged(newConfig);
setContentView(R.layout.main);

// Reinitialize the residemenu
setUpMenu();

}

On this call residemenu can do the clean up or others because the main view will be destroyed.

from androidresidemenu.

SpecialCyCi avatar SpecialCyCi commented on June 15, 2024

OK, thanks your idea!
I will find someway to implement it.

from androidresidemenu.

Related Issues (20)

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.