Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.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">
<com.google.android.material.chip.ChipGroup
android:id="@+id/chipGroup"
android:layout_width="match_parent"
package com.example.daggerandroidmvvm.lobby;
import android.arch.lifecycle.ViewModelProviders;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
// RecyclerView Adapter implemented as ListAdapter and DiffCallback
class Mydapter(
private val clickListener: (String) -> Unit
) :
ListAdapter<MyUiModel, MyViewHolder>(MyDiffCallback()) {
override fun onCreateViewHolder(
parent: ViewGroup,
position: Int
@jshvarts
jshvarts / DaggerParentChildExample.kt
Created October 14, 2020 16:02 — forked from arkivanov/DaggerParentChildExample.kt
Dagger parent-child example
// Deps
interface Database
interface Network
// Child
interface ChildRepository
class Child(dependencies: Dependencies) {
// In ViewModel:
private val error = ConflatedBroadcastChannel<ErrorType>()
fun errorEffect(): Flow<ErrorType> = error.asFlow()
val errorType = if (connectionHelper.isConnected()) {
ErrorType.GENERIC
} else {
ErrorType.CONNECTION
fun logCoroutine(message: String) = "[${Thread.currentThread().name}] $message"
// call with
Timber.d(logCoroutine("Initial coroutine launched"))
fun logCoroutine(message: String, coroutineContext: CoroutineContext) {
println("coroutine is executing on thread : ${Thread.currentThread().name} : $message : $coroutineContext")
}
fun logCoroutine(message: String) {
println("coroutineå is executing on thread : ${Thread.currentThread().name}: $message")
}
package com.jshvarts.notesnavigation.presentation.deletenote
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.navigation.Navigation.findNavController
package com.jshvarts.notesnavigation.presentation.notedetail
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import androidx.lifecycle.ViewModelProviders
import androidx.navigation.Navigation.findNavController