Exemplo n.º 1
0
  @Override
  public void onBackPressed() {
    boolean handled = false;
    try {
      FragmentManager fm = getSupportFragmentManager();
      Fragment frag = fm.findFragmentById(R.id.fragment_content);
      if (!(frag instanceof FragUtils.BackPressedHandler)) {
        Log.d(TAG, "frag type was: " + (frag == null ? "null" : frag.getClass().getSimpleName()));
        return;
      }

      if (!frag.isVisible()) {
        Log.d(TAG, "frag was not visible!");
        return;
      }

      handled = ((FragUtils.BackPressedHandler) frag).handleBackPressed();
      //      Log.w(TAG, "handleBackPressed returned: " + handled);
    } catch (Exception e) {
      Log.e(TAG, "Could not check onBackPressed", e);
    } finally {
      if (!handled) {
        super.onBackPressed();
      }
    }
  }
Exemplo n.º 2
0
  @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);
    }
  }
Exemplo n.º 3
0
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   Log.v(TAG, getClass().getSimpleName() + ".onSaveInstanceState (" + hashCode() + ")");
   super.onSaveInstanceState(outState);
   outState.putInt(PrefKey.opentab.name(), getCurrentTab());
   outState.putBundle("fragData", m_fragData);
 }
Exemplo n.º 4
0
  @Override
  protected void onRestoreInstanceState(Bundle savedInstanceState) {
    Log.v(
        TAG,
        getClass().getSimpleName()
            + ".onRestoreInstanceState ("
            + hashCode()
            + "): "
            + (savedInstanceState != null));
    super.onRestoreInstanceState(savedInstanceState);
    if (savedInstanceState == null) return;

    Bundle fragData = savedInstanceState.getBundle("fragData");
    if (fragData != null) {
      for (String key : fragData.keySet()) {
        if (!m_fragData.containsKey(key)) m_fragData.putBundle(key, fragData.getBundle(key));
      }
    }
    int curTab = savedInstanceState.getInt(PrefKey.opentab.name(), -1);
    if (curTab != getCurrentTab()) {
      setCurrentTab(curTab);
    }
  }
Exemplo n.º 5
0
 public MainActivity() {
   Log.v(TAG, getClass().getSimpleName() + ".<init> (" + hashCode() + ")");
 }
Exemplo n.º 6
0
 @Override
 public void onPause() {
   Log.v(TAG, getClass().getSimpleName() + ".onPause (" + hashCode() + ")");
   saveData();
   super.onPause();
 }
Exemplo n.º 7
0
 @Override
 protected void onResume() {
   Log.v(TAG, getClass().getSimpleName() + ".onResume (" + hashCode() + ")");
   super.onResume();
 }