This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.shellmonger.apps.mynotes.ui | |
import android.support.v7.app.AppCompatActivity | |
import android.os.Bundle | |
import android.util.Log | |
import com.shellmonger.apps.mynotes.R | |
import com.shellmonger.apps.mynotes.extensions.set | |
import com.shellmonger.apps.mynotes.models.Note | |
import kotlinx.android.synthetic.main.activity_note_detail.* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class NoteDetailViewModel : ViewModel() { | |
companion object { | |
private val TAG = this::class.java.simpleName | |
} | |
private val mutableNoteId: MutableLiveData<String?> = MutableLiveData() | |
val currentNote: LiveData<Note> | |
init { | |
currentNote = Transformations.switchMap(mutableNoteId, { loadNote(it!!) }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.shellmonger.apps.mynotes.ui | |
import android.arch.lifecycle.Observer | |
import android.arch.lifecycle.ViewModelProviders | |
import android.support.v7.app.AppCompatActivity | |
import android.os.Bundle | |
import android.util.Log | |
import com.shellmonger.apps.mynotes.R | |
import com.shellmonger.apps.mynotes.extensions.set | |
import com.shellmonger.apps.mynotes.models.Note |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.shellmonger.apps.mynotes.ui | |
import android.arch.lifecycle.Observer | |
import android.arch.lifecycle.ViewModelProviders | |
import android.os.Bundle | |
import android.support.v4.app.Fragment | |
import android.util.Log | |
import android.view.LayoutInflater | |
import android.view.View | |
import android.view.ViewGroup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.shellmonger.apps.mynotes.ui | |
import android.support.v7.app.AppCompatActivity | |
import android.os.Bundle | |
import android.util.Log | |
import com.shellmonger.apps.mynotes.R | |
class NoteDetailActivity : AppCompatActivity() { | |
companion object { | |
private val TAG = this::class.java.simpleName |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout | |
xmlns:android="http://schemas.android.com/apk/res/android" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> | |
<FrameLayout | |
android:id="@+id/note_detail_fragment" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? { | |
val rootView = inflater.inflate(R.layout.fragment_note_detail, container, false) | |
viewModel.currentNote.observe(this, Observer { | |
it?.let { | |
rootView.detail_id_field.text = it.noteId | |
rootView.detail_title_editor.text.set(it.title) | |
rootView.detail_content_editor.text.set(it.content) | |
} | |
}) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.shellmonger.apps.mynotes.ui | |
import android.support.v7.app.AppCompatActivity | |
import android.os.Bundle | |
import android.util.Log | |
import com.shellmonger.apps.mynotes.R | |
class NoteDetailActivity : AppCompatActivity() { | |
companion object { | |
private val TAG = this::class.java.simpleName |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.shellmonger.apps.mynotes.viewmodels | |
import android.arch.lifecycle.LiveData | |
import android.arch.lifecycle.MutableLiveData | |
import android.arch.lifecycle.Transformations | |
import android.arch.lifecycle.ViewModel | |
import android.util.Log | |
import com.shellmonger.apps.mynotes.models.Note | |
import com.shellmonger.apps.mynotes.repositories.MockNotesRepository |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
xmlns:tools="http://schemas.android.com/tools" | |
android:layout_width="match_parent" | |
android:layout_height="match_parent" | |
tools:context=".ui.NoteListActivity"> | |
<android.support.design.widget.FloatingActionButton | |
android:id="@+id/note_list_add_note" |