Showing
7 changed files
with
103 additions
and
3 deletions
... | @@ -37,7 +37,7 @@ dependencies { | ... | @@ -37,7 +37,7 @@ dependencies { |
37 | implementation 'com.android.support:design:27.1.1' | 37 | implementation 'com.android.support:design:27.1.1' |
38 | 38 | ||
39 | 39 | ||
40 | - | 40 | + implementation 'com.google.firebase:firebase-database:17.0.0' |
41 | testImplementation 'junit:junit:4.12' | 41 | testImplementation 'junit:junit:4.12' |
42 | androidTestImplementation 'androidx.test:runner:1.2.0' | 42 | androidTestImplementation 'androidx.test:runner:1.2.0' |
43 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | 43 | androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' | ... | ... |
... | @@ -15,6 +15,14 @@ | ... | @@ -15,6 +15,14 @@ |
15 | }, | 15 | }, |
16 | "oauth_client": [ | 16 | "oauth_client": [ |
17 | { | 17 | { |
18 | + "client_id": "1004426035643-ju8i4dbd1psjka5qqjsntos2kodrt2ca.apps.googleusercontent.com", | ||
19 | + "client_type": 1, | ||
20 | + "android_info": { | ||
21 | + "package_name": "com.example.vip", | ||
22 | + "certificate_hash": "8ac95d8222d265210a8ef81c0f1fa04561152680" | ||
23 | + } | ||
24 | + }, | ||
25 | + { | ||
18 | "client_id": "1004426035643-0id5kb6rfoi38qi0ji2tvm7o8vvinvbe.apps.googleusercontent.com", | 26 | "client_id": "1004426035643-0id5kb6rfoi38qi0ji2tvm7o8vvinvbe.apps.googleusercontent.com", |
19 | "client_type": 1, | 27 | "client_type": 1, |
20 | "android_info": { | 28 | "android_info": { | ... | ... |
... | @@ -11,6 +11,7 @@ | ... | @@ -11,6 +11,7 @@ |
11 | <activity android:name=".SignInActivity"></activity> | 11 | <activity android:name=".SignInActivity"></activity> |
12 | <activity android:name=".SignUpActivity" /> | 12 | <activity android:name=".SignUpActivity" /> |
13 | <activity android:name=".MainActivity"/> | 13 | <activity android:name=".MainActivity"/> |
14 | + <activity android:name=".SearchActivity"/> | ||
14 | <activity android:name=".SplashActivity" android:theme="@style/SplashTheme"> | 15 | <activity android:name=".SplashActivity" android:theme="@style/SplashTheme"> |
15 | <intent-filter> | 16 | <intent-filter> |
16 | <action android:name="android.intent.action.MAIN" /> | 17 | <action android:name="android.intent.action.MAIN" /> | ... | ... |
1 | +package com.example.vip | ||
2 | + | ||
3 | +import android.os.Bundle | ||
4 | +import androidx.appcompat.app.AppCompatActivity | ||
5 | +//import androidx.appcompat.widget.SearchView | ||
6 | +import android.widget.SearchView | ||
7 | +import android.widget.Toast | ||
8 | +import androidx.core.app.ComponentActivity.ExtraData | ||
9 | +import androidx.core.content.ContextCompat.getSystemService | ||
10 | +import android.icu.lang.UCharacter.GraphemeClusterBreak.T | ||
11 | +import android.view.View | ||
12 | +import android.widget.Button | ||
13 | +import android.content.Intent | ||
14 | +import android.util.Log | ||
15 | +import com.google.firebase.database.* | ||
16 | +import com.google.firebase.database.DatabaseReference | ||
17 | +import com.google.firebase.database.FirebaseDatabase | ||
18 | + | ||
19 | + | ||
20 | + | ||
21 | +data class MemoItem( | ||
22 | + val Target : String = "", | ||
23 | + val Policy : String = "", | ||
24 | + val Content : String = "", | ||
25 | + val Link : String = "" | ||
26 | +) | ||
27 | + | ||
28 | +var database = FirebaseDatabase.getInstance().reference | ||
29 | + | ||
30 | +class SearchActivity : AppCompatActivity() { | ||
31 | + override fun onCreate(savedInstanceState: Bundle?) { | ||
32 | + super.onCreate(savedInstanceState) | ||
33 | + setContentView(R.layout.search) | ||
34 | + | ||
35 | + | ||
36 | + val searchView: SearchView | ||
37 | + searchView = findViewById(R.id.searchForm) | ||
38 | + | ||
39 | + searchView.setOnQueryTextListener(object : SearchView.OnQueryTextListener { | ||
40 | + override fun onQueryTextSubmit(query: String): Boolean { | ||
41 | + // 검색 버튼이 눌러졌을 때 이벤트 처리 | ||
42 | + | ||
43 | + database.orderByChild("Policy").startAt("$query").endAt("$query"+"\uf8ff").addListenerForSingleValueEvent(object : ValueEventListener { | ||
44 | + override fun onCancelled(p0: DatabaseError) { | ||
45 | + Toast.makeText(this@SearchActivity, "실패부분 : $query", Toast.LENGTH_SHORT).show() | ||
46 | + } | ||
47 | + override fun onDataChange(dataSnapshot: DataSnapshot) { | ||
48 | + | ||
49 | +// 타겟 1개 if (dataSnapshot.exists()){ | ||
50 | +// val memo = dataSnapshot.getValue(MemoItem::class.java) | ||
51 | +// if (memo != null){ | ||
52 | + // Toast.makeText(this@SearchActivity, memo!!.Policy, Toast.LENGTH_SHORT).show() | ||
53 | + // } | ||
54 | +// | ||
55 | +// } | ||
56 | + for(memoSnapshot in dataSnapshot.children){ | ||
57 | + val memo = memoSnapshot.getValue(MemoItem::class.java) | ||
58 | + Toast.makeText(this@SearchActivity, memo!!.Policy, Toast.LENGTH_SHORT).show() | ||
59 | + } | ||
60 | + } | ||
61 | + }) | ||
62 | + Toast.makeText(this@SearchActivity, "검색 처리됨 : $query", Toast.LENGTH_SHORT).show() | ||
63 | + return true | ||
64 | + } | ||
65 | + | ||
66 | + override fun onQueryTextChange(newText: String): Boolean { | ||
67 | + // 검색어가 변경되었을 때 이벤트 처리 | ||
68 | + return false | ||
69 | + } | ||
70 | + }) | ||
71 | + } | ||
72 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | package com.example.vip | 1 | package com.example.vip |
2 | 2 | ||
3 | +import android.content.Intent | ||
3 | import android.os.Bundle | 4 | import android.os.Bundle |
4 | import android.view.Menu | 5 | import android.view.Menu |
5 | import android.view.MenuItem | 6 | import android.view.MenuItem |
... | @@ -108,7 +109,9 @@ class SignInActivity : AppCompatActivity() { | ... | @@ -108,7 +109,9 @@ class SignInActivity : AppCompatActivity() { |
108 | Snackbar.make(toolbar,"Menu pressed",Snackbar.LENGTH_SHORT).show() | 109 | Snackbar.make(toolbar,"Menu pressed",Snackbar.LENGTH_SHORT).show() |
109 | } | 110 | } |
110 | R.id.menu_search->{ // 검색 버튼 | 111 | R.id.menu_search->{ // 검색 버튼 |
111 | - Snackbar.make(toolbar,"Search menu pressed",Snackbar.LENGTH_SHORT).show() | 112 | + val search_Intent = Intent(this, SearchActivity::class.java) |
113 | + startActivity(search_Intent) | ||
114 | + //Snackbar.make(toolbar,"Search menu pressed",Snackbar.LENGTH_SHORT).show() | ||
112 | } | 115 | } |
113 | } | 116 | } |
114 | return super.onOptionsItemSelected(item) | 117 | return super.onOptionsItemSelected(item) | ... | ... |
... | @@ -10,7 +10,6 @@ class SplashActivity : AppCompatActivity() { | ... | @@ -10,7 +10,6 @@ class SplashActivity : AppCompatActivity() { |
10 | override fun onCreate(savedInstanceState: Bundle?) { | 10 | override fun onCreate(savedInstanceState: Bundle?) { |
11 | super.onCreate(savedInstanceState) | 11 | super.onCreate(savedInstanceState) |
12 | 12 | ||
13 | - | ||
14 | val intent = Intent(this, MainActivity::class.java) | 13 | val intent = Intent(this, MainActivity::class.java) |
15 | startActivity(intent) | 14 | startActivity(intent) |
16 | finish() | 15 | finish() | ... | ... |
vip/app/src/main/res/layout/search.xml
0 → 100644
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | + xmlns:app="http://schemas.android.com/apk/res-auto" | ||
4 | + android:orientation="vertical" | ||
5 | + android:layout_width="match_parent" | ||
6 | + android:layout_height="match_parent"> | ||
7 | + | ||
8 | + <SearchView | ||
9 | + android:id="@+id/searchForm" | ||
10 | + android:queryHint="복지 정책 입력" | ||
11 | + app:showAsAction="always" | ||
12 | + android:layout_width="match_parent" | ||
13 | + android:layout_height="wrap_content" > | ||
14 | + | ||
15 | + </SearchView> | ||
16 | + | ||
17 | +</LinearLayout> | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
-
Please register or login to post a comment