Showing
4 changed files
with
64 additions
and
28 deletions
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,21 +39,45 @@ class RecommendActivity : AppCompatActivity() { | ... | @@ -26,21 +39,45 @@ 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) | ||
55 | + | ||
56 | + policyList.add( | ||
57 | + PolicyItem( | ||
58 | + ContextCompat.getDrawable(this@RecommendActivity, R.drawable.image01)!!, | ||
59 | + memo!!.Policy, | ||
60 | + memo!!.Policy, | ||
61 | + memo!!.Policy, | ||
62 | + 4.toFloat(), | ||
63 | + "0" | ||
64 | + | ||
65 | + ) | ||
66 | + ) | ||
67 | + } | ||
29 | 68 | ||
30 | - policyList.add( | 69 | + val adapter = PolicyAdapter(policyList) |
31 | - PolicyItem( | 70 | + policyRecyclerView.adapter = adapter |
32 | - ContextCompat.getDrawable(this, R.drawable.image01)!!, | ||
33 | - getString(R.string.title01), | ||
34 | - getString(R.string.title01), | ||
35 | - getString(R.string.title01), | ||
36 | - 4.toFloat(), | ||
37 | - "0" | ||
38 | 71 | ||
39 | - ) | 72 | + } |
40 | - ) | 73 | + |
74 | + }) | ||
75 | + | ||
76 | + | ||
77 | + } else { | ||
78 | + Toast.makeText(this, "putExtra value not found", Toast.LENGTH_SHORT).show() | ||
79 | + } | ||
41 | 80 | ||
42 | - val adapter = PolicyAdapter(policyList) | ||
43 | - policyRecyclerView.adapter = adapter | ||
44 | 81 | ||
45 | 82 | ||
46 | // 1. 툴바 사용 설정 | 83 | // 1. 툴바 사용 설정 | ... | ... |
... | @@ -38,28 +38,28 @@ | ... | @@ -38,28 +38,28 @@ |
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" |
55 | - android:layout_width="match_parent" | 54 | + android:layout_width="match_parent" |
56 | - android:layout_height="wrap_content" | 55 | + android:layout_height="wrap_content" |
57 | - android:layout_gravity="bottom" | 56 | + android:layout_gravity="bottom" |
58 | - android:background="#FFF" | 57 | + android:background="#FFF" |
59 | - app:itemIconTint="#29ABE2" | 58 | + app:itemIconTint="#29ABE2" |
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 | ... | ... |
-
Please register or login to post a comment