use of james.alarmio.fragments.StopwatchFragment 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