Skip to content

Instantly share code, notes, and snippets.

@robUx4
Created August 12, 2015 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robUx4/79a214234561c52aace5 to your computer and use it in GitHub Desktop.
Save robUx4/79a214234561c52aace5 to your computer and use it in GitHub Desktop.
Android rotation detection
@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