package com.stylepoints.habittracker.viewmodel.CentralHubActivity;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import com.stylepoints.habittracker.R;
import com.stylepoints.habittracker.repository.DatabaseInitUtil;
import com.stylepoints.habittracker.repository.local.AppDatabase;
import com.stylepoints.habittracker.viewmodel.HabitEventRelatedActivites.EventsMainActivity;
import com.stylepoints.habittracker.viewmodel.HabitRelatedActivities.HabitsMainActivity;


public class MainActivity extends AppCompatActivity {
    private AppDatabase db;

    Button habitButton;
    Button eventButton;
    Button profileButton;
    Button socialButton;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


        AppDatabase db = AppDatabase.getAppDatabase(getApplicationContext());
        // for now, initialize database with a couple of test entries
        DatabaseInitUtil.initializeDbWithTestData(db);

        setupButtons();
    }

    private void setupButtons() {
        habitButton = (Button) findViewById(R.id.habitsMenuButton);
        eventButton = (Button) findViewById(R.id.eventsMenuButton);
        profileButton = (Button) findViewById(R.id.profileMenuButton);
        socialButton = (Button) findViewById(R.id.socialMenuButton);

        eventButton.setOnClickListener(new Button.OnClickListener(){
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, EventsMainActivity.class);
                startActivity(intent);
            }
        });

        habitButton.setOnClickListener(new Button.OnClickListener(){
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(MainActivity.this, HabitsMainActivity.class);
                startActivity(intent);
            }
        });
    }
}

@@ -61,16 +61,56 @@
 ivity;%0A%0A
+import android.arch.lifecycle.LiveData;%0A
 import a
@@ -255,22 +255,90 @@
 .widget.
-Button
+ArrayAdapter;%0Aimport android.widget.Button;%0Aimport android.widget.ListView
 ;%0A%0Aimpor
@@ -436,16 +436,80 @@
 itUtil;%0A
+import com.stylepoints.habittracker.repository.HabitRepository;%0A
 import c
@@ -566,16 +566,89 @@
 tabase;%0A
+import com.stylepoints.habittracker.repository.local.entity.HabitEntity;%0A
 import c
@@ -728,24 +728,90 @@
 inActivity;%0A
+import com.stylepoints.habittracker.viewmodel.HabitListViewModel;%0A
 import com.s
@@ -888,16 +888,40 @@
 ivity;%0A%0A
+import java.util.List;%0A%0A
 %0Apublic 
@@ -1096,16 +1096,126 @@
 utton;%0A%0A
+    ListView listView;%0A%0A    private LiveData%3CList%3CHabitEntity%3E%3E habitList;%0A    private HabitRepository repo;%0A%0A
     @Ove
@@ -1587,64 +1587,799 @@
     
-setupButtons();%0A    %7D%0A%0A    private void setupButtons() %7B
+repo = HabitRepository.getInstance(db);%0A        habitList = repo.loadAll();%0A%0A        bindToUi();%0A        subscribeToModel();%0A    %7D%0A%0A    private void subscribeToModel() %7B%0A        habitList.observe(this, habitList -%3E %7B%0A            if (habitList == null) %7B return; %7D%0A            // TODO: do this a better way%0A            for (HabitEntity habit : habitList) %7B%0A                if (!habit.isActiveToday()) %7B%0A                    habitList.remove(habit);%0A                %7D%0A            %7D%0A%0A            ArrayAdapter%3CHabitEntity%3E adapter = new ArrayAdapter%3CHabitEntity%3E(%0A                    this, android.R.layout.simple_list_item_1, habitList);%0A            listView.setAdapter(adapter);%0A        %7D);%0A    %7D%0A%0A    private void bindToUi() %7B%0A        listView = (ListView) findViewById(R.id.todaysHabitsList);
 %0A   

add list of habits that are scheduled for today on main page