Skip to content

Commit dd932cb

Browse files
committed
🔧 add LakuePopupActivity
1 parent 98b1608 commit dd932cb

File tree

5 files changed

+63
-5
lines changed

5 files changed

+63
-5
lines changed

app/build.gradle

+3
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ dependencies {
5454
implementation 'androidx.recyclerview:recyclerview:1.3.0'
5555
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
5656

57+
//popup창
58+
implementation 'com.github.lakue119:LakuePopupActivity:1.0.1'
59+
5760

5861
implementation 'androidx.core:core-ktx:1.10.0'
5962
implementation 'androidx.appcompat:appcompat:1.6.1'

app/src/main/java/com/alt/letseatingtime_android/network/retrofit/API.kt

+6-2
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,13 @@ import com.alt.letseatingtime_android.network.retrofit.request.SignupRequest
66
import com.alt.letseatingtime_android.network.retrofit.response.login.LoginResponse
77
import com.alt.letseatingtime_android.network.retrofit.response.SignupResponse
88
import com.alt.letseatingtime_android.network.retrofit.response.profile.ProfileResponse
9-
import com.bumptech.glide.annotation.GlideType
9+
import com.alt.letseatingtime_android.network.retrofit.response.WithdrawResponse
1010
import okhttp3.ResponseBody
1111
import retrofit2.Call
1212
import retrofit2.http.Body
1313
import retrofit2.http.GET
1414
import retrofit2.http.Header
1515
import retrofit2.http.POST
16-
import retrofit2.http.Part
1716
import retrofit2.http.Path
1817
import retrofit2.http.Query
1918

@@ -50,4 +49,9 @@ interface API {
5049
@Header("Authorization") Authorization: String
5150
):Call<LoginResponse>
5251

52+
@POST("/api/user/withdraw")
53+
fun withdraw(
54+
@Header("Authorization") Authorization: String
55+
): Call<WithdrawResponse>
56+
5357
}

app/src/main/java/com/alt/letseatingtime_android/ui/activity/HomeActivity.kt

+50-2
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,20 @@ import android.content.Context
44
import android.content.Intent
55
import android.graphics.Bitmap
66
import android.graphics.BitmapFactory
7-
import androidx.appcompat.app.AppCompatActivity
87
import android.os.Bundle
98
import android.util.Log
109
import android.widget.Toast
10+
import androidx.appcompat.app.AppCompatActivity
1111
import com.alt.letseatingtime_android.MyApplication.Companion.prefs
1212
import com.alt.letseatingtime_android.network.retrofit.RetrofitClient
13+
import com.alt.letseatingtime_android.network.retrofit.response.WithdrawResponse
1314
import com.alt.letseatingtime_android.network.retrofit.response.meal.MealResponse
1415
import com.alt.letseatingtime_android.network.retrofit.response.profile.ProfileResponse
1516
import com.bumptech.glide.Glide
1617
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
1821
import okhttp3.ResponseBody
1922
import retrofit2.Call
2023
import retrofit2.Callback
@@ -24,6 +27,7 @@ import java.time.LocalDateTime
2427
import java.time.LocalTime
2528
import java.time.format.DateTimeFormatter
2629

30+
2731
class HomeActivity : AppCompatActivity() {
2832
private val binding: ActivityHomeBinding by lazy { ActivityHomeBinding.inflate(layoutInflater) }
2933

@@ -59,6 +63,22 @@ class HomeActivity : AppCompatActivity() {
5963
startActivity(intent)
6064
finish()
6165
}
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+
};
6282
}
6383

6484
private fun getImg(id: String) {
@@ -177,6 +197,34 @@ class HomeActivity : AppCompatActivity() {
177197
})
178198
}
179199

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+
180228
}
181229

182230

app/src/main/java/com/alt/letseatingtime_android/ui/activity/LoginActivity.kt

+3-1
Original file line numberDiff line numberDiff line change
@@ -64,13 +64,15 @@ class LoginActivity : AppCompatActivity() {
6464
val result = response.body()
6565
if (response.code() == 200) {
6666
val intent = Intent(this@LoginActivity, HomeActivity::class.java)
67-
MyApplication.prefs.accessToken = result?.data?.accessToken
6867
if(binding.cbLogin.isChecked){
6968
MyApplication.prefs.refreshToken = result?.data?.refreshToken
7069
MyApplication.prefs.accessToken = result?.data?.accessToken
7170
Log.d("상태","로그인 상태 유지")
7271
} else {
72+
Log.d("토큰로그인",result?.data?.accessToken.toString())
7373
MyApplication.prefs.accessToken = result?.data?.accessToken
74+
MyApplication.prefs.refreshToken = null
75+
Log.d("토큰로그인",MyApplication.prefs.accessToken.toString())
7476
Log.d("상태","로그인 상태 유지X")
7577
}
7678

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ dependencyResolutionManagement {
1010
repositories {
1111
google()
1212
mavenCentral()
13+
maven { url 'https://jitpack.io' }
1314
}
1415
}
1516
rootProject.name = "LetsEatingTime"

0 commit comments

Comments
 (0)