-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: BeginAdventureActivity에서 진행중인 게임이 있는지 판단하는 기능 구현 (#277)
* design: 로딩을 위한 스켈레톤 UI 생성 * feat: 진행중인 상태의 게임을 받아오고 로딩하는 과정을 추가 * feat: 작업중 * rename: 로티 파일 이름 변경 * design: 스켈레톤 뷰 지우고 로티 뷰 추가 * feat: 로티 로딩뷰로 수정 * style: 로그 삭제 * feat: 뷰 진행 플로우 변경 * refactor: 직접 만든 로직을 이미 존재하는 코틀린 api로 대체
- Loading branch information
Showing
11 changed files
with
244 additions
and
7 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
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
48 changes: 48 additions & 0 deletions
48
...id/app/src/main/java/com/now/naaga/presentation/beginadventure/BeginAdventureViewModel.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,48 @@ | ||
package com.now.naaga.presentation.beginadventure | ||
|
||
import androidx.lifecycle.LiveData | ||
import androidx.lifecycle.MutableLiveData | ||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.ViewModelProvider | ||
import com.now.domain.model.Adventure | ||
import com.now.domain.model.AdventureStatus | ||
import com.now.domain.repository.AdventureRepository | ||
import com.now.naaga.data.repository.DefaultAdventureRepository | ||
import com.now.naaga.data.throwable.DataThrowable | ||
|
||
class BeginAdventureViewModel(private val adventureRepository: AdventureRepository) : ViewModel() { | ||
private val _adventure = MutableLiveData<Adventure>() | ||
val adventure: LiveData<Adventure> = _adventure | ||
|
||
private val _error = MutableLiveData<DataThrowable>() | ||
val error: LiveData<DataThrowable> = _error | ||
|
||
private val _loading = MutableLiveData<Boolean>(false) | ||
val loading: LiveData<Boolean> = _loading | ||
|
||
fun fetchAdventure(adventureStatus: AdventureStatus) { | ||
_loading.value = true | ||
adventureRepository.fetchAdventureByStatus(adventureStatus) { result -> | ||
_loading.value = false | ||
result | ||
.onSuccess { | ||
_adventure.value = it.firstOrNull() | ||
} | ||
.onFailure { | ||
_error.value = it as DataThrowable | ||
} | ||
} | ||
} | ||
|
||
companion object { | ||
val Factory = BeginAdventureViewModelFactory(DefaultAdventureRepository()) | ||
|
||
class BeginAdventureViewModelFactory( | ||
private val adventureRepository: AdventureRepository, | ||
) : ViewModelProvider.Factory { | ||
override fun <T : ViewModel> create(modelClass: Class<T>): T { | ||
return BeginAdventureViewModel(adventureRepository) as T | ||
} | ||
} | ||
} | ||
} |
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,12 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<set xmlns:android="http://schemas.android.com/apk/res/android"> | ||
|
||
<alpha | ||
android:duration="500" | ||
android:fromAlpha="0.7" | ||
android:interpolator="@android:anim/accelerate_interpolator" | ||
android:repeatCount="infinite" | ||
android:repeatMode="reverse" | ||
android:toAlpha="1.0" /> | ||
|
||
</set> |
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
97 changes: 97 additions & 0 deletions
97
android/app/src/main/res/layout/skeleton_begin_adventure.xml
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,97 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
|
||
<layout 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"> | ||
|
||
<data> | ||
|
||
<variable | ||
name="viewModel" | ||
type="com.now.naaga.presentation.beginadventure.BeginAdventureViewModel" /> | ||
</data> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="@color/main_gray" | ||
android:elevation="8dp" | ||
tools:context=".presentation.beginadventure.BeginAdventureActivity"> | ||
|
||
<androidx.constraintlayout.widget.ConstraintLayout | ||
android:id="@+id/cl_beginAdventure_begin" | ||
style="@style/BeginActivity.Button.Skeleton" | ||
android:layout_width="0dp" | ||
android:layout_height="wrap_content" | ||
android:layout_marginHorizontal="40dp" | ||
android:layout_marginTop="100dp" | ||
android:paddingVertical="32dp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent"> | ||
|
||
<ImageView | ||
android:id="@+id/iv_beginAdventure_logo" | ||
android:layout_width="0dp" | ||
android:layout_height="0dp" | ||
android:layout_marginHorizontal="40dp" | ||
android:src="@drawable/ic_logo_white" | ||
app:layout_constraintDimensionRatio="1:1.1" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" /> | ||
|
||
<TextView | ||
android:id="@+id/tv_beginAdventure_begin" | ||
android:layout_width="wrap_content" | ||
android:layout_height="wrap_content" | ||
android:layout_marginTop="@dimen/space_default_medium" | ||
android:fontFamily="@font/pretendard_bold" | ||
android:text="@{viewModel.adventure == null ? @string/beginAdventure_do_adventure : @string/beginAdventure_continue_adventure}" | ||
android:textColor="@color/white" | ||
android:textSize="32sp" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toBottomOf="@id/iv_beginAdventure_logo" /> | ||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
|
||
<ImageButton | ||
android:id="@+id/iv_beginAdventure_mypage" | ||
style="@style/BeginActivity.Button.Skeleton" | ||
android:layout_width="80dp" | ||
android:layout_height="80dp" | ||
android:src="@drawable/ic_mypage" | ||
app:layout_constraintBottom_toBottomOf="@+id/iv_beginAdventure_upload" | ||
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toEndOf="@+id/iv_beginAdventure_upload" | ||
app:layout_constraintTop_toTopOf="@+id/iv_beginAdventure_upload" /> | ||
|
||
<ImageButton | ||
android:id="@+id/iv_beginAdventure_rank" | ||
style="@style/BeginActivity.Button.Skeleton" | ||
android:layout_width="80dp" | ||
android:layout_height="80dp" | ||
android:src="@drawable/ic_rank" | ||
app:layout_constraintBottom_toBottomOf="@+id/iv_beginAdventure_upload" | ||
app:layout_constraintEnd_toStartOf="@+id/iv_beginAdventure_upload" | ||
app:layout_constraintHorizontal_chainStyle="packed" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="@+id/iv_beginAdventure_upload" /> | ||
|
||
<ImageButton | ||
android:id="@+id/iv_beginAdventure_upload" | ||
style="@style/BeginActivity.Button.Skeleton" | ||
android:layout_width="80dp" | ||
android:layout_height="80dp" | ||
android:layout_marginHorizontal="30dp" | ||
android:layout_marginBottom="20dp" | ||
android:src="@drawable/ic_upload" | ||
app:layout_constraintBottom_toBottomOf="parent" | ||
app:layout_constraintEnd_toStartOf="@+id/iv_beginAdventure_mypage" | ||
app:layout_constraintHorizontal_bias="0.5" | ||
app:layout_constraintStart_toEndOf="@+id/iv_beginAdventure_rank" /> | ||
|
||
|
||
</androidx.constraintlayout.widget.ConstraintLayout> | ||
</layout> |
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 @@ | ||
{"v":"5.8.1","fr":30,"ip":0,"op":60,"w":300,"h":300,"nm":"loading_6","ddd":0,"assets":[],"layers":[{"ddd":0,"ind":1,"ty":4,"nm":"Shape Layer 2","sr":1,"ks":{"o":{"a":0,"k":100,"ix":11},"r":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0]},{"t":60,"s":[360]}],"ix":10},"p":{"a":0,"k":[150.00000000000003,150.00000000000003,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[30.000000000000004,30.000000000000004,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[300,300],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.22745098039215686,0.6627450980392157,0.8627450980392157,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":50,"ix":5},"lc":2,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false},{"ty":"tm","s":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":10,"s":[0]},{"t":60,"s":[99]}],"ix":1},"e":{"a":1,"k":[{"i":{"x":[0.667],"y":[1]},"o":{"x":[0.333],"y":[0]},"t":0,"s":[1]},{"t":50,"s":[100]}],"ix":2},"o":{"a":1,"k":[{"i":{"x":[0.833],"y":[0.833]},"o":{"x":[0.167],"y":[0.167]},"t":0,"s":[0]},{"t":60,"s":[3]}],"ix":3},"m":1,"ix":2,"nm":"Trim Paths 1","mn":"ADBE Vector Filter - Trim","hd":false}],"ip":0,"op":300,"st":0,"bm":0},{"ddd":0,"ind":2,"ty":4,"nm":"Shape Layer 1","sr":1,"ks":{"o":{"a":0,"k":30,"ix":11},"r":{"a":0,"k":0,"ix":10},"p":{"a":0,"k":[150.00000000000003,150.00000000000003,0],"ix":2,"l":2},"a":{"a":0,"k":[0,0,0],"ix":1,"l":2},"s":{"a":0,"k":[30.000000000000004,30.000000000000004,100],"ix":6,"l":2}},"ao":0,"shapes":[{"ty":"gr","it":[{"d":1,"ty":"el","s":{"a":0,"k":[300,300],"ix":2},"p":{"a":0,"k":[0,0],"ix":3},"nm":"Ellipse Path 1","mn":"ADBE Vector Shape - Ellipse","hd":false},{"ty":"st","c":{"a":0,"k":[0.6666666666666666,0.8431372549019608,0.9215686274509803,1],"ix":3},"o":{"a":0,"k":100,"ix":4},"w":{"a":0,"k":50,"ix":5},"lc":1,"lj":1,"ml":4,"bm":0,"nm":"Stroke 1","mn":"ADBE Vector Graphic - Stroke","hd":false},{"ty":"tr","p":{"a":0,"k":[0,0],"ix":2},"a":{"a":0,"k":[0,0],"ix":1},"s":{"a":0,"k":[100,100],"ix":3},"r":{"a":0,"k":0,"ix":6},"o":{"a":0,"k":100,"ix":7},"sk":{"a":0,"k":0,"ix":4},"sa":{"a":0,"k":0,"ix":5},"nm":"Transform"}],"nm":"Ellipse 1","np":3,"cix":2,"bm":0,"ix":1,"mn":"ADBE Vector Group","hd":false}],"ip":0,"op":300,"st":0,"bm":0}],"markers":[]} |
File renamed without changes.
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