신기성

recommend activity

<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/../.." vcs="Git" />
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
\ No newline at end of file
......
......@@ -9,7 +9,11 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/NoActionBar">
<activity android:name=".TestingActivity"></activity>
<activity android:name=".DetailActivity"></activity>
<activity android:name=".InfoActivity" />
<activity android:name=".FavoritesActivity" />
<activity android:name=".RecommendActivity" />
<activity android:name=".TestingActivity" />
<activity android:name=".SignInActivity" />
<activity android:name=".SignUpActivity" />
<activity android:name=".MainActivity" />
......
package com.example.vip
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
class DetailActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_detail)
}
}
package com.example.vip
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
class FavoritesActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_favorites)
}
}
package com.example.vip
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
class InfoActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_info)
}
}
package com.example.vip
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.recyclerview.widget.RecyclerView
import kotlinx.android.synthetic.main.item_policy.view.*
import kotlinx.android.synthetic.main.item_policyfield.view.*
class PolicyAdapter(private val items: ArrayList<PolicyItem>) :
RecyclerView.Adapter<PolicyAdapter.ViewHolder>() {
override fun getItemCount() = items.size
override fun onBindViewHolder(holder: PolicyAdapter.ViewHolder, position: Int) {
val item = items[position]
holder.apply {
bind(item)
itemView.tag = item
}
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int):
PolicyAdapter.ViewHolder {
val inflatedView = LayoutInflater.from(parent.context)
.inflate(R.layout.item_policy, parent, false)
return PolicyAdapter.ViewHolder(inflatedView)
}
class ViewHolder(v: View) : RecyclerView.ViewHolder(v) {
private var view: View = v
fun bind(item: PolicyItem) {
view.policyImage.setImageDrawable(item.policyItemImage)
view.policyDday.text = item.policyItemDday
view.policyHost.text = item.policyItemHost
view.policyTitle.text = item.policyItemTitle
view.policyScore.rating= item.policyItemScore
view.policyFavor.text=item.policyItemFavor
view.setOnClickListener{
val intent=Intent(view.context, DetailActivity::class.java)
//putExtraStart
intent.putExtra("key",item.policyItemTitle)
//putExtraEnd
view.context.startActivity(intent)
}
}
}
}
\ No newline at end of file
package com.example.vip
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
......@@ -14,11 +15,9 @@ class PolicyFieldAdapter(private val items: ArrayList<PolicyFieldItem>) :
override fun onBindViewHolder(holder: PolicyFieldAdapter.ViewHolder, position: Int) {
val item = items[position]
val listener = View.OnClickListener {it ->
Toast.makeText(it.context, "Clicked: ${item.policyFieldItemText}", Toast.LENGTH_SHORT).show()
}
holder.apply {
bind(listener, item)
bind(item)
itemView.tag = item
}
}
......@@ -34,10 +33,17 @@ class PolicyFieldAdapter(private val items: ArrayList<PolicyFieldItem>) :
private var view: View = v
fun bind(listener: View.OnClickListener, item: PolicyFieldItem) {
fun bind(item: PolicyFieldItem) {
view.fieldIcon.setImageDrawable(item.policyFieldItemImage)
view.fieldIconText.text = item.policyFieldItemText
view.setOnClickListener(listener)
view.setOnClickListener{
val intent=Intent(view.context, RecommendActivity::class.java)
//putExtraStart
intent.putExtra("key",item.policyFieldItemText)
//putExtraEnd
view.context.startActivity(intent)
}
}
}
}
\ No newline at end of file
......
package com.example.vip
import android.graphics.drawable.Drawable
class PolicyItem(val policyItemImage: Drawable,
val policyItemDday: String,
val policyItemHost: String,
val policyItemTitle: String,
val policyItemScore: Float,
val policyItemFavor: String) {
}
\ No newline at end of file
package com.example.vip
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.util.Half.toFloat
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.ActionBar
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.viewpager.widget.ViewPager
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.activity_recommend.*
import kotlinx.android.synthetic.main.activity_signin.*
import kotlinx.android.synthetic.main.activity_signin.toolbar
class RecommendActivity : 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_recommend)
val policyList = ArrayList<PolicyItem>()
policyList.add(
PolicyItem(
ContextCompat.getDrawable(this, R.drawable.image01)!!,
getString(R.string.title01),
getString(R.string.title01),
getString(R.string.title01),
4.toFloat(),
"0"
)
)
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
}
package com.example.vip
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.ActionBar
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.viewpager.widget.ViewPager
import com.google.android.material.bottomnavigation.BottomNavigationView
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.activity_signin.*
class SignInActivity : AppCompatActivity() {
internal lateinit var viewpager : ViewPager
////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_signin)
......@@ -55,30 +61,7 @@ class SignInActivity : AppCompatActivity() {
getString(R.string.title06)
)
)
policyFieldList.add(
PolicyFieldItem(
ContextCompat.getDrawable(this, R.drawable.image07)!!,
getString(R.string.title07)
)
)
policyFieldList.add(
PolicyFieldItem(
ContextCompat.getDrawable(this, R.drawable.image08)!!,
getString(R.string.title08)
)
)
policyFieldList.add(
PolicyFieldItem(
ContextCompat.getDrawable(this, R.drawable.image09)!!,
getString(R.string.title09)
)
)
policyFieldList.add(
PolicyFieldItem(
ContextCompat.getDrawable(this, R.drawable.image10)!!,
getString(R.string.title10)
)
)
val adapter = PolicyFieldAdapter(policyFieldList)
policyFieldRecyclerView.adapter = adapter
......@@ -94,6 +77,13 @@ class SignInActivity : AppCompatActivity() {
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 {
......@@ -117,4 +107,35 @@ class SignInActivity : AppCompatActivity() {
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
}
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".DetailActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".FavoritesActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".InfoActivity">
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".RecommendActivity">
<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="100dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:layout_constraintBottom_toBottomOf="@id/bottomNavigation"
tools:listitem="@layout/item_policy" />
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:id="@+id/fragmentContainer"
/>
<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" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
......@@ -46,10 +46,10 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/policyFieldRecyclerView"
android:layout_width="match_parent"
android:layout_height="340dp"
android:layout_height="wrap_content"
app:layoutManager="androidx.recyclerview.widget.GridLayoutManager"
app:spanCount="3"
app:layout_constraintBottom_toBottomOf="@id/bottom_navigation"
app:layout_constraintBottom_toBottomOf="@id/bottomNavigation"
tools:listitem="@layout/item_policyfield" />
<FrameLayout
......@@ -60,7 +60,7 @@
/>
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottom_navigation"
android:id="@+id/bottomNavigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<ImageView
android:id="@+id/policyImage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
tools:srcCompat="@tools:sample/avatars" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
android:orientation="horizontal">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<TextView
android:id="@+id/policyDday"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/policyHost"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
<TextView
android:id="@+id/policyTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TextView" />
<RatingBar
android:id="@+id/policyScore"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</LinearLayout>
<TextView
android:id="@+id/policyFavor"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="TextView" />
</LinearLayout>
</LinearLayout>
\ No newline at end of file
......@@ -21,6 +21,6 @@
android:layout_height="340dp"
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
app:spanCount="3"
app:layout_constraintBottom_toBottomOf="@id/bottom_navigation"
app:layout_constraintBottom_toBottomOf="@id/bottomNavigation"
tools:listitem="@layout/item_search" />
</LinearLayout>
\ No newline at end of file
......
......@@ -2,25 +2,25 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_recents"
android:id="@+id/bottomHome"
android:enabled="true"
android:icon="@drawable/home"
android:title="WELLO"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_favorites"
android:id="@+id/bottomRecommend"
android:enabled="true"
android:icon="@drawable/instagram"
android:icon="@drawable/wish"
android:title="추천정책"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_nearby"
android:id="@+id/bottomFavorites"
android:enabled="true"
android:icon="@drawable/wish"
android:icon="@drawable/instagram"
android:title="찜 목록"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_info"
android:id="@+id/bottomInfo"
android:enabled="true"
android:icon="@drawable/info"
android:title="내 정보"
......