@@ -4,17 +4,20 @@ import android.content.Context
4
4
import android.content.Intent
5
5
import android.graphics.Bitmap
6
6
import android.graphics.BitmapFactory
7
- import androidx.appcompat.app.AppCompatActivity
8
7
import android.os.Bundle
9
8
import android.util.Log
10
9
import android.widget.Toast
10
+ import androidx.appcompat.app.AppCompatActivity
11
11
import com.alt.letseatingtime_android.MyApplication.Companion.prefs
12
12
import com.alt.letseatingtime_android.network.retrofit.RetrofitClient
13
+ import com.alt.letseatingtime_android.network.retrofit.response.WithdrawResponse
13
14
import com.alt.letseatingtime_android.network.retrofit.response.meal.MealResponse
14
15
import com.alt.letseatingtime_android.network.retrofit.response.profile.ProfileResponse
15
16
import com.bumptech.glide.Glide
16
17
import com.example.letseatingtime.databinding.ActivityHomeBinding
17
- import kotlinx.coroutines.Deferred
18
+ import com.lakue.lakuepopupactivity.PopupActivity
19
+ import com.lakue.lakuepopupactivity.PopupGravity
20
+ import com.lakue.lakuepopupactivity.PopupType
18
21
import okhttp3.ResponseBody
19
22
import retrofit2.Call
20
23
import retrofit2.Callback
@@ -24,6 +27,7 @@ import java.time.LocalDateTime
24
27
import java.time.LocalTime
25
28
import java.time.format.DateTimeFormatter
26
29
30
+
27
31
class HomeActivity : AppCompatActivity () {
28
32
private val binding: ActivityHomeBinding by lazy { ActivityHomeBinding .inflate(layoutInflater) }
29
33
@@ -59,6 +63,22 @@ class HomeActivity : AppCompatActivity() {
59
63
startActivity(intent)
60
64
finish()
61
65
}
66
+
67
+ // binding.withdrawal.setOnClickListener {
68
+ //
69
+ // withdrawal()
70
+ // }
71
+
72
+ binding.withdrawal.setOnClickListener {
73
+ val intent = Intent (baseContext, PopupActivity ::class .java)
74
+ intent.putExtra(" type" , PopupType .SELECT )
75
+ intent.putExtra(" gravity" , PopupGravity .LEFT )
76
+ intent.putExtra(" title" , " 경고" )
77
+ intent.putExtra(" content" , " 정말로 계정을 삭제 하실건가요?" )
78
+ intent.putExtra(" buttonLeft" , " 확인" )
79
+ intent.putExtra(" buttonRight" , " 취소" )
80
+ startActivityForResult(intent, 2 )
81
+ };
62
82
}
63
83
64
84
private fun getImg (id : String ) {
@@ -177,6 +197,34 @@ class HomeActivity : AppCompatActivity() {
177
197
})
178
198
}
179
199
200
+ private fun withdrawal (){
201
+ RetrofitClient .api.withdraw(" Bearer ${prefs.accessToken.toString()} " ).enqueue(object : Callback <WithdrawResponse >{
202
+ override fun onResponse (
203
+ call : Call <WithdrawResponse >,
204
+ response : Response <WithdrawResponse >
205
+ ) {
206
+ if (response.isSuccessful){
207
+ logout()
208
+ } else {
209
+ Log .d(" 토큰로그인" , prefs.accessToken.toString())
210
+ Log .d(" 애러" ,response.code().toString())
211
+ }
212
+ }
213
+
214
+ override fun onFailure (call : Call <WithdrawResponse >, t : Throwable ) {
215
+ Log .d(" 애러" ,t.message.toString())
216
+ }
217
+
218
+ })
219
+ }
220
+
221
+ fun logout (){
222
+ val intent = Intent (this , LoginActivity ::class .java)
223
+ intent.addFlags(Intent .FLAG_ACTIVITY_NO_ANIMATION )
224
+ startActivity(intent)
225
+ finish()
226
+ }
227
+
180
228
}
181
229
182
230
0 commit comments