soonmyeong2

Merge branch 'tab'

......@@ -40,6 +40,7 @@ dependencies {
implementation 'com.google.firebase:firebase-messaging:20.0.0'
implementation 'com.google.firebase:firebase-database:17.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
......
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 AFragment : 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.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
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 BFragment : 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.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
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 CFragment : 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.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
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 DFragment : 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.os.Bundle
import androidx.fragment.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
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 EFragment : 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
}
})
}
}
......@@ -19,7 +19,7 @@ import com.google.firebase.database.FirebaseDatabase
import com.google.firebase.database.ValueEventListener
import kotlinx.android.synthetic.main.activity_favorites.*
import kotlinx.android.synthetic.main.activity_recommend.*
import kotlinx.android.synthetic.main.activity_recommend.policyRecyclerView
//import kotlinx.android.synthetic.main.activity_recommend.policyRecyclerView
import kotlinx.android.synthetic.main.activity_recommend.toolbar
import kotlinx.android.synthetic.main.activity_signin.*
......@@ -57,6 +57,7 @@ class FavoritesActivity : AppCompatActivity() {
////bottom navigation view operation start 1
lateinit var bottomBar: ActionBar
////bottom navigation view operation end 1
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_favorites)
......
package com.example.vip
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentStatePagerAdapter
class MainAdapter(fm: FragmentManager) : FragmentStatePagerAdapter(fm) {
private val fragmentTitleList = mutableListOf("전체", "교육", "고용","주거","건강")
override fun getItem(position: Int): Fragment {
return when (position) {
0 -> AFragment()
1 -> BFragment()
2 -> CFragment()
3 -> DFragment()
4 -> EFragment()
else -> null!!
}
}
// 생성 할 Fragment 의 개수
override fun getCount() = 5
override fun destroyItem(container: ViewGroup, position: Int, `object`: Any) {
super.destroyItem(container, position, `object`)
//Log.e("FragmentPagerAdapter", "destroyItem position : $position")
}
override fun getPageTitle(position: Int): CharSequence? {
return fragmentTitleList[position]
}
}
\ No newline at end of file
......@@ -62,8 +62,11 @@ data class MemoItemRecom(
val D_day : String = ""
)
class RecommendActivity : AppCompatActivity() {
private val adapter by lazy { MainAdapter(supportFragmentManager) }
var recomdatabase = FirebaseDatabase.getInstance().reference
////bottom navigation view operation start 1
......@@ -73,11 +76,18 @@ class RecommendActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_recommend)
// 뷰페이저 어댑터 연결
vpMainActivity.adapter = RecommendActivity@adapter
// 탭 레이아웃에 뷰페이저 연결
tabLayout.setupWithViewPager(vpMainActivity)
// 네비게이션 뷰 포커스 맞추는 코드
val bottomNavigationView: BottomNavigationView = findViewById(R.id.bottomNavigation2) as BottomNavigationView
bottomNavigationView.selectedItemId = R.id.bottomRecommend
bottomNavigationView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener)
/*
val policyList = ArrayList<PolicyItem>()
if (intent.hasExtra("key")) {
......@@ -124,8 +134,8 @@ class RecommendActivity : AppCompatActivity() {
)
)
}
val adapter = PolicyAdapter(policyList)
policyRecyclerView.adapter = adapter
//val adapter = PolicyAdapter(policyList)
//policyRecyclerView.adapter = adapter
}
})
......@@ -173,11 +183,13 @@ class RecommendActivity : AppCompatActivity() {
)
)
}
val adapter = PolicyAdapter(policyList)
policyRecyclerView.adapter = adapter
//val adapter = PolicyAdapter(policyList)
//policyRecyclerView.adapter = adapter
}
})
}
*/
// 1. 툴바 사용 설정
setSupportActionBar(toolbar)
// 2. 툴바 왼쪽 버튼 설정
......
......@@ -21,7 +21,6 @@
android:id="@+id/toolbar"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="11dp"
android:background="#FFF"
android:elevation="5dp"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
......@@ -34,14 +33,28 @@
android:src="@drawable/toolbar_logo" />
</androidx.appcompat.widget.Toolbar>
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/policyRecyclerView"
</com.google.android.material.appbar.AppBarLayout>
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="500dp"
android:layout_weight="1"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_policy" />
android:layout_height="wrap_content"
android:layout_marginBottom="11dp"
android:background="#FFF"
android:elevation="5dp"
app:tabSelectedTextColor="#29ABE2"
app:tabTextAppearance="@style/MyTabLayoutTextAppearance"
app:tabTextColor="#000" />
<androidx.viewpager.widget.ViewPager
android:id="@+id/vpMainActivity"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1" />
<FrameLayout
android:layout_width="match_parent"
......@@ -61,8 +74,6 @@
app:labelVisibilityMode="labeled"
app:menu="@menu/bottom_nav_menu" />
</FrameLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
......
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".AFragment">
<!-- TODO: Update blank fragment layout -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/policyRecyclerView"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_weight="1"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem="@layout/item_policy">
</androidx.recyclerview.widget.RecyclerView>
</LinearLayout>
</FrameLayout>
\ No newline at end of file
......@@ -21,4 +21,7 @@
<string name="msg_subscribed" translatable="false">success!</string>
<string name="msg_subscribe_failed" translatable="false">fail!</string>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>
......
......@@ -22,4 +22,11 @@
<item name="android:colorControlNormal">#29ABE2</item>
</style>
<style name="MyTabLayoutTextAppearance" parent="TextAppearance.AppCompat.Widget.ActionBar.Title.Inverse">
<item name="android:textSize">14dp</item>
<item name="android:textColorPrimary">#FFF</item> <!-- 탭바 선택된 텍스트 -->
<item name="android:textColorSecondary">#000</item> <!-- 탭바 텍스트 -->
</style>
</resources>
......