Android Open Source - CriminalIntent Single Fragment Activity






From Project

Back to project page CriminalIntent.

License

The source code is released under:

MIT License

If you think the Android project CriminalIntent listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.ambergleam.criminalintent.helper;
/*  w w w . j av  a 2s  . c  o m*/
import com.ambergleam.criminalintent.R;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;

public abstract class SingleFragmentActivity extends FragmentActivity {

  protected abstract Fragment createFragment();
  
  protected int getLayoutResId() {
    return R.layout.activity_fragment;
  }
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(getLayoutResId());
    FragmentManager fm = getSupportFragmentManager();
    Fragment fragment = fm.findFragmentById(R.id.fragmentContainer);

    if (fragment == null) {
      fragment = createFragment();
      fm.beginTransaction().add(R.id.fragmentContainer, fragment).commit();
    }
  }

}




Java Source Code List

com.ambergleam.criminalintent.controller.CrimeFragment.java
com.ambergleam.criminalintent.controller.CrimeListActivity.java
com.ambergleam.criminalintent.controller.CrimeListFragment.java
com.ambergleam.criminalintent.controller.CrimePagerActivity.java
com.ambergleam.criminalintent.controller.DatePickerFragment.java
com.ambergleam.criminalintent.helper.CriminalIntentJSONSerializer.java
com.ambergleam.criminalintent.helper.SingleFragmentActivity.java
com.ambergleam.criminalintent.model.CrimeLab.java
com.ambergleam.criminalintent.model.Crime.java