Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
Version 1.4.5 적용
Browse files Browse the repository at this point in the history
  • Loading branch information
kangmin1012 committed Jun 24, 2022
2 parents 9632917 + 2be3cdb commit 34beac1
Show file tree
Hide file tree
Showing 25 changed files with 195 additions and 111 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ android {
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)

signingConfig = signingConfigs.getByName("release")
}

getByName("debug") {
isMinifyEnabled = false
isShrinkResources = false
}

getByName("debug") {
Expand Down
20 changes: 12 additions & 8 deletions app/src/main/java/com/teamounce/ounce/base/BindingActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ import androidx.annotation.LayoutRes
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import androidx.lifecycle.*
import com.teamounce.ounce.component.LoadingDialog

abstract class BindingActivity<T : ViewDataBinding>(@LayoutRes private val layoutResId: Int) :
Expand All @@ -29,13 +27,17 @@ abstract class BindingActivity<T : ViewDataBinding>(@LayoutRes private val layou
super.onDestroy()
}

protected inner class LifeCycleEventLogger(private val className: String) : LifecycleObserver {
protected inner class LifeCycleEventLogger(
private val className: String
) : LifecycleEventObserver {
fun registerLogger(lifecycle: Lifecycle) {
lifecycle.addObserver(this)
}

@OnLifecycleEvent(Lifecycle.Event.ON_ANY)
fun log() {
override fun onStateChanged(
source: LifecycleOwner,
event: Lifecycle.Event
) {
Log.d("${className}LifeCycleEvent", "${lifecycle.currentState}")
}
}
Expand All @@ -44,13 +46,15 @@ abstract class BindingActivity<T : ViewDataBinding>(@LayoutRes private val layou
try {
if (!loadingDialog.isShowing)
loadingDialog.show()
} catch (e: Exception) {}
} catch (e: Exception) {
}
}

fun dismissLoadingDialog() {
try {
if (loadingDialog.isShowing)
loadingDialog.dismiss()
} catch (e: Exception) {}
} catch (e: Exception) {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,5 @@ class LoadingDialog(context: Context, isCancelable: Boolean = false) : Dialog(co
setCancelable(isCancelable)

setContentView(R.layout.dialog_loading)

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.teamounce.ounce.data.local.singleton

object BaseValue {
const val baseUrl = "http://3.39.215.185:8080"
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.teamounce.ounce.data.remote.singleton

import com.teamounce.ounce.data.local.singleton.BaseValue
import com.teamounce.ounce.data.remote.api.MainService
import com.teamounce.ounce.util.AuthInterceptor
import okhttp3.OkHttpClient
Expand All @@ -8,7 +9,7 @@ import retrofit2.Retrofit
import retrofit2.converter.gson.GsonConverterFactory

object RetrofitObjects {
private const val BASE_URL = "http://13.125.2.249:8080"
private const val BASE_URL = BaseValue.baseUrl
private fun httpLoggingInterceptor(): HttpLoggingInterceptor {
val loggingInterceptor = HttpLoggingInterceptor()
loggingInterceptor.level = HttpLoggingInterceptor.Level.BODY
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/java/com/teamounce/ounce/di/RetrofitModule.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.teamounce.ounce.di

import com.teamounce.ounce.data.local.singleton.BaseValue
import com.teamounce.ounce.util.AuthInterceptor
import com.teamounce.ounce.util.TokenRefreshInterceptor
import dagger.Module
Expand Down Expand Up @@ -53,6 +54,6 @@ class RetrofitModule {
}

companion object {
private const val BASE_URL = "http://13.125.2.249:8080"
private const val BASE_URL = BaseValue.baseUrl
}
}
19 changes: 19 additions & 0 deletions app/src/main/java/com/teamounce/ounce/di/SingletonModule.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.teamounce.ounce.di

import android.content.Context
import com.teamounce.ounce.util.CatInfoStore
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object SingletonModule {
@Singleton
@Provides
fun provideCatInfoStore(@ApplicationContext context: Context): CatInfoStore =
CatInfoStore(context)
}
Original file line number Diff line number Diff line change
@@ -1,21 +1,37 @@
package com.teamounce.ounce.feed.model

import com.google.gson.annotations.SerializedName

data class ResponseFeedReviewData(
@SerializedName("data")
val data: List<Data>,
@SerializedName("responseMessage")
val responseMessage: String
) {
data class Data(
@SerializedName("createdDate")
val createdDate: String,
@SerializedName("manufacturer")
val manufacturer: String,
@SerializedName("memo")
val memo: String,
@SerializedName("myImg")
val myImg: String,
@SerializedName("preference")
val preference: Int,
@SerializedName("productImg")
val productImg: String,
@SerializedName("productName")
val productName: String,
@SerializedName("reviewIndex")
val reviewIndex: Int,
@SerializedName("tag1")
val tag1: String,
@SerializedName("tag2")
val tag2: String,
@SerializedName("tag3")
val tag3: String,
@SerializedName("updatedDate")
val updatedDate: String
)
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
package com.teamounce.ounce.feed.model

import com.google.gson.annotations.SerializedName

data class ResponseFilterData(
@SerializedName("data")
val data: Data,
@SerializedName("responseMessage")
val responseMessage: String
) {
data class Data(
@SerializedName("manu")
val manu: List<String>,
@SerializedName("tag")
val tag: List<String>,
@SerializedName("type")
val type: List<String>
)
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
package com.teamounce.ounce.login.model

data class RequestGoogleLogin(val token: String)
import com.google.gson.annotations.SerializedName

data class RequestGoogleLogin(
@SerializedName("token")
val token: String
)
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ class LoginViewModel @Inject constructor(

fun googleLogin(token: String) = viewModelScope.launch {
runCatching {
Log.d("google token : ", token)
loginRepository.googleLogin(token)
}.onSuccess {
OunceLocalRepository.apply {
Expand Down
36 changes: 13 additions & 23 deletions app/src/main/java/com/teamounce/ounce/main/BottomSheetAdapter.kt
Original file line number Diff line number Diff line change
@@ -1,27 +1,28 @@
package com.teamounce.ounce.main

import android.app.Activity
import android.content.Context
import android.content.ContextWrapper
import android.view.LayoutInflater
import android.view.ViewGroup
import android.widget.CompoundButton
import androidx.recyclerview.widget.RecyclerView
import com.teamounce.ounce.data.local.singleton.OunceLocalRepository
import com.teamounce.ounce.databinding.ItemBottomMainBinding
import com.teamounce.ounce.util.SharedPreferences
import com.teamounce.ounce.util.CatInfoStore

class BottomSheetAdapter(
private val catInfoStore: CatInfoStore,
private val listener: OnRefreshListener
) : RecyclerView.Adapter<BottomSheetAdapter.BottomSheetViewHolder>() {
fun interface OnRefreshListener {
fun update()
}

class BottomSheetAdapter(context: Context) :
RecyclerView.Adapter<BottomSheetAdapter.BottomSheetViewHolder>() {
val mContext = getActivity(context)
var bottomSheetProfileData = mutableListOf<BottomSheetProfileData>()
private var checkedRadioButton: CompoundButton? = null
private var mSelectedItem = -1
val bottomSheetFragment = BottomSheetFragment()

inner class BottomSheetViewHolder(var binding: ItemBottomMainBinding) :
RecyclerView.ViewHolder(binding.root) {
var sharedPreferences = SharedPreferences(mContext)

fun bind(
bottomSheetProfileData: BottomSheetProfileData,
Expand All @@ -31,13 +32,13 @@ class BottomSheetAdapter(context: Context) :
binding.bottomSheetProfileData = bottomSheetProfileData
binding.catSelectBtn.setOnCheckedChangeListener(checkedChangedListener)

if (position == sharedPreferences.getCatPositionSelected()) {
if (position == catInfoStore.getCatPositionSelected()) {
binding.catSelectBtn.isChecked = true
} else {
if (selectedPosition == position) {
binding.catSelectBtn.isChecked = true
changeCat(position)
sharedPreferences.setCatPositionSelected(position)
catInfoStore.setCatPositionSelected(position)
} else {
binding.catSelectBtn.isChecked = false
}
Expand Down Expand Up @@ -72,11 +73,8 @@ class BottomSheetAdapter(context: Context) :
}

fun changeCat(position: Int) {
if (mContext is MainActivity) {
OunceLocalRepository.catIndex = bottomSheetProfileData[position].catIndex
mContext.refreshData()
mContext.bottomSheetFragment.dismiss()
}
OunceLocalRepository.catIndex = bottomSheetProfileData[position].catIndex
listener.update()
}

private val checkedChangedListener =
Expand All @@ -93,12 +91,4 @@ class BottomSheetAdapter(context: Context) :
}

}

private fun getActivity(context: Context): Activity {
return when (context) {
is Activity -> context
is ContextWrapper -> getActivity(context.getBaseContext())
else -> error("Non Activity based context")
}
}
}
53 changes: 31 additions & 22 deletions app/src/main/java/com/teamounce/ounce/main/BottomSheetFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -10,70 +10,79 @@ import com.teamounce.ounce.R
import com.teamounce.ounce.data.local.singleton.OunceLocalRepository
import com.teamounce.ounce.data.remote.singleton.RetrofitObjects
import com.teamounce.ounce.databinding.BottomSheetMainBinding
import com.teamounce.ounce.util.SharedPreferences
import com.teamounce.ounce.util.CatInfoStore
import dagger.hilt.android.AndroidEntryPoint
import retrofit2.Call
import retrofit2.Response
import javax.inject.Inject


@AndroidEntryPoint
class BottomSheetFragment : BottomSheetDialogFragment() {
private lateinit var bottomSheetAdapter: BottomSheetAdapter
@Inject
lateinit var prefs: CatInfoStore
private var bottomSheetAdapter: BottomSheetAdapter? = null
private var bottomSheetDatas = mutableListOf<BottomSheetProfileData>()
private lateinit var prefs: SharedPreferences
private var _binding: BottomSheetMainBinding? = null
private val binding get() = _binding!!
var listener: BottomSheetAdapter.OnRefreshListener? = null

override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?,
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
): View {
_binding = BottomSheetMainBinding.inflate(inflater, container, false)
setAdapter()
return binding.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
prefs = SharedPreferences(view.context)
}

override fun getTheme(): Int = R.style.BottomSheetDialogTheme

private fun setAdapter() {
bottomSheetAdapter = BottomSheetAdapter(requireContext())
bottomSheetAdapter = BottomSheetAdapter(prefs) {
listener?.update()
dismiss()
}
binding.recyclerviewCatlist.adapter = bottomSheetAdapter
loadBottomsheetDatas()
}

private fun loadBottomsheetDatas() {
RetrofitObjects.getMainService()
.bottomSheetProfileRetrofit(OunceLocalRepository.catIndex)
.enqueue(object :
retrofit2.Callback<BottomSheetResponseData> {
.enqueue(object : retrofit2.Callback<BottomSheetResponseData> {
override fun onFailure(call: Call<BottomSheetResponseData>, t: Throwable) {
Log.d("서버 실패", "${t}")
Log.d("서버 실패", "$t")
}

override fun onResponse(
call: Call<BottomSheetResponseData>,
response: Response<BottomSheetResponseData>
) {
if (response.isSuccessful) {
bottomSheetDatas = response.body()!!.data

response.body()!!.data.forEach{
if(it.state) OunceLocalRepository.catIndex = it.catIndex
response.body()?.data?.forEach {
if (it.state) OunceLocalRepository.catIndex = it.catIndex
}

bottomSheetAdapter.bottomSheetProfileData = bottomSheetDatas
bottomSheetAdapter?.bottomSheetProfileData = bottomSheetDatas
prefs.setCatList(bottomSheetDatas)
bottomSheetAdapter.notifyDataSetChanged()
bottomSheetAdapter?.notifyDataSetChanged()
}
}
})
}

override fun dismiss() {
super.dismiss()
override fun onDestroyView() {
bottomSheetAdapter = null
super.onDestroyView()
}


companion object {
fun newInstance(listener: BottomSheetAdapter.OnRefreshListener) =
BottomSheetFragment().apply {
this.listener = listener
}
}
}
Loading

0 comments on commit 34beac1

Please sign in to comment.