~oppen/gra

6d3a38561d08dcacab76a5d9f61b2adbfdcfe09b — Öppen 3 days ago aa36c10
fix livedata bus
M .gradle/6.1.1/fileHashes/fileHashes.bin => .gradle/6.1.1/fileHashes/fileHashes.bin +0 -0

M .gradle/6.1.1/fileHashes/fileHashes.lock => .gradle/6.1.1/fileHashes/fileHashes.lock +0 -0

M .gradle/buildOutputCleanup/buildOutputCleanup.lock => .gradle/buildOutputCleanup/buildOutputCleanup.lock +0 -0

M .gradle/buildOutputCleanup/outputFiles.bin => .gradle/buildOutputCleanup/outputFiles.bin +0 -0

M .gradle/checksums/checksums.lock => .gradle/checksums/checksums.lock +0 -0

M .gradle/checksums/md5-checksums.bin => .gradle/checksums/md5-checksums.bin +0 -0

M .gradle/checksums/sha1-checksums.bin => .gradle/checksums/sha1-checksums.bin +0 -0

A app/build/generated/source/buildConfig/debug/oppen/editor/BuildConfig.java => app/build/generated/source/buildConfig/debug/oppen/editor/BuildConfig.java +12 -0
@@ 0,0 1,12 @@
/**
 * Automatically generated file. DO NOT MODIFY
 */
package oppen.editor;

public final class BuildConfig {
  public static final boolean DEBUG = Boolean.parseBoolean("true");
  public static final String APPLICATION_ID = "oppen.editor";
  public static final String BUILD_TYPE = "debug";
  public static final int VERSION_CODE = 1;
  public static final String VERSION_NAME = "1.0.0-3-gaa36c10";
}

M app/src/main/AndroidManifest.xml => app/src/main/AndroidManifest.xml +7 -5
@@ 10,7 10,9 @@
        android:roundIcon="@drawable/logo"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name="oppen.gra.GraActivity">
        <activity android:name="oppen.gra.GraActivity"
            android:screenOrientation="portrait"
            tools:ignore="LockedOrientationActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />



@@ 21,11 23,11 @@
            android:name=".ui.EditorActivity"
            android:screenOrientation="portrait"
            tools:ignore="LockedOrientationActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
<!--            <intent-filter>-->
<!--                <action android:name="android.intent.action.MAIN" />-->

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
<!--                <category android:name="android.intent.category.LAUNCHER" />-->
<!--            </intent-filter>-->
        </activity>
    </application>


M app/src/main/java/oppen/gra/GraActivity.kt => app/src/main/java/oppen/gra/GraActivity.kt +6 -7
@@ 9,18 9,17 @@ import kotlinx.android.synthetic.main.activity_gra.*
import oppen.editor.R
import snack

class GraActivity : AppCompatActivity() {
class GraActivity: AppCompatActivity() {

  override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_gra)

    val model: GraViewModel by viewModels()
    model.subscribe().observe(this, Observer<GraState>{ state ->
      render(model, state)
    })
    model.initialise(this, contentResolver)
      .observe(this, Observer<GraState>{ state ->
        render(model, state)
      }
    )
  }

  private fun render(model: GraViewModel, state: GraState){


@@ 46,10 45,10 @@ class GraActivity : AppCompatActivity() {
  }

  private fun renderActive(model: GraViewModel, state: GraState.Active) {

    println("renderActive()")
  }

  private fun renderEmpty(model: GraViewModel){
    
    println("renderEmpty()")
  }
}
\ No newline at end of file

A app/src/main/java/oppen/gra/GraApp.kt => app/src/main/java/oppen/gra/GraApp.kt +10 -0
@@ 0,0 1,10 @@
package oppen.gra

import android.app.Application

class GraApp: Application() {

  override fun onCreate() {
    super.onCreate()
  }
}
\ No newline at end of file

M app/src/main/java/oppen/gra/GraState.kt => app/src/main/java/oppen/gra/GraState.kt +1 -1
@@ 1,7 1,7 @@
package oppen.gra

sealed class GraState {
  object Empty : GraState()
  object Empty: GraState()
  data class Active(val filename: String, val content: String): GraState()
  data class Error(val error: GraError): GraState()
}

M app/src/main/java/oppen/gra/GraViewModel.kt => app/src/main/java/oppen/gra/GraViewModel.kt +6 -5
@@ 10,15 10,16 @@ import oppen.editor.io.FileDatasource
class GraViewModel: ViewModel() {

    private lateinit var repository: GraRepository
    private val editorState = MutableLiveData<GraState>()

    private val editorState: MutableLiveData<GraState> by lazy {
        MutableLiveData<GraState>().also {
            repository.initialise(editorState::postValue)
    fun initialise(context: Context, contentResolver: ContentResolver){
        repository = GraRepository(FileDatasource(context, contentResolver))
        repository.initialise { state ->
            editorState.value = state
        }
    }

    fun initialise(context: Context, contentResolver: ContentResolver): LiveData<GraState> {
        repository = GraRepository(FileDatasource(context, contentResolver))
    fun subscribe(): LiveData<GraState> {
        return editorState
    }
}
\ No newline at end of file