Commit cceb98ea authored by Geoffrey Métais's avatar Geoffrey Métais

Save current framgment ID on rotation

parent b52a16e2
......@@ -214,6 +214,12 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
mSidebarAdapter = new SidebarAdapter(this);
mListView.setAdapter(mSidebarAdapter);
if (savedInstanceState != null){
mCurrentFragment = savedInstanceState.getString("current");
if (mCurrentFragment != null)
mSidebarAdapter.setCurrentFragment(mCurrentFragment);
}
/* Initialize UI variables */
mInfoLayout = v_main.findViewById(R.id.info_layout);
......@@ -365,6 +371,11 @@ public class MainActivity extends ActionBarActivity implements OnItemClickListen
mFocusedPrior = 0;
}
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString("current", mCurrentFragment);
}
@Override
protected void onDestroy() {
super.onDestroy();
......
......@@ -35,6 +35,7 @@ import android.content.Context;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
......@@ -131,7 +132,7 @@ public class SidebarAdapter extends BaseAdapter {
textView.setCompoundDrawables(img, null, null, null);
}
// Set in bold the current item.
if (mCurrentFragmentId.equals(sidebarEntry.id))
if (TextUtils.equals(mCurrentFragmentId,sidebarEntry.id))
textView.setTypeface(null, Typeface.BOLD);
else
textView.setTypeface(null, Typeface.NORMAL);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment