@@ -13,6 +13,7 @@ import android.view.View
13
13
import android.view.ViewGroup
14
14
import android.widget.Button
15
15
import android.widget.ImageButton
16
+ import android.widget.TextView
16
17
import android.widget.Toast
17
18
import androidx.core.content.ContextCompat
18
19
import androidx.fragment.app.Fragment
@@ -129,30 +130,65 @@ class CommunityDetailFragment : Fragment() {
129
130
val reportBtn = view.findViewById<Button >(R .id.button_dialog_report)
130
131
131
132
reportBtn.setOnClickListener {
132
- val call: Call <Unit > = FeedRequestToServer .writeService
133
- .reportDiary(
134
- feedDetail.get(" id" ) as Int ,
135
- " application/json" ,
136
- viewModel.getJWT()
137
- )
138
- call.enqueue(object : Callback <Unit > {
139
- override fun onResponse (call : Call <Unit >, response : Response <Unit >) {
140
- if (response.isSuccessful) {
141
- Toast .makeText(requireContext(), " 신고했습니다." , Toast .LENGTH_SHORT ).show()
142
- reportDialog?.dismiss()
143
- } else {
144
- if (response.code() == 404 || response.code() == 401 ){
145
- Toast .makeText(requireContext(), response.message(), Toast .LENGTH_SHORT ).show()
133
+ reportDialog?.dismiss()
134
+
135
+ val reportCheckDialog = activity?.let { it1 -> Dialog (it1) }
136
+ val reportCheckDialogInflater: LayoutInflater = LayoutInflater .from(activity)
137
+ val mView: View =
138
+ reportCheckDialogInflater.inflate(R .layout.dialog_detail_delete, null )
139
+ val reportBtn: Button = mView.findViewById(R .id.button_dialog_delete)
140
+ val closeBtn: Button = mView.findViewById(R .id.button_dialog_close)
141
+ val window = reportCheckDialog?.window
142
+ window?.setBackgroundDrawable(ColorDrawable (Color .TRANSPARENT ))
143
+
144
+ val reportTitle: TextView = mView.findViewById(R .id.textview_dialog_delete)
145
+ val reportContent: TextView = mView.findViewById(R .id. textview_delete_content)
146
+ reportTitle.text = " 신고하기"
147
+ reportContent.text = " 10회 이상 신고될 경우 \n 게시물이 삭제되고 계정이 차단 조치돼"
148
+ reportBtn.text = " 신고"
149
+
150
+
151
+ if (reportCheckDialog != null ) {
152
+ reportCheckDialog.setContentView(mView)
153
+ reportCheckDialog.create()
154
+ reportCheckDialog.show()
155
+ }
156
+ closeBtn.setOnClickListener {
157
+ if (reportCheckDialog != null ) {
158
+ reportCheckDialog.dismiss()
159
+ reportCheckDialog.cancel()
160
+ }
161
+ }
162
+ reportBtn.setOnClickListener {
163
+ val call: Call <Unit > = FeedRequestToServer .writeService
164
+ .reportDiary(
165
+ feedDetail.get(" id" ) as Int ,
166
+ " application/json" ,
167
+ viewModel.getJWT()
168
+ )
169
+ call.enqueue(object : Callback <Unit > {
170
+ override fun onResponse (call : Call <Unit >, response : Response <Unit >) {
171
+ if (response.isSuccessful) {
172
+ Toast .makeText(requireContext(), " 신고했습니다." , Toast .LENGTH_SHORT )
173
+ .show()
174
+ reportDialog?.dismiss()
175
+ } else {
176
+ if (response.code() == 404 || response.code() == 401 ) {
177
+ Toast .makeText(
178
+ requireContext(),
179
+ " 이미 신고한 게시물입니다." ,
180
+ Toast .LENGTH_SHORT
181
+ ).show()
182
+ }
146
183
}
147
- // Toast.makeText(requireContext(), response.toString(), Toast.LENGTH_SHORT).show ()
184
+ reportCheckDialog?.dismiss ()
148
185
}
149
- }
150
186
151
- override fun onFailure (call : Call <Unit >, t : Throwable ) {
152
- Log .d(" Report Diary NT Error" , " Report Error!" )
153
- }
154
- })
155
- reportDialog?.dismiss()
187
+ override fun onFailure (call : Call <Unit >, t : Throwable ) {
188
+ Log .d(" Report Diary NT Error" , " Report Error!" )
189
+ }
190
+ })
191
+ }
156
192
}
157
193
158
194
reportDialog?.setContentView(view)
0 commit comments