Skip to content

Commit

Permalink
Fixed Bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
seunggyu97 committed Mar 23, 2023
1 parent 156fb05 commit d8f01c8
Show file tree
Hide file tree
Showing 31 changed files with 1,750 additions and 321 deletions.
8 changes: 8 additions & 0 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,14 @@
android:name=".ui.MatchLocationMapActivity"
android:windowSoftInputMode="adjustNothing"
android:exported="true" />
<activity
android:name=".ui.MatchDetailPageActivity"
android:windowSoftInputMode="adjustResize"
android:exported="true" />
<activity
android:name=".ui.ReportMatchActivity"
android:windowSoftInputMode="adjustResize"
android:exported="true" />
</application>

</manifest>
62 changes: 62 additions & 0 deletions app/src/main/java/com/seunggyu/stitch/Util/SnackBarLabelCustom.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package com.seunggyu.stitch.Util

import android.content.res.Resources
import android.util.TypedValue
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.databinding.DataBindingUtil
import com.google.android.material.snackbar.BaseTransientBottomBar.ANIMATION_MODE_SLIDE
import com.google.android.material.snackbar.Snackbar
import com.seunggyu.stitch.R
import com.seunggyu.stitch.databinding.SnackbarCustomBinding
import com.seunggyu.stitch.databinding.SnackbarCustomLabelBinding

class SnackBarLabelCustom(view: View, private val message: String) {

companion object {

fun make(view: View, message: String) = SnackBarLabelCustom(view, message)
}

private val context = view.context
private val snackbar = Snackbar.make(view, "", 5000)
private val snackbarLayout = snackbar.view as Snackbar.SnackbarLayout

private val inflater = LayoutInflater.from(context)
private val snackbarBinding: SnackbarCustomLabelBinding = DataBindingUtil.inflate(inflater, R.layout.snackbar_custom_label, null, false)

init {
initView()
initData()
}

private fun initView() {
with(snackbarLayout) {
removeAllViews()
val mlayoutParams = snackbarLayout.layoutParams as ViewGroup.MarginLayoutParams
mlayoutParams.setMargins(16.dpToPx(), 0, 16.dpToPx(), 100.dpToPx())
layoutParams = mlayoutParams
setPadding(0, 0, 0, 0)
setBackgroundColor(ContextCompat.getColor(context, android.R.color.transparent))
addView(snackbarBinding.root, 0)
}
}

private fun initData() {
snackbarBinding.tvSnackbarMsg.text = message
}

fun show() {
snackbar.animationMode = ANIMATION_MODE_SLIDE
snackbar.show()
}

fun Int.dpToPx(): Int {
return TypedValue.applyDimension(
TypedValue.COMPLEX_UNIT_DIP, this.toFloat(),
Resources.getSystem().displayMetrics
).toInt()
}
}
14 changes: 7 additions & 7 deletions app/src/main/java/com/seunggyu/stitch/data/RetrofitApi.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.seunggyu.stitch.data

import com.seunggyu.stitch.BuildConfig
import com.seunggyu.stitch.Util.Constants.SERVER_ADDRESS
import com.seunggyu.stitch.data.RetrofitService
import com.squareup.moshi.Moshi
import com.squareup.moshi.kotlin.reflect.KotlinJsonAdapterFactory
import okhttp3.OkHttpClient
Expand All @@ -13,9 +11,11 @@ import retrofit2.converter.moshi.MoshiConverterFactory
object RetrofitApi {
private const val BASE_URL = SERVER_ADDRESS

private val moshi: Moshi = Moshi.Builder()
.add(KotlinJsonAdapterFactory())
.build()
private val moshi: Moshi by lazy {
Moshi.Builder()
.add(KotlinJsonAdapterFactory())
.build()
}

private val okHttpClient: OkHttpClient by lazy {
OkHttpClient.Builder()
Expand All @@ -27,13 +27,13 @@ object RetrofitApi {

private val retrofit: Retrofit by lazy {
Retrofit.Builder()
.baseUrl(BASE_URL)
.addConverterFactory(MoshiConverterFactory.create(moshi))
.client(okHttpClient)
.baseUrl(BASE_URL)
.build()
}

val retrofitService: RetrofitService by lazy {
retrofit.create(RetrofitService::class.java)
}
}
}
19 changes: 19 additions & 0 deletions app/src/main/java/com/seunggyu/stitch/data/RetrofitService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package com.seunggyu.stitch.data

import com.seunggyu.stitch.data.model.User
import com.seunggyu.stitch.data.model.request.CreateNewMatchRequest
import com.seunggyu.stitch.data.model.request.JoinMatchRequest
import com.seunggyu.stitch.data.model.request.ReportRequest
import com.seunggyu.stitch.data.model.request.SignupRequest
import com.seunggyu.stitch.data.model.response.*
import retrofit2.Response
Expand All @@ -25,6 +27,23 @@ interface RetrofitService {
@Body createMatchRequest: CreateNewMatchRequest,
): Response<CreateNewMatchResponse>

@POST("report")
suspend fun report(
@Body reportRequest: ReportRequest,
): Response<ReportResponse>

@DELETE("match/leave")
suspend fun quitMatch(
@Query("memberId") memberId: String,
@Query("matchId") matchId: String,
): Response<Object>

@PUT("match/join/id={id}")
suspend fun joinMatch(
@Path("id") id: String,
@Body joinMatchRequest: JoinMatchRequest,
): Response<String>

// 홈화면 매치 가져오기
@GET("match/home")
suspend fun getHomeData(): Response<HomeDataResponse>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ data class CreateNewMatchRequest(
val numOfMembsers: Int?,
@Json(name = "startTime")
val startTime: String?,
@Json(name = "isTeach")
val isTeach: Boolean?,
@Json(name = "teach")
val teach: Boolean?,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.seunggyu.stitch.data.model.request


import com.squareup.moshi.Json

data class JoinMatchRequest(
@Json(name = "id")
val id: String?
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.seunggyu.stitch.data.model.request


import com.squareup.moshi.Json

data class ReportRequest(
@Json(name = "matchId")
val matchId: String?,
@Json(name = "memberId")
val memberId: String?,
@Json(name = "reason")
val reason: String?,
@Json(name = "reporterId")
val reporterId: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.squareup.moshi.Json

data class MatchDetailResponse(
@Json(name = "joinedMembers")
val joinedMembers: List<JoinedMember?>?,
val joinedMembers: List<JoinedMember>?,
@Json(name = "match")
val match: Match?
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.seunggyu.stitch.data.model.response


import com.squareup.moshi.Json

data class ReportResponse(
@Json(name = "id")
val id: String?,
@Json(name = "matchId")
val matchId: String?,
@Json(name = "memberId")
val memberId: String?,
@Json(name = "reason")
val reason: String?,
@Json(name = "reporterId")
val reporterId: String?,
@Json(name = "sk")
val sk: String?,
@Json(name = "type")
val type: String?
)
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.seunggyu.stitch.dialog
import android.app.Dialog
import android.content.Context
import android.os.Bundle
import androidx.core.content.ContextCompat
import androidx.databinding.DataBindingUtil
import com.seunggyu.stitch.R
import com.seunggyu.stitch.databinding.DialogCustomAlertBinding
Expand All @@ -12,7 +13,8 @@ class CustomAlertDialog(
private val _title: String,
private val _description: String,
private val _negativeText: String,
private val _positiveText: String
private val _positiveText: String,
private val _color: String,
) : Dialog(context) {

private lateinit var binding: DialogCustomAlertBinding
Expand All @@ -38,6 +40,14 @@ class CustomAlertDialog(
negativeText = _negativeText
positiveText = _positiveText

when(_color) {
"error" -> {
binding.btnAlertPositive.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.button_round_100_stroke_75_error))
binding.btnAlertPositive.text = "삭제하기"
binding.btnAlertPositive.setTextColor(ContextCompat.getColor(context, R.color.white))
}
}

btnAlertNegative.setOnClickListener {
listener?.invoke(false)
dismiss()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package com.seunggyu.stitch.dialog

import android.app.Dialog
import android.content.Context
import android.os.Bundle
import androidx.core.content.ContextCompat
import androidx.databinding.DataBindingUtil
import com.seunggyu.stitch.R
import com.seunggyu.stitch.databinding.DialogCustomAlertBinding

class CustomAlertLabelDialog(
context: Context,
private val _title: String,
private val _description: String,
private val _negativeText: String,
private val _positiveText: String,
private val _color: String,
) : Dialog(context) {

private lateinit var binding: DialogCustomAlertBinding

private var listener: ((Boolean) -> Unit)? = null

fun setDialogListener(listener: (Boolean) -> Unit) {
this.listener = listener
}

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = DialogCustomAlertBinding.inflate(layoutInflater)
setContentView(binding.root)

init()
}

fun init() {
with(binding) {
title = _title
description = _description
negativeText = _negativeText
positiveText = _positiveText

when(_color) {
"error" -> {
binding.btnAlertPositive.setBackgroundDrawable(ContextCompat.getDrawable(context, R.drawable.button_round_100_stroke_75_error))
binding.btnAlertPositive.text = "삭제하기"
binding.btnAlertPositive.setTextColor(ContextCompat.getColor(context, R.color.white))
}
}

btnAlertNegative.setOnClickListener {
listener?.invoke(false)
dismiss()
}

btnAlertPositive.setOnClickListener {
listener?.invoke(true)
dismiss()
}
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import android.content.Intent
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.activityViewModels
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
import com.seunggyu.stitch.GlobalApplication
import com.seunggyu.stitch.databinding.DialogBottomsheetMatchDetailTimeBinding
import com.seunggyu.stitch.databinding.DialogBottomsheetMenuMemberBinding
import com.seunggyu.stitch.ui.ReportMatchActivity
import com.seunggyu.stitch.viewModel.CreateNewMatchViewModel

// accessType
// 0 : 매치에서 참여자인경우 (신고하기, 매치취소하기, 취소)
// 1 : 매치에서 참여자가 아닌경우 (신고하기, 취소)
// 2 : 프로필 상대방 신고하는 경우 (신고하기, 취소)

class MenuMemberBottomSheetDialog(accessType: Int) :
BottomSheetDialogFragment() {
private lateinit var binding: DialogBottomsheetMenuMemberBinding
private val viewModel by activityViewModels<MatchDetailPageViewModel>()

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View {
super.onCreateView(inflater, container, savedInstanceState)
binding = DialogBottomsheetMenuMemberBinding.inflate(inflater, container, false)

dialogInit()

return binding.root
}

private fun dialogInit() {
binding.btnMenuReport?.setOnClickListener {
val intent = Intent(requireContext(), ReportMatchActivity::class.java)
intent.putExtra("matchId", viewModel.passedMatchId.toString())
intent.putExtra("memberId", "0")
intent.putExtra("reporterId", GlobalApplication.prefs.getString("userId"))
startActivity(intent)
dismiss()
}
binding.btnMenuQuit?.setOnClickListener {
viewModel.quitMatch()
dismiss()
}
binding.btnMenuCancel?.setOnClickListener {
dismiss()
}
}
}
Loading

0 comments on commit d8f01c8

Please sign in to comment.