-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
207 additions
and
210 deletions.
There are no files selected for viewing
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
4 changes: 2 additions & 2 deletions
4
app/src/main/java/com/flab/deepsleep/data/api/UnplashService.kt
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
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
2 changes: 1 addition & 1 deletion
2
...b/deepsleep/data/entity/photos/Results.kt → .../deepsleep/data/entity/unplash/Results.kt
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
2 changes: 1 addition & 1 deletion
2
...psleep/data/entity/photos/SearchPhotos.kt → ...sleep/data/entity/unplash/SearchPhotos.kt
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
2 changes: 1 addition & 1 deletion
2
...eepsleep/data/entity/photos/SearchUser.kt → ...epsleep/data/entity/unplash/SearchUser.kt
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
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
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
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
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
4 changes: 2 additions & 2 deletions
4
app/src/main/java/com/flab/deepsleep/data/repository/photo/UnplashRepository.kt
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
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
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
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
40 changes: 40 additions & 0 deletions
40
app/src/main/java/com/flab/deepsleep/ui/details/DetailsViewModel.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.flab.deepsleep.ui.details | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.viewModelScope | ||
import com.flab.deepsleep.data.repository.db.PhotoRepository | ||
import com.flab.deepsleep.ui.photo.UiItem | ||
import com.flab.deepsleep.ui.photo.toPhoto | ||
import dagger.hilt.android.lifecycle.HiltViewModel | ||
import kotlinx.coroutines.flow.collectLatest | ||
import kotlinx.coroutines.launch | ||
import javax.inject.Inject | ||
|
||
@HiltViewModel | ||
class DetailsViewModel @Inject constructor( | ||
private val photoRepository: PhotoRepository | ||
) : ViewModel() { | ||
|
||
/* Bookmark */ | ||
private val _isLiked = MutableLiveData<Boolean>() | ||
val isLiked: LiveData<Boolean> get() = _isLiked | ||
|
||
/* 즐겨찾기 추가 */ | ||
fun insertPhoto(uiItem: UiItem) { | ||
viewModelScope.launch { | ||
photoRepository.insertPhoto(uiItem.toPhoto()) | ||
} | ||
} | ||
|
||
fun loadPhotoLikeStatus(photoId: String) { | ||
viewModelScope.launch { | ||
photoRepository.getSinglePhoto(photoId).collectLatest { photo -> | ||
photo?.let { | ||
_isLiked.value = photo.isLike | ||
} | ||
} | ||
} | ||
} | ||
} |
13 changes: 4 additions & 9 deletions
13
...ava/com/flab/deepsleep/MainApplication.kt → ...in/java/com/flab/deepsleep/ui/main/App.kt
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,23 @@ | ||
package com.flab.deepsleep | ||
package com.flab.deepsleep.ui.main | ||
|
||
import android.app.Application | ||
import com.flab.deepsleep.utils.TimberDebugTree | ||
import com.flab.deepsleep.BuildConfig | ||
import dagger.hilt.android.HiltAndroidApp | ||
import timber.log.Timber | ||
|
||
|
||
@HiltAndroidApp | ||
class MainApplication: Application(){ | ||
|
||
class App : Application() { | ||
override fun onCreate() { | ||
super.onCreate() | ||
|
||
if (BuildConfig.DEBUG) { | ||
// Timber Initialize | ||
Timber.uprootAll() | ||
Timber.plant(object : Timber.DebugTree() { | ||
override fun createStackElementTag(element: StackTraceElement): String { | ||
val threadName = Thread.currentThread().name | ||
return "<$threadName> (${element.fileName}:${element.lineNumber})#${element.methodName} " | ||
} | ||
}) | ||
|
||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.