Android/kotlin
-
[Android/ kotlin] STOMP 를 이용한 실시간 양방향 채팅 기능 구현Android/kotlin 2023. 2. 16. 02:25
Spring boot에서 STOMP, Redis, Websocket을 이용해 채팅서버를 만들게 된다. 그렇다면 안드로이드에서는 stomp를 활용한 채팅기능을 구현하려면 어떻게 코드를 구성해야 할까? 1. 퍼미션 추가 //chat implementation fileTree(dir: "libs", include: ["*.jar"]) // stomp 라이브러리 추가 api "com.github.NaikSoftware:StompProtocolAndroid:1.6.4" //implementation 'com.github.NaikSoftware:StompProtocolAndroid:1.6.5' implementation 'com.github.bishoybasily:stomp:2.0.5' implementation ..
-
[android/kotlin] recyclerview item clicklistenerAndroid/kotlin 2022. 8. 28. 23:02
Framgent init{ instance = this } companion object{ private var instance: ChannelUpdateFragment? = null fun getInstance(): ChannelUpdateFragment? { return instance }} Adapter override fun onBindViewHolder(holder: ViewHolder, position: Int) { val item=items[position] holder.setItem(item) val TeamRegisterFragment = TeamRegisterFragment.getInstance() holder.itemView.member_delete_button.setOnClickLi..
-
[Android/kotlin] Bundle 사용법, Fragment와 Fragment 사이 데이터 전달, Fragment 전환Android/kotlin 2022. 8. 24. 22:27
Fragment와 Fragment 사이에 데이터는 Bundle을 이용하여 가능하다. 1. 전달하는 Fragment val fragmentA = TeamMainFragment() val bundle = Bundle() bundle.putString("teamName",teamaBody.teamName.toString()) fragmentA.arguments=bundle val transaction = requireActivity().supportFragmentManager.beginTransaction() transaction.add(R.id.container,fragmentA) transaction.replace(R.id.container, fragmentA.apply { arguments = bundl..
-
[Android / kotlin] Retrofit으로 LocalDateTime형식 데이터 주고받기Android/kotlin 2022. 7. 17. 01:53
일반적인 json string 형식과 다르게 localdatetime형식의 데이터를 서버에 전송하거나 받을때는 DateFormat을 추가한 Gson객체를 생성하고 localdatetimeConverter도 만들어 준다. 서버에 전송하거나 받고 싶은 LocalDateTime형식의 데이터 예시 "2022-07-16T16:43:58.977Z" 1. gson객체 val gson = GsonBuilder() .setDateFormat("yyyy-MM-dd'T'HH:mm:ss") .registerTypeAdapter(LocalDateTime::class.java, LocalDateTimeConverter()).create() 2. LocalDateTimeConverter.kt class LocalDateTimeCo..
-
[Android/kotiln] jwt 토큰 임시 저장, shared preference, OkHttp3 Interceptor 사용법Android/kotlin 2022. 6. 21. 02:07
Android에서 JWT 사용과정 1. 사용자가 아이디, 비밀번호를 통해 로그인 2. 서버에서 토큰을 발급받아 response로 받는다 3. 그 토큰을 Shared Preference를 사용하여 저장 4. 서버에 요청할 때 저장소의 토큰을 header에 넣어 요청 Shared Preference 간단한 값을 저장할 때 주로 사용하는 저장소 예) 토큰, 초기 설정 값 등 사용법 1. PreferenceUtil 파일만들기 class PreferenceUtil(context: Context) { private val prefs: SharedPreferences = context.getSharedPreferences("prefs_name", Context.MODE_PRIVATE) var token:String?..