Android
-
Dragger-Hilt (Android Dependency Injection)Android 2023. 10. 30. 11:54
DI OOP(객체지향프로그래밍)에서 객체 간의 관계가 연관을 맺을 수 있도록 코드를 구성하는 것을 의존성 주입(의존관계구성)이라 함 의존성 주입방법 Constructor Injection Function@Method(Setter) Injection Field Injection Service Locator Pattern 의존성을 주입하는 방법 수동주입(종속 항목 수동 삽입) DI Framework을 이용한 주입(hilt) 장점 코드의 재사용성 익숙해지면 가독성이 좋음 코드를 분리하여 구성하므로 리팩토링이 용이하다 코드를 객체관점에서 분리하여 구성할 수 있어 테스트가 용이하다 => 실제 비지니스 로직과 연관된 부수적 작업을 분리하여 개발 가능 scopre(생명주기)를 이용한 관리 Dagger java/kot..
-
[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..