/* * Copyright (C) 2018 PLNech * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */ 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) setSupportActionBar(toolbar) fab.setOnClickListener { view -> 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 { // Inflate the menu; this adds items to the action bar if it is present. menuInflater.inflate(R.menu.menu_home, menu) return true } override fun onOptionsItemSelected(item: MenuItem): Boolean { // Handle action bar item clicks here. The action bar will // automatically handle clicks on the Home/Up button, so long // as you specify a parent activity in AndroidManifest.xml. return when (item.itemId) { R.id.action_settings -> true 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 } }