Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
kkjsw17 committed Jun 20, 2021
2 parents f04260d + 603a350 commit 13c5f21
Show file tree
Hide file tree
Showing 8 changed files with 90 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class AddArticleActivity : AppCompatActivity() {
val articleTitle = binding.titleEditText.text.toString()
val articleContent = binding.contentEditText.text.toString()
val recruitmentNumberText = binding.recruitmentNumberEditText.text.toString()
val recruitmentNumber = recruitmentNumberText.toInt()


if (articleTitle.isEmpty()) {
Toast.makeText(this, "글의 제목을 입력해주세요.", Toast.LENGTH_SHORT).show()
Expand All @@ -187,6 +187,7 @@ class AddArticleActivity : AppCompatActivity() {

showProgress()

val recruitmentNumber = recruitmentNumberText.toInt()
//중간에 이미지가 있으면 업로드 과정을 추가
selectedUriList = imageAdapter.getUriList()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ class AddTagAdapter(open val context: Context, open var data: MutableList<TagMod
// 모서리가 둥근 태그 스타일 적용(임시)
subTagText.setTextAppearance(R.style.TAG_STYLE)
subTagText.setBackgroundResource(R.drawable.layout_tag_background)
subTagText.textSize = 12f
// 태그 간 간격 설정
val p = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
Expand Down
102 changes: 77 additions & 25 deletions app/src/main/java/kr/ac/konkuk/koogle/Adapter/TagAdapter.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@ package kr.ac.konkuk.koogle.Adapter

import android.content.Context
import android.text.Editable
import android.text.InputType
import android.text.TextUtils
import android.text.TextWatcher
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.inputmethod.EditorInfo
import android.widget.*
import android.widget.LinearLayout
import androidx.core.view.children
import androidx.core.view.setMargins
import androidx.recyclerview.widget.RecyclerView
import kr.ac.konkuk.koogle.R
import kr.ac.konkuk.koogle.Model.TagModel
import kr.ac.konkuk.koogle.Model.TagType
import kr.ac.konkuk.koogle.R
import java.security.spec.EllipticCurve


/*
2021-05-27 주예진 작성
Expand Down Expand Up @@ -78,24 +84,35 @@ class TagAdapter(val context: Context, val data: MutableList<TagModel>,
var mainTagText: TextView = itemView.findViewById(R.id.mainTagText)
var mainTag: String = ""
var subTagView: LinearLayout = itemView.findViewById(R.id.subTagView)
var editNow: Int = 0
var editNowSub: Int = 0
var nowIndex: Int = -1
var editNowSub: Int = -1

private fun editTagStart(subTagName: String): Boolean{
for((j, t) in data.withIndex()){
for((i, st) in t.sub_tag_list.withIndex()){
if(subTagName == st){
editNow = j
editNowSub = i
return true
}
if(nowIndex==-1) return false

// 새로 추가된 태그의 경우
if(subTagName == " "){
editNowSub = data[nowIndex].sub_tag_list.size - 1
}

for((i, st) in data[nowIndex].sub_tag_list.withIndex()){
if(subTagName == st){
editNowSub = i
return true
}
}

for((j, t) in data.withIndex()){

}
return false
}

private fun editTag(subTagName: String){
data[editNow].sub_tag_list[editNowSub] = subTagName
if(subTagName.isNullOrBlank())
data[nowIndex].sub_tag_list.removeAt(editNowSub)
else
data[nowIndex].sub_tag_list[editNowSub] = subTagName
}

// SubTag 한 칸을 생성한다.
Expand Down Expand Up @@ -131,6 +148,10 @@ class TagAdapter(val context: Context, val data: MutableList<TagModel>,

override fun afterTextChanged(s: Editable?) {
editTag(subTagText.text.toString())
if(s.isNullOrBlank()){
for (c in subTagView.children)
((c as ScrollView).getChildAt(0) as LinearLayout).removeView(subTagText)
}
}

})
Expand All @@ -143,25 +164,36 @@ class TagAdapter(val context: Context, val data: MutableList<TagModel>,
return subTagText
}

private fun getRow(index: Int): LinearLayout{
return (subTagView.getChildAt(index) as ScrollView).getChildAt(0) as LinearLayout
}

// 태그 추가 버튼
fun makePlusBtn(): TextView {
private fun makePlusBtn(): TextView {
var subTagText = TextView(context)
subTagText.text = "+"
// 모서리가 둥근 태그 스타일 적용(임시)
subTagText.setTextAppearance(R.style.TAG_STYLE)
subTagText.setBackgroundResource(R.drawable.layout_tag_background)
subTagText.setBackgroundResource(R.drawable.layout_tag_background)
// 태그 간 간격 설정
val p = LinearLayout.LayoutParams(
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT
)
p.setMargins(5)
subTagText.layoutParams = p
// 모서리가 둥근 태그 스타일 적용(임시)
subTagText.setTextAppearance(R.style.TAG_STYLE)
subTagText.setBackgroundResource(R.drawable.layout_tag_background)
subTagText.setBackgroundResource(R.drawable.layout_tag_background)
subTagText.maxLines = 1
subTagText.ellipsize = TextUtils.TruncateAt.MARQUEE
subTagText.isSingleLine = true
subTagText.inputType = InputType.TYPE_CLASS_TEXT

// 새 태그 추가 기능
subTagText.setOnClickListener {
var lastRow: LinearLayout =
subTagView.getChildAt(subTagView.childCount - 1) as LinearLayout
var lastRow: LinearLayout = getRow(subTagView.childCount - 1)
// 이미 빈 태그가 있으면 추가하지 않음
if((lastRow.getChildAt(lastRow.childCount - 1) as TextView).text.toString()
== " ") return@setOnClickListener
lastRow.addView(makeSubTagView(" "), lastRow.childCount-1)
}
return subTagText
Expand All @@ -176,8 +208,7 @@ class TagAdapter(val context: Context, val data: MutableList<TagModel>,
addRow()
}
// 새로운 Table row 를 추가해야 하는지 길이 검사(임시)
lastRow =
subTagView.getChildAt(subTagView.childCount - 1) as LinearLayout
lastRow = getRow(subTagView.childCount - 1)
var len = 0
val row_len = 26
val margin = 1
Expand All @@ -189,15 +220,13 @@ class TagAdapter(val context: Context, val data: MutableList<TagModel>,
if (len > row_len) {
addRow()
}
lastRow =
subTagView.getChildAt(subTagView.childCount - 1) as LinearLayout
lastRow = getRow(subTagView.childCount - 1)

lastRow.addView(makeSubTagView(tag))
}
// 프로필 편집 액티비티의 경우 + 버튼 추가
if(isSetting){
lastRow =
subTagView.getChildAt(subTagView.childCount - 1) as LinearLayout
lastRow = getRow(subTagView.childCount - 1)
lastRow.addView(makePlusBtn())

// 데이터에 추가
Expand All @@ -208,6 +237,12 @@ class TagAdapter(val context: Context, val data: MutableList<TagModel>,
}
}

// 현재 Main Tag 의 View index 구함
// 리사이클러 뷰 내 위치 변경 시에도 업데이트 되어야 함
for ((i, t) in data.withIndex()){
if(t.main_tag_name == mainTag) nowIndex = i
}

}

// 태그 row 추가
Expand All @@ -220,7 +255,24 @@ class TagAdapter(val context: Context, val data: MutableList<TagModel>,
)
row.orientation = LinearLayout.HORIZONTAL
row.layoutParams = lp
subTagView.addView(row)

val newScrollView = ScrollView(context)

val layoutParams = LinearLayout.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
newScrollView.layoutParams = layoutParams

val linearParams = LinearLayout.LayoutParams(
800,
ViewGroup.LayoutParams.WRAP_CONTENT
)
row.orientation = LinearLayout.HORIZONTAL
row.layoutParams = linearParams

newScrollView.addView(row)
subTagView.addView(newScrollView)
}
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/layout/activity_check_map.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@
android:layout_height="wrap_content"
android:src="@drawable/ic_my_location"
app:layout_constraintEnd_toEndOf="parent"
android:backgroundTint="@color/colorMain"
app:layout_constraintBottom_toBottomOf="@id/mapFragment"
android:layout_marginEnd="32dp"
android:layout_marginBottom="32dp"
app:borderWidth="0dp"
android:contentDescription="현재 위치" />

</androidx.constraintlayout.widget.ConstraintLayout>
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_edit_profile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@
android:src="@drawable/ic_baseline_add_24"
app:tint="@color/white"
android:backgroundTint="@color/colorMain"
app:borderWidth="0dp"
android:layout_marginVertical="12dp"/>

</LinearLayout>
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/res/layout/activity_log_in.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@
<LinearLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="2"
android:layout_weight="2.5"
android:orientation="horizontal"
android:padding="12dp">

<LinearLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="9" />
android:layout_weight="7" />

<LinearLayout
android:layout_width="0dp"
Expand All @@ -84,21 +84,21 @@

<Button
android:id="@+id/signUpButton"
android:fontFamily="@font/font"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:fontFamily="@font/font"
android:text="@string/sign_up"
android:textStyle="bold" />

<Button
android:id="@+id/loginButton"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:layout_marginStart="8dp"
android:fontFamily="@font/font"
android:layout_marginEnd="14dp"
android:layout_weight="1"
android:fontFamily="@font/font"
android:text="@string/log_in"
android:textStyle="bold" />

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/tag_style.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="TAG_STYLE">
<item name="android:textSize">15sp</item>
<item name="android:textSize">12sp</item>
<item name="android:textColor">@color/black</item>
<item name="android:background">@drawable/layout_tag_background</item>
</style>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/values/tag_style_selected.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<style name="TAG_STYLE_SELECTED">
<item name="android:textSize">15sp</item>
<item name="android:textSize">12sp</item>
<item name="android:textColor">@color/white</item>
<item name="android:background">@drawable/layout_tag_selected_background</item>
</style>
Expand Down

0 comments on commit 13c5f21

Please sign in to comment.