Toggle navigation
Toggle navigation
This project
Loading...
Sign in
장연우
/
WELLO
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
신기성
2019-10-30 01:31:54 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
6a0bde744f9321f0f6a922a04bd14d156efbe476
6a0bde74
1 parent
e8b813ef
search item recyclerview implementation
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
138 additions
and
18 deletions
vip/app/src/main/AndroidManifest.xml
vip/app/src/main/java/com/example/vip/SearchActivity.kt
vip/app/src/main/java/com/example/vip/SearchAdapter.kt
vip/app/src/main/java/com/example/vip/SearchItem.kt
vip/app/src/main/java/com/example/vip/TestingActivity.kt
vip/app/src/main/res/layout/activity_testing.xml
vip/app/src/main/res/layout/item_search.xml
vip/app/src/main/res/layout/search.xml
vip/app/src/main/res/values/strings.xml
vip/app/src/main/AndroidManifest.xml
View file @
6a0bde7
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android=
"http://schemas.android.com/apk/res/android"
package=
"com.example.vip"
>
<application
android:allowBackup=
"true"
android:icon=
"@mipmap/ic_launcher"
...
...
@@ -8,15 +9,20 @@
android:roundIcon=
"@mipmap/ic_launcher_round"
android:supportsRtl=
"true"
android:theme=
"@style/NoActionBar"
>
<activity
android:name=
".SignInActivity"
></activity>
<activity
android:name=
".TestingActivity"
></activity>
<activity
android:name=
".SignInActivity"
/>
<activity
android:name=
".SignUpActivity"
/>
<activity
android:name=
".MainActivity"
/>
<activity
android:name=
".SearchActivity"
/>
<activity
android:name=
".SplashActivity"
android:theme=
"@style/SplashTheme"
>
<activity
android:name=
".MainActivity"
/>
<activity
android:name=
".SearchActivity"
/>
<activity
android:name=
".SplashActivity"
android:theme=
"@style/SplashTheme"
>
<intent-filter>
<action
android:name=
"android.intent.action.MAIN"
/>
<category
android:name=
"android.intent.category.LAUNCHER"
/>
</intent-filter>
</activity>
</application>
</manifest>
\ No newline at end of file
...
...
vip/app/src/main/java/com/example/vip/SearchActivity.kt
View file @
6a0bde7
...
...
@@ -12,9 +12,11 @@ import android.view.View
import
android.widget.Button
import
android.content.Intent
import
android.util.Log
import
androidx.core.content.ContextCompat
import
com.google.firebase.database.*
import
com.google.firebase.database.DatabaseReference
import
com.google.firebase.database.FirebaseDatabase
import
kotlinx.android.synthetic.main.search.*
...
...
@@ -32,6 +34,9 @@ class SearchActivity : AppCompatActivity() {
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
search
)
val
searchList
=
ArrayList
<
SearchItem
>()
val
searchView
:
SearchView
searchView
=
findViewById
(
R
.
id
.
searchForm
)
...
...
@@ -45,24 +50,26 @@ class SearchActivity : AppCompatActivity() {
Toast
.
makeText
(
this
@SearchActivity
,
"실패부분 : $query"
,
Toast
.
LENGTH_SHORT
).
show
()
}
override
fun
onDataChange
(
dataSnapshot
:
DataSnapshot
)
{
// 타겟 1개 if (dataSnapshot.exists()){
// val memo = dataSnapshot.getValue(MemoItem::class.java)
// if (memo != null){
// Toast.makeText(this@SearchActivity, memo!!.Policy, Toast.LENGTH_SHORT).show()
// }
//
// }
for
(
memoSnapshot
in
dataSnapshot
.
children
){
val
memo
=
memoSnapshot
.
getValue
(
MemoItem
::
class
.
java
)
Toast
.
makeText
(
this
@SearchActivity
,
memo
!!
.
Policy
,
Toast
.
LENGTH_SHORT
).
show
()
searchList
.
add
(
SearchItem
(
ContextCompat
.
getDrawable
(
this
@SearchActivity
,
R
.
drawable
.
image01
)
!!
,
memo
!!
.
Policy
)
)
}
val
adapter
=
SearchAdapter
(
searchList
)
searchRecyclerView
.
adapter
=
adapter
}
})
Toast
.
makeText
(
this
@SearchActivity
,
"검색 처리됨 : $query"
,
Toast
.
LENGTH_SHORT
).
show
()
searchList
.
clear
()
return
true
}
override
fun
onQueryTextChange
(
newText
:
String
):
Boolean
{
// 검색어가 변경되었을 때 이벤트 처리
return
false
...
...
vip/app/src/main/java/com/example/vip/SearchAdapter.kt
0 → 100644
View file @
6a0bde7
package
com.example.vip
import
android.content.Intent
import
android.system.Os.bind
import
android.view.LayoutInflater
import
android.view.View
import
android.view.ViewGroup
import
android.widget.Toast
import
androidx.recyclerview.widget.RecyclerView
import
kotlinx.android.synthetic.main.item_policyfield.view.*
import
kotlinx.android.synthetic.main.item_search.view.*
class
SearchAdapter
(
private
val
items
:
ArrayList
<
SearchItem
>)
:
RecyclerView
.
Adapter
<
SearchAdapter
.
ViewHolder
>()
{
override
fun
getItemCount
()
=
items
.
size
override
fun
onBindViewHolder
(
holder
:
SearchAdapter
.
ViewHolder
,
position
:
Int
)
{
val
item
=
items
[
position
]
holder
.
apply
{
bind
(
item
)
itemView
.
tag
=
item
}
}
override
fun
onCreateViewHolder
(
parent
:
ViewGroup
,
viewType
:
Int
):
SearchAdapter
.
ViewHolder
{
val
inflatedView
=
LayoutInflater
.
from
(
parent
.
context
)
.
inflate
(
R
.
layout
.
item_search
,
parent
,
false
)
return
SearchAdapter
.
ViewHolder
(
inflatedView
)
}
class
ViewHolder
(
v
:
View
)
:
RecyclerView
.
ViewHolder
(
v
)
{
private
var
view
:
View
=
v
fun
bind
(
item
:
SearchItem
)
{
view
.
searchIcon
.
setImageDrawable
(
item
.
searchItemImage
)
view
.
searchIconText
.
text
=
item
.
searchItemText
view
.
setOnClickListener
{
val
intent
=
Intent
(
view
.
context
,
TestingActivity
::
class
.
java
)
view
.
context
.
startActivity
(
intent
)
}
}
}
}
\ No newline at end of file
vip/app/src/main/java/com/example/vip/SearchItem.kt
0 → 100644
View file @
6a0bde7
package
com.example.vip
import
android.graphics.drawable.Drawable
class
SearchItem
(
val
searchItemImage
:
Drawable
,
val
searchItemText
:
String
)
{
}
\ No newline at end of file
vip/app/src/main/java/com/example/vip/TestingActivity.kt
0 → 100644
View file @
6a0bde7
package
com.example.vip
import
androidx.appcompat.app.AppCompatActivity
import
android.os.Bundle
class
TestingActivity
:
AppCompatActivity
()
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
activity_testing
)
}
}
vip/app/src/main/res/layout/activity_testing.xml
0 → 100644
View file @
6a0bde7
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
tools:context=
".TestingActivity"
>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
vip/app/src/main/res/layout/item_search.xml
0 → 100644
View file @
6a0bde7
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:orientation=
"horizontal"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_margin=
"20dp"
>
<ImageView
android:id=
"@+id/searchIcon"
android:layout_width=
"100dp"
android:layout_height=
"wrap_content"
android:adjustViewBounds=
"true"
/>
<TextView
android:id=
"@+id/searchIconText"
android:layout_width=
"150dp"
android:layout_height=
"wrap_content"
android:textSize=
"20sp"
/>
</LinearLayout>
\ No newline at end of file
vip/app/src/main/res/layout/search.xml
View file @
6a0bde7
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:tools=
"http://schemas.android.com/tools"
android:orientation=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
...
...
@@ -14,4 +15,12 @@
</SearchView>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/searchRecyclerView"
android:layout_width=
"match_parent"
android:layout_height=
"340dp"
app:layoutManager=
"androidx.recyclerview.widget.LinearLayoutManager"
app:spanCount=
"3"
app:layout_constraintBottom_toBottomOf=
"@id/bottom_navigation"
tools:listitem=
"@layout/item_search"
/>
</LinearLayout>
\ No newline at end of file
...
...
vip/app/src/main/res/values/strings.xml
View file @
6a0bde7
...
...
@@ -12,9 +12,9 @@
<string
name=
"title09"
>
빈카테고리
</string>
<string
name=
"title10"
>
빈카테고리
</string>
<string
name=
"alarm"
>
Home
</string>
<string
name=
"clock"
>
추천정책
</string>
<string
name=
"timer"
>
찜 목록
</string>
<string
name=
"stopwatch"
>
내 정보
</string>
<string
name=
"alarm"
>
Home
</string>
<string
name=
"clock"
>
추천정책
</string>
<string
name=
"timer"
>
찜 목록
</string>
<string
name=
"stopwatch"
>
내 정보
</string>
</resources>
...
...
Please
register
or
login
to post a comment