This file contains 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 CacheDataSourceImpl | |
constructor( | |
private val blogDao: BlogDao, | |
private val cacheMapper: CacheMapper | |
): CacheDataSource{ | |
override suspend fun insert(blog: Blog): Long { | |
return blogDao.insert(cacheMapper.mapToEntity(blog)) | |
} |
This file contains 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
@Module | |
@InstallIn(ApplicationComponent::class) | |
abstract class AbstractCacheModule{ | |
@Singleton | |
@Binds | |
abstract fun bindCacheDataSource( | |
cacheDataSourceImpl: CacheDataSourceImpl | |
): CacheDataSource | |
} |
This file contains 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
<!-- **NOTE** This must be in /debug/ --> | |
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="com.codingwithmitch.daggerhiltplayground"> | |
<application> | |
<activity | |
android:name="com.codingwithmitch.daggerhiltplayground.HiltTestActivity" | |
android:exported="false" /> | |
</application> |
This file contains 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
import 'package:flutter/material.dart'; | |
import 'package:provider/provider.dart'; | |
import '../models/product.dart'; | |
import '../providers/product_provider.dart'; | |
import '../screens/product_detail_screen.dart'; | |
import '../styles.dart'; | |
class ProductItem extends StatelessWidget { |
This file contains 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 Product { | |
final String id; | |
final String title; | |
final String description; | |
final double price; | |
final String imageUrl; | |
bool isFavorite; | |
Product({ |
This file contains 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 TabsScreen extends StatefulWidget { | |
@override | |
_TabsScreenState createState() => _TabsScreenState(); | |
} | |
class _TabsScreenState extends State<TabsScreen> { | |
final List<Map<String, Object>> _pages = [ | |
{"page": CategoriesScreen(), "title": "Categories"}, |
This file contains 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 TabsScreen extends StatefulWidget { | |
@override | |
_TabsScreenState createState() => _TabsScreenState(); | |
} | |
class _TabsScreenState extends State<TabsScreen> { | |
static const NUM_TABS = 2; |
This file contains 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
@Test | |
fun updateNote_success_confirmNetworkAndCacheUpdated() = runBlocking { | |
val randomNote = noteCacheDataSource.searchNotes("", "", 1) | |
.get(0) | |
// bug fix start | |
val updatedNote = Note( | |
id = randomNote.id, | |
title = UUID.randomUUID().toString(), | |
body = UUID.randomUUID().toString(), |
This file contains 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
@Test | |
fun deleteNetworkNotes_confirmCacheSync() = runBlocking { | |
// select some notes to be deleted from cache | |
val networkNotes = noteNetworkDataSource.getAllNotes() | |
val notesToDelete: ArrayList<Note> = ArrayList() | |
for(note in networkNotes){ | |
notesToDelete.add(note) | |
noteNetworkDataSource.deleteNote(note.id) // delete from notes node | |
noteNetworkDataSource.insertDeletedNote(note) // insert into deletes node |
This file contains 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.codingwithmitch.cleannotes.di | |
import com.codingwithmitch.cleannotes.business.data.NoteDataFactory | |
import com.codingwithmitch.cleannotes.business.data.cache.FakeNoteCacheDataSourceImpl | |
import com.codingwithmitch.cleannotes.business.data.cache.abstraction.NoteCacheDataSource | |
import com.codingwithmitch.cleannotes.business.data.network.FakeNoteNetworkDataSourceImpl | |
import com.codingwithmitch.cleannotes.business.data.network.abstraction.NoteNetworkDataSource | |
import com.codingwithmitch.cleannotes.business.domain.model.Note | |
import com.codingwithmitch.cleannotes.business.domain.model.NoteFactory | |
import com.codingwithmitch.cleannotes.business.domain.util.DateUtil |