Created
August 12, 2015 08:34
-
-
Save robUx4/79a214234561c52aace5 to your computer and use it in GitHub Desktop.
Android rotation detection
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void onConfigurationChanged(Configuration newConfig) { | |
super.onConfigurationChanged(newConfig); | |
//TouiteurLog.e(false, "onConfigurationChanged"); | |
int newOrientation = newConfig.orientation; | |
if (mOrientation != newOrientation) { | |
mOrientation = newOrientation; | |
if (false && Touiteur.isTablet()) { | |
// TODO: store whatever state we need | |
boolean layoutRedone = false; | |
mAdapterLock.lock(); | |
try { | |
if (null != mViewPager && null != mColumnAdapter) { | |
// save the state of the old adapter | |
int currentPage = mViewPager.getCurrentItem(); | |
Bundle savedColumns = mColumnAdapter.saveColumnData(); | |
//Parcelable savedData = mViewPager.onSaveInstanceState(); | |
//Parcelable state = mColumnAdapter.saveState(); | |
redoLayout(null); | |
layoutRedone = true; | |
// restore the state on the new adapter | |
//mColumnAdapter.restoreState(state, getClassLoader()); | |
//mViewPager.onRestoreInstanceState(savedData); | |
mColumnAdapter.restoreColumnData(savedColumns); | |
mViewPager.setCurrentItem(currentPage); | |
mColumnAdapter.setInUse(isStarted && isAtFront()); | |
} | |
} finally { | |
mAdapterLock.unlock(); | |
} | |
if (layoutRedone){ | |
onStreamConnectionChanged(); | |
supportInvalidateOptionsMenu(); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment