use of james.alarmio.fragments.HomeFragment in project Alarmio by TheAndroidMaster.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
alarmio = (Alarmio) getApplicationContext();
alarmio.setListener(this);
if (savedInstanceState == null) {
fragment = new SplashFragment();
getSupportFragmentManager().beginTransaction().add(R.id.fragment, fragment).commit();
} else {
if (fragment == null)
fragment = new HomeFragment();
getSupportFragmentManager().beginTransaction().replace(R.id.fragment, fragment).commit();
}
getSupportFragmentManager().addOnBackStackChangedListener(this);
}
use of james.alarmio.fragments.HomeFragment in project Alarmio by TheAndroidMaster.
the class MainActivity method onNewIntent.
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
if (intent.hasExtra(EXTRA_FRAGMENT)) {
boolean shouldBackStack = fragment instanceof HomeFragment;
int fragmentId = intent.getIntExtra(EXTRA_FRAGMENT, -1);
if (fragmentId == FRAGMENT_TIMER && intent.hasExtra(TimerReceiver.EXTRA_TIMER_ID)) {
int id = intent.getIntExtra(TimerReceiver.EXTRA_TIMER_ID, 0);
if (alarmio.getTimers().size() <= id || id < 0)
return;
Bundle args = new Bundle();
args.putParcelable(TimerFragment.EXTRA_TIMER, alarmio.getTimers().get(id));
fragment = new TimerFragment();
fragment.setArguments(args);
} else if (fragmentId == FRAGMENT_STOPWATCH) {
if (fragment instanceof StopwatchFragment)
return;
fragment = new StopwatchFragment();
} else
return;
FragmentTransaction transaction = getSupportFragmentManager().beginTransaction().setCustomAnimations(R.anim.slide_in_up_sheet, R.anim.slide_out_up_sheet, R.anim.slide_in_down_sheet, R.anim.slide_out_down_sheet).replace(R.id.fragment, fragment);
if (shouldBackStack)
transaction.addToBackStack(null);
transaction.commit();
}
}
Aggregations