use of com.hci.carebase.ui.fragments.AppointmentsFragment in project Carebase by robertsimoes.
the class MainActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
/**
* Set Toolbar
*/
Toolbar myToolbar = (Toolbar) findViewById(R.id.general_fragments_toolbar);
setSupportActionBar(myToolbar);
ILocalCache cache = new LocalCacheDb(this);
String userId = cache.getUserId();
boolean isFirstInstall = cache.isFirstInstall();
if (isFirstInstall) {
cache.setFirstInstall(false);
startActivity(new Intent(this, IntroActivity.class));
}
/* Get Patient Info */
src.getPatient(userId, new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
Toast.makeText(MainActivity.this, "Welcome Back!", Toast.LENGTH_SHORT).show();
Log.d("TAG", "SUCCESS \n\n\n\n ------");
Patient p = dataSnapshot.getValue(Patient.class);
fragmentArgs = new Bundle();
fragmentArgs.putSerializable(Const.BUNDLE_KEY_PATIENT, p);
BottomNavigationView bottomNavigationView = (BottomNavigationView) findViewById(R.id.main_bottom_navigation);
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch(item.getItemId()) {
case R.id.action_inbox:
invalidateOptionsMenu();
selectedFragment = InboxFragment.newInstance(fragmentArgs);
currentFragment = Frag.INBOX;
break;
case R.id.action_appointments:
invalidateOptionsMenu();
AppointmentsFragment f = AppointmentsFragment.newInstance(fragmentArgs);
f.setCallback(MainActivity.this);
selectedFragment = f;
currentFragment = Frag.APPOINTMENTS;
break;
case R.id.action_rx:
invalidateOptionsMenu();
selectedFragment = RxFragment.newInstance(fragmentArgs);
currentFragment = Frag.RX;
break;
case R.id.action_profile:
invalidateOptionsMenu();
selectedFragment = ProfileFragment.newInstance(fragmentArgs);
currentFragment = Frag.PROFILE_EDIT;
break;
}
refreshFragmentUI(selectedFragment);
return true;
}
});
// Before the application or user has picked anything to display
// Let's just display the inbox fragment by default so that when the app loads up
// we pick that.
}
@Override
public void onCancelled(DatabaseError databaseError) {
Log.e("ERR", "Could not load patient snapshot" + databaseError.getDetails());
}
});
}
Aggregations