generated from NOW-SOPT-ANDROID/now-sopt-android-template
-
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
1 parent
677469d
commit ff58fd7
Showing
6 changed files
with
61 additions
and
0 deletions.
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
app/src/main/java/com/sopt/now/presentation/Home/HomeViewModel.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,4 @@ | ||
package com.sopt.now.presentation.Home | ||
|
||
class HomeViewModel { | ||
} |
4 changes: 4 additions & 0 deletions
4
app/src/main/java/com/sopt/now/presentation/Login/LoginViewModel.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,4 @@ | ||
package com.sopt.now.presentation.Login | ||
|
||
class LoginViewModel { | ||
} |
4 changes: 4 additions & 0 deletions
4
app/src/main/java/com/sopt/now/presentation/Mypage/MypageViewModel.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,4 @@ | ||
package com.sopt.now.presentation.Mypage | ||
|
||
class MypageViewModel { | ||
} |
24 changes: 24 additions & 0 deletions
24
app/src/main/java/com/sopt/now/presentation/common/ViewModelFactory.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,24 @@ | ||
package com.sopt.now.presentation.common | ||
|
||
import androidx.lifecycle.ViewModel | ||
import androidx.lifecycle.ViewModelProvider | ||
import com.sopt.now.presentation.Home.HomeViewModel | ||
import com.sopt.now.presentation.Login.LoginViewModel | ||
import com.sopt.now.presentation.Mypage.MypageViewModel | ||
import com.sopt.now.presentation.Signup.SignupViewModel | ||
import java.lang.IllegalArgumentException | ||
|
||
class ViewModelFactory: ViewModelProvider.Factory { | ||
override fun <T: ViewModel> create(modelClass: Class<T>): T { | ||
if(modelClass.isAssignableFrom(SignupViewModel::class.java)) { | ||
return SignupViewModel() as T | ||
} else if(modelClass.isAssignableFrom(LoginViewModel::class.java)) { | ||
return LoginViewModel() as T | ||
} else if(modelClass.isAssignableFrom(HomeViewModel::class.java)) { | ||
return HomeViewModel() as T | ||
} else if(modelClass.isAssignableFrom(MypageViewModel::class.java)) { | ||
return MypageViewModel() as T | ||
} | ||
throw IllegalArgumentException("Unknown ViewModel Class") | ||
} | ||
} |
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,14 @@ | ||
package com.sopt.now.util | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
@Serializable | ||
data class BaseResponse<T>( | ||
@SerialName("code") | ||
val code: Int, | ||
@SerialName("message") | ||
val message: String, | ||
@SerialName("data") | ||
val data: 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,11 @@ | ||
package com.sopt.now.util | ||
|
||
sealed class UiState<out T> { | ||
object Loading : UiState<Nothing>() | ||
|
||
object Empty : UiState<Nothing>() | ||
|
||
data class Success<T>(val data: T) : UiState<T>() | ||
|
||
data class Error(val message: String?) : UiState<Nothing>() | ||
} |