Skip to content

Commit 5234526

Browse files
committed
feat: 검색 목록에서 클릭 시 editText 로 복사 완료
1 parent a6fb285 commit 5234526

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

app/src/main/java/com/seok/gfd/adapter/SearchGithubIdAdapter.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package com.seok.gfd.adapter
33
import android.view.LayoutInflater
44
import android.view.View
55
import android.view.ViewGroup
6+
import android.widget.EditText
67
import androidx.fragment.app.FragmentActivity
78
import androidx.lifecycle.ViewModelProviders
89
import androidx.recyclerview.widget.RecyclerView
@@ -11,8 +12,9 @@ import com.seok.gfd.room.entity.SearchGithubId
1112
import com.seok.gfd.viewmodel.GithubIdViewModel
1213
import kotlinx.android.synthetic.main.item_search_github_id.view.*
1314

14-
class SearchGithubIdAdapter(list: ArrayList<SearchGithubId>) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
15+
class SearchGithubIdAdapter(list: ArrayList<SearchGithubId>, edtText : EditText) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
1516
private val githubIds: ArrayList<SearchGithubId> = list
17+
private val searchEditText = edtText
1618
private lateinit var githubIdsViewModel: GithubIdViewModel
1719

1820
inner class SearchGithubIdViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView){
@@ -24,6 +26,9 @@ class SearchGithubIdAdapter(list: ArrayList<SearchGithubId>) : RecyclerView.Adap
2426
notifyItemRemoved(this.adapterPosition)
2527
notifyDataSetChanged()
2628
}
29+
itemView.item_search_card_view.setOnClickListener {
30+
searchEditText.setText(searchGithubId.gidName)
31+
}
2732
}
2833
}
2934

app/src/main/java/com/seok/gfd/views/SearchActivity.kt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package com.seok.gfd.views
33
import android.os.Bundle
44
import android.text.Editable
55
import android.text.TextWatcher
6-
import android.view.View.OnFocusChangeListener
76
import android.view.WindowManager
87
import android.view.animation.AnimationUtils
98
import androidx.appcompat.app.AppCompatActivity
@@ -16,7 +15,6 @@ import com.seok.gfd.R
1615
import com.seok.gfd.adapter.SearchGithubIdAdapter
1716
import com.seok.gfd.room.entity.SearchGithubId
1817
import com.seok.gfd.viewmodel.GithubIdViewModel
19-
import kotlinx.android.synthetic.main.activity_guest_main.*
2018
import kotlinx.android.synthetic.main.activity_search.*
2119

2220

@@ -65,7 +63,7 @@ class SearchActivity : AppCompatActivity() {
6563

6664
private fun init() {
6765
githubIds = ArrayList()
68-
searchGithubIdAdapter = SearchGithubIdAdapter(githubIds)
66+
searchGithubIdAdapter = SearchGithubIdAdapter(githubIds, search_edt_id)
6967
gridLayoutManager = GridLayoutManager(this, 1)
7068
search_recycler_view.layoutManager = gridLayoutManager
7169
search_recycler_view.adapter = searchGithubIdAdapter

0 commit comments

Comments
 (0)