Showing
4 changed files
with
246 additions
and
5 deletions
| 1 | package com.example.vip | 1 | package com.example.vip |
| 2 | 2 | ||
| 3 | -import androidx.appcompat.app.AppCompatActivity | 3 | +import android.app.Activity |
| 4 | +import android.content.Intent | ||
| 4 | import android.os.Bundle | 5 | import android.os.Bundle |
| 6 | +import android.util.Half.toFloat | ||
| 7 | +import android.view.Menu | ||
| 8 | +import android.view.MenuItem | ||
| 9 | +import android.view.View | ||
| 10 | +import android.widget.ImageView | ||
| 11 | +import android.widget.RatingBar | ||
| 12 | +import android.widget.TextView | ||
| 13 | +import android.widget.Toast | ||
| 14 | +import androidx.appcompat.app.ActionBar | ||
| 15 | +import androidx.appcompat.app.AppCompatActivity | ||
| 16 | +import androidx.core.content.ContextCompat | ||
| 17 | +import androidx.viewpager.widget.ViewPager | ||
| 18 | +import com.google.android.material.bottomnavigation.BottomNavigationView | ||
| 19 | +import com.google.android.material.snackbar.Snackbar | ||
| 20 | +import com.google.firebase.database.DataSnapshot | ||
| 21 | +import com.google.firebase.database.DatabaseError | ||
| 22 | +import com.google.firebase.database.FirebaseDatabase | ||
| 23 | +import com.google.firebase.database.ValueEventListener | ||
| 24 | +import kotlinx.android.synthetic.main.activity_detail.* | ||
| 25 | +import kotlinx.android.synthetic.main.activity_recommend.* | ||
| 26 | +import kotlinx.android.synthetic.main.activity_signin.* | ||
| 27 | +import kotlinx.android.synthetic.main.activity_signin.toolbar | ||
| 28 | +import kotlinx.android.synthetic.main.search.* | ||
| 29 | + | ||
| 30 | +data class MemoItemDetail( | ||
| 31 | + val Target : String = "", | ||
| 32 | + val Policy : String = "", | ||
| 33 | + val Content : String = "", | ||
| 34 | + val Link : String = "" | ||
| 35 | +) | ||
| 5 | 36 | ||
| 6 | class DetailActivity : AppCompatActivity() { | 37 | class DetailActivity : AppCompatActivity() { |
| 7 | 38 | ||
| 39 | + ////bottom navigation view operation start 1 | ||
| 40 | + lateinit var bottomBar: ActionBar | ||
| 41 | + ////bottom navigation view operation end 1 | ||
| 8 | override fun onCreate(savedInstanceState: Bundle?) { | 42 | override fun onCreate(savedInstanceState: Bundle?) { |
| 9 | super.onCreate(savedInstanceState) | 43 | super.onCreate(savedInstanceState) |
| 10 | setContentView(R.layout.activity_detail) | 44 | setContentView(R.layout.activity_detail) |
| 45 | + | ||
| 46 | + var detaildatabase = FirebaseDatabase.getInstance().reference | ||
| 47 | + | ||
| 48 | + if (intent.hasExtra("key")) { | ||
| 49 | + //textView.text = intent.getStringExtra("key") 텍뷰추가하면 인텐트로 값넘기는거 보임 | ||
| 50 | + | ||
| 51 | + detaildatabase.orderByChild("Policy").startAt(intent.getStringExtra("key")).endAt(intent.getStringExtra("key")+"\uf8ff").addListenerForSingleValueEvent(object : | ||
| 52 | + ValueEventListener { | ||
| 53 | + override fun onCancelled(p0: DatabaseError) { | ||
| 54 | + Toast.makeText(this@DetailActivity, "실패부분", Toast.LENGTH_SHORT).show() | ||
| 55 | + } | ||
| 56 | + override fun onDataChange(dataSnapshot: DataSnapshot) { | ||
| 57 | + for (memoSnapshot in dataSnapshot.children){ | ||
| 58 | + val memo = memoSnapshot.getValue(MemoItemDetail::class.java) | ||
| 59 | + | ||
| 60 | + var detailImage: ImageView =findViewById(R.id.policyImageDetail) | ||
| 61 | + var detailDday: TextView =findViewById(R.id.policyDdayDetail) | ||
| 62 | + var detailHost: TextView =findViewById(R.id.policyHostDetail) | ||
| 63 | + var detailTitle: TextView =findViewById(R.id.policyTitleDetail) | ||
| 64 | + var detailScore: RatingBar =findViewById(R.id.policyScoreDetail) | ||
| 65 | + var detailFavor: TextView =findViewById(R.id.policyFavorDetail) | ||
| 66 | + | ||
| 67 | + detailImage.setImageResource(R.drawable.image01) | ||
| 68 | + detailDday.text=memo!!.Policy | ||
| 69 | + detailHost.text=memo!!.Policy | ||
| 70 | + detailTitle.text=memo!!.Policy | ||
| 71 | + detailScore.rating=4.toFloat() | ||
| 72 | + detailFavor.text="0" | ||
| 73 | + | ||
| 74 | + } | ||
| 75 | + } | ||
| 76 | + }) | ||
| 77 | + | ||
| 78 | + | ||
| 79 | + } else { | ||
| 80 | + Toast.makeText(this, "putExtra value not found", Toast.LENGTH_SHORT).show() | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + | ||
| 84 | + | ||
| 85 | + // 1. 툴바 사용 설정 | ||
| 86 | + setSupportActionBar(toolbar) | ||
| 87 | + | ||
| 88 | + // 2. 툴바 왼쪽 버튼 설정 | ||
| 89 | + supportActionBar!!.setDisplayHomeAsUpEnabled(true) // 왼쪽 버튼 사용 여부 true | ||
| 90 | + supportActionBar!!.setHomeAsUpIndicator(R.drawable.return_page) // 왼쪽 버튼 아이콘 설정 | ||
| 91 | + supportActionBar!!.setDisplayShowTitleEnabled(false) // 타이틀 안보이게 하기 | ||
| 92 | + | ||
| 93 | + ////bottom navigation view operation start 2 | ||
| 94 | + bottomBar=supportActionBar!! | ||
| 95 | + val bottomNavigation: BottomNavigationView =findViewById(R.id.bottomNavigation) | ||
| 96 | + bottomNavigation.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener) | ||
| 97 | + ////bottom navigation view operation end 2 | ||
| 98 | + | ||
| 99 | + } | ||
| 100 | + // 3.툴바 메뉴 버튼을 설정 | ||
| 101 | + override fun onCreateOptionsMenu(menu: Menu?): Boolean { | ||
| 102 | + menuInflater.inflate(R.menu.main_menu, menu) // main_menu 메뉴를 toolbar 메뉴 버튼으로 설정 | ||
| 103 | + return true | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + // 4.툴바 메뉴 버튼이 클릭 됐을 때 콜백 | ||
| 107 | + override fun onOptionsItemSelected(item: MenuItem?): Boolean { | ||
| 108 | + // 클릭된 메뉴 아이템의 아이디 마다 when 구절로 클릭시 동작을 설정한다. | ||
| 109 | + when(item!!.itemId){ | ||
| 110 | + android.R.id.home->{ // 메뉴 버튼 | ||
| 111 | + Snackbar.make(toolbar,"Menu pressed",Snackbar.LENGTH_SHORT).show() | ||
| 112 | + } | ||
| 113 | + R.id.menu_search->{ // 검색 버튼 | ||
| 114 | + val search_Intent = Intent(this, SearchActivity::class.java) | ||
| 115 | + startActivity(search_Intent) | ||
| 116 | + //Snackbar.make(toolbar,"Search menu pressed",Snackbar.LENGTH_SHORT).show() | ||
| 117 | + } | ||
| 118 | + } | ||
| 119 | + return super.onOptionsItemSelected(item) | ||
| 11 | } | 120 | } |
| 121 | + | ||
| 122 | + //bottom navigation view operation start 3 | ||
| 123 | + private val mOnNavigationItemSelectedListener=BottomNavigationView.OnNavigationItemSelectedListener{item-> | ||
| 124 | + when (item.itemId){ | ||
| 125 | + | ||
| 126 | + R.id.bottomHome ->{ | ||
| 127 | + val intent = Intent(this, SignInActivity::class.java) | ||
| 128 | + startActivity(intent) | ||
| 129 | + return@OnNavigationItemSelectedListener true | ||
| 130 | + } | ||
| 131 | + R.id.bottomRecommend ->{ | ||
| 132 | + val intent = Intent(this, RecommendActivity::class.java) | ||
| 133 | + startActivity(intent) | ||
| 134 | + return@OnNavigationItemSelectedListener true | ||
| 135 | + } | ||
| 136 | + R.id.bottomFavorites ->{ | ||
| 137 | + val intent = Intent(this, FavoritesActivity::class.java) | ||
| 138 | + startActivity(intent) | ||
| 139 | + return@OnNavigationItemSelectedListener true | ||
| 140 | + } | ||
| 141 | + R.id.bottomInfo ->{ | ||
| 142 | + val intent = Intent(this, InfoActivity::class.java) | ||
| 143 | + startActivity(intent) | ||
| 144 | + return@OnNavigationItemSelectedListener true | ||
| 145 | + } | ||
| 146 | + | ||
| 147 | + | ||
| 148 | + } | ||
| 149 | + false | ||
| 150 | + } | ||
| 151 | +//bottom navigation view operation end 3 | ||
| 152 | + | ||
| 12 | } | 153 | } | ... | ... |
| ... | @@ -51,7 +51,7 @@ class RecommendActivity : AppCompatActivity() { | ... | @@ -51,7 +51,7 @@ class RecommendActivity : AppCompatActivity() { |
| 51 | } | 51 | } |
| 52 | override fun onDataChange(dataSnapshot: DataSnapshot) { | 52 | override fun onDataChange(dataSnapshot: DataSnapshot) { |
| 53 | for (memoSnapshot in dataSnapshot.children){ | 53 | for (memoSnapshot in dataSnapshot.children){ |
| 54 | - val memo = memoSnapshot.getValue(MemoItem::class.java) | 54 | + val memo = memoSnapshot.getValue(MemoItemRecom::class.java) |
| 55 | 55 | ||
| 56 | policyList.add( | 56 | policyList.add( |
| 57 | PolicyItem( | 57 | PolicyItem( | ... | ... |
| ... | @@ -4,6 +4,106 @@ | ... | @@ -4,6 +4,106 @@ |
| 4 | xmlns:tools="http://schemas.android.com/tools" | 4 | xmlns:tools="http://schemas.android.com/tools" |
| 5 | android:layout_width="match_parent" | 5 | android:layout_width="match_parent" |
| 6 | android:layout_height="match_parent" | 6 | android:layout_height="match_parent" |
| 7 | - tools:context=".DetailActivity"> | 7 | + tools:context=".RecommendActivity"> |
| 8 | + | ||
| 9 | + | ||
| 10 | + <LinearLayout | ||
| 11 | + android:id="@+id/linearLayout" | ||
| 12 | + android:layout_width="match_parent" | ||
| 13 | + android:layout_height="match_parent" | ||
| 14 | + android:orientation="vertical" | ||
| 15 | + app:layout_constraintBottom_toBottomOf="parent" | ||
| 16 | + app:layout_constraintEnd_toEndOf="parent" | ||
| 17 | + app:layout_constraintStart_toStartOf="parent" | ||
| 18 | + app:layout_constraintTop_toTopOf="parent"> | ||
| 19 | + | ||
| 20 | + <androidx.appcompat.widget.Toolbar | ||
| 21 | + android:id="@+id/toolbar" | ||
| 22 | + android:layout_width="fill_parent" | ||
| 23 | + android:layout_height="wrap_content" | ||
| 24 | + android:layout_marginBottom="11dp" | ||
| 25 | + android:background="#FFF" | ||
| 26 | + android:elevation="5dp" | ||
| 27 | + android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar" | ||
| 28 | + app:popupTheme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"> | ||
| 29 | + | ||
| 30 | + <ImageView | ||
| 31 | + android:layout_width="77dp" | ||
| 32 | + android:layout_height="44dp" | ||
| 33 | + android:layout_gravity="center" | ||
| 34 | + android:src="@drawable/toolbar_logo" /> | ||
| 35 | + </androidx.appcompat.widget.Toolbar> | ||
| 36 | + | ||
| 37 | + | ||
| 38 | + <ImageView | ||
| 39 | + android:id="@+id/policyImageDetail" | ||
| 40 | + android:layout_width="match_parent" | ||
| 41 | + android:layout_height="200dp" | ||
| 42 | + tools:srcCompat="@tools:sample/avatars" /> | ||
| 43 | + | ||
| 44 | + <LinearLayout | ||
| 45 | + android:layout_width="match_parent" | ||
| 46 | + android:layout_height="450dp" | ||
| 47 | + android:orientation="horizontal"> | ||
| 48 | + | ||
| 49 | + <LinearLayout | ||
| 50 | + android:layout_width="match_parent" | ||
| 51 | + android:layout_height="match_parent" | ||
| 52 | + android:orientation="vertical"> | ||
| 53 | + | ||
| 54 | + <TextView | ||
| 55 | + android:id="@+id/policyDdayDetail" | ||
| 56 | + android:layout_width="match_parent" | ||
| 57 | + android:layout_height="wrap_content" | ||
| 58 | + android:text="TextView" /> | ||
| 59 | + | ||
| 60 | + <TextView | ||
| 61 | + android:id="@+id/policyHostDetail" | ||
| 62 | + android:layout_width="match_parent" | ||
| 63 | + android:layout_height="wrap_content" | ||
| 64 | + android:text="TextView" /> | ||
| 65 | + | ||
| 66 | + <TextView | ||
| 67 | + android:id="@+id/policyTitleDetail" | ||
| 68 | + android:layout_width="match_parent" | ||
| 69 | + android:layout_height="wrap_content" | ||
| 70 | + android:text="TextView" /> | ||
| 71 | + | ||
| 72 | + <RatingBar | ||
| 73 | + android:id="@+id/policyScoreDetail" | ||
| 74 | + android:layout_width="match_parent" | ||
| 75 | + android:layout_height="wrap_content" /> | ||
| 76 | + </LinearLayout> | ||
| 77 | + | ||
| 78 | + <TextView | ||
| 79 | + android:id="@+id/policyFavorDetail" | ||
| 80 | + android:layout_width="wrap_content" | ||
| 81 | + android:layout_height="wrap_content" | ||
| 82 | + android:layout_weight="1" | ||
| 83 | + android:text="TextView" /> | ||
| 84 | + | ||
| 85 | + </LinearLayout> | ||
| 86 | + | ||
| 87 | + <FrameLayout | ||
| 88 | + android:layout_width="match_parent" | ||
| 89 | + android:layout_height="wrap_content" | ||
| 90 | + android:id="@+id/fragmentContainer" | ||
| 91 | + app:layout_constraintBottom_toBottomOf="parent" | ||
| 92 | + > | ||
| 93 | + | ||
| 94 | + <com.google.android.material.bottomnavigation.BottomNavigationView | ||
| 95 | + android:id="@+id/bottomNavigation" | ||
| 96 | + android:layout_width="match_parent" | ||
| 97 | + android:layout_height="wrap_content" | ||
| 98 | + android:layout_gravity="bottom" | ||
| 99 | + android:background="#FFF" | ||
| 100 | + app:itemIconTint="#29ABE2" | ||
| 101 | + app:itemTextColor="#29ABE2" | ||
| 102 | + app:labelVisibilityMode="labeled" | ||
| 103 | + app:menu="@menu/bottom_nav_menu" /> | ||
| 104 | + </FrameLayout> | ||
| 105 | + | ||
| 106 | + </LinearLayout> | ||
| 107 | + | ||
| 108 | +</androidx.constraintlayout.widget.ConstraintLayout> | ||
| 8 | 109 | ||
| 9 | -</androidx.constraintlayout.widget.ConstraintLayout> | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | <resources> | 1 | <resources> |
| 2 | <string name="app_name">WELLO</string> | 2 | <string name="app_name">WELLO</string> |
| 3 | 3 | ||
| 4 | - <string name="title01">교육</string> | 4 | + <string name="title01">시간</string> |
| 5 | <string name="title02">고용</string> | 5 | <string name="title02">고용</string> |
| 6 | <string name="title03">주거</string> | 6 | <string name="title03">주거</string> |
| 7 | <string name="title04">건강</string> | 7 | <string name="title04">건강</string> | ... | ... |
-
Please register or login to post a comment