roomorama / Caldroid

A better calendar for Android
Other
1.42k stars 531 forks source link

CaldroidFragment.SQUARE_TEXT_VIEW_CELL not saved in rotation #367

Closed luizfp closed 8 years ago

luizfp commented 8 years ago

I'm using caldroid in my app and using the method to save fragments state on rotation:

if (caldroidFragment != null) {
    caldroidFragment.saveStatesToKey(outState, CALDROID_STATE);
}

...

if (savedInstanceState != null) {
    caldroidFragment.restoreStatesFromKey(savedInstanceState, CALDROID_STATE);
}

The problem is that in the first time that I create a fragment, I use this:

args.putBoolean(CaldroidFragment.SQUARE_TEXT_VIEW_CELL, false);

But, this configuration is not saved in rotation.

If the user came back to portrait mode after go to landscape, the CaldroidFragment.SQUARE_TEXT_VIEW_CELL is not 'false' anymore. And because of that the calendar now has wrong height.

If I save the fragment state manually and set the CaldroidFragment.SQUARE_TEXT_VIEW_CELL to false again the problem is solved, but, it would be better if it were done in the method: caldroidFragment.saveStatesToKey(outState, CALDROID_STATE);

My workaround is this:

if (caldroidFragment != null) {
    outState.putInt(CaldroidFragment.MONTH, caldroidFragment.getMonth());
    outState.putInt(CaldroidFragment.YEAR, caldroidFragment.getYear());
}

...

if (savedInstanceState != null) {
    savedInstanceState.putBoolean(CaldroidFragment.SQUARE_TEXT_VIEW_CELL, false);
    caldroidFragment.setArguments(savedInstanceState);
}
thomasdao commented 8 years ago

@luizfp thanks for reporting this bug. You can try Caldroid 3.0.1 which I fixed this issue properly

luizfp commented 8 years ago

I tested and its working properly. Thanks!