diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 912e668..ec38812 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -10,7 +10,7 @@ android:supportsRtl="true" android:theme="@style/AppTheme"> diff --git a/app/src/main/java/fr/plnech/lifelogger/HomeActivity.kt b/app/src/main/java/fr/plnech/lifelogger/ui/HomeActivity.kt similarity index 63% rename from app/src/main/java/fr/plnech/lifelogger/HomeActivity.kt rename to app/src/main/java/fr/plnech/lifelogger/ui/HomeActivity.kt index 4c0de40..3e42709 100644 --- a/app/src/main/java/fr/plnech/lifelogger/HomeActivity.kt +++ b/app/src/main/java/fr/plnech/lifelogger/ui/HomeActivity.kt @@ -1,15 +1,22 @@ -package fr.plnech.lifelogger +package fr.plnech.lifelogger.ui import android.os.Bundle import android.support.design.widget.Snackbar import android.support.v7.app.AppCompatActivity import android.view.Menu import android.view.MenuItem - +import fr.plnech.lifelogger.R +import fr.plnech.lifelogger.model.DataPoint +import fr.plnech.lifelogger.model.Log +import fr.plnech.lifelogger.model.LogAdapter import kotlinx.android.synthetic.main.activity_home.* +import kotlinx.android.synthetic.main.content_home.* class HomeActivity : AppCompatActivity() { + + private lateinit var adapter: LogAdapter + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_home) @@ -19,6 +26,16 @@ class HomeActivity : AppCompatActivity() { Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) .setAction("Action", null).show() } + + adapter = LogAdapter(this, generateDebugData()) + list?.adapter = adapter + adapter.notifyDataSetChanged() + +// val model = ViewModelProviders.of(this).get(LogViewModel::class.java) +// model.logs.observe(this, Observer { +// +// }) + } override fun onCreateOptionsMenu(menu: Menu): Boolean { @@ -36,4 +53,28 @@ class HomeActivity : AppCompatActivity() { else -> super.onOptionsItemSelected(item) } } + + private fun generateDebugData(): ArrayList { + var logs : ArrayList = ArrayList() + val stairs = Log("Stairway to heaven") + stairs.addPoint(DataPoint("stairs", 7)) + stairs.addPoint(DataPoint("lift")) + stairs.addPoint(DataPoint("stairs", 4)) + stairs.addPoint(DataPoint("stairs", 4)) + stairs.addPoint(DataPoint("lift")) + + val moods = Log("MoodBoard") + moods.addPoint(DataPoint("happy")) + moods.addPoint(DataPoint("focused")) + moods.addPoint(DataPoint("relax")) + + val mind = Log("MindBoard") + mind.addPoint(DataPoint("HeadSpace", 10)) + mind.addPoint(DataPoint("HeadSpace", 5)) + + logs.add(stairs) + logs.add(moods) + logs.add(mind) + return logs + } } diff --git a/app/src/main/res/layout/activity_home.xml b/app/src/main/res/layout/activity_home.xml index 98ea454..6fae260 100644 --- a/app/src/main/res/layout/activity_home.xml +++ b/app/src/main/res/layout/activity_home.xml @@ -5,7 +5,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" - tools:context="fr.plnech.lifelogger.HomeActivity"> + tools:context="fr.plnech.lifelogger.ui.HomeActivity"> + app:srcCompat="@android:drawable/ic_dialog_dialer"/> diff --git a/app/src/main/res/layout/content_home.xml b/app/src/main/res/layout/content_home.xml index d22f8a2..adf3323 100644 --- a/app/src/main/res/layout/content_home.xml +++ b/app/src/main/res/layout/content_home.xml @@ -6,16 +6,19 @@ android:layout_width="match_parent" android:layout_height="match_parent" app:layout_behavior="@string/appbar_scrolling_view_behavior" - tools:context="fr.plnech.lifelogger.HomeActivity" + tools:context="fr.plnech.lifelogger.ui.HomeActivity" tools:showIn="@layout/activity_home"> - - diff --git a/app/src/main/res/menu/menu_home.xml b/app/src/main/res/menu/menu_home.xml index 3322162..0d1cc05 100644 --- a/app/src/main/res/menu/menu_home.xml +++ b/app/src/main/res/menu/menu_home.xml @@ -1,7 +1,7 @@ + tools:context="fr.plnech.lifelogger.ui.HomeActivity">