@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home: case R.id.home: FragUtils.popFragmentViewDelayed(getSupportFragmentManager()); return true; case R.id.account: StaticUtils.launchLoginEditor(this); return true; case R.id.help: StaticUtils.launchHelp(this); return true; case R.id.reset: StaticUtils.wipeData(this); return true; case R.id.resync: StaticUtils.requestSync(this, m_handler); return true; case R.id.settings: StaticUtils.launchPreferencesEditor(this); return true; case R.id.about: AboutActivity.showAbout(this); return true; default: return super.onOptionsItemSelected(item); } }
@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Log.v( TAG, getClass().getSimpleName() + ".onCreate (" + hashCode() + "): " + (savedInstanceState != null)); ApiCompatUtil compatUtil = ApiCompatUtil.getInstance(); compatUtil.requestWindowFeatures(this); setContentView(R.layout.prime); compatUtil.setWindowFeatures(this); compatUtil.setupActionBar(this); int curTab = DEFAULT_TAB; if (savedInstanceState != null) { Bundle fragData = savedInstanceState.getBundle("fragData"); if (fragData != null) { Log.d(TAG, "MainActivity.onCreate: got fragData!"); for (String key : fragData.keySet()) { Log.d(TAG, " fragData key: " + key); if (!m_fragData.containsKey(key)) m_fragData.putBundle(key, fragData.getBundle(key)); } } curTab = savedInstanceState.getInt(PrefKey.opentab.name(), DEFAULT_TAB); } boolean upgraded = false; if (savedInstanceState != null) { // setCurrentTab(savedInstanceState.getInt(PrefKey.opentab.name(), -1)); } else { Resources resources = getResources(); SharedPreferences p = StaticUtils.getApplicationPreferences(this); upgraded = StaticUtils.checkUpgrade(this); if (!readInstanceState(this)) setInitialState(); if (PrefKey.sync_on_open.getBoolean(p, resources)) { WeaveAccountInfo loginInfo = StaticUtils.getLoginInfo(this); if (upgraded || loginInfo == null) { StaticUtils.requestSync(this, m_handler); } } } FragmentManager fm = getSupportFragmentManager(); // You can find Fragments just like you would with a View by using FragmentManager. Fragment fragment = fm.findFragmentById(R.id.fragment_content); // If we are using activity_fragment_xml.xml then this the fragment will not be null, otherwise // it will be. if (fragment == null) { setMyFragment(new MiscListFragment(), false); } }