Skip to content

Commit

Permalink
Merge pull request #81 from FakeDevelopers/feature/BDBD-503
Browse files Browse the repository at this point in the history
FEAT : BDBD-503 로그인 / 메인 액티비티 분리
  • Loading branch information
minseonglove authored Dec 29, 2022
2 parents cb240f0 + 93deb36 commit 0a603cb
Show file tree
Hide file tree
Showing 14 changed files with 221 additions and 160 deletions.
5 changes: 4 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
android:theme="@style/Theme.BidderBidder">
<meta-data android:name="io.sentry.auto-init" android:value="false" />
<activity
android:name=".MainActivity"
android:name=".ui.LoginActivity"
android:exported="true"
android:windowSoftInputMode="adjustResize">
<intent-filter>
Expand All @@ -25,5 +25,8 @@
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".ui.MainActivity"
android:windowSoftInputMode="adjustResize" />
</application>
</manifest>
Original file line number Diff line number Diff line change
@@ -1,22 +1,6 @@
package com.fakedevelopers.bidderbidder.api.di

import com.fakedevelopers.bidderbidder.api.data.Constants.Companion.BASE_URL
import com.fakedevelopers.bidderbidder.api.repository.ChatRepository
import com.fakedevelopers.bidderbidder.api.repository.ProductCategoryRepository
import com.fakedevelopers.bidderbidder.api.repository.ProductDetailRepository
import com.fakedevelopers.bidderbidder.api.repository.ProductListRepository
import com.fakedevelopers.bidderbidder.api.repository.ProductRegistrationRepository
import com.fakedevelopers.bidderbidder.api.repository.ProductSearchRepository
import com.fakedevelopers.bidderbidder.api.repository.SigninGoogleRepository
import com.fakedevelopers.bidderbidder.api.repository.UserLoginRepository
import com.fakedevelopers.bidderbidder.api.service.ChatService
import com.fakedevelopers.bidderbidder.api.service.ProductCategoryService
import com.fakedevelopers.bidderbidder.api.service.ProductDetailService
import com.fakedevelopers.bidderbidder.api.service.ProductListService
import com.fakedevelopers.bidderbidder.api.service.ProductRegistrationService
import com.fakedevelopers.bidderbidder.api.service.ProductSearchService
import com.fakedevelopers.bidderbidder.api.service.SigninGoogleService
import com.fakedevelopers.bidderbidder.api.service.UserLoginService
import com.fakedevelopers.bidderbidder.api.util.LoginAuthInterceptor
import com.google.firebase.auth.FirebaseAuth
import com.google.gson.Gson
Expand Down Expand Up @@ -124,94 +108,6 @@ object ApiModule {
}
}

// 로그인 요청
@Singleton
@Provides
fun provideUserLoginService(@NormalRetrofit retrofit: Retrofit): UserLoginService = retrofit.create(
UserLoginService::class.java
)

@Singleton
@Provides
fun provideUserLoginRepository(service: UserLoginService): UserLoginRepository = UserLoginRepository(service)

// 게시글 등록 요청
@Singleton
@Provides
fun provideUserProductRegistrationService(@NormalRetrofit retrofit: Retrofit): ProductRegistrationService =
retrofit.create(ProductRegistrationService::class.java)

@Singleton
@Provides
fun provideUserProductRegistrationRepository(service: ProductRegistrationService): ProductRegistrationRepository =
ProductRegistrationRepository(service)

// 상품 카테고리 요청
@Singleton
@Provides
fun provideProductCategoryService(@NormalRetrofit retrofit: Retrofit): ProductCategoryService =
retrofit.create(ProductCategoryService::class.java)

@Singleton
@Provides
fun provideProductCategoryRepository(service: ProductCategoryService): ProductCategoryRepository =
ProductCategoryRepository(service)

// 상품 리스트 요청
@Singleton
@Provides
fun provideProductListService(@NormalRetrofit retrofit: Retrofit): ProductListService =
retrofit.create(ProductListService::class.java)

@Singleton
@Provides
fun provideProductListRepository(service: ProductListService): ProductListRepository =
ProductListRepository(service)

// 구글 로그인 요청
@Singleton
@Provides
fun provideSigninGoogleService(@AuthRetrofit retrofit: Retrofit): SigninGoogleService =
retrofit.create(SigninGoogleService::class.java)

@Singleton
@Provides
fun provideSigninGoogleRepository(service: SigninGoogleService): SigninGoogleRepository =
SigninGoogleRepository(service)

// 상품 상세 정보, 입찰
@Singleton
@Provides
fun provideProductDetailService(@NormalRetrofit retrofit: Retrofit): ProductDetailService =
retrofit.create(ProductDetailService::class.java)

@Singleton
@Provides
fun provideProductDetailRepository(service: ProductDetailService): ProductDetailRepository =
ProductDetailRepository(service)

// 스트림 유저 토큰
@Singleton
@Provides
fun provideChatService(@NormalRetrofit retrofit: Retrofit): ChatService =
retrofit.create(ChatService::class.java)

@Singleton
@Provides
fun provideChatRepository(service: ChatService): ChatRepository =
ChatRepository(service)

// 인기 검색어 요청
@Singleton
@Provides
fun provideProductSearchService(@NormalRetrofit retrofit: Retrofit): ProductSearchService =
retrofit.create(ProductSearchService::class.java)

@Singleton
@Provides
fun provideProductSearchRepository(service: ProductSearchService): ProductSearchRepository =
ProductSearchRepository(service)

@Singleton
@Provides
fun provideAuthInterceptor(auth: FirebaseAuth) = LoginAuthInterceptor(auth)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.fakedevelopers.bidderbidder.api.di

import com.fakedevelopers.bidderbidder.api.repository.SigninGoogleRepository
import com.fakedevelopers.bidderbidder.api.repository.UserLoginRepository
import com.fakedevelopers.bidderbidder.api.service.SigninGoogleService
import com.fakedevelopers.bidderbidder.api.service.UserLoginService
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ViewModelComponent
import dagger.hilt.android.scopes.ViewModelScoped
import retrofit2.Retrofit

@Module
@InstallIn(ViewModelComponent::class)
class LoginModule {
// 로그인 요청
@ViewModelScoped
@Provides
fun provideUserLoginService(@NormalRetrofit retrofit: Retrofit): UserLoginService = retrofit.create(
UserLoginService::class.java
)

@ViewModelScoped
@Provides
fun provideUserLoginRepository(service: UserLoginService): UserLoginRepository = UserLoginRepository(service)

// 구글 로그인 요청
@ViewModelScoped
@Provides
fun provideSigninGoogleService(@AuthRetrofit retrofit: Retrofit): SigninGoogleService =
retrofit.create(SigninGoogleService::class.java)

@ViewModelScoped
@Provides
fun provideSigninGoogleRepository(service: SigninGoogleService): SigninGoogleRepository =
SigninGoogleRepository(service)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.fakedevelopers.bidderbidder.api.di

import com.fakedevelopers.bidderbidder.api.repository.ChatRepository
import com.fakedevelopers.bidderbidder.api.repository.ProductCategoryRepository
import com.fakedevelopers.bidderbidder.api.repository.ProductDetailRepository
import com.fakedevelopers.bidderbidder.api.repository.ProductListRepository
import com.fakedevelopers.bidderbidder.api.repository.ProductRegistrationRepository
import com.fakedevelopers.bidderbidder.api.repository.ProductSearchRepository
import com.fakedevelopers.bidderbidder.api.service.ChatService
import com.fakedevelopers.bidderbidder.api.service.ProductCategoryService
import com.fakedevelopers.bidderbidder.api.service.ProductDetailService
import com.fakedevelopers.bidderbidder.api.service.ProductListService
import com.fakedevelopers.bidderbidder.api.service.ProductRegistrationService
import com.fakedevelopers.bidderbidder.api.service.ProductSearchService
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityRetainedComponent
import dagger.hilt.android.scopes.ActivityRetainedScoped
import retrofit2.Retrofit

@Module
@InstallIn(ActivityRetainedComponent::class)
class MainModule {
// 게시글 등록 요청
@ActivityRetainedScoped
@Provides
fun provideUserProductRegistrationService(@NormalRetrofit retrofit: Retrofit): ProductRegistrationService =
retrofit.create(ProductRegistrationService::class.java)

@ActivityRetainedScoped
@Provides
fun provideUserProductRegistrationRepository(service: ProductRegistrationService): ProductRegistrationRepository =
ProductRegistrationRepository(service)

// 상품 카테고리 요청
@ActivityRetainedScoped
@Provides
fun provideProductCategoryService(@NormalRetrofit retrofit: Retrofit): ProductCategoryService =
retrofit.create(ProductCategoryService::class.java)

@ActivityRetainedScoped
@Provides
fun provideProductCategoryRepository(service: ProductCategoryService): ProductCategoryRepository =
ProductCategoryRepository(service)

// 상품 리스트 요청
@ActivityRetainedScoped
@Provides
fun provideProductListService(@NormalRetrofit retrofit: Retrofit): ProductListService =
retrofit.create(ProductListService::class.java)

@ActivityRetainedScoped
@Provides
fun provideProductListRepository(service: ProductListService): ProductListRepository =
ProductListRepository(service)

// 상품 상세 정보, 입찰
@ActivityRetainedScoped
@Provides
fun provideProductDetailService(@NormalRetrofit retrofit: Retrofit): ProductDetailService =
retrofit.create(ProductDetailService::class.java)

@ActivityRetainedScoped
@Provides
fun provideProductDetailRepository(service: ProductDetailService): ProductDetailRepository =
ProductDetailRepository(service)

// 스트림 유저 토큰
@ActivityRetainedScoped
@Provides
fun provideChatService(@NormalRetrofit retrofit: Retrofit): ChatService =
retrofit.create(ChatService::class.java)

@ActivityRetainedScoped
@Provides
fun provideChatRepository(service: ChatService): ChatRepository =
ChatRepository(service)

// 인기 검색어 요청
@ActivityRetainedScoped
@Provides
fun provideProductSearchService(@NormalRetrofit retrofit: Retrofit): ProductSearchService =
retrofit.create(ProductSearchService::class.java)

@ActivityRetainedScoped
@Provides
fun provideProductSearchRepository(service: ProductSearchService): ProductSearchRepository =
ProductSearchRepository(service)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.fakedevelopers.bidderbidder.ui

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import com.fakedevelopers.bidderbidder.R
import dagger.hilt.android.AndroidEntryPoint

@AndroidEntryPoint
class LoginActivity : AppCompatActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_login)
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.fakedevelopers.bidderbidder
package com.fakedevelopers.bidderbidder.ui

import android.os.Bundle
import android.view.MotionEvent
Expand All @@ -8,6 +8,7 @@ import androidx.appcompat.app.AppCompatActivity
import androidx.navigation.NavController
import androidx.navigation.NavDirections
import androidx.navigation.fragment.NavHostFragment
import com.fakedevelopers.bidderbidder.R
import com.fakedevelopers.bidderbidder.databinding.ActivityMainBinding
import com.jakewharton.threetenabp.AndroidThreeTen
import dagger.hilt.android.AndroidEntryPoint
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.fakedevelopers.bidderbidder.ui.login

import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand All @@ -14,6 +15,7 @@ import androidx.navigation.fragment.findNavController
import com.fakedevelopers.bidderbidder.R
import com.fakedevelopers.bidderbidder.api.data.Constants.Companion.LOGIN_SUCCESS
import com.fakedevelopers.bidderbidder.databinding.FragmentLoginBinding
import com.fakedevelopers.bidderbidder.ui.MainActivity
import com.orhanobut.logger.Logger
import dagger.hilt.android.AndroidEntryPoint
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -68,10 +70,9 @@ class LoginFragment : Fragment() {
lifecycleScope.launch {
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
viewModel.loginResponse.collect {
if (it.isSuccessful) {
if (it.body().toString() == LOGIN_SUCCESS) {
findNavController().navigate(R.id.action_loginFragment_to_mainFragment)
}
if (it.isSuccessful && it.body().toString() == LOGIN_SUCCESS) {
startActivity(Intent(requireContext(), MainActivity::class.java))
requireActivity().finish()
} else {
Logger.e(it.errorBody().toString())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.fakedevelopers.bidderbidder.ui.loginType

import android.app.Activity.RESULT_OK
import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand All @@ -18,6 +19,7 @@ import com.fakedevelopers.bidderbidder.HiltApplication
import com.fakedevelopers.bidderbidder.R
import com.fakedevelopers.bidderbidder.api.data.Constants.Companion.WEB_CLIENT_ID
import com.fakedevelopers.bidderbidder.databinding.FragmentLoginTypeBinding
import com.fakedevelopers.bidderbidder.ui.MainActivity
import com.google.android.gms.auth.api.Auth
import com.google.android.gms.auth.api.signin.GoogleSignIn
import com.google.android.gms.auth.api.signin.GoogleSignInClient
Expand Down Expand Up @@ -95,7 +97,8 @@ class LoginTypeFragment : Fragment() {
viewModel.signinGoogleResponse.collect {
if (it.isSuccessful) {
Toast.makeText(requireActivity(), "success", Toast.LENGTH_LONG).show()
findNavController().navigate(R.id.action_loginTypeFragment_to_productListFragment)
startActivity(Intent(requireContext(), MainActivity::class.java))
requireActivity().finish()
} else {
Toast.makeText(requireActivity(), "failure", Toast.LENGTH_LONG).show()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,7 @@ class ProductListFragment : Fragment() {
super.onViewCreated(view, savedInstanceState)
val args: ProductListFragmentArgs by navArgs()
if (viewModel.isInitialize) {
kotlin.runCatching {
args.searchWord
}.onSuccess {
viewModel.setSearchWord(it)
}
viewModel.setSearchWord(args.searchWord)
viewModel.requestProductList(true)
}
initListener()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.fakedevelopers.bidderbidder.ui.register

import android.content.Intent
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
Expand All @@ -15,10 +16,10 @@ import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.navigation.NavOptions
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.fragment.findNavController
import androidx.navigation.navOptions
import com.fakedevelopers.bidderbidder.R
import com.fakedevelopers.bidderbidder.databinding.FragmentUserRegistrationBinding
import com.fakedevelopers.bidderbidder.ui.MainActivity
import com.fakedevelopers.bidderbidder.ui.register.RegistrationProgressState.ACCEPT_TERMS
import com.fakedevelopers.bidderbidder.ui.register.RegistrationProgressState.CONGRATULATIONS
import com.fakedevelopers.bidderbidder.ui.register.RegistrationProgressState.INPUT_ID
Expand Down Expand Up @@ -159,7 +160,10 @@ class UserRegistrationFragment : Fragment() {
INPUT_ID -> navigate(R.id.userRegistrationIdFragment)
INPUT_PASSWORD -> navigate(R.id.userRegistrationPasswordFragment)
PHONE_AUTH_BEFORE_SENDING -> navigate(R.id.phoneAuthFragment)
CONGRATULATIONS -> findNavController().navigate(R.id.action_userRegistrationFragment_to_productListFragment)
CONGRATULATIONS -> {
startActivity(Intent(requireContext(), MainActivity::class.java))
requireActivity().finish()
}
else -> {
// 여긴 아무것도 안해!
}
Expand Down
Loading

0 comments on commit 0a603cb

Please sign in to comment.