신기성

recommend page list done

1 <?xml version="1.0" encoding="UTF-8"?> 1 <?xml version="1.0" encoding="UTF-8"?>
2 <project version="4"> 2 <project version="4">
3 <component name="VcsDirectoryMappings"> 3 <component name="VcsDirectoryMappings">
4 - <mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
5 <mapping directory="$PROJECT_DIR$/.." vcs="Git" /> 4 <mapping directory="$PROJECT_DIR$/.." vcs="Git" />
6 </component> 5 </component>
7 </project> 6 </project>
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -6,15 +6,28 @@ import android.os.Bundle ...@@ -6,15 +6,28 @@ import android.os.Bundle
6 import android.util.Half.toFloat 6 import android.util.Half.toFloat
7 import android.view.Menu 7 import android.view.Menu
8 import android.view.MenuItem 8 import android.view.MenuItem
9 +import android.widget.Toast
9 import androidx.appcompat.app.ActionBar 10 import androidx.appcompat.app.ActionBar
10 import androidx.appcompat.app.AppCompatActivity 11 import androidx.appcompat.app.AppCompatActivity
11 import androidx.core.content.ContextCompat 12 import androidx.core.content.ContextCompat
12 import androidx.viewpager.widget.ViewPager 13 import androidx.viewpager.widget.ViewPager
13 import com.google.android.material.bottomnavigation.BottomNavigationView 14 import com.google.android.material.bottomnavigation.BottomNavigationView
14 import com.google.android.material.snackbar.Snackbar 15 import com.google.android.material.snackbar.Snackbar
16 +import com.google.firebase.database.DataSnapshot
17 +import com.google.firebase.database.DatabaseError
18 +import com.google.firebase.database.FirebaseDatabase
19 +import com.google.firebase.database.ValueEventListener
15 import kotlinx.android.synthetic.main.activity_recommend.* 20 import kotlinx.android.synthetic.main.activity_recommend.*
16 import kotlinx.android.synthetic.main.activity_signin.* 21 import kotlinx.android.synthetic.main.activity_signin.*
17 import kotlinx.android.synthetic.main.activity_signin.toolbar 22 import kotlinx.android.synthetic.main.activity_signin.toolbar
23 +import kotlinx.android.synthetic.main.search.*
24 +
25 +data class MemoItemRecom(
26 + val Target : String = "",
27 + val Policy : String = "",
28 + val Content : String = "",
29 + val Link : String = ""
30 +)
18 31
19 class RecommendActivity : AppCompatActivity() { 32 class RecommendActivity : AppCompatActivity() {
20 33
...@@ -26,22 +39,46 @@ class RecommendActivity : AppCompatActivity() { ...@@ -26,22 +39,46 @@ class RecommendActivity : AppCompatActivity() {
26 setContentView(R.layout.activity_recommend) 39 setContentView(R.layout.activity_recommend)
27 40
28 val policyList = ArrayList<PolicyItem>() 41 val policyList = ArrayList<PolicyItem>()
42 + var recomdatabase = FirebaseDatabase.getInstance().reference
43 +
44 + if (intent.hasExtra("key")) {
45 + //textView.text = intent.getStringExtra("key") 텍뷰추가하면 인텐트로 값넘기는거 보임
46 +
47 + recomdatabase.orderByChild("Policy").startAt(intent.getStringExtra("key")).endAt(intent.getStringExtra("key")+"\uf8ff").addListenerForSingleValueEvent(object :
48 + ValueEventListener {
49 + override fun onCancelled(p0: DatabaseError) {
50 + Toast.makeText(this@RecommendActivity, "실패부분", Toast.LENGTH_SHORT).show()
51 + }
52 + override fun onDataChange(dataSnapshot: DataSnapshot) {
53 + for (memoSnapshot in dataSnapshot.children){
54 + val memo = memoSnapshot.getValue(MemoItem::class.java)
29 55
30 policyList.add( 56 policyList.add(
31 PolicyItem( 57 PolicyItem(
32 - ContextCompat.getDrawable(this, R.drawable.image01)!!, 58 + ContextCompat.getDrawable(this@RecommendActivity, R.drawable.image01)!!,
33 - getString(R.string.title01), 59 + memo!!.Policy,
34 - getString(R.string.title01), 60 + memo!!.Policy,
35 - getString(R.string.title01), 61 + memo!!.Policy,
36 4.toFloat(), 62 4.toFloat(),
37 "0" 63 "0"
38 64
39 ) 65 )
40 ) 66 )
67 + }
41 68
42 val adapter = PolicyAdapter(policyList) 69 val adapter = PolicyAdapter(policyList)
43 policyRecyclerView.adapter = adapter 70 policyRecyclerView.adapter = adapter
44 71
72 + }
73 +
74 + })
75 +
76 +
77 + } else {
78 + Toast.makeText(this, "putExtra value not found", Toast.LENGTH_SHORT).show()
79 + }
80 +
81 +
45 82
46 // 1. 툴바 사용 설정 83 // 1. 툴바 사용 설정
47 setSupportActionBar(toolbar) 84 setSupportActionBar(toolbar)
......
...@@ -38,17 +38,16 @@ ...@@ -38,17 +38,16 @@
38 <androidx.recyclerview.widget.RecyclerView 38 <androidx.recyclerview.widget.RecyclerView
39 android:id="@+id/policyRecyclerView" 39 android:id="@+id/policyRecyclerView"
40 android:layout_width="match_parent" 40 android:layout_width="match_parent"
41 - android:layout_height="100dp" 41 + android:layout_height="500dp"
42 app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager" 42 app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
43 - app:layout_constraintBottom_toBottomOf="@id/bottomNavigation"
44 tools:listitem="@layout/item_policy" /> 43 tools:listitem="@layout/item_policy" />
45 44
46 <FrameLayout 45 <FrameLayout
47 android:layout_width="match_parent" 46 android:layout_width="match_parent"
48 android:layout_height="wrap_content" 47 android:layout_height="wrap_content"
49 - android:layout_weight="1"
50 android:id="@+id/fragmentContainer" 48 android:id="@+id/fragmentContainer"
51 - /> 49 + app:layout_constraintBottom_toBottomOf="parent"
50 + >
52 51
53 <com.google.android.material.bottomnavigation.BottomNavigationView 52 <com.google.android.material.bottomnavigation.BottomNavigationView
54 android:id="@+id/bottomNavigation" 53 android:id="@+id/bottomNavigation"
...@@ -60,6 +59,7 @@ ...@@ -60,6 +59,7 @@
60 app:itemTextColor="#29ABE2" 59 app:itemTextColor="#29ABE2"
61 app:labelVisibilityMode="labeled" 60 app:labelVisibilityMode="labeled"
62 app:menu="@menu/bottom_nav_menu" /> 61 app:menu="@menu/bottom_nav_menu" />
62 + </FrameLayout>
63 63
64 </LinearLayout> 64 </LinearLayout>
65 65
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
3 xmlns:app="http://schemas.android.com/apk/res-auto" 3 xmlns:app="http://schemas.android.com/apk/res-auto"
4 xmlns:tools="http://schemas.android.com/tools" 4 xmlns:tools="http://schemas.android.com/tools"
5 android:layout_width="match_parent" 5 android:layout_width="match_parent"
6 - android:layout_height="match_parent" 6 + android:layout_height="100dp"
7 android:orientation="horizontal"> 7 android:orientation="horizontal">
8 8
9 9
......