@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_history_base); GoalTrackerApplication.INSTANCE.setCurrentActivity(this); setupWindowAnimations(); mFirebaseRef = new Firebase(GoalTrackerApplication.FIREBASE_URL) .child("accounts") .child(Util.currentUser.getId()); setUpNotificationCountWithFirebaseListener(); spinner = (Spinner) findViewById(R.id.spinnerSelectBase); spinner.setAdapter(new BaseActivitySelectorAdapter(this, R.layout.layout_spinner_dropdown)); spinner.setOnItemSelectedListener(this); ListView listOfHistory = (ListView) findViewById(R.id.listOfHistory); historyListAdapter = new HistoryListAdapter( mFirebaseRef.child("history").orderByChild("sort"), this, R.layout.layout_history_row); listOfHistory.setAdapter(historyListAdapter); // A little indication of connection status mConnectedListener = mFirebaseRef .getRoot() .child(".info/connected") .addValueEventListener( new ValueEventListener() { @Override public void onDataChange(DataSnapshot dataSnapshot) { boolean connected = (Boolean) dataSnapshot.getValue(); if (!connected) { ToastDisplayer.displayHint( "Could not connect to Database", ToastType.FAILURE, getApplicationContext()); } } @Override public void onCancelled(FirebaseError firebaseError) {} }); }
@Override protected void onResume() { super.onResume(); GoalTrackerApplication.INSTANCE.registerReceiver(); }