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
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Commits
Issue Boards
Authored by
soonmyeong2
2019-10-29 22:06:59 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e8b813ef45845d2f70ef061755391b274f0cbcae
e8b813ef
1 parent
e0343f2f
make search bar;
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
103 additions
and
3 deletions
vip/app/build.gradle
vip/app/google-services.json
vip/app/src/main/AndroidManifest.xml
vip/app/src/main/java/com/example/vip/SearchActivity.kt
vip/app/src/main/java/com/example/vip/SignInActivity.kt
vip/app/src/main/java/com/example/vip/SplashActivity.kt
vip/app/src/main/res/layout/search.xml
vip/app/build.gradle
View file @
e8b813e
...
...
@@ -37,7 +37,7 @@ dependencies {
implementation
'com.android.support:design:27.1.1'
implementation
'com.google.firebase:firebase-database:17.0.0'
testImplementation
'junit:junit:4.12'
androidTestImplementation
'androidx.test:runner:1.2.0'
androidTestImplementation
'androidx.test.espresso:espresso-core:3.2.0'
...
...
vip/app/google-services.json
View file @
e8b813e
...
...
@@ -15,6 +15,14 @@
},
"oauth_client"
:
[
{
"client_id"
:
"1004426035643-ju8i4dbd1psjka5qqjsntos2kodrt2ca.apps.googleusercontent.com"
,
"client_type"
:
1
,
"android_info"
:
{
"package_name"
:
"com.example.vip"
,
"certificate_hash"
:
"8ac95d8222d265210a8ef81c0f1fa04561152680"
}
},
{
"client_id"
:
"1004426035643-0id5kb6rfoi38qi0ji2tvm7o8vvinvbe.apps.googleusercontent.com"
,
"client_type"
:
1
,
"android_info"
:
{
...
...
vip/app/src/main/AndroidManifest.xml
View file @
e8b813e
...
...
@@ -11,6 +11,7 @@
<activity
android:name=
".SignInActivity"
></activity>
<activity
android:name=
".SignUpActivity"
/>
<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"
/>
...
...
vip/app/src/main/java/com/example/vip/SearchActivity.kt
0 → 100644
View file @
e8b813e
package
com.example.vip
import
android.os.Bundle
import
androidx.appcompat.app.AppCompatActivity
//import androidx.appcompat.widget.SearchView
import
android.widget.SearchView
import
android.widget.Toast
import
androidx.core.app.ComponentActivity.ExtraData
import
androidx.core.content.ContextCompat.getSystemService
import
android.icu.lang.UCharacter.GraphemeClusterBreak.T
import
android.view.View
import
android.widget.Button
import
android.content.Intent
import
android.util.Log
import
com.google.firebase.database.*
import
com.google.firebase.database.DatabaseReference
import
com.google.firebase.database.FirebaseDatabase
data class
MemoItem
(
val
Target
:
String
=
""
,
val
Policy
:
String
=
""
,
val
Content
:
String
=
""
,
val
Link
:
String
=
""
)
var
database
=
FirebaseDatabase
.
getInstance
().
reference
class
SearchActivity
:
AppCompatActivity
()
{
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
setContentView
(
R
.
layout
.
search
)
val
searchView
:
SearchView
searchView
=
findViewById
(
R
.
id
.
searchForm
)
searchView
.
setOnQueryTextListener
(
object
:
SearchView
.
OnQueryTextListener
{
override
fun
onQueryTextSubmit
(
query
:
String
):
Boolean
{
// 검색 버튼이 눌러졌을 때 이벤트 처리
database
.
orderByChild
(
"Policy"
).
startAt
(
"$query"
).
endAt
(
"$query"
+
"\uf8ff"
).
addListenerForSingleValueEvent
(
object
:
ValueEventListener
{
override
fun
onCancelled
(
p0
:
DatabaseError
)
{
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
()
}
}
})
Toast
.
makeText
(
this
@SearchActivity
,
"검색 처리됨 : $query"
,
Toast
.
LENGTH_SHORT
).
show
()
return
true
}
override
fun
onQueryTextChange
(
newText
:
String
):
Boolean
{
// 검색어가 변경되었을 때 이벤트 처리
return
false
}
})
}
}
\ No newline at end of file
vip/app/src/main/java/com/example/vip/SignInActivity.kt
View file @
e8b813e
package
com.example.vip
import
android.content.Intent
import
android.os.Bundle
import
android.view.Menu
import
android.view.MenuItem
...
...
@@ -108,7 +109,9 @@ class SignInActivity : AppCompatActivity() {
Snackbar
.
make
(
toolbar
,
"Menu pressed"
,
Snackbar
.
LENGTH_SHORT
).
show
()
}
R
.
id
.
menu_search
->{
// 검색 버튼
Snackbar
.
make
(
toolbar
,
"Search menu pressed"
,
Snackbar
.
LENGTH_SHORT
).
show
()
val
search_Intent
=
Intent
(
this
,
SearchActivity
::
class
.
java
)
startActivity
(
search_Intent
)
//Snackbar.make(toolbar,"Search menu pressed",Snackbar.LENGTH_SHORT).show()
}
}
return
super
.
onOptionsItemSelected
(
item
)
...
...
vip/app/src/main/java/com/example/vip/SplashActivity.kt
View file @
e8b813e
...
...
@@ -10,7 +10,6 @@ class SplashActivity : AppCompatActivity() {
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
val
intent
=
Intent
(
this
,
MainActivity
::
class
.
java
)
startActivity
(
intent
)
finish
()
...
...
vip/app/src/main/res/layout/search.xml
0 → 100644
View file @
e8b813e
<?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=
"vertical"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
>
<SearchView
android:id=
"@+id/searchForm"
android:queryHint=
"복지 정책 입력"
app:showAsAction=
"always"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
>
</SearchView>
</LinearLayout>
\ No newline at end of file
Please
register
or
login
to post a comment