Toggle navigation
Toggle navigation
This project
Loading...
Sign in
장연우
/
WELLO
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
신기성
2019-11-07 00:04:47 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
1e2d13c57f0c1e50d2a30ae19aff20bdc6f8f9f2
1e2d13c5
1 parent
d4d4df10
search activity to detail activity putextra modifying
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
225 additions
and
1 deletions
vip/app/src/main/java/com/example/vip/FavoritesActivity.kt
vip/app/src/main/java/com/example/vip/SearchAdapter.kt
vip/app/src/main/res/layout/activity_favorites.xml
vip/app/src/main/java/com/example/vip/FavoritesActivity.kt
View file @
1e2d13c
package
com.example.vip
import
android.content.Intent
import
androidx.appcompat.app.AppCompatActivity
import
android.os.Bundle
import
android.view.Menu
import
android.view.MenuItem
import
android.widget.Toast
import
androidx.appcompat.app.ActionBar
import
androidx.core.content.ContextCompat
import
com.google.android.material.bottomnavigation.BottomNavigationView
import
com.google.android.material.snackbar.Snackbar
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.activity_recommend.*
import
kotlinx.android.synthetic.main.activity_recommend.toolbar
import
kotlinx.android.synthetic.main.activity_signin.*
data class
MemoItemFavor
(
val
Target
:
String
=
""
,
val
Policy
:
String
=
""
,
val
Content
:
String
=
""
,
val
Link
:
String
=
""
)
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
)
val
policyList
=
ArrayList
<
PolicyItem
>()
var
favordatabase
=
FirebaseDatabase
.
getInstance
().
reference
if
(
intent
.
hasExtra
(
"key"
))
{
//textView.text = intent.getStringExtra("key") 텍뷰추가하면 인텐트로 값넘기는거 보임
favordatabase
.
orderByChild
(
"Policy"
).
startAt
(
intent
.
getStringExtra
(
"key"
)).
endAt
(
intent
.
getStringExtra
(
"key"
)+
"\uf8ff"
).
addListenerForSingleValueEvent
(
object
:
ValueEventListener
{
override
fun
onCancelled
(
p0
:
DatabaseError
)
{
Toast
.
makeText
(
this
@FavoritesActivity
,
"실패부분"
,
Toast
.
LENGTH_SHORT
).
show
()
}
override
fun
onDataChange
(
dataSnapshot
:
DataSnapshot
)
{
for
(
memoSnapshot
in
dataSnapshot
.
children
){
val
memo
=
memoSnapshot
.
getValue
(
MemoItemFavor
::
class
.
java
)
policyList
.
add
(
PolicyItem
(
ContextCompat
.
getDrawable
(
this
@FavoritesActivity
,
R
.
drawable
.
image01
)
!!
,
memo
!!
.
Policy
,
memo
!!
.
Policy
,
memo
!!
.
Policy
,
4
.
toFloat
(),
""
)
)
}
val
adapter
=
PolicyAdapter
(
policyList
)
policyRecyclerView
.
adapter
=
adapter
}
})
}
else
{
Toast
.
makeText
(
this
,
"putExtra value not found"
,
Toast
.
LENGTH_SHORT
).
show
()
favordatabase
.
orderByChild
(
"Policy"
).
startAt
(
intent
.
getStringExtra
(
"\uf8ff"
)).
addListenerForSingleValueEvent
(
object
:
ValueEventListener
{
override
fun
onCancelled
(
p0
:
DatabaseError
)
{
Toast
.
makeText
(
this
@FavoritesActivity
,
"실패부분"
,
Toast
.
LENGTH_SHORT
).
show
()
}
override
fun
onDataChange
(
dataSnapshot
:
DataSnapshot
)
{
for
(
memoSnapshot
in
dataSnapshot
.
children
){
val
memo
=
memoSnapshot
.
getValue
(
MemoItemFavor
::
class
.
java
)
policyList
.
add
(
PolicyItem
(
ContextCompat
.
getDrawable
(
this
@FavoritesActivity
,
R
.
drawable
.
image01
)
!!
,
memo
!!
.
Policy
,
memo
!!
.
Policy
,
memo
!!
.
Policy
,
4
.
toFloat
(),
""
)
)
}
val
adapter
=
PolicyAdapter
(
policyList
)
policyRecyclerView
.
adapter
=
adapter
}
})
}
// 1. 툴바 사용 설정
setSupportActionBar
(
toolbar
)
// 2. 툴바 왼쪽 버튼 설정
supportActionBar
!!
.
setDisplayHomeAsUpEnabled
(
true
)
// 왼쪽 버튼 사용 여부 true
supportActionBar
!!
.
setHomeAsUpIndicator
(
R
.
drawable
.
return_page
)
// 왼쪽 버튼 아이콘 설정
supportActionBar
!!
.
setDisplayShowTitleEnabled
(
false
)
// 타이틀 안보이게 하기
////bottom navigation view operation start 2
bottomBar
=
supportActionBar
!!
val
bottomNavigation
:
BottomNavigationView
=
findViewById
(
R
.
id
.
bottomNavigation
)
bottomNavigation
.
setOnNavigationItemSelectedListener
(
mOnNavigationItemSelectedListener
)
////bottom navigation view operation end 2
}
// 3.툴바 메뉴 버튼을 설정
override
fun
onCreateOptionsMenu
(
menu
:
Menu
?):
Boolean
{
menuInflater
.
inflate
(
R
.
menu
.
main_menu
,
menu
)
// main_menu 메뉴를 toolbar 메뉴 버튼으로 설정
return
true
}
// 4.툴바 메뉴 버튼이 클릭 됐을 때 콜백
override
fun
onOptionsItemSelected
(
item
:
MenuItem
?):
Boolean
{
// 클릭된 메뉴 아이템의 아이디 마다 when 구절로 클릭시 동작을 설정한다.
when
(
item
!!
.
itemId
){
android
.
R
.
id
.
home
->{
// 메뉴 버튼
Snackbar
.
make
(
toolbar
,
"Menu pressed"
,
Snackbar
.
LENGTH_SHORT
).
show
()
}
R
.
id
.
menu_search
->{
// 검색 버튼
val
search_Intent
=
Intent
(
this
,
SearchActivity
::
class
.
java
)
startActivity
(
search_Intent
)
//Snackbar.make(toolbar,"Search menu pressed",Snackbar.LENGTH_SHORT).show()
}
}
return
super
.
onOptionsItemSelected
(
item
)
}
//bottom navigation view operation start 3
private
val
mOnNavigationItemSelectedListener
=
BottomNavigationView
.
OnNavigationItemSelectedListener
{
item
->
when
(
item
.
itemId
){
R
.
id
.
bottomHome
->{
val
intent
=
Intent
(
this
,
SignInActivity
::
class
.
java
)
startActivity
(
intent
)
return
@OnNavigationItemSelectedListener
true
}
R
.
id
.
bottomRecommend
->{
val
intent
=
Intent
(
this
,
RecommendActivity
::
class
.
java
)
startActivity
(
intent
)
return
@OnNavigationItemSelectedListener
true
}
R
.
id
.
bottomFavorites
->{
val
intent
=
Intent
(
this
,
FavoritesActivity
::
class
.
java
)
startActivity
(
intent
)
return
@OnNavigationItemSelectedListener
true
}
R
.
id
.
bottomInfo
->{
val
intent
=
Intent
(
this
,
InfoActivity
::
class
.
java
)
startActivity
(
intent
)
return
@OnNavigationItemSelectedListener
true
}
}
false
}
//bottom navigation view operation end 3
}
...
...
vip/app/src/main/java/com/example/vip/SearchAdapter.kt
View file @
1e2d13c
...
...
@@ -37,7 +37,8 @@ class SearchAdapter(private val items: ArrayList<SearchItem>) :
view
.
searchIconText
.
text
=
item
.
searchItemText
view
.
setOnClickListener
{
val
intent
=
Intent
(
view
.
context
,
WelcomeActivity
::
class
.
java
)
val
intent
=
Intent
(
view
.
context
,
DetailActivity
::
class
.
java
)
intent
.
putExtra
(
"key"
,
item
.
searchItemText
)
view
.
context
.
startActivity
(
intent
)
}
}
...
...
vip/app/src/main/res/layout/activity_favorites.xml
View file @
1e2d13c
...
...
@@ -6,4 +6,60 @@
android:layout_height=
"match_parent"
tools:context=
".FavoritesActivity"
>
<LinearLayout
android:id=
"@+id/linearLayout"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toTopOf=
"parent"
>
<androidx.appcompat.widget.Toolbar
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"
app:popupTheme=
"@style/ThemeOverlay.AppCompat.Dark.ActionBar"
>
<ImageView
android:layout_width=
"77dp"
android:layout_height=
"44dp"
android:layout_gravity=
"center"
android:src=
"@drawable/toolbar_logo"
/>
</androidx.appcompat.widget.Toolbar>
<androidx.recyclerview.widget.RecyclerView
android:id=
"@+id/policyRecyclerView"
android:layout_width=
"match_parent"
android:layout_height=
"500dp"
android:layout_weight=
"1"
app:layoutManager=
"androidx.recyclerview.widget.LinearLayoutManager"
tools:listitem=
"@layout/item_policy"
/>
<FrameLayout
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:id=
"@+id/fragmentContainer"
app:layout_constraintBottom_toBottomOf=
"parent"
>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id=
"@+id/bottomNavigation"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_gravity=
"bottom"
android:background=
"#FFF"
app:itemIconTint=
"#29ABE2"
app:itemTextColor=
"#29ABE2"
app:labelVisibilityMode=
"labeled"
app:menu=
"@menu/bottom_nav_menu"
/>
</FrameLayout>
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
...
...
Please
register
or
login
to post a comment