soonmyeong2

add recommanded tab

1 +package com.example.vip
2 +
3 +
4 +import android.content.Context
5 +import android.content.SharedPreferences
6 +import android.os.Bundle
7 +import androidx.fragment.app.Fragment
8 +import android.view.LayoutInflater
9 +import android.view.View
10 +import android.view.ViewGroup
11 +import android.widget.Toast
12 +import androidx.core.content.ContextCompat
13 +import com.google.firebase.database.DataSnapshot
14 +import com.google.firebase.database.DatabaseError
15 +import com.google.firebase.database.FirebaseDatabase
16 +import com.google.firebase.database.ValueEventListener
17 +import kotlinx.android.synthetic.main.fragment_a.*
18 +
19 +
20 +class FFragment : Fragment() {
21 +
22 + override fun onCreateView(
23 + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
24 + // Inflate the layout for this fragment
25 + return inflater.inflate(R.layout.fragment_a, container, false)
26 + }
27 +
28 + override fun onActivityCreated(savedInstanceState: Bundle?) {
29 + super.onActivityCreated(savedInstanceState)
30 +
31 + val policyList = ArrayList<PolicyItem>()
32 + var recomdatabase = FirebaseDatabase.getInstance().reference
33 +
34 + recomdatabase.orderByChild("View").addListenerForSingleValueEvent(object :
35 + ValueEventListener {
36 + override fun onCancelled(p0: DatabaseError) {
37 + //Toast.makeText(this@RecommendActivity, "실패부분", Toast.LENGTH_SHORT).show()
38 + }
39 + override fun onDataChange(dataSnapshot: DataSnapshot) {
40 + for (memoSnapshot in dataSnapshot.children){
41 + val memo = memoSnapshot.getValue(MemoItemRecom::class.java)
42 +
43 + policyList.add(
44 + PolicyItem(
45 + ContextCompat.getDrawable(context!!.applicationContext, R.drawable.recommend_default_blue)!!,
46 + memo!!.Policy,
47 + memo!!.Content,
48 + memo!!.Link,
49 + memo!!.View,
50 + memo!!.Keyword,
51 + memo!!.Date,
52 + memo!!.Review,
53 + memo!!.Score,
54 + memo!!.Category1,
55 + memo!!.Category2,
56 + memo!!.Category3,
57 + memo!!.Category4,
58 + memo!!.Category5,
59 + memo!!.Category6,
60 + memo!!.Category7,
61 + memo!!.Category8,
62 + memo!!.Category9,
63 + memo!!.Category10,
64 + memo!!.Category11,
65 + memo!!.Category12,
66 + memo!!.Category13,
67 + memo!!.Category14,
68 + memo!!.Category15,
69 + memo!!.Category16,
70 + memo!!.Value,
71 + memo!!.D_day
72 + )
73 + )
74 + }
75 + val adapter = PolicyAdapter(policyList)
76 + policyRecyclerView.adapter = adapter
77 + }
78 + })
79 + }
80 +}
1 +package com.example.vip
2 +
3 +
4 +import android.content.Context
5 +import android.content.SharedPreferences
6 +import android.os.Bundle
7 +import androidx.fragment.app.Fragment
8 +import android.view.LayoutInflater
9 +import android.view.View
10 +import android.view.ViewGroup
11 +import android.widget.Toast
12 +import androidx.core.content.ContextCompat
13 +import com.google.firebase.database.DataSnapshot
14 +import com.google.firebase.database.DatabaseError
15 +import com.google.firebase.database.FirebaseDatabase
16 +import com.google.firebase.database.ValueEventListener
17 +import kotlinx.android.synthetic.main.fragment_a.*
18 +
19 +
20 +class GFragment : Fragment() {
21 +
22 + override fun onCreateView(
23 + inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
24 + // Inflate the layout for this fragment
25 + return inflater.inflate(R.layout.fragment_a, container, false)
26 + }
27 +
28 + override fun onActivityCreated(savedInstanceState: Bundle?) {
29 + super.onActivityCreated(savedInstanceState)
30 +
31 + val policyList = ArrayList<PolicyItem>()
32 + var recomdatabase = FirebaseDatabase.getInstance().reference
33 +
34 + recomdatabase.orderByChild("View").addListenerForSingleValueEvent(object :
35 + ValueEventListener {
36 + override fun onCancelled(p0: DatabaseError) {
37 + //Toast.makeText(this@RecommendActivity, "실패부분", Toast.LENGTH_SHORT).show()
38 + }
39 + override fun onDataChange(dataSnapshot: DataSnapshot) {
40 + for (memoSnapshot in dataSnapshot.children){
41 + val memo = memoSnapshot.getValue(MemoItemRecom::class.java)
42 +
43 + policyList.add(
44 + PolicyItem(
45 + ContextCompat.getDrawable(context!!.applicationContext, R.drawable.recommend_default_blue)!!,
46 + memo!!.Policy,
47 + memo!!.Content,
48 + memo!!.Link,
49 + memo!!.View,
50 + memo!!.Keyword,
51 + memo!!.Date,
52 + memo!!.Review,
53 + memo!!.Score,
54 + memo!!.Category1,
55 + memo!!.Category2,
56 + memo!!.Category3,
57 + memo!!.Category4,
58 + memo!!.Category5,
59 + memo!!.Category6,
60 + memo!!.Category7,
61 + memo!!.Category8,
62 + memo!!.Category9,
63 + memo!!.Category10,
64 + memo!!.Category11,
65 + memo!!.Category12,
66 + memo!!.Category13,
67 + memo!!.Category14,
68 + memo!!.Category15,
69 + memo!!.Category16,
70 + memo!!.Value,
71 + memo!!.D_day
72 + )
73 + )
74 + }
75 + val adapter = PolicyAdapter(policyList)
76 + policyRecyclerView.adapter = adapter
77 + }
78 + })
79 + }
80 +}
...@@ -13,6 +13,7 @@ import android.widget.ImageView ...@@ -13,6 +13,7 @@ import android.widget.ImageView
13 import android.widget.Toast 13 import android.widget.Toast
14 import kotlinx.android.synthetic.main.activity_info.* 14 import kotlinx.android.synthetic.main.activity_info.*
15 import android.graphics.drawable.ColorDrawable 15 import android.graphics.drawable.ColorDrawable
16 +import android.widget.TextView
16 import androidx.core.content.ContextCompat 17 import androidx.core.content.ContextCompat
17 import com.google.android.material.bottomnavigation.BottomNavigationView 18 import com.google.android.material.bottomnavigation.BottomNavigationView
18 import kotlinx.android.synthetic.main.activity_favorites.* 19 import kotlinx.android.synthetic.main.activity_favorites.*
...@@ -39,7 +40,12 @@ class InfoActivity : AppCompatActivity() { ...@@ -39,7 +40,12 @@ class InfoActivity : AppCompatActivity() {
39 val prof: SharedPreferences =getSharedPreferences("profdata", Context.MODE_PRIVATE) 40 val prof: SharedPreferences =getSharedPreferences("profdata", Context.MODE_PRIVATE)
40 val editor: SharedPreferences.Editor=prof.edit() 41 val editor: SharedPreferences.Editor=prof.edit()
41 42
42 - //Toast.makeText(applicationContext,prof.getString("manorwoman","nothing"), Toast.LENGTH_SHORT).show() 43 + var user_email : TextView = findViewById(R.id.InfoEmail)
44 + user_email.text = prof.getString("user_email", "wello@email.com")//.toString()
45 + var gender : TextView = findViewById(R.id.InfoProfilProgress)
46 + gender.text = prof.getString("gender", "미입력")
47 +
48 + //Toast.makeText(applicationContext,prof.getString("manorwoman","nothing"), Toast.LENGTH_SHORT).show()
43 49
44 InfoProfilModify.setOnClickListener { 50 InfoProfilModify.setOnClickListener {
45 51
......
...@@ -150,6 +150,7 @@ class InputProfilFirstThreeActivity : AppCompatActivity() { ...@@ -150,6 +150,7 @@ class InputProfilFirstThreeActivity : AppCompatActivity() {
150 150
151 if (manButton.isChecked){ 151 if (manButton.isChecked){
152 editor.putInt("c3_2",1) 152 editor.putInt("c3_2",1)
153 + editor.putString("gender", "남자")
153 editor.commit() 154 editor.commit()
154 editor.putString("first_three","done");editor.commit() 155 editor.putString("first_three","done");editor.commit()
155 156
...@@ -157,6 +158,7 @@ class InputProfilFirstThreeActivity : AppCompatActivity() { ...@@ -157,6 +158,7 @@ class InputProfilFirstThreeActivity : AppCompatActivity() {
157 } 158 }
158 else{ 159 else{
159 editor.putInt("c3_3",1) 160 editor.putInt("c3_3",1)
161 + editor.putString("gender", "여자")
160 editor.commit() 162 editor.commit()
161 editor.putString("first_three","done");editor.commit() 163 editor.putString("first_three","done");editor.commit()
162 164
......
...@@ -60,6 +60,7 @@ class MainActivity : AppCompatActivity() { ...@@ -60,6 +60,7 @@ class MainActivity : AppCompatActivity() {
60 60
61 61
62 if (user!=null){ 62 if (user!=null){
63 + editor.putString("user_email", edit_email.text.toString())
63 editor.putInt("c1_1",1); editor.commit() 64 editor.putInt("c1_1",1); editor.commit()
64 editor.putInt("c2_1",1); editor.commit() 65 editor.putInt("c2_1",1); editor.commit()
65 editor.putInt("c3_1",1); editor.commit() 66 editor.putInt("c3_1",1); editor.commit()
......
...@@ -5,7 +5,7 @@ import androidx.fragment.app.FragmentManager ...@@ -5,7 +5,7 @@ import androidx.fragment.app.FragmentManager
5 import androidx.fragment.app.FragmentStatePagerAdapter 5 import androidx.fragment.app.FragmentStatePagerAdapter
6 6
7 class MainAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) { 7 class MainAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) {
8 - private val fragmentTitleList = mutableListOf("전체", "교육", "고용","주거","건강") 8 + private val fragmentTitleList = mutableListOf("전체", "교육", "고용","주거","건강", "금융", "문화")
9 9
10 override fun getItem(position: Int): Fragment { 10 override fun getItem(position: Int): Fragment {
11 11
...@@ -21,13 +21,17 @@ class MainAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) { ...@@ -21,13 +21,17 @@ class MainAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) {
21 21
22 4 -> EFragment() 22 4 -> EFragment()
23 23
24 + 5 -> FFragment()
25 +
26 + 6 -> GFragment()
27 +
24 else -> null!! 28 else -> null!!
25 } 29 }
26 30
27 } 31 }
28 32
29 // 생성 할 Fragment 의 개수 33 // 생성 할 Fragment 의 개수
30 - override fun getCount() = 5 34 + override fun getCount() = 7
31 35
32 override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) { 36 override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
33 super.destroyItem(container, position, `object`) 37 super.destroyItem(container, position, `object`)
......
...@@ -88,6 +88,7 @@ ...@@ -88,6 +88,7 @@
88 android:layout_gravity="right" 88 android:layout_gravity="right"
89 android:layout_weight="1" 89 android:layout_weight="1"
90 android:gravity="center" 90 android:gravity="center"
91 + android:paddingBottom="11dp"
91 android:text="성별" 92 android:text="성별"
92 android:textColor="#29ABE2" 93 android:textColor="#29ABE2"
93 android:textSize="13dp" /> 94 android:textSize="13dp" />
...@@ -116,6 +117,7 @@ ...@@ -116,6 +117,7 @@
116 android:layout_gravity="center" 117 android:layout_gravity="center"
117 android:layout_weight="1" 118 android:layout_weight="1"
118 android:gravity="center" 119 android:gravity="center"
120 + android:paddingBottom="11dp"
119 android:text="gender" 121 android:text="gender"
120 android:textSize="16dp" /> 122 android:textSize="16dp" />
121 </LinearLayout> 123 </LinearLayout>
......
...@@ -53,6 +53,7 @@ ...@@ -53,6 +53,7 @@
53 android:id="@+id/vpMainActivity" 53 android:id="@+id/vpMainActivity"
54 android:layout_width="match_parent" 54 android:layout_width="match_parent"
55 android:layout_height="50dp" 55 android:layout_height="50dp"
56 + app:srcCompat="@drawable/image01"
56 android:layout_weight="1" /> 57 android:layout_weight="1" />
57 58
58 59
......