parent
6b466ac7d7
commit
49209c4c4a
|
@ -29,7 +29,6 @@ import androidx.appcompat.widget.PopupMenu
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager
|
import androidx.recyclerview.widget.LinearLayoutManager
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
import androidx.recyclerview.widget.RecyclerView
|
||||||
import coil.load
|
|
||||||
import coil.transform.CircleCropTransformation
|
import coil.transform.CircleCropTransformation
|
||||||
import com.github.dhaval2404.imagepicker.ImagePicker
|
import com.github.dhaval2404.imagepicker.ImagePicker
|
||||||
import com.google.gson.Gson
|
import com.google.gson.Gson
|
||||||
|
@ -696,37 +695,44 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||||
|
|
||||||
if (response.creatorId == SharedPreferenceManager.userId) {
|
if (response.creatorId == SharedPreferenceManager.userId) {
|
||||||
binding.ivEdit.setOnClickListener {
|
binding.ivEdit.setOnClickListener {
|
||||||
roomInfoEditDialog.setRoomInfo(response.title, response.notice)
|
viewModel.getAllMenuPreset {
|
||||||
roomInfoEditDialog.setCoverImageUrl(response.coverImageUrl)
|
roomInfoEditDialog.setRoomInfo(response.title, response.notice)
|
||||||
roomInfoEditDialog.setConfirmAction { newTitle, newContent, newCoverImageUri ->
|
roomInfoEditDialog.setCoverImageUrl(response.coverImageUrl)
|
||||||
viewModel.editLiveRoomInfo(
|
roomInfoEditDialog.setMenuPreset(it)
|
||||||
response.roomId,
|
roomInfoEditDialog.setConfirmAction { newTitle, newContent, newCoverImageUri, isActivateMenu, menuId, menu ->
|
||||||
newTitle,
|
viewModel.editLiveRoomInfo(
|
||||||
newContent,
|
response.roomId,
|
||||||
newCoverImageUri,
|
newTitle,
|
||||||
onSuccess = {
|
newContent,
|
||||||
binding.tvTitle.text = newTitle
|
newCoverImageUri,
|
||||||
setNoticeAndClickableUrl(binding.tvNotice, newContent)
|
isActivateMenu,
|
||||||
|
menuId,
|
||||||
|
menu,
|
||||||
|
onSuccess = {
|
||||||
|
Toast.makeText(
|
||||||
|
applicationContext,
|
||||||
|
"라이브 정보가 수정되었습니다.",
|
||||||
|
Toast.LENGTH_LONG
|
||||||
|
).show()
|
||||||
|
|
||||||
if (newCoverImageUri != null) {
|
agora.sendRawMessageToGroup(
|
||||||
binding.ivCover.load(newCoverImageUri)
|
rawMessage = Gson().toJson(
|
||||||
|
LiveRoomChatRawMessage(
|
||||||
|
type = LiveRoomChatRawMessageType.EDIT_ROOM_INFO,
|
||||||
|
message = "",
|
||||||
|
can = 0,
|
||||||
|
donationMessage = ""
|
||||||
|
)
|
||||||
|
).toByteArray()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
agora.sendRawMessageToGroup(
|
handler.post {
|
||||||
rawMessage = Gson().toJson(
|
roomInfoEditDialog.show(screenWidth)
|
||||||
LiveRoomChatRawMessage(
|
}
|
||||||
type = LiveRoomChatRawMessageType.EDIT_ROOM_INFO,
|
|
||||||
message = "",
|
|
||||||
can = 0,
|
|
||||||
donationMessage = ""
|
|
||||||
)
|
|
||||||
).toByteArray()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
roomInfoEditDialog.show(screenWidth)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.ivEdit.visibility = View.VISIBLE
|
binding.ivEdit.visibility = View.VISIBLE
|
||||||
|
@ -811,6 +817,7 @@ class LiveRoomActivity : BaseActivity<ActivityLiveRoomBinding>(ActivityLiveRoomB
|
||||||
binding.tvMenuPan.visibility = View.VISIBLE
|
binding.tvMenuPan.visibility = View.VISIBLE
|
||||||
binding.tvMenuPanDetail.text = response.menuPan
|
binding.tvMenuPanDetail.text = response.menuPan
|
||||||
} else {
|
} else {
|
||||||
|
viewModel.toggleShowMenuPan(false)
|
||||||
binding.tvMenuPan.visibility = View.GONE
|
binding.tvMenuPan.visibility = View.GONE
|
||||||
binding.tvMenuPanDetail.text = ""
|
binding.tvMenuPanDetail.text = ""
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,7 @@ import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||||
import kr.co.vividnext.sodalive.live.LiveRepository
|
import kr.co.vividnext.sodalive.live.LiveRepository
|
||||||
import kr.co.vividnext.sodalive.live.room.donation.GetLiveRoomDonationStatusResponse
|
import kr.co.vividnext.sodalive.live.room.donation.GetLiveRoomDonationStatusResponse
|
||||||
import kr.co.vividnext.sodalive.live.room.info.GetRoomInfoResponse
|
import kr.co.vividnext.sodalive.live.room.info.GetRoomInfoResponse
|
||||||
|
import kr.co.vividnext.sodalive.live.room.menu.GetMenuPresetResponse
|
||||||
import kr.co.vividnext.sodalive.live.room.profile.GetLiveRoomUserProfileResponse
|
import kr.co.vividnext.sodalive.live.room.profile.GetLiveRoomUserProfileResponse
|
||||||
import kr.co.vividnext.sodalive.live.room.update.EditLiveRoomInfoRequest
|
import kr.co.vividnext.sodalive.live.room.update.EditLiveRoomInfoRequest
|
||||||
import kr.co.vividnext.sodalive.live.roulette.RouletteItem
|
import kr.co.vividnext.sodalive.live.roulette.RouletteItem
|
||||||
|
@ -363,9 +364,14 @@ class LiveRoomViewModel(
|
||||||
_isShowNotice.value = !isShowNotice.value!!
|
_isShowNotice.value = !isShowNotice.value!!
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toggleShowMenuPan() {
|
fun toggleShowMenuPan(isShowMenuPan: Boolean? = null) {
|
||||||
_isShowNotice.value = false
|
_isShowNotice.value = false
|
||||||
_isShowMenuPan.value = !isShowMenuPan.value!!
|
|
||||||
|
if (isShowMenuPan != null) {
|
||||||
|
_isShowMenuPan.value = isShowMenuPan
|
||||||
|
} else {
|
||||||
|
_isShowMenuPan.value = !this.isShowMenuPan.value!!
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun toggleBackgroundImage() {
|
fun toggleBackgroundImage() {
|
||||||
|
@ -377,6 +383,9 @@ class LiveRoomViewModel(
|
||||||
newTitle: String,
|
newTitle: String,
|
||||||
newContent: String,
|
newContent: String,
|
||||||
newCoverImageUri: Uri? = null,
|
newCoverImageUri: Uri? = null,
|
||||||
|
isActivateMenu: Boolean?,
|
||||||
|
menuId: Long,
|
||||||
|
menu: String,
|
||||||
onSuccess: () -> Unit
|
onSuccess: () -> Unit
|
||||||
) {
|
) {
|
||||||
val request = EditLiveRoomInfoRequest(
|
val request = EditLiveRoomInfoRequest(
|
||||||
|
@ -392,17 +401,25 @@ class LiveRoomViewModel(
|
||||||
},
|
},
|
||||||
numberOfPeople = null,
|
numberOfPeople = null,
|
||||||
beginDateTimeString = null,
|
beginDateTimeString = null,
|
||||||
timezone = null
|
timezone = null,
|
||||||
|
menuPanId = if (isActivateMenu == true) menuId else 0,
|
||||||
|
menuPan = if (isActivateMenu == true) menu else "",
|
||||||
|
isActiveMenuPan = isActivateMenu
|
||||||
)
|
)
|
||||||
|
|
||||||
val requestJson = if (request.title != null || request.notice != null) {
|
val requestJson = if (
|
||||||
|
request.title != null ||
|
||||||
|
request.notice != null ||
|
||||||
|
request.isActiveMenuPan != null ||
|
||||||
|
request.menuPan.isNotBlank()
|
||||||
|
) {
|
||||||
Gson().toJson(request)
|
Gson().toJson(request)
|
||||||
} else {
|
} else {
|
||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
val coverImage = if (newCoverImageUri != null) {
|
val coverImage = if (newCoverImageUri != null) {
|
||||||
val file = File(getRealPathFromURI(newCoverImageUri!!))
|
val file = File(getRealPathFromURI(newCoverImageUri))
|
||||||
MultipartBody.Part.createFormData(
|
MultipartBody.Part.createFormData(
|
||||||
"coverImage",
|
"coverImage",
|
||||||
file.name,
|
file.name,
|
||||||
|
@ -637,7 +654,7 @@ class LiveRoomViewModel(
|
||||||
{
|
{
|
||||||
_isLoading.value = false
|
_isLoading.value = false
|
||||||
if (it.success && it.data != null) {
|
if (it.success && it.data != null) {
|
||||||
_userProfileLiveData.value = it.data!!
|
_userProfileLiveData.value = it.data
|
||||||
onSuccess()
|
onSuccess()
|
||||||
} else {
|
} else {
|
||||||
if (it.message != null) {
|
if (it.message != null) {
|
||||||
|
@ -910,6 +927,40 @@ class LiveRoomViewModel(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun getAllMenuPreset(onSuccess: (List<GetMenuPresetResponse>) -> Unit) {
|
||||||
|
_isLoading.value = true
|
||||||
|
|
||||||
|
compositeDisposable.add(
|
||||||
|
repository.getAllMenu(
|
||||||
|
creatorId = SharedPreferenceManager.userId,
|
||||||
|
token = "Bearer ${SharedPreferenceManager.token}"
|
||||||
|
)
|
||||||
|
.subscribeOn(Schedulers.io())
|
||||||
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
|
.subscribe(
|
||||||
|
{
|
||||||
|
if (it.success) {
|
||||||
|
onSuccess(it.data ?: listOf())
|
||||||
|
} else {
|
||||||
|
if (it.message != null) {
|
||||||
|
_toastLiveData.postValue(it.message)
|
||||||
|
} else {
|
||||||
|
_toastLiveData.postValue(
|
||||||
|
"알 수 없는 오류가 발생했습니다. 다시 시도해 주세요."
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_isLoading.value = false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
_isLoading.value = false
|
||||||
|
it.message?.let { message -> Logger.e(message) }
|
||||||
|
_toastLiveData.postValue("알 수 없는 오류가 발생했습니다. 다시 시도해 주세요.")
|
||||||
|
}
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
private fun randomSelectRouletteItem(
|
private fun randomSelectRouletteItem(
|
||||||
can: Int,
|
can: Int,
|
||||||
items: List<RouletteItem>,
|
items: List<RouletteItem>,
|
||||||
|
|
|
@ -731,13 +731,13 @@ class LiveRoomCreateActivity : BaseActivity<ActivityLiveRoomCreateBinding>(
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun selectMenuPresetButton(
|
private fun selectMenuPresetButton(
|
||||||
ivSelectRoulette: ImageView,
|
ivSelectMenuPreset: ImageView,
|
||||||
llSelectRoulette: LinearLayout,
|
llSelectMenuPreset: LinearLayout,
|
||||||
tvSelectRoulette: TextView
|
tvSelectMenuPreset: TextView
|
||||||
) {
|
) {
|
||||||
ivSelectRoulette.visibility = View.VISIBLE
|
ivSelectMenuPreset.visibility = View.VISIBLE
|
||||||
llSelectRoulette.setBackgroundResource(R.drawable.bg_round_corner_6_7_3bb9f1)
|
llSelectMenuPreset.setBackgroundResource(R.drawable.bg_round_corner_6_7_3bb9f1)
|
||||||
tvSelectRoulette.setTextColor(
|
tvSelectMenuPreset.setTextColor(
|
||||||
ContextCompat.getColor(
|
ContextCompat.getColor(
|
||||||
applicationContext,
|
applicationContext,
|
||||||
R.color.color_eeeeee
|
R.color.color_eeeeee
|
||||||
|
|
|
@ -11,7 +11,7 @@ import kr.co.vividnext.sodalive.base.BaseViewModel
|
||||||
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
|
||||||
import kr.co.vividnext.sodalive.live.LiveRepository
|
import kr.co.vividnext.sodalive.live.LiveRepository
|
||||||
import kr.co.vividnext.sodalive.live.room.LiveRoomType
|
import kr.co.vividnext.sodalive.live.room.LiveRoomType
|
||||||
import kr.co.vividnext.sodalive.live.room.menu.GetMenuResponse
|
import kr.co.vividnext.sodalive.live.room.menu.GetMenuPresetResponse
|
||||||
import okhttp3.MediaType.Companion.toMediaType
|
import okhttp3.MediaType.Companion.toMediaType
|
||||||
import okhttp3.MultipartBody
|
import okhttp3.MultipartBody
|
||||||
import okhttp3.RequestBody.Companion.asRequestBody
|
import okhttp3.RequestBody.Companion.asRequestBody
|
||||||
|
@ -89,7 +89,7 @@ class LiveRoomCreateViewModel(
|
||||||
|
|
||||||
private var menuId = 0L
|
private var menuId = 0L
|
||||||
var menu = ""
|
var menu = ""
|
||||||
val menuList = mutableListOf<GetMenuResponse>()
|
val menuList = mutableListOf<GetMenuPresetResponse>()
|
||||||
|
|
||||||
fun setRoomType(roomType: LiveRoomType) {
|
fun setRoomType(roomType: LiveRoomType) {
|
||||||
if (_roomTypeLiveData.value!! != roomType) {
|
if (_roomTypeLiveData.value!! != roomType) {
|
||||||
|
@ -346,8 +346,6 @@ class LiveRoomCreateViewModel(
|
||||||
menuList.clear()
|
menuList.clear()
|
||||||
menuList.addAll(data ?: listOf())
|
menuList.addAll(data ?: listOf())
|
||||||
selectMenuPreset(SelectedMenu.MENU_1)
|
selectMenuPreset(SelectedMenu.MENU_1)
|
||||||
|
|
||||||
Logger.e("data: $data")
|
|
||||||
} else {
|
} else {
|
||||||
if (it.message != null) {
|
if (it.message != null) {
|
||||||
_toastLiveData.postValue(it.message)
|
_toastLiveData.postValue(it.message)
|
||||||
|
|
|
@ -2,7 +2,8 @@ package kr.co.vividnext.sodalive.live.room.menu
|
||||||
|
|
||||||
import com.google.gson.annotations.SerializedName
|
import com.google.gson.annotations.SerializedName
|
||||||
|
|
||||||
data class GetMenuResponse(
|
data class GetMenuPresetResponse(
|
||||||
@SerializedName("id") val id: Long,
|
@SerializedName("id") val id: Long,
|
||||||
@SerializedName("menu") val menu: String
|
@SerializedName("menu") val menu: String,
|
||||||
|
@SerializedName("isActive") val isActive: Boolean
|
||||||
)
|
)
|
|
@ -11,5 +11,5 @@ interface MenuApi {
|
||||||
fun getAllMenu(
|
fun getAllMenu(
|
||||||
@Query("creatorId") creatorId: Long,
|
@Query("creatorId") creatorId: Long,
|
||||||
@Header("Authorization") authHeader: String
|
@Header("Authorization") authHeader: String
|
||||||
): Single<ApiResponse<List<GetMenuResponse>>>
|
): Single<ApiResponse<List<GetMenuPresetResponse>>>
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,5 +7,8 @@ data class EditLiveRoomInfoRequest(
|
||||||
@SerializedName("notice") val notice: String?,
|
@SerializedName("notice") val notice: String?,
|
||||||
@SerializedName("numberOfPeople") val numberOfPeople: Int?,
|
@SerializedName("numberOfPeople") val numberOfPeople: Int?,
|
||||||
@SerializedName("beginDateTimeString") val beginDateTimeString: String?,
|
@SerializedName("beginDateTimeString") val beginDateTimeString: String?,
|
||||||
@SerializedName("timezone") val timezone: String?
|
@SerializedName("timezone") val timezone: String?,
|
||||||
|
@SerializedName("menuPanId") val menuPanId: Long = 0,
|
||||||
|
@SerializedName("menuPan") val menuPan: String = "",
|
||||||
|
@SerializedName("isActiveMenuPan") val isActiveMenuPan: Boolean? = null
|
||||||
)
|
)
|
||||||
|
|
|
@ -1,20 +1,29 @@
|
||||||
package kr.co.vividnext.sodalive.live.room.update
|
package kr.co.vividnext.sodalive.live.room.update
|
||||||
|
|
||||||
import android.app.Activity
|
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
import android.graphics.drawable.ColorDrawable
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.View
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
|
import android.widget.ImageView
|
||||||
|
import android.widget.LinearLayout
|
||||||
|
import android.widget.TextView
|
||||||
|
import android.widget.Toast
|
||||||
import androidx.appcompat.app.AlertDialog
|
import androidx.appcompat.app.AlertDialog
|
||||||
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.lifecycle.MutableLiveData
|
||||||
import coil.load
|
import coil.load
|
||||||
import coil.transform.RoundedCornersTransformation
|
import coil.transform.RoundedCornersTransformation
|
||||||
import kr.co.vividnext.sodalive.R
|
import kr.co.vividnext.sodalive.R
|
||||||
import kr.co.vividnext.sodalive.databinding.DialogLiveRoomInfoUpdateBinding
|
import kr.co.vividnext.sodalive.databinding.DialogLiveRoomInfoUpdateBinding
|
||||||
import kr.co.vividnext.sodalive.extensions.dpToPx
|
import kr.co.vividnext.sodalive.extensions.dpToPx
|
||||||
|
import kr.co.vividnext.sodalive.live.room.create.LiveRoomCreateViewModel
|
||||||
|
import kr.co.vividnext.sodalive.live.room.menu.GetMenuPresetResponse
|
||||||
|
|
||||||
class LiveRoomInfoEditDialog(
|
class LiveRoomInfoEditDialog(
|
||||||
activity: Activity,
|
private val activity: AppCompatActivity,
|
||||||
layoutInflater: LayoutInflater,
|
layoutInflater: LayoutInflater,
|
||||||
onClickImagePicker: () -> Unit
|
onClickImagePicker: () -> Unit
|
||||||
) {
|
) {
|
||||||
|
@ -24,6 +33,17 @@ class LiveRoomInfoEditDialog(
|
||||||
private var coverImageUrl: String? = null
|
private var coverImageUrl: String? = null
|
||||||
private var coverImageUri: Uri? = null
|
private var coverImageUri: Uri? = null
|
||||||
|
|
||||||
|
private var menuId = 0L
|
||||||
|
private val menuList = mutableListOf<GetMenuPresetResponse>()
|
||||||
|
|
||||||
|
private val isActivateMenuLiveData = MutableLiveData(false)
|
||||||
|
private val selectedMenuLiveData = MutableLiveData<LiveRoomCreateViewModel.SelectedMenu>()
|
||||||
|
|
||||||
|
private var menu: String = ""
|
||||||
|
private var isActivateMenu: Boolean? = null
|
||||||
|
|
||||||
|
private lateinit var selectedMenu: LiveRoomCreateViewModel.SelectedMenu
|
||||||
|
|
||||||
init {
|
init {
|
||||||
val dialogBuilder = AlertDialog.Builder(activity)
|
val dialogBuilder = AlertDialog.Builder(activity)
|
||||||
dialogBuilder.setView(dialogView.root)
|
dialogBuilder.setView(dialogView.root)
|
||||||
|
@ -35,6 +55,60 @@ class LiveRoomInfoEditDialog(
|
||||||
dialogView.ivPhotoPicker.setOnClickListener { onClickImagePicker() }
|
dialogView.ivPhotoPicker.setOnClickListener { onClickImagePicker() }
|
||||||
dialogView.ivClose.setOnClickListener { alertDialog.dismiss() }
|
dialogView.ivClose.setOnClickListener { alertDialog.dismiss() }
|
||||||
dialogView.tvCancel.setOnClickListener { alertDialog.dismiss() }
|
dialogView.tvCancel.setOnClickListener { alertDialog.dismiss() }
|
||||||
|
|
||||||
|
dialogView.ivSwitch.setOnClickListener {
|
||||||
|
isActivateMenuLiveData.value = !isActivateMenuLiveData.value!!
|
||||||
|
isActivateMenu = isActivateMenuLiveData.value!!
|
||||||
|
|
||||||
|
if (selectedMenuLiveData.value == null) {
|
||||||
|
selectMenuPreset(LiveRoomCreateViewModel.SelectedMenu.MENU_1)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dialogView.llSelectMenu1.setOnClickListener {
|
||||||
|
selectMenuPreset(LiveRoomCreateViewModel.SelectedMenu.MENU_1)
|
||||||
|
}
|
||||||
|
|
||||||
|
dialogView.llSelectMenu2.setOnClickListener {
|
||||||
|
selectMenuPreset(LiveRoomCreateViewModel.SelectedMenu.MENU_2)
|
||||||
|
}
|
||||||
|
|
||||||
|
dialogView.llSelectMenu3.setOnClickListener {
|
||||||
|
selectMenuPreset(LiveRoomCreateViewModel.SelectedMenu.MENU_3)
|
||||||
|
}
|
||||||
|
|
||||||
|
selectedMenuLiveData.observe(activity) {
|
||||||
|
deselectAllMenuPreset()
|
||||||
|
|
||||||
|
when (it) {
|
||||||
|
LiveRoomCreateViewModel.SelectedMenu.MENU_2 -> selectMenuPresetButton(
|
||||||
|
dialogView.ivSelectMenu2,
|
||||||
|
dialogView.llSelectMenu2,
|
||||||
|
dialogView.tvSelectMenu2
|
||||||
|
)
|
||||||
|
|
||||||
|
LiveRoomCreateViewModel.SelectedMenu.MENU_3 -> selectMenuPresetButton(
|
||||||
|
dialogView.ivSelectMenu3,
|
||||||
|
dialogView.llSelectMenu3,
|
||||||
|
dialogView.tvSelectMenu3
|
||||||
|
)
|
||||||
|
|
||||||
|
else -> selectMenuPresetButton(
|
||||||
|
dialogView.ivSelectMenu1,
|
||||||
|
dialogView.llSelectMenu1,
|
||||||
|
dialogView.tvSelectMenu1
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
isActivateMenuLiveData.observe(activity) {
|
||||||
|
if (it) {
|
||||||
|
dialogView.llEditMenu.visibility = View.VISIBLE
|
||||||
|
dialogView.ivSwitch.setImageResource(R.drawable.btn_toggle_on_big)
|
||||||
|
} else {
|
||||||
|
dialogView.llEditMenu.visibility = View.GONE
|
||||||
|
dialogView.ivSwitch.setImageResource(R.drawable.btn_toggle_off_big)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setRoomInfo(
|
fun setRoomInfo(
|
||||||
|
@ -63,13 +137,47 @@ class LiveRoomInfoEditDialog(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setConfirmAction(confirmAction: (String, String, Uri?) -> Unit) {
|
fun setMenuPreset(menuList: List<GetMenuPresetResponse>) {
|
||||||
|
this.menuList.clear()
|
||||||
|
this.isActivateMenu = null
|
||||||
|
this.menuList.addAll(menuList)
|
||||||
|
this.selectedMenuLiveData.value = null
|
||||||
|
menuList.forEachIndexed { index, menuPreset ->
|
||||||
|
if (menuPreset.isActive) {
|
||||||
|
selectedMenu = when (index) {
|
||||||
|
1 -> LiveRoomCreateViewModel.SelectedMenu.MENU_2
|
||||||
|
2 -> LiveRoomCreateViewModel.SelectedMenu.MENU_3
|
||||||
|
else -> LiveRoomCreateViewModel.SelectedMenu.MENU_1
|
||||||
|
}
|
||||||
|
|
||||||
|
isActivateMenuLiveData.value = true
|
||||||
|
selectMenuPreset(selectedMenu)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun setConfirmAction(confirmAction: (String, String, Uri?, Boolean?, Long, String) -> Unit) {
|
||||||
dialogView.tvConfirm.setOnClickListener {
|
dialogView.tvConfirm.setOnClickListener {
|
||||||
alertDialog.dismiss()
|
alertDialog.dismiss()
|
||||||
|
|
||||||
val newTitle = dialogView.etTitle.text.toString()
|
val newTitle = dialogView.etTitle.text.toString()
|
||||||
val newContent = dialogView.etContent.text.toString()
|
val newContent = dialogView.etContent.text.toString()
|
||||||
confirmAction(newTitle, newContent, coverImageUri)
|
val menu = dialogView.etMenu.text.toString()
|
||||||
|
|
||||||
|
confirmAction(
|
||||||
|
newTitle,
|
||||||
|
newContent,
|
||||||
|
coverImageUri,
|
||||||
|
if (isActivateMenu != null) {
|
||||||
|
isActivateMenu
|
||||||
|
} else if (this.menu != menu || this.selectedMenu != selectedMenuLiveData.value!!) {
|
||||||
|
true
|
||||||
|
} else {
|
||||||
|
isActivateMenu
|
||||||
|
},
|
||||||
|
menuId,
|
||||||
|
menu
|
||||||
|
)
|
||||||
coverImageUri = null
|
coverImageUri = null
|
||||||
coverImageUrl = null
|
coverImageUrl = null
|
||||||
}
|
}
|
||||||
|
@ -85,4 +193,103 @@ class LiveRoomInfoEditDialog(
|
||||||
|
|
||||||
alertDialog.window?.attributes = lp
|
alertDialog.window?.attributes = lp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun deselectAllMenuPreset() {
|
||||||
|
dialogView.ivSelectMenu1.visibility = View.GONE
|
||||||
|
dialogView.ivSelectMenu2.visibility = View.GONE
|
||||||
|
dialogView.ivSelectMenu3.visibility = View.GONE
|
||||||
|
|
||||||
|
dialogView.llSelectMenu1.setBackgroundResource(R.drawable.bg_round_corner_6_7_13181b)
|
||||||
|
dialogView.tvSelectMenu1.setTextColor(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
activity,
|
||||||
|
R.color.color_3bb9f1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
if (menuList.size > 0) {
|
||||||
|
dialogView.llSelectMenu2.setBackgroundResource(R.drawable.bg_round_corner_6_7_13181b)
|
||||||
|
dialogView.tvSelectMenu2.setTextColor(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
activity,
|
||||||
|
R.color.color_3bb9f1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
dialogView.llSelectMenu2.setBackgroundResource(R.drawable.bg_round_corner_6_7_777777)
|
||||||
|
dialogView.tvSelectMenu2.setTextColor(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
activity,
|
||||||
|
R.color.color_555555
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menuList.size > 1) {
|
||||||
|
dialogView.llSelectMenu3.setBackgroundResource(R.drawable.bg_round_corner_6_7_13181b)
|
||||||
|
dialogView.tvSelectMenu3.setTextColor(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
activity,
|
||||||
|
R.color.color_3bb9f1
|
||||||
|
)
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
dialogView.llSelectMenu3.setBackgroundResource(R.drawable.bg_round_corner_6_7_777777)
|
||||||
|
dialogView.tvSelectMenu3.setTextColor(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
activity,
|
||||||
|
R.color.color_555555
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun selectMenuPresetButton(
|
||||||
|
ivSelectMenuPreset: ImageView,
|
||||||
|
llSelectMenuPreset: LinearLayout,
|
||||||
|
tvSelectMenuPreset: TextView
|
||||||
|
) {
|
||||||
|
ivSelectMenuPreset.visibility = View.VISIBLE
|
||||||
|
llSelectMenuPreset.setBackgroundResource(R.drawable.bg_round_corner_6_7_3bb9f1)
|
||||||
|
tvSelectMenuPreset.setTextColor(
|
||||||
|
ContextCompat.getColor(
|
||||||
|
activity,
|
||||||
|
R.color.color_eeeeee
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun selectMenuPreset(selectedMenuPreset: LiveRoomCreateViewModel.SelectedMenu) {
|
||||||
|
if (
|
||||||
|
menuList.isEmpty() &&
|
||||||
|
(
|
||||||
|
selectedMenuPreset == LiveRoomCreateViewModel.SelectedMenu.MENU_2 ||
|
||||||
|
selectedMenuPreset == LiveRoomCreateViewModel.SelectedMenu.MENU_3
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
Toast.makeText(activity, "메뉴 1을 먼저 설정하세요", Toast.LENGTH_SHORT).show()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (menuList.size == 1 && selectedMenuPreset == LiveRoomCreateViewModel.SelectedMenu.MENU_3) {
|
||||||
|
Toast.makeText(activity, "메뉴 1과 메뉴 2를 먼저 설정하세요", Toast.LENGTH_SHORT).show()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (selectedMenuLiveData.value != selectedMenuPreset) {
|
||||||
|
selectedMenuLiveData.value = selectedMenuPreset
|
||||||
|
|
||||||
|
if (menuList.size > selectedMenuPreset.ordinal) {
|
||||||
|
val menuPreset = menuList[selectedMenuPreset.ordinal]
|
||||||
|
|
||||||
|
menu = menuPreset.menu
|
||||||
|
menuId = menuPreset.id
|
||||||
|
dialogView.etMenu.setText(menuPreset.menu)
|
||||||
|
} else {
|
||||||
|
menu = ""
|
||||||
|
menuId = 0
|
||||||
|
dialogView.etMenu.setText("")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -135,6 +135,169 @@
|
||||||
tools:ignore="LabelFor" />
|
tools:ignore="LabelFor" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginHorizontal="13.3dp"
|
||||||
|
android:layout_marginTop="33.3dp"
|
||||||
|
android:orientation="vertical">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/gmarket_sans_bold"
|
||||||
|
android:text="메뉴"
|
||||||
|
android:textColor="@color/color_eeeeee"
|
||||||
|
android:textSize="16.7sp" />
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="8dp">
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:fontFamily="@font/gmarket_sans_medium"
|
||||||
|
android:lineSpacingExtra="5sp"
|
||||||
|
android:text="메뉴를 활성화 하시겠습니까?"
|
||||||
|
android:textColor="@color/color_eeeeee"
|
||||||
|
android:textSize="13.3sp" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_switch"
|
||||||
|
android:layout_width="33.3dp"
|
||||||
|
android:layout_height="20dp"
|
||||||
|
android:layout_alignParentEnd="true"
|
||||||
|
android:layout_centerVertical="true"
|
||||||
|
android:contentDescription="@null"
|
||||||
|
android:src="@drawable/btn_toggle_off_big" />
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/ll_edit_menu"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="13.3dp"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:visibility="gone">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:orientation="horizontal">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/ll_select_menu_1"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/bg_round_corner_6_7_13181b"
|
||||||
|
android:gravity="center"
|
||||||
|
android:paddingVertical="14.3dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_select_menu_1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="6.7dp"
|
||||||
|
android:contentDescription="@null"
|
||||||
|
android:src="@drawable/ic_select_check"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_select_menu_1"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/gmarket_sans_bold"
|
||||||
|
android:text="메뉴 1"
|
||||||
|
android:textColor="@color/color_3bb9f1"
|
||||||
|
android:textSize="14.7sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/ll_select_menu_2"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="13.3dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/bg_round_corner_6_7_777777"
|
||||||
|
android:gravity="center"
|
||||||
|
android:paddingVertical="14.3dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_select_menu_2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="6.7dp"
|
||||||
|
android:contentDescription="@null"
|
||||||
|
android:src="@drawable/ic_select_check"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_select_menu_2"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/gmarket_sans_bold"
|
||||||
|
android:text="메뉴 2"
|
||||||
|
android:textColor="@color/color_555555"
|
||||||
|
android:textSize="14.7sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/ll_select_menu_3"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="13.3dp"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:background="@drawable/bg_round_corner_6_7_777777"
|
||||||
|
android:gravity="center"
|
||||||
|
android:paddingVertical="14.3dp">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/iv_select_menu_3"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="6.7dp"
|
||||||
|
android:contentDescription="@null"
|
||||||
|
android:src="@drawable/ic_select_check"
|
||||||
|
android:visibility="gone" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/tv_select_menu_3"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:fontFamily="@font/gmarket_sans_bold"
|
||||||
|
android:text="메뉴 3"
|
||||||
|
android:textColor="@color/color_555555"
|
||||||
|
android:textSize="14.7sp" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/et_menu"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="200dp"
|
||||||
|
android:layout_marginTop="13.3dp"
|
||||||
|
android:background="@drawable/bg_round_corner_6_7_222222"
|
||||||
|
android:fontFamily="@font/gmarket_sans_medium"
|
||||||
|
android:gravity="top"
|
||||||
|
android:hint="메뉴판을 작성해주세요."
|
||||||
|
android:importantForAutofill="no"
|
||||||
|
android:inputType="textMultiLine"
|
||||||
|
android:overScrollMode="always"
|
||||||
|
android:padding="20dp"
|
||||||
|
android:scrollbarStyle="insideInset"
|
||||||
|
android:scrollbars="vertical"
|
||||||
|
android:textColor="@color/color_eeeeee"
|
||||||
|
android:textColorHint="@color/color_777777"
|
||||||
|
android:textCursorDrawable="@drawable/edit_text_cursor"
|
||||||
|
android:textSize="13.3sp"
|
||||||
|
tools:ignore="LabelFor" />
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
|
Loading…
Reference in New Issue