feat(UI): HomeActivity with logs

parent 86f046b5
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
android:supportsRtl="true" android:supportsRtl="true"
android:theme="@style/AppTheme"> android:theme="@style/AppTheme">
<activity <activity
android:name=".HomeActivity" android:name=".ui.HomeActivity"
android:label="@string/app_name" android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar"> android:theme="@style/AppTheme.NoActionBar">
<intent-filter> <intent-filter>
......
package fr.plnech.lifelogger package fr.plnech.lifelogger.ui
import android.os.Bundle import android.os.Bundle
import android.support.design.widget.Snackbar import android.support.design.widget.Snackbar
import android.support.v7.app.AppCompatActivity import android.support.v7.app.AppCompatActivity
import android.view.Menu import android.view.Menu
import android.view.MenuItem 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.activity_home.*
import kotlinx.android.synthetic.main.content_home.*
class HomeActivity : AppCompatActivity() { class HomeActivity : AppCompatActivity() {
private lateinit var adapter: LogAdapter
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home) setContentView(R.layout.activity_home)
...@@ -19,6 +26,16 @@ class HomeActivity : AppCompatActivity() { ...@@ -19,6 +26,16 @@ class HomeActivity : AppCompatActivity() {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show() .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 { override fun onCreateOptionsMenu(menu: Menu): Boolean {
...@@ -36,4 +53,28 @@ class HomeActivity : AppCompatActivity() { ...@@ -36,4 +53,28 @@ class HomeActivity : AppCompatActivity() {
else -> super.onOptionsItemSelected(item) else -> super.onOptionsItemSelected(item)
} }
} }
private fun generateDebugData(): ArrayList<Log> {
var logs : ArrayList<Log> = 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
}
} }
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
tools:context="fr.plnech.lifelogger.HomeActivity"> tools:context="fr.plnech.lifelogger.ui.HomeActivity">
<android.support.design.widget.AppBarLayout <android.support.design.widget.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
...@@ -29,6 +29,6 @@ ...@@ -29,6 +29,6 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="bottom|end" android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin" android:layout_margin="@dimen/fab_margin"
app:srcCompat="@android:drawable/ic_dialog_email"/> app:srcCompat="@android:drawable/ic_dialog_dialer"/>
</android.support.design.widget.CoordinatorLayout> </android.support.design.widget.CoordinatorLayout>
...@@ -6,16 +6,19 @@ ...@@ -6,16 +6,19 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior" 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"> tools:showIn="@layout/activity_home">
<TextView <ListView
android:layout_width="wrap_content" android:id="@+id/list"
android:layout_height="wrap_content" android:layout_width="0dp"
android:text="Hello World!" android:layout_height="0dp"
android:layout_marginBottom="8dp"
android:layout_marginEnd="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintRight_toRightOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/> app:layout_constraintTop_toTopOf="parent"/>
</android.support.constraint.ConstraintLayout> </android.support.constraint.ConstraintLayout>
<menu xmlns:android="http://schemas.android.com/apk/res/android" <menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
tools:context="fr.plnech.lifelogger.HomeActivity"> tools:context="fr.plnech.lifelogger.ui.HomeActivity">
<item <item
android:id="@+id/action_settings" android:id="@+id/action_settings"
android:orderInCategory="100" android:orderInCategory="100"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment