soonmyeong2

bottomnavi correct working if change activicy

No preview for this file type

298 Bytes

...@@ -17,7 +17,9 @@ import com.google.firebase.database.DataSnapshot ...@@ -17,7 +17,9 @@ import com.google.firebase.database.DataSnapshot
17 import com.google.firebase.database.DatabaseError 17 import com.google.firebase.database.DatabaseError
18 import com.google.firebase.database.FirebaseDatabase 18 import com.google.firebase.database.FirebaseDatabase
19 import com.google.firebase.database.ValueEventListener 19 import com.google.firebase.database.ValueEventListener
20 +import kotlinx.android.synthetic.main.activity_favorites.*
20 import kotlinx.android.synthetic.main.activity_recommend.* 21 import kotlinx.android.synthetic.main.activity_recommend.*
22 +import kotlinx.android.synthetic.main.activity_recommend.policyRecyclerView
21 import kotlinx.android.synthetic.main.activity_recommend.toolbar 23 import kotlinx.android.synthetic.main.activity_recommend.toolbar
22 import kotlinx.android.synthetic.main.activity_signin.* 24 import kotlinx.android.synthetic.main.activity_signin.*
23 25
...@@ -37,6 +39,12 @@ class FavoritesActivity : AppCompatActivity() { ...@@ -37,6 +39,12 @@ class FavoritesActivity : AppCompatActivity() {
37 super.onCreate(savedInstanceState) 39 super.onCreate(savedInstanceState)
38 setContentView(R.layout.activity_favorites) 40 setContentView(R.layout.activity_favorites)
39 41
42 + // 네비게이션 뷰 포커스 맞추는 코드
43 + val bottomNavigationView: BottomNavigationView = findViewById(R.id.bottomNavigation3) as BottomNavigationView
44 + bottomNavigationView.selectedItemId = R.id.bottomFavorites
45 + bottomNavigationView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener)
46 +
47 +
40 val policyList = ArrayList<PolicyItem>() 48 val policyList = ArrayList<PolicyItem>()
41 var favordatabase = FirebaseDatabase.getInstance().reference 49 var favordatabase = FirebaseDatabase.getInstance().reference
42 50
...@@ -67,41 +75,39 @@ class FavoritesActivity : AppCompatActivity() { ...@@ -67,41 +75,39 @@ class FavoritesActivity : AppCompatActivity() {
67 memo!!.Policy, 75 memo!!.Policy,
68 4.toFloat(), 76 4.toFloat(),
69 " " 77 " "
70 -
71 ) 78 )
72 ) 79 )
73 } 80 }
74 81
75 val adapter = PolicyAdapter(policyList) 82 val adapter = PolicyAdapter(policyList)
76 policyRecyclerView.adapter = adapter 83 policyRecyclerView.adapter = adapter
77 -
78 } 84 }
79 -
80 }) 85 })
81 -
82 } 86 }
83 87
84 - if (intent.hasExtra("key")) { 88 + /* if (intent.hasExtra("key")) {
85 //textView.text = intent.getStringExtra("key") 텍뷰추가하면 인텐트로 값넘기는거 보임 89 //textView.text = intent.getStringExtra("key") 텍뷰추가하면 인텐트로 값넘기는거 보임
86 90
87 } else { 91 } else {
88 Toast.makeText(this, "putExtra value not found", Toast.LENGTH_SHORT).show() 92 Toast.makeText(this, "putExtra value not found", Toast.LENGTH_SHORT).show()
89 } 93 }
90 94
95 + */
96 +
91 97
92 98
93 // 1. 툴바 사용 설정 99 // 1. 툴바 사용 설정
94 setSupportActionBar(toolbar) 100 setSupportActionBar(toolbar)
95 101
96 // 2. 툴바 왼쪽 버튼 설정 102 // 2. 툴바 왼쪽 버튼 설정
97 - supportActionBar!!.setDisplayHomeAsUpEnabled(true) // 왼쪽 버튼 사용 여부 true 103 + supportActionBar!!.setDisplayHomeAsUpEnabled(false) // 왼쪽 버튼 사용 여부 true
98 supportActionBar!!.setHomeAsUpIndicator(R.drawable.return_page) // 왼쪽 버튼 아이콘 설정 104 supportActionBar!!.setHomeAsUpIndicator(R.drawable.return_page) // 왼쪽 버튼 아이콘 설정
99 supportActionBar!!.setDisplayShowTitleEnabled(false) // 타이틀 안보이게 하기 105 supportActionBar!!.setDisplayShowTitleEnabled(false) // 타이틀 안보이게 하기
100 106
101 ////bottom navigation view operation start 2 107 ////bottom navigation view operation start 2
102 bottomBar=supportActionBar!! 108 bottomBar=supportActionBar!!
103 - val bottomNavigation: BottomNavigationView =findViewById(R.id.bottomNavigation) 109 + //val bottomNavigation: BottomNavigationView =findViewById(R.id.bottomNavigation)
104 - bottomNavigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener) 110 + //bottomNavigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener)
105 ////bottom navigation view operation end 2 111 ////bottom navigation view operation end 2
106 112
107 } 113 }
...@@ -116,6 +122,7 @@ class FavoritesActivity : AppCompatActivity() { ...@@ -116,6 +122,7 @@ class FavoritesActivity : AppCompatActivity() {
116 // 클릭된 메뉴 아이템의 아이디 마다 when 구절로 클릭시 동작을 설정한다. 122 // 클릭된 메뉴 아이템의 아이디 마다 when 구절로 클릭시 동작을 설정한다.
117 when(item!!.itemId){ 123 when(item!!.itemId){
118 android.R.id.home->{ // 메뉴 버튼 124 android.R.id.home->{ // 메뉴 버튼
125 + bottomNavigation3.selectedItemId = R.id.bottomFavorites
119 Snackbar.make(toolbar,"Menu pressed", Snackbar.LENGTH_SHORT).show() 126 Snackbar.make(toolbar,"Menu pressed", Snackbar.LENGTH_SHORT).show()
120 } 127 }
121 R.id.menu_search->{ // 검색 버튼 128 R.id.menu_search->{ // 검색 버튼
...@@ -127,27 +134,45 @@ class FavoritesActivity : AppCompatActivity() { ...@@ -127,27 +134,45 @@ class FavoritesActivity : AppCompatActivity() {
127 return super.onOptionsItemSelected(item) 134 return super.onOptionsItemSelected(item)
128 } 135 }
129 136
137 + var back_pressed: Long = 0 // 뒤로가기 종료
138 +
139 + override fun onBackPressed() {
140 + if (back_pressed + 2000 > System.currentTimeMillis()) {
141 + finishAffinity()
142 + System.runFinalization()
143 + System.exit(0)
144 + }
145 + //super.onBackPressed()
146 + else
147 + Toast.makeText(getBaseContext(), "\'뒤로\' 버튼을 한번 더 누르시면 종료됩니다.", Toast.LENGTH_SHORT).show()
148 + back_pressed = System.currentTimeMillis()
149 + }
150 +
151 +
130 //bottom navigation view operation start 3 152 //bottom navigation view operation start 3
131 private val mOnNavigationItemSelectedListener= 153 private val mOnNavigationItemSelectedListener=
132 BottomNavigationView.OnNavigationItemSelectedListener{ item-> 154 BottomNavigationView.OnNavigationItemSelectedListener{ item->
133 when (item.itemId){ 155 when (item.itemId){
134 156
135 R.id.bottomHome ->{ 157 R.id.bottomHome ->{
158 + //bottomNavigation3.selectedItemId = R.id.bottomFavorites
136 val intent = Intent(this, SignInActivity::class.java) 159 val intent = Intent(this, SignInActivity::class.java)
137 startActivity(intent) 160 startActivity(intent)
138 return@OnNavigationItemSelectedListener true 161 return@OnNavigationItemSelectedListener true
139 } 162 }
140 R.id.bottomRecommend ->{ 163 R.id.bottomRecommend ->{
164 + //bottomNavigation3.selectedItemId = R.id.bottomFavorites
141 val intent = Intent(this, RecommendActivity::class.java) 165 val intent = Intent(this, RecommendActivity::class.java)
142 startActivity(intent) 166 startActivity(intent)
143 return@OnNavigationItemSelectedListener true 167 return@OnNavigationItemSelectedListener true
144 } 168 }
145 R.id.bottomFavorites ->{ 169 R.id.bottomFavorites ->{
146 - val intent = Intent(this, FavoritesActivity::class.java) 170 + //val intent = Intent(this, FavoritesActivity::class.java)
147 - startActivity(intent) 171 + //startActivity(intent)
148 - return@OnNavigationItemSelectedListener true 172 + //return@OnNavigationItemSelectedListener true
149 } 173 }
150 R.id.bottomInfo ->{ 174 R.id.bottomInfo ->{
175 + //bottomNavigation3.selectedItemId = R.id.bottomFavorites
151 val intent = Intent(this, InfoActivity::class.java) 176 val intent = Intent(this, InfoActivity::class.java)
152 startActivity(intent) 177 startActivity(intent)
153 return@OnNavigationItemSelectedListener true 178 return@OnNavigationItemSelectedListener true
......
...@@ -14,6 +14,8 @@ import android.widget.Toast ...@@ -14,6 +14,8 @@ 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 androidx.core.content.ContextCompat 16 import androidx.core.content.ContextCompat
17 +import com.google.android.material.bottomnavigation.BottomNavigationView
18 +import kotlinx.android.synthetic.main.activity_favorites.*
17 import kotlinx.android.synthetic.main.activity_settings_in_form.* 19 import kotlinx.android.synthetic.main.activity_settings_in_form.*
18 20
19 class InfoActivity : AppCompatActivity() { 21 class InfoActivity : AppCompatActivity() {
...@@ -22,6 +24,12 @@ class InfoActivity : AppCompatActivity() { ...@@ -22,6 +24,12 @@ class InfoActivity : AppCompatActivity() {
22 super.onCreate(savedInstanceState) 24 super.onCreate(savedInstanceState)
23 setContentView(R.layout.activity_info) 25 setContentView(R.layout.activity_info)
24 26
27 + // 네비게이션 뷰 포커스 맞추는 코드
28 + val bottomNavigationView: BottomNavigationView = findViewById(R.id.bottomNavigation4) as BottomNavigationView
29 + bottomNavigationView.selectedItemId = R.id.bottomInfo
30 + bottomNavigationView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener)
31 +
32 +
25 // statusbar color chacnge 33 // statusbar color chacnge
26 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 34 if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
27 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); 35 getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
...@@ -31,8 +39,7 @@ class InfoActivity : AppCompatActivity() { ...@@ -31,8 +39,7 @@ class InfoActivity : AppCompatActivity() {
31 val prof: SharedPreferences =getSharedPreferences("profdata", Context.MODE_PRIVATE) 39 val prof: SharedPreferences =getSharedPreferences("profdata", Context.MODE_PRIVATE)
32 val editor: SharedPreferences.Editor=prof.edit() 40 val editor: SharedPreferences.Editor=prof.edit()
33 41
34 - Toast.makeText(applicationContext,prof.getString("manorwoman","nothing"), 42 + //Toast.makeText(applicationContext,prof.getString("manorwoman","nothing"), Toast.LENGTH_SHORT).show()
35 - Toast.LENGTH_SHORT).show()
36 43
37 InfoProfilModify.setOnClickListener { 44 InfoProfilModify.setOnClickListener {
38 var intent = Intent(this, SettingActivity::class.java) 45 var intent = Intent(this, SettingActivity::class.java)
...@@ -53,15 +60,50 @@ class InfoActivity : AppCompatActivity() { ...@@ -53,15 +60,50 @@ class InfoActivity : AppCompatActivity() {
53 var intent = Intent(this, QuestionsActivity::class.java) 60 var intent = Intent(this, QuestionsActivity::class.java)
54 startActivity(intent) 61 startActivity(intent)
55 } 62 }
63 + }
64 +
65 + var back_pressed: Long = 0 // 뒤로가기 종료
56 66
57 - //pushing test start 67 + override fun onBackPressed() {
58 - // InfoButtonSettings.setOnClickListener { 68 + if (back_pressed + 2000 > System.currentTimeMillis()) {
59 - // //var intent = Intent(this, SettingActivity::class.java) 69 + finishAffinity()
60 - //test start 70 + System.runFinalization()
61 - // var intent = Intent(this, InputProfilFirstOneActivity::class.java) 71 + System.exit(0)
62 - //test end 72 + }
63 - // startActivity(intent) 73 + //super.onBackPressed()
64 - // } 74 + else
65 - //pushing test end 75 + Toast.makeText(getBaseContext(), "\'뒤로\' 버튼을 한번 더 누르시면 종료됩니다.", Toast.LENGTH_SHORT).show()
76 + back_pressed = System.currentTimeMillis()
66 } 77 }
78 +
79 +
80 + private val mOnNavigationItemSelectedListener=
81 + BottomNavigationView.OnNavigationItemSelectedListener{ item->
82 + when (item.itemId){
83 + R.id.bottomHome ->{
84 + //bottomNavigation4.selectedItemId = R.id.bottomInfo
85 + val intent = Intent(this, SignInActivity::class.java)
86 + startActivity(intent)
87 + return@OnNavigationItemSelectedListener true
88 + }
89 + R.id.bottomRecommend ->{
90 + //bottomNavigation4.selectedItemId = R.id.bottomInfo
91 + val intent = Intent(this, RecommendActivity::class.java)
92 + startActivity(intent)
93 + return@OnNavigationItemSelectedListener true
94 + }
95 + R.id.bottomFavorites ->{
96 + //bottomNavigation4.selectedItemId = R.id.bottomInfo
97 + val intent = Intent(this, FavoritesActivity::class.java)
98 + startActivity(intent)
99 + return@OnNavigationItemSelectedListener true
100 + }
101 + R.id.bottomInfo ->{
102 + //val intent = Intent(this, InfoActivity::class.java)
103 + //startActivity(intent)
104 + //return@OnNavigationItemSelectedListener true
105 + }
106 + }
107 + false
108 + }
67 } 109 }
......
...@@ -7,6 +7,4 @@ class PolicyItem(val policyItemImage: Drawable, ...@@ -7,6 +7,4 @@ class PolicyItem(val policyItemImage: Drawable,
7 val policyItemHost: String, 7 val policyItemHost: String,
8 val policyItemTitle: String, 8 val policyItemTitle: String,
9 val policyItemScore: Float, 9 val policyItemScore: Float,
10 - val policyItemFavor: String) {
11 -
12 -}
...\ No newline at end of file ...\ No newline at end of file
10 + val policyItemFavor: String)
...\ No newline at end of file ...\ No newline at end of file
......
1 package com.example.vip 1 package com.example.vip
2 2
3 import android.app.Activity 3 import android.app.Activity
4 +import android.content.ClipData
4 import android.content.Context 5 import android.content.Context
5 import android.content.Intent 6 import android.content.Intent
6 import android.content.SharedPreferences 7 import android.content.SharedPreferences
...@@ -8,6 +9,7 @@ import android.os.Bundle ...@@ -8,6 +9,7 @@ import android.os.Bundle
8 import android.util.Half.toFloat 9 import android.util.Half.toFloat
9 import android.view.Menu 10 import android.view.Menu
10 import android.view.MenuItem 11 import android.view.MenuItem
12 +import android.widget.Button
11 import android.widget.Toast 13 import android.widget.Toast
12 import androidx.appcompat.app.ActionBar 14 import androidx.appcompat.app.ActionBar
13 import androidx.appcompat.app.AppCompatActivity 15 import androidx.appcompat.app.AppCompatActivity
...@@ -26,6 +28,11 @@ import kotlinx.android.synthetic.main.activity_signin.toolbar ...@@ -26,6 +28,11 @@ import kotlinx.android.synthetic.main.activity_signin.toolbar
26 import kotlinx.android.synthetic.main.item_policy.* 28 import kotlinx.android.synthetic.main.item_policy.*
27 import kotlinx.android.synthetic.main.item_policy.view.* 29 import kotlinx.android.synthetic.main.item_policy.view.*
28 import kotlinx.android.synthetic.main.search.* 30 import kotlinx.android.synthetic.main.search.*
31 +import androidx.core.app.ComponentActivity.ExtraData
32 +import androidx.core.content.ContextCompat.getSystemService
33 +import android.icu.lang.UCharacter.GraphemeClusterBreak.T
34 +import androidx.core.view.size
35 +
29 36
30 data class MemoItemRecom( 37 data class MemoItemRecom(
31 val Target : String = "", 38 val Target : String = "",
...@@ -36,6 +43,8 @@ data class MemoItemRecom( ...@@ -36,6 +43,8 @@ data class MemoItemRecom(
36 43
37 class RecommendActivity : AppCompatActivity() { 44 class RecommendActivity : AppCompatActivity() {
38 45
46 + var recomdatabase = FirebaseDatabase.getInstance().reference
47 +
39 ////bottom navigation view operation start 1 48 ////bottom navigation view operation start 1
40 lateinit var bottomBar: ActionBar 49 lateinit var bottomBar: ActionBar
41 ////bottom navigation view operation end 1 50 ////bottom navigation view operation end 1
...@@ -43,14 +52,18 @@ class RecommendActivity : AppCompatActivity() { ...@@ -43,14 +52,18 @@ class RecommendActivity : AppCompatActivity() {
43 super.onCreate(savedInstanceState) 52 super.onCreate(savedInstanceState)
44 setContentView(R.layout.activity_recommend) 53 setContentView(R.layout.activity_recommend)
45 54
55 + // 네비게이션 뷰 포커스 맞추는 코드
56 + val bottomNavigationView: BottomNavigationView = findViewById(R.id.bottomNavigation2) as BottomNavigationView
57 + bottomNavigationView.selectedItemId = R.id.bottomRecommend
58 + bottomNavigationView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener)
59 +
46 val policyList = ArrayList<PolicyItem>() 60 val policyList = ArrayList<PolicyItem>()
47 - var recomdatabase = FirebaseDatabase.getInstance().reference
48 61
49 if (intent.hasExtra("key")) { 62 if (intent.hasExtra("key")) {
50 //textView.text = intent.getStringExtra("key") 텍뷰추가하면 인텐트로 값넘기는거 보임 63 //textView.text = intent.getStringExtra("key") 텍뷰추가하면 인텐트로 값넘기는거 보임
51 64
52 - recomdatabase.orderByChild("Policy").startAt(intent.getStringExtra("key")).endAt(intent.getStringExtra("key")+"\uf8ff").addListenerForSingleValueEvent(object : 65 + // startAt(intent.getStringExtra("key")).endAt(intent.getStringExtra("key")+"\uf8ff")
53 - ValueEventListener { 66 + recomdatabase.orderByChild("View").addListenerForSingleValueEvent(object : ValueEventListener {
54 override fun onCancelled(p0: DatabaseError) { 67 override fun onCancelled(p0: DatabaseError) {
55 Toast.makeText(this@RecommendActivity, "실패부분", Toast.LENGTH_SHORT).show() 68 Toast.makeText(this@RecommendActivity, "실패부분", Toast.LENGTH_SHORT).show()
56 } 69 }
...@@ -63,7 +76,7 @@ class RecommendActivity : AppCompatActivity() { ...@@ -63,7 +76,7 @@ class RecommendActivity : AppCompatActivity() {
63 ContextCompat.getDrawable(this@RecommendActivity, R.drawable.image01)!!, 76 ContextCompat.getDrawable(this@RecommendActivity, R.drawable.image01)!!,
64 "상시", 77 "상시",
65 memo!!.Policy, 78 memo!!.Policy,
66 - memo!!.Policy, 79 + memo.Policy,
67 4.toFloat(), 80 4.toFloat(),
68 "" 81 ""
69 ) 82 )
...@@ -75,9 +88,9 @@ class RecommendActivity : AppCompatActivity() { ...@@ -75,9 +88,9 @@ class RecommendActivity : AppCompatActivity() {
75 }) 88 })
76 89
77 } else { 90 } else {
78 - Toast.makeText(this, "putExtra value not found", Toast.LENGTH_SHORT).show() 91 + //Toast.makeText(this, "putExtra value not found", Toast.LENGTH_SHORT).show()
79 92
80 - recomdatabase.orderByChild("Policy").startAt(intent.getStringExtra("\uf8ff")).addListenerForSingleValueEvent(object : 93 + recomdatabase.orderByChild("View").addListenerForSingleValueEvent(object :
81 ValueEventListener { 94 ValueEventListener {
82 override fun onCancelled(p0: DatabaseError) { 95 override fun onCancelled(p0: DatabaseError) {
83 Toast.makeText(this@RecommendActivity, "실패부분", Toast.LENGTH_SHORT).show() 96 Toast.makeText(this@RecommendActivity, "실패부분", Toast.LENGTH_SHORT).show()
...@@ -91,12 +104,12 @@ class RecommendActivity : AppCompatActivity() { ...@@ -91,12 +104,12 @@ class RecommendActivity : AppCompatActivity() {
91 ContextCompat.getDrawable(this@RecommendActivity, R.drawable.image01)!!, 104 ContextCompat.getDrawable(this@RecommendActivity, R.drawable.image01)!!,
92 "상시", 105 "상시",
93 memo!!.Policy, 106 memo!!.Policy,
94 - memo!!.Policy, 107 + memo.Policy,
95 4.toFloat(), 108 4.toFloat(),
96 "" 109 ""
97 -
98 ) 110 )
99 ) 111 )
112 + //Toast.makeText(this@RecommendActivity, memo.View.toString(), Toast.LENGTH_SHORT).show()
100 } 113 }
101 val adapter = PolicyAdapter(policyList) 114 val adapter = PolicyAdapter(policyList)
102 policyRecyclerView.adapter = adapter 115 policyRecyclerView.adapter = adapter
...@@ -106,13 +119,13 @@ class RecommendActivity : AppCompatActivity() { ...@@ -106,13 +119,13 @@ class RecommendActivity : AppCompatActivity() {
106 // 1. 툴바 사용 설정 119 // 1. 툴바 사용 설정
107 setSupportActionBar(toolbar) 120 setSupportActionBar(toolbar)
108 // 2. 툴바 왼쪽 버튼 설정 121 // 2. 툴바 왼쪽 버튼 설정
109 - supportActionBar!!.setDisplayHomeAsUpEnabled(true) // 왼쪽 버튼 사용 여부 true 122 + supportActionBar!!.setDisplayHomeAsUpEnabled(false) // 왼쪽 버튼 사용 여부 true
110 supportActionBar!!.setHomeAsUpIndicator(R.drawable.return_page) // 왼쪽 버튼 아이콘 설정 123 supportActionBar!!.setHomeAsUpIndicator(R.drawable.return_page) // 왼쪽 버튼 아이콘 설정
111 supportActionBar!!.setDisplayShowTitleEnabled(false) // 타이틀 안보이게 하기 124 supportActionBar!!.setDisplayShowTitleEnabled(false) // 타이틀 안보이게 하기
112 ////bottom navigation view operation start 2 125 ////bottom navigation view operation start 2
113 bottomBar=supportActionBar!! 126 bottomBar=supportActionBar!!
114 - val bottomNavigation: BottomNavigationView =findViewById(R.id.bottomNavigation) 127 + //val bottomNavigation: BottomNavigationView =findViewById(R.id.bottomNavigation)
115 - bottomNavigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener) 128 + //bottomNavigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener)
116 ////bottom navigation view operation end 2 129 ////bottom navigation view operation end 2
117 } 130 }
118 // 3.툴바 메뉴 버튼을 설정 131 // 3.툴바 메뉴 버튼을 설정
...@@ -136,26 +149,47 @@ class RecommendActivity : AppCompatActivity() { ...@@ -136,26 +149,47 @@ class RecommendActivity : AppCompatActivity() {
136 return super.onOptionsItemSelected(item) 149 return super.onOptionsItemSelected(item)
137 } 150 }
138 151
152 + var back_pressed: Long = 0 // 뒤로가기 종료
153 +
154 + override fun onBackPressed() {
155 + if (back_pressed + 2000 > System.currentTimeMillis()) {
156 + finishAffinity()
157 + System.runFinalization()
158 + System.exit(0)
159 + }
160 + //super.onBackPressed()
161 + else
162 + Toast.makeText(getBaseContext(), "\'뒤로\' 버튼을 한번 더 누르시면 종료됩니다.", Toast.LENGTH_SHORT).show()
163 + back_pressed = System.currentTimeMillis()
164 + }
165 +
166 + private fun update_policy_view(policy_id: String, View_count: Int) {
167 + recomdatabase.child(policy_id).child("View").setValue(View_count-1)/// .setValue(user)
168 + }
169 +
139 //bottom navigation view operation start 3 170 //bottom navigation view operation start 3
140 private val mOnNavigationItemSelectedListener=BottomNavigationView.OnNavigationItemSelectedListener{item-> 171 private val mOnNavigationItemSelectedListener=BottomNavigationView.OnNavigationItemSelectedListener{item->
141 when (item.itemId){ 172 when (item.itemId){
142 173
143 R.id.bottomHome ->{ 174 R.id.bottomHome ->{
175 + //bottomNavigation2.selectedItemId = R.id.bottomRecommend
144 val intent = Intent(this, SignInActivity::class.java) 176 val intent = Intent(this, SignInActivity::class.java)
145 startActivity(intent) 177 startActivity(intent)
146 return@OnNavigationItemSelectedListener true 178 return@OnNavigationItemSelectedListener true
147 } 179 }
148 R.id.bottomRecommend ->{ 180 R.id.bottomRecommend ->{
149 - val intent = Intent(this, RecommendActivity::class.java) 181 + //val intent = Intent(this, RecommendActivity::class.java)
150 - startActivity(intent) 182 + //startActivity(intent)
151 - return@OnNavigationItemSelectedListener true 183 + //return@OnNavigationItemSelectedListener true
152 } 184 }
153 R.id.bottomFavorites ->{ 185 R.id.bottomFavorites ->{
186 + //bottomNavigation2.selectedItemId = R.id.bottomRecommend
154 val intent = Intent(this, FavoritesActivity::class.java) 187 val intent = Intent(this, FavoritesActivity::class.java)
155 startActivity(intent) 188 startActivity(intent)
156 return@OnNavigationItemSelectedListener true 189 return@OnNavigationItemSelectedListener true
157 } 190 }
158 R.id.bottomInfo ->{ 191 R.id.bottomInfo ->{
192 + //bottomNavigation2.selectedItemId = R.id.bottomRecommend
159 val intent = Intent(this, InfoActivity::class.java) 193 val intent = Intent(this, InfoActivity::class.java)
160 startActivity(intent) 194 startActivity(intent)
161 return@OnNavigationItemSelectedListener true 195 return@OnNavigationItemSelectedListener true
......
...@@ -26,6 +26,12 @@ class SignInActivity : AppCompatActivity() { ...@@ -26,6 +26,12 @@ class SignInActivity : AppCompatActivity() {
26 super.onCreate(savedInstanceState) 26 super.onCreate(savedInstanceState)
27 setContentView(R.layout.activity_signin) 27 setContentView(R.layout.activity_signin)
28 28
29 + // 네비게이션 뷰 포커스 맞추는 코드
30 + val bottomNavigationView: BottomNavigationView = findViewById(R.id.bottomNavigation) as BottomNavigationView
31 + bottomNavigationView.selectedItemId = R.id.bottomHome
32 + bottomNavigationView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener)
33 +
34 +
29 val builder = AlertDialog.Builder(this) 35 val builder = AlertDialog.Builder(this)
30 val dialogView = layoutInflater.inflate(R.layout.dialog_example, null) 36 val dialogView = layoutInflater.inflate(R.layout.dialog_example, null)
31 //val dialogText = dialogView.findViewById<EditText>(R.id.dialogEt) 37 //val dialogText = dialogView.findViewById<EditText>(R.id.dialogEt)
...@@ -104,8 +110,8 @@ class SignInActivity : AppCompatActivity() { ...@@ -104,8 +110,8 @@ class SignInActivity : AppCompatActivity() {
104 110
105 ////bottom navigation view operation start 2 111 ////bottom navigation view operation start 2
106 bottomBar=supportActionBar!! 112 bottomBar=supportActionBar!!
107 - val bottomNavigation: BottomNavigationView =findViewById(R.id.bottomNavigation) 113 + //val bottomNavigation: BottomNavigationView =findViewById(R.id.bottomNavigation)
108 - bottomNavigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener) 114 + //bottomNavigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener)
109 ////bottom navigation view operation end 2 115 ////bottom navigation view operation end 2
110 116
111 } 117 }
...@@ -148,23 +154,25 @@ class SignInActivity : AppCompatActivity() { ...@@ -148,23 +154,25 @@ class SignInActivity : AppCompatActivity() {
148 //bottom navigation view operation start 3 154 //bottom navigation view operation start 3
149 private val mOnNavigationItemSelectedListener=BottomNavigationView.OnNavigationItemSelectedListener{item-> 155 private val mOnNavigationItemSelectedListener=BottomNavigationView.OnNavigationItemSelectedListener{item->
150 when (item.itemId){ 156 when (item.itemId){
151 -
152 R.id.bottomHome ->{ 157 R.id.bottomHome ->{
153 - val intent = Intent(this, SignInActivity::class.java) 158 + // val intent = Intent(this, SignInActivity::class.java)
154 - startActivity(intent) 159 + // startActivity(intent)
155 - return@OnNavigationItemSelectedListener true 160 + // return@OnNavigationItemSelectedListener true
156 } 161 }
157 R.id.bottomRecommend ->{ 162 R.id.bottomRecommend ->{
163 + //bottomNavigation.selectedItemId = R.id.bottomHome
158 val intent = Intent(this, RecommendActivity::class.java) 164 val intent = Intent(this, RecommendActivity::class.java)
159 startActivity(intent) 165 startActivity(intent)
160 return@OnNavigationItemSelectedListener true 166 return@OnNavigationItemSelectedListener true
161 } 167 }
162 R.id.bottomFavorites ->{ 168 R.id.bottomFavorites ->{
169 + //bottomNavigation.selectedItemId = R.id.bottomHome
163 val intent = Intent(this, FavoritesActivity::class.java) 170 val intent = Intent(this, FavoritesActivity::class.java)
164 startActivity(intent) 171 startActivity(intent)
165 return@OnNavigationItemSelectedListener true 172 return@OnNavigationItemSelectedListener true
166 } 173 }
167 R.id.bottomInfo ->{ 174 R.id.bottomInfo ->{
175 + //bottomNavigation.selectedItemId = R.id.bottomHome
168 val intent = Intent(this, InfoActivity::class.java) 176 val intent = Intent(this, InfoActivity::class.java)
169 startActivity(intent) 177 startActivity(intent)
170 return@OnNavigationItemSelectedListener true 178 return@OnNavigationItemSelectedListener true
......
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<selector xmlns:android="http://schemas.android.com/apk/res/android">
3 + <item android:state_checked="true" android:color="#29ABE2" />
4 + <item android:color="#DDDDDD" />
5 +</selector>
...\ No newline at end of file ...\ No newline at end of file
...@@ -92,8 +92,8 @@ ...@@ -92,8 +92,8 @@
92 android:layout_height="wrap_content" 92 android:layout_height="wrap_content"
93 android:layout_gravity="bottom" 93 android:layout_gravity="bottom"
94 android:background="#FFF" 94 android:background="#FFF"
95 - app:itemIconTint="#29ABE2" 95 + app:itemIconTint="@drawable/bottom_selector"
96 - app:itemTextColor="#29ABE2" 96 + app:itemTextColor="@drawable/bottom_selector"
97 app:labelVisibilityMode="labeled" 97 app:labelVisibilityMode="labeled"
98 app:menu="@menu/bottom_nav_menu" /> 98 app:menu="@menu/bottom_nav_menu" />
99 99
......
...@@ -50,13 +50,13 @@ ...@@ -50,13 +50,13 @@
50 > 50 >
51 51
52 <com.google.android.material.bottomnavigation.BottomNavigationView 52 <com.google.android.material.bottomnavigation.BottomNavigationView
53 - android:id="@+id/bottomNavigation" 53 + android:id="@+id/bottomNavigation3"
54 android:layout_width="match_parent" 54 android:layout_width="match_parent"
55 android:layout_height="wrap_content" 55 android:layout_height="wrap_content"
56 android:layout_gravity="bottom" 56 android:layout_gravity="bottom"
57 android:background="#FFF" 57 android:background="#FFF"
58 - app:itemIconTint="#29ABE2" 58 + app:itemIconTint="@drawable/bottom_selector"
59 - app:itemTextColor="#29ABE2" 59 + app:itemTextColor="@drawable/bottom_selector"
60 app:labelVisibilityMode="labeled" 60 app:labelVisibilityMode="labeled"
61 app:menu="@menu/bottom_nav_menu" /> 61 app:menu="@menu/bottom_nav_menu" />
62 </FrameLayout> 62 </FrameLayout>
......
...@@ -57,6 +57,8 @@ ...@@ -57,6 +57,8 @@
57 <LinearLayout 57 <LinearLayout
58 android:layout_width="match_parent" 58 android:layout_width="match_parent"
59 android:layout_height="match_parent" 59 android:layout_height="match_parent"
60 + android:layout_marginTop="20dp"
61 + android:layout_marginBottom="20dp"
60 android:layout_weight="1" 62 android:layout_weight="1"
61 android:orientation="horizontal"> 63 android:orientation="horizontal">
62 64
...@@ -198,13 +200,13 @@ ...@@ -198,13 +200,13 @@
198 > 200 >
199 201
200 <com.google.android.material.bottomnavigation.BottomNavigationView 202 <com.google.android.material.bottomnavigation.BottomNavigationView
201 - android:id="@+id/bottomNavigation" 203 + android:id="@+id/bottomNavigation4"
202 android:layout_width="match_parent" 204 android:layout_width="match_parent"
203 android:layout_height="wrap_content" 205 android:layout_height="wrap_content"
204 android:layout_gravity="bottom" 206 android:layout_gravity="bottom"
205 android:background="#FFF" 207 android:background="#FFF"
206 - app:itemIconTint="#29ABE2" 208 + app:itemIconTint="@drawable/bottom_selector"
207 - app:itemTextColor="#29ABE2" 209 + app:itemTextColor="@drawable/bottom_selector"
208 app:labelVisibilityMode="labeled" 210 app:labelVisibilityMode="labeled"
209 app:menu="@menu/bottom_nav_menu" /> 211 app:menu="@menu/bottom_nav_menu" />
210 </FrameLayout> 212 </FrameLayout>
......
...@@ -159,8 +159,8 @@ ...@@ -159,8 +159,8 @@
159 android:layout_height="wrap_content" 159 android:layout_height="wrap_content"
160 android:layout_gravity="bottom" 160 android:layout_gravity="bottom"
161 android:background="#FFF" 161 android:background="#FFF"
162 - app:itemIconTint="#29ABE2" 162 + app:itemIconTint="@drawable/bottom_selector"
163 - app:itemTextColor="#29ABE2" 163 + app:itemTextColor="@drawable/bottom_selector"
164 app:labelVisibilityMode="labeled" 164 app:labelVisibilityMode="labeled"
165 app:menu="@menu/bottom_nav_menu" /> 165 app:menu="@menu/bottom_nav_menu" />
166 166
......
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
45 android:layout_height="wrap_content" 45 android:layout_height="wrap_content"
46 android:layout_gravity="bottom" 46 android:layout_gravity="bottom"
47 android:background="#FFF" 47 android:background="#FFF"
48 - app:itemIconTint="#29ABE2" 48 + app:itemIconTint="@drawable/bottom_selector"
49 - app:itemTextColor="#29ABE2" 49 + app:itemTextColor="@drawable/bottom_selector"
50 app:labelVisibilityMode="labeled" 50 app:labelVisibilityMode="labeled"
51 app:menu="@menu/bottom_nav_menu" /> 51 app:menu="@menu/bottom_nav_menu" />
52 52
......
...@@ -85,8 +85,8 @@ ...@@ -85,8 +85,8 @@
85 android:layout_height="wrap_content" 85 android:layout_height="wrap_content"
86 android:layout_gravity="bottom" 86 android:layout_gravity="bottom"
87 android:background="#FFF" 87 android:background="#FFF"
88 - app:itemIconTint="#29ABE2" 88 + app:itemIconTint="@drawable/bottom_selector"
89 - app:itemTextColor="#29ABE2" 89 + app:itemTextColor="@drawable/bottom_selector"
90 app:labelVisibilityMode="labeled" 90 app:labelVisibilityMode="labeled"
91 app:menu="@menu/bottom_nav_menu" /> 91 app:menu="@menu/bottom_nav_menu" />
92 92
......
...@@ -85,10 +85,10 @@ ...@@ -85,10 +85,10 @@
85 android:layout_height="wrap_content" 85 android:layout_height="wrap_content"
86 android:layout_gravity="bottom" 86 android:layout_gravity="bottom"
87 android:background="#FFF" 87 android:background="#FFF"
88 - app:itemIconTint="#29ABE2" 88 + app:itemIconTint="@drawable/bottom_selector"
89 - app:itemTextColor="#29ABE2" 89 + app:itemTextColor="@drawable/bottom_selector"
90 app:labelVisibilityMode="labeled" 90 app:labelVisibilityMode="labeled"
91 - app:menu="@menu/bottom_nav_menu" > 91 + app:menu="@menu/bottom_nav_menu">
92 92
93 </com.google.android.material.bottomnavigation.BottomNavigationView> 93 </com.google.android.material.bottomnavigation.BottomNavigationView>
94 94
......
...@@ -51,13 +51,13 @@ ...@@ -51,13 +51,13 @@
51 > 51 >
52 52
53 <com.google.android.material.bottomnavigation.BottomNavigationView 53 <com.google.android.material.bottomnavigation.BottomNavigationView
54 - android:id="@+id/bottomNavigation" 54 + android:id="@+id/bottomNavigation2"
55 android:layout_width="match_parent" 55 android:layout_width="match_parent"
56 android:layout_height="wrap_content" 56 android:layout_height="wrap_content"
57 android:layout_gravity="bottom" 57 android:layout_gravity="bottom"
58 android:background="#FFF" 58 android:background="#FFF"
59 - app:itemIconTint="#29ABE2" 59 + app:itemIconTint="@drawable/bottom_selector"
60 - app:itemTextColor="#29ABE2" 60 + app:itemTextColor="@drawable/bottom_selector"
61 app:labelVisibilityMode="labeled" 61 app:labelVisibilityMode="labeled"
62 app:menu="@menu/bottom_nav_menu" /> 62 app:menu="@menu/bottom_nav_menu" />
63 </FrameLayout> 63 </FrameLayout>
......
...@@ -129,8 +129,8 @@ ...@@ -129,8 +129,8 @@
129 android:layout_height="wrap_content" 129 android:layout_height="wrap_content"
130 android:layout_gravity="bottom" 130 android:layout_gravity="bottom"
131 android:background="#FFF" 131 android:background="#FFF"
132 - app:itemIconTint="#29ABE2" 132 + app:itemIconTint="@drawable/bottom_selector"
133 - app:itemTextColor="#29ABE2" 133 + app:itemTextColor="@drawable/bottom_selector"
134 app:labelVisibilityMode="labeled" 134 app:labelVisibilityMode="labeled"
135 app:menu="@menu/bottom_nav_menu" /> 135 app:menu="@menu/bottom_nav_menu" />
136 136
......
...@@ -84,8 +84,8 @@ ...@@ -84,8 +84,8 @@
84 android:layout_gravity="bottom" 84 android:layout_gravity="bottom"
85 android:background="#FFF" 85 android:background="#FFF"
86 android:elevation="8dp" 86 android:elevation="8dp"
87 - app:itemIconTint="#29ABE2" 87 + app:itemIconTint="@drawable/bottom_selector"
88 - app:itemTextColor="#29ABE2" 88 + app:itemTextColor="@drawable/bottom_selector"
89 app:labelVisibilityMode="labeled" 89 app:labelVisibilityMode="labeled"
90 app:menu="@menu/bottom_nav_menu" /> 90 app:menu="@menu/bottom_nav_menu" />
91 91
......
...@@ -45,8 +45,8 @@ ...@@ -45,8 +45,8 @@
45 android:layout_height="wrap_content" 45 android:layout_height="wrap_content"
46 android:layout_gravity="bottom" 46 android:layout_gravity="bottom"
47 android:background="#FFF" 47 android:background="#FFF"
48 - app:itemIconTint="#29ABE2" 48 + app:itemIconTint="@drawable/bottom_selector"
49 - app:itemTextColor="#29ABE2" 49 + app:itemTextColor="@drawable/bottom_selector"
50 app:labelVisibilityMode="labeled" 50 app:labelVisibilityMode="labeled"
51 app:menu="@menu/bottom_nav_menu" /> 51 app:menu="@menu/bottom_nav_menu" />
52 52
......
...@@ -105,8 +105,8 @@ ...@@ -105,8 +105,8 @@
105 android:layout_height="wrap_content" 105 android:layout_height="wrap_content"
106 android:layout_gravity="bottom" 106 android:layout_gravity="bottom"
107 android:background="#FFF" 107 android:background="#FFF"
108 - app:itemIconTint="#29ABE2" 108 + app:itemIconTint="@drawable/bottom_selector"
109 - app:itemTextColor="#29ABE2" 109 + app:itemTextColor="@drawable/bottom_selector"
110 app:labelVisibilityMode="labeled" 110 app:labelVisibilityMode="labeled"
111 app:menu="@menu/bottom_nav_menu" /> 111 app:menu="@menu/bottom_nav_menu" />
112 112
......