Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”€ :: (#57) νšŒμ‚¬ 상세 νŽ˜μ΄μ§€ μž‘μ„± ν™”λ©΄ #59

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 14 additions & 13 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.gsps.gsp_android" >

<!--가러리 κΆŒν•œ-->
package="com.gsps.gsp_android">
<!-- 가러리 κΆŒν•œ -->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<!--가러리 κΆŒν•œ-->
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <!-- 가러리 κΆŒν•œ -->
<uses-permission android:name="android.permission.CAMERA" />

<application
Expand All @@ -14,28 +12,31 @@
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/Theme.GSP_Android" >
android:theme="@style/Theme.GSP_Android">
<activity
android:name=".ui.main.MemberInfoCategoryActivity"
android:exported="false" />
<activity
android:name=".ui.main.MemberInfoWritingActivity"
android:exported="false" />
<activity
android:name=".ui.main.SignUpActivity"
android:exported="false" >
</activity>
android:exported="false" />
<activity
android:name=".ui.main.SubAnnouncementActivity"
android:exported="false" />
<activity
android:name=".ui.main.AnnouncementActivity"
android:exported="false"/>
android:exported="false" />
<activity
android:name=".ui.main.MemberInfoActivity"
android:exported="false" />

<activity
android:name=".ui.main.InterestSettingActivity"
android:exported="false" />
<activity
android:name=".ui.main.MyOfficeActivity"
android:exported="false" />

<activity
android:name=".ui.main.ProfileActivity"
android:exported="false" />
Expand All @@ -48,7 +49,7 @@
android:theme="@style/Theme.MaterialComponents.DayNight.DarkActionBar" />
<activity
android:name=".ui.splash.SplashActivity"
android:exported="true" >
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand All @@ -57,7 +58,7 @@
</activity>
<activity
android:name=".ui.main.MainActivity"
android:exported="false"/>
android:exported="false" />
</application>

</manifest>
78 changes: 78 additions & 0 deletions app/src/main/java/com/gsps/gsp_android/ui/main/CategoryAdapter.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.gsps.gsp_android.ui.main

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.gsps.gsp_android.databinding.ItemCategoryBinding

class CategoryAdapter(
val context: Context,
private val itemList: MutableList<CategoryModel>,
private val mFinishCallback: SetFinish,
private val mResultCallback: SetResult
) : RecyclerView.Adapter<CategoryAdapter.CategoryHolder>() {
private var isNewRadioButtonChecked: Boolean = false
private var lastCheckedPosition = -1
private var isSomethingChecked = false

override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): CategoryHolder {
val binding =
ItemCategoryBinding.inflate(
LayoutInflater.from(parent.context),
parent,
false
)
return CategoryHolder(binding)
}

override fun onBindViewHolder(holder: CategoryHolder, position: Int) {
val categoryModel = itemList[position]

if (isNewRadioButtonChecked) {
holder.binding.rbCategory.isChecked = categoryModel.getChecked()
} else if (holder.adapterPosition == 0) {
lastCheckedPosition = 0;
}

holder.bind(itemList[position])
}

override fun getItemCount(): Int {
return itemList.size
}

inner class CategoryHolder(var binding: ItemCategoryBinding) :
RecyclerView.ViewHolder(binding.root) {
init {
binding.rbCategory.setOnClickListener {
if (lastCheckedPosition == adapterPosition && itemList[adapterPosition].getChecked()) {
isNewRadioButtonChecked = false
isSomethingChecked = false
itemList[adapterPosition].setChecked(false)
notifyDataSetChanged()
} else {
isNewRadioButtonChecked = true
isSomethingChecked = true
itemList[lastCheckedPosition].setChecked(false)
itemList[adapterPosition].setChecked(true)
lastCheckedPosition = adapterPosition
notifyDataSetChanged()
}

mFinishCallback.setFinish(isSomethingChecked)
if (isSomethingChecked) {
mResultCallback.setResult(itemList[lastCheckedPosition].getCategory())
}
}
}

fun bind(item: CategoryModel) {
binding.rbCategory.text = item.getCategory()
binding.rbCategory.isChecked = item.getChecked()
}
}
}
22 changes: 22 additions & 0 deletions app/src/main/java/com/gsps/gsp_android/ui/main/CategoryModel.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package com.gsps.gsp_android.ui.main

data class CategoryModel(
private var category: String,
private var isChecked: Boolean
) {
fun getCategory(): String {
return category
}

fun setCategory(category: String) {
this.category = category
}

fun getChecked(): Boolean {
return isChecked
}

fun setChecked(isChecked: Boolean) {
this.isChecked = isChecked
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class InterestsFullListAdapter(
override fun onCreateViewHolder(
parent: ViewGroup,
viewType: Int
): InterestsFullListAdapter.InterestsFullListHolder {
): InterestsFullListHolder {
val binding =
InterestsFullListItemBinding.inflate(
LayoutInflater.from(parent.context),
Expand All @@ -23,10 +23,7 @@ class InterestsFullListAdapter(
return InterestsFullListHolder(binding)
}

override fun onBindViewHolder(
holder: InterestsFullListAdapter.InterestsFullListHolder,
position: Int
) {
override fun onBindViewHolder(holder: InterestsFullListHolder, position: Int) {
holder.bind(itemList[position])
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package com.gsps.gsp_android.ui.main

import android.content.Intent
import android.widget.LinearLayout
import androidx.recyclerview.widget.StaggeredGridLayoutManager
import com.gsps.gsp_android.R
import com.gsps.gsp_android.databinding.ActivityMemberInfoCategoryBinding
import com.gsps.gsp_android.ui.base.BaseActivity

class MemberInfoCategoryActivity :
BaseActivity<ActivityMemberInfoCategoryBinding>(R.layout.activity_member_info_category),
SetFinish, SetResult {
var category: String = ""
override fun initView() {
initCategory()

val categoryList: MutableList<CategoryModel> = mutableListOf(
CategoryModel("λ””μžμΈ", false),
CategoryModel("건섀", false),
CategoryModel("인쇄&곡예", false),
CategoryModel("사무", false),
CategoryModel("ν™˜κ²½&μ—λ„ˆμ§€", false),
CategoryModel("경영&νšŒκ³„", false),
CategoryModel("ν™”ν•™&λ°”μ΄μ˜€", false),
CategoryModel("μ˜μ—…νŒλ§€", false),
CategoryModel("μ„¬μœ &의볡", false),
CategoryModel("기획&λ§ˆμΌ€νŒ…", false),
CategoryModel("보건&의료", false),
CategoryModel("μ „κΈ°&μ „μž", false),
CategoryModel("μ‚¬νšŒλ³΅μ§€", false),
CategoryModel("재료", false)
)
binding.categoryContainer.adapter = CategoryAdapter(this, categoryList, this, this)
binding.categoryContainer.layoutManager =
StaggeredGridLayoutManager(5, LinearLayout.HORIZONTAL)

binding.btnFinish.setOnClickListener {
val intent = Intent()
intent.putExtra("category", category)
setResult(RESULT_OK, intent)
finish()
}

binding.btnGoBack.setOnClickListener {
finish()
}
}

override fun setFinish(status: Boolean) {
binding.btnFinish.isEnabled = status
}

override fun setResult(category: String) {
this.category = category
}

fun initCategory() {
this.category = ""
}
}
Loading