@Override public void onResume() { super.onResume(); System.out.println("Mainactivity onresume"); if (DatabaseController.isLoggedIn()) { notifications.clear(); notifications.addAll(masterController.getUserDB().getChangeList().getChangedNotifications()); adapter.notifyDataSetChanged(); System.out.println("Mainactivity onresume ADAPTERUPDATE: " + notifications.toString()); // Safety Catch-All DatabaseController.save(); } }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); masterController = new MasterController(); if (masterController.getDatabaseController() == null) masterController.initializeController(); // TODO HACK StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(policy); if (DatabaseController.isLoggedIn()) { setContentView(R.layout.activity_main); recentActivities = (ListView) findViewById(R.id.activitiesList); notifications = new ArrayList<Notification>(); adapter = new RecentActivityAdapter(this, notifications); recentActivities.setAdapter(adapter); } else { setContentView(R.layout.first_time_user); // first_time (login) newUserName = (EditText) findViewById(R.id.usernameField); newUserEmail = (EditText) findViewById(R.id.emailField); makeNewUser = (Button) findViewById(R.id.beginApp); } // Checks internet connectivity every second on separate thread Thread thread = new Thread( new Runnable() { @Override public void run() { while (true) { connected = isConnected(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } }); thread.start(); }