Skip to content

Commit

Permalink
Style: KtLint
Browse files Browse the repository at this point in the history
12/30
  • Loading branch information
wsi1212 committed Dec 30, 2023
1 parent 806e573 commit e5d0dd8
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 119 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,10 @@ import kr.hs.dgsw.mentomenv2.base.BaseListAdapter
import kr.hs.dgsw.mentomenv2.databinding.ItemHomeBinding
import kr.hs.dgsw.mentomenv2.domain.model.Post


class HomeAdapter(
private val itemClick: (Post) -> Unit
private val itemClick: (Post) -> Unit,
) :
BaseListAdapter<Post, ItemHomeBinding>(R.layout.item_home, PostDiffUtilCallback) {

@SuppressLint("SetTextI18n")
override fun action(
item: Post,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ class HomeFragment : BaseFragment<FragmentHomeBinding, HomeViewModel>() {
HomeAdapter {
findNavController().navigate(HomeFragmentDirections.actionHomeFragmentToDetailFragment(it))
Log.d("HomeFragemnt", "HomeFragment item clicked")

}

override fun setupViews() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import dagger.hilt.android.lifecycle.HiltViewModel
import kotlinx.coroutines.flow.MutableSharedFlow
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.asSharedFlow
import kotlinx.coroutines.flow.take
import kr.hs.dgsw.mentomenv2.base.BaseViewModel
import kr.hs.dgsw.mentomenv2.domain.model.Post
import kr.hs.dgsw.mentomenv2.domain.usecase.post.GetAllPostUseCase
Expand All @@ -16,135 +15,135 @@ import javax.inject.Inject

@HiltViewModel
class HomeViewModel
@Inject
constructor(
private val getAllPostUseCase: GetAllPostUseCase,
private val getPostsByTagUseCase: GetPostsByTagUseCase,
) : BaseViewModel() {
val postState = MutableStateFlow<PostState>(PostState())
private val _errorFlow = MutableSharedFlow<String?>()
val errorFlow = _errorFlow.asSharedFlow()
private val isLoading: MutableLiveData<Boolean> = MutableLiveData(false)
var allPosts: List<Post>? = null
@Inject
constructor(
private val getAllPostUseCase: GetAllPostUseCase,
private val getPostsByTagUseCase: GetPostsByTagUseCase,
) : BaseViewModel() {
val postState = MutableStateFlow<PostState>(PostState())
private val _errorFlow = MutableSharedFlow<String?>()
val errorFlow = _errorFlow.asSharedFlow()
private val isLoading: MutableLiveData<Boolean> = MutableLiveData(false)
var allPosts: List<Post>? = null

init {
getAllPost()
}

fun getAllPost() {
getAllPostUseCase.invoke().safeApiCall(
isLoading,
successAction = {
allPosts = it
postState.value =
PostState(
postList = it,
tag = "ALL",
)
},
errorAction = {
_errorFlow.tryEmit(Utils.NETWORK_ERROR_MESSAGE)
},
)
}

fun onClickDesignBtn() {
if (postState.value.tag == "DESIGN") {
init {
getAllPost()
} else {
getPostsByTagUseCase("DESIGN").safeApiCall(
isLoading,
successAction = {
postState.value =
PostState(
postList = it,
tag = "DESIGN",
)
},
errorAction = {
_errorFlow.tryEmit(Utils.NETWORK_ERROR_MESSAGE)
},
)
}
}

fun onClickWebBtn() {
if (postState.value.tag == "WEB") {
getAllPost()
} else {
getPostsByTagUseCase("WEB").safeApiCall(
fun getAllPost() {
getAllPostUseCase.invoke().safeApiCall(
isLoading,
successAction = {
allPosts = it
postState.value =
PostState(
postList = it,
tag = "WEB",
tag = "ALL",
)
},
errorAction = {
_errorFlow.tryEmit(Utils.NETWORK_ERROR_MESSAGE)
},
)
}
}

fun onClickAndroidBtn() {
if (postState.value.tag == "ANDROID") {
getAllPost()
} else {
getPostsByTagUseCase("ANDROID").safeApiCall(
isLoading,
successAction = {
postState.value =
PostState(
postList = it,
tag = "ANDROID",
)
},
errorAction = {
_errorFlow.tryEmit(Utils.NETWORK_ERROR_MESSAGE)
},
)
fun onClickDesignBtn() {
if (postState.value.tag == "DESIGN") {
getAllPost()
} else {
getPostsByTagUseCase("DESIGN").safeApiCall(
isLoading,
successAction = {
postState.value =
PostState(
postList = it,
tag = "DESIGN",
)
},
errorAction = {
_errorFlow.tryEmit(Utils.NETWORK_ERROR_MESSAGE)
},
)
}
}
}

fun onClickServerBtn() {
if (postState.value.tag == "SERVER") {
getAllPost()
} else {
getPostsByTagUseCase("SERVER").safeApiCall(
isLoading,
successAction = {
postState.value =
PostState(
postList = it,
tag = "SERVER",
)
},
errorAction = {
_errorFlow.tryEmit(Utils.NETWORK_ERROR_MESSAGE)
},
)
fun onClickWebBtn() {
if (postState.value.tag == "WEB") {
getAllPost()
} else {
getPostsByTagUseCase("WEB").safeApiCall(
isLoading,
successAction = {
postState.value =
PostState(
postList = it,
tag = "WEB",
)
},
errorAction = {
_errorFlow.tryEmit(Utils.NETWORK_ERROR_MESSAGE)
},
)
}
}
}

fun onClickIOSBtn() {
if (postState.value.tag == "IOS") {
getAllPost()
} else {
getPostsByTagUseCase("IOS").safeApiCall(
isLoading,
successAction = {
postState.value =
PostState(
postList = it,
tag = "IOS",
)
},
errorAction = {
_errorFlow.tryEmit(Utils.NETWORK_ERROR_MESSAGE)
},
)
fun onClickAndroidBtn() {
if (postState.value.tag == "ANDROID") {
getAllPost()
} else {
getPostsByTagUseCase("ANDROID").safeApiCall(
isLoading,
successAction = {
postState.value =
PostState(
postList = it,
tag = "ANDROID",
)
},
errorAction = {
_errorFlow.tryEmit(Utils.NETWORK_ERROR_MESSAGE)
},
)
}
}

fun onClickServerBtn() {
if (postState.value.tag == "SERVER") {
getAllPost()
} else {
getPostsByTagUseCase("SERVER").safeApiCall(
isLoading,
successAction = {
postState.value =
PostState(
postList = it,
tag = "SERVER",
)
},
errorAction = {
_errorFlow.tryEmit(Utils.NETWORK_ERROR_MESSAGE)
},
)
}
}

fun onClickIOSBtn() {
if (postState.value.tag == "IOS") {
getAllPost()
} else {
getPostsByTagUseCase("IOS").safeApiCall(
isLoading,
successAction = {
postState.value =
PostState(
postList = it,
tag = "IOS",
)
},
errorAction = {
_errorFlow.tryEmit(Utils.NETWORK_ERROR_MESSAGE)
},
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class MyViewModel
imgUrls = listOf("https://flexible.img.hani.co.kr/flexible/normal/640/427/imgdb/original/2023/1106/20231106503357.jpg"),
createDateTime = "2023-11-06T14:28:51.528245",
postId = 1,
profileUrl = "https://dodam.kr.object.ncloudstorage.com/dodam/357d39e0-4c1c-4c31-81c8-f791c14566dfDODAM_FILE_280255852.jpg",
"https://dodam.kr.object.ncloudstorage.com/dodam/357d39e0-4c1c-4c31-81c8-f791c14566dfDODAM_FILE_280255852.jpg",
stdInfo = stdInfo,
tag = "DESIGN",
updateDateTime = "2023-11-06T14:28:51.528245",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ class SignInActivity : BaseActivity<ActivitySignInBinding, SingInViewModel>() {
collectTokenState()
collectEvent()
settingDAuth(
Client.clientId,
Client.clientSecret,
Client.redirectUri,
Client.CLIENT_ID,
Client.CLIENT_SECRET,
Client.REDIRECT_URL,
)
lifecycleScope.launch {
viewModel.getToken()
viewModel.tokenState.collect { token ->
if (token.refreshToken != "") {
getRefreshToken(
token.refreshToken,
Client.clientId,
Client.CLIENT_ID,
onSuccess = {
Log.d("start: getRefreshToken Success", it.expiresIn + "token type : " + it.tokenType)
viewModel.setAccessToken(it.accessToken)
Expand Down

0 comments on commit e5d0dd8

Please sign in to comment.