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
easyhooon committed Jun 20, 2021
2 parents 9435e64 + 8f8b04a commit 42900d5
Show file tree
Hide file tree
Showing 9 changed files with 111 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ class ArticleActivity : AppCompatActivity() {
imageAdapter = ArticleImageAdapter()
imageAdapter.itemClickListener = object : ArticleImageAdapter.OnItemClickListener {
override fun onItemClick(holder: ArticleImageAdapter.ViewHolder, uri: Uri) {
// val intent = Intent(this@ArticleActivity, ImageViewActivity::class.java)
// intent.putExtra("uri", uri)
// startActivity(intent)
val intent = Intent(this@ArticleActivity, ImageViewActivity::class.java)
intent.putExtra("url", uri.toString())
startActivity(intent)
}
}
binding.photoImageRecyclerView.adapter = imageAdapter
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ package kr.ac.konkuk.koogle.Activity
import android.net.Uri
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.bumptech.glide.Glide
import kr.ac.konkuk.koogle.R
import kr.ac.konkuk.koogle.databinding.ActivityImageViewBinding
import java.net.URLEncoder

class ImageViewActivity : AppCompatActivity() {
lateinit var binding: ActivityImageViewBinding
Expand All @@ -14,7 +16,12 @@ class ImageViewActivity : AppCompatActivity() {
binding = ActivityImageViewBinding.inflate(layoutInflater)
setContentView(binding.root)

val uri = intent.getSerializableExtra("uri") as Uri
binding.imageView.setImageURI(uri)
Glide.with(binding.imageView)
.load(intent.getStringExtra("url"))
.into(binding.imageView)

binding.cancelImageView.setOnClickListener {
finish()
}
}
}
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
22 changes: 17 additions & 5 deletions app/src/main/res/layout/activity_image_view.xml
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http:https://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http:https://schemas.android.com/apk/res/android"
xmlns:app="http:https://schemas.android.com/apk/res-auto"
xmlns:tools="http:https://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Activity.ImageViewActivity"
android:background="@color/black">
android:background="@color/black"
tools:context=".Activity.ImageViewActivity">

<ImageView
android:id="@+id/imageView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop" />
</androidx.constraintlayout.widget.ConstraintLayout>
android:scaleType="fitCenter" />

<ImageView
android:id="@+id/cancelImageView"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="right|top"
android:layout_margin="20dp"
app:srcCompat="@drawable/cancel"
app:tint="#FFFFFF"
tools:layout_editor_absoluteX="345dp"
tools:ignore="RtlHardcoded" />

</FrameLayout>
1 change: 1 addition & 0 deletions app/src/main/res/layout/item_article.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="6dp"
android:scaleType="center"
android:src="@drawable/profile_image"
app:srcCompat="@drawable/ic_launcher_foreground" />

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 42900d5

Please sign in to comment.