soonmyeong2

add recommanded tab

package com.example.vip
import android.content.Context
import android.content.SharedPreferences
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.content.ContextCompat
import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.database.ValueEventListener
import kotlinx.android.synthetic.main.fragment_a.*
class FFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_a, container, false)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
val policyList = ArrayList<PolicyItem>()
var recomdatabase = FirebaseDatabase.getInstance().reference
recomdatabase.orderByChild("View").addListenerForSingleValueEvent(object :
ValueEventListener {
override fun onCancelled(p0: DatabaseError) {
//Toast.makeText(this@RecommendActivity, "실패부분", Toast.LENGTH_SHORT).show()
}
override fun onDataChange(dataSnapshot: DataSnapshot) {
for (memoSnapshot in dataSnapshot.children){
val memo = memoSnapshot.getValue(MemoItemRecom::class.java)
policyList.add(
PolicyItem(
ContextCompat.getDrawable(context!!.applicationContext, R.drawable.recommend_default_blue)!!,
memo!!.Policy,
memo!!.Content,
memo!!.Link,
memo!!.View,
memo!!.Keyword,
memo!!.Date,
memo!!.Review,
memo!!.Score,
memo!!.Category1,
memo!!.Category2,
memo!!.Category3,
memo!!.Category4,
memo!!.Category5,
memo!!.Category6,
memo!!.Category7,
memo!!.Category8,
memo!!.Category9,
memo!!.Category10,
memo!!.Category11,
memo!!.Category12,
memo!!.Category13,
memo!!.Category14,
memo!!.Category15,
memo!!.Category16,
memo!!.Value,
memo!!.D_day
)
)
}
val adapter = PolicyAdapter(policyList)
policyRecyclerView.adapter = adapter
}
})
}
}
package com.example.vip
import android.content.Context
import android.content.SharedPreferences
import android.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.content.ContextCompat
import com.google.firebase.database.DataSnapshot
import com.google.firebase.database.DatabaseError
import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.database.ValueEventListener
import kotlinx.android.synthetic.main.fragment_a.*
class GFragment : Fragment() {
override fun onCreateView(
inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_a, container, false)
}
override fun onActivityCreated(savedInstanceState: Bundle?) {
super.onActivityCreated(savedInstanceState)
val policyList = ArrayList<PolicyItem>()
var recomdatabase = FirebaseDatabase.getInstance().reference
recomdatabase.orderByChild("View").addListenerForSingleValueEvent(object :
ValueEventListener {
override fun onCancelled(p0: DatabaseError) {
//Toast.makeText(this@RecommendActivity, "실패부분", Toast.LENGTH_SHORT).show()
}
override fun onDataChange(dataSnapshot: DataSnapshot) {
for (memoSnapshot in dataSnapshot.children){
val memo = memoSnapshot.getValue(MemoItemRecom::class.java)
policyList.add(
PolicyItem(
ContextCompat.getDrawable(context!!.applicationContext, R.drawable.recommend_default_blue)!!,
memo!!.Policy,
memo!!.Content,
memo!!.Link,
memo!!.View,
memo!!.Keyword,
memo!!.Date,
memo!!.Review,
memo!!.Score,
memo!!.Category1,
memo!!.Category2,
memo!!.Category3,
memo!!.Category4,
memo!!.Category5,
memo!!.Category6,
memo!!.Category7,
memo!!.Category8,
memo!!.Category9,
memo!!.Category10,
memo!!.Category11,
memo!!.Category12,
memo!!.Category13,
memo!!.Category14,
memo!!.Category15,
memo!!.Category16,
memo!!.Value,
memo!!.D_day
)
)
}
val adapter = PolicyAdapter(policyList)
policyRecyclerView.adapter = adapter
}
})
}
}
......@@ -13,6 +13,7 @@ import android.widget.ImageView
import android.widget.Toast
import kotlinx.android.synthetic.main.activity_info.*
import android.graphics.drawable.ColorDrawable
import android.widget.TextView
import androidx.core.content.ContextCompat
import com.google.android.material.bottomnavigation.BottomNavigationView
import kotlinx.android.synthetic.main.activity_favorites.*
......@@ -39,7 +40,12 @@ class InfoActivity : AppCompatActivity() {
val prof: SharedPreferences =getSharedPreferences("profdata", Context.MODE_PRIVATE)
val editor: SharedPreferences.Editor=prof.edit()
//Toast.makeText(applicationContext,prof.getString("manorwoman","nothing"), Toast.LENGTH_SHORT).show()
var user_email : TextView = findViewById(R.id.InfoEmail)
user_email.text = prof.getString("user_email", "wello@email.com")//.toString()
var gender : TextView = findViewById(R.id.InfoProfilProgress)
gender.text = prof.getString("gender", "미입력")
//Toast.makeText(applicationContext,prof.getString("manorwoman","nothing"), Toast.LENGTH_SHORT).show()
InfoProfilModify.setOnClickListener {
......
......@@ -150,6 +150,7 @@ class InputProfilFirstThreeActivity : AppCompatActivity() {
if (manButton.isChecked){
editor.putInt("c3_2",1)
editor.putString("gender", "남자")
editor.commit()
editor.putString("first_three","done");editor.commit()
......@@ -157,6 +158,7 @@ class InputProfilFirstThreeActivity : AppCompatActivity() {
}
else{
editor.putInt("c3_3",1)
editor.putString("gender", "여자")
editor.commit()
editor.putString("first_three","done");editor.commit()
......
......@@ -60,6 +60,7 @@ class MainActivity : AppCompatActivity() {
if (user!=null){
editor.putString("user_email", edit_email.text.toString())
editor.putInt("c1_1",1); editor.commit()
editor.putInt("c2_1",1); editor.commit()
editor.putInt("c3_1",1); editor.commit()
......
......@@ -5,7 +5,7 @@ import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
class MainAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) {
private val fragmentTitleList = mutableListOf("전체", "교육", "고용","주거","건강")
private val fragmentTitleList = mutableListOf("전체", "교육", "고용","주거","건강", "금융", "문화")
override fun getItem(position: Int): Fragment {
......@@ -21,13 +21,17 @@ class MainAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) {
4 -> EFragment()
5 -> FFragment()
6 -> GFragment()
else -> null!!
}
}
// 생성 할 Fragment 의 개수
override fun getCount() = 5
override fun getCount() = 7
override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
super.destroyItem(container, position, `object`)
......
......@@ -88,6 +88,7 @@
android:layout_gravity="right"
android:layout_weight="1"
android:gravity="center"
android:paddingBottom="11dp"
android:text="성별"
android:textColor="#29ABE2"
android:textSize="13dp" />
......@@ -116,6 +117,7 @@
android:layout_gravity="center"
android:layout_weight="1"
android:gravity="center"
android:paddingBottom="11dp"
android:text="gender"
android:textSize="16dp" />
</LinearLayout>
......
......@@ -53,6 +53,7 @@
android:id="@+id/vpMainActivity"
android:layout_width="match_parent"
android:layout_height="50dp"
app:srcCompat="@drawable/image01"
android:layout_weight="1" />
......