Skip to content
This repository has been archived by the owner on Nov 3, 2022. It is now read-only.

Commit

Permalink
Merge pull request #659 from TeamBeMe/release/1.1.2
Browse files Browse the repository at this point in the history
Release 1.1.2
  • Loading branch information
l2hyunwoo authored Apr 5, 2021
2 parents 1999403 + a01d288 commit 083bd0f
Show file tree
Hide file tree
Showing 4 changed files with 68 additions and 32 deletions.
35 changes: 35 additions & 0 deletions app/src/main/java/com/teambeme/beme/answer/view/AnswerActivity.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package com.teambeme.beme.answer.view

import android.animation.ValueAnimator
import android.content.Context
import android.graphics.Color
import android.os.Bundle
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.style.ForegroundColorSpan
import android.text.style.UnderlineSpan
import android.util.Log
import android.view.ViewGroup
import android.view.inputmethod.InputMethodManager
import androidx.activity.viewModels
import androidx.constraintlayout.widget.ConstraintLayout
import androidx.lifecycle.lifecycleScope
Expand All @@ -17,6 +21,7 @@ import com.teambeme.beme.answer.viewmodel.AnswerViewModel
import com.teambeme.beme.base.BindingActivity
import com.teambeme.beme.data.local.entity.AnswerData
import com.teambeme.beme.databinding.ActivityAnswerBinding
import com.teambeme.beme.util.KeyboardVisibilityUtils
import com.teambeme.beme.util.StatusBarUtil
import com.teambeme.beme.util.dp
import com.teambeme.beme.util.recordClickEvent
Expand All @@ -27,6 +32,7 @@ import kotlinx.coroutines.launch
@AndroidEntryPoint
class AnswerActivity : BindingActivity<ActivityAnswerBinding>(R.layout.activity_answer) {
private val answerViewModel: AnswerViewModel by viewModels()
private lateinit var keyboardVisibilityUtils: KeyboardVisibilityUtils
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding.lifecycleOwner = this
Expand Down Expand Up @@ -54,6 +60,35 @@ class AnswerActivity : BindingActivity<ActivityAnswerBinding>(R.layout.activity_
binding.txtAnswerComplete.setOnClickListener { submitAnswer(isChange) }
setSwitchListener()
observePublicSwitch()
setHideKeyboard()
setEditTextWhenOpenKeyboard()
}

private fun setHideKeyboard() {
binding.constraintAnswer.setOnClickListener {
val keyboard = getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
keyboard.hideSoftInputFromWindow(binding.txtAnswerAnswer.windowToken, 0)
}
}

private fun setEditTextWhenOpenKeyboard() {
val param = binding.txtAnswerAnswer.layoutParams as ViewGroup.MarginLayoutParams
keyboardVisibilityUtils = KeyboardVisibilityUtils(window,
onShowKeyboard = { keyboardHeight, _ ->
param.setMargins(
param.leftMargin,
param.topMargin,
param.rightMargin,
keyboardHeight - 300
)
binding.txtAnswerAnswer.layoutParams = param
Log.d("keyboard", keyboardHeight.toString())
},
onHideKeyboard = {
param.setMargins(param.leftMargin, param.topMargin, param.rightMargin, 30)
binding.txtAnswerAnswer.layoutParams = param
}
)
}

private fun setTitleText(answerData: AnswerData) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,13 @@ class QuestionPagerAdapter(
private val fragmentManager: FragmentManager,
private val homeViewModel: HomeViewModel,
private val questionButtonClickListener: QuestionButtonClickListener
) :
RecyclerView.Adapter<RecyclerView.ViewHolder>() {
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private var answerList = mutableListOf<Answer>()

inner class QuestionViewHolder(
private val context: Context,
private val binding: ItemHomeQuestionBinding
) :
RecyclerView.ViewHolder(binding.root) {
) : RecyclerView.ViewHolder(binding.root) {
fun onBind(answer: Answer, position: Int) {
binding.answer = answer

Expand Down Expand Up @@ -104,8 +102,7 @@ class QuestionPagerAdapter(
) : RecyclerView.ViewHolder(binding.root) {
fun onBind(supportFragmentManager: FragmentManager) {
binding.btnHomeMoreQuestion.setOnClickListener {
Log.d("Home", "${answerList.all { answer -> answer.content != null }}")
if (answerList.all { answer -> answer.content != null }) {
if (answerList.last().content != null) {
homeViewModel.getMoreQuestion()
} else {
val answerSuggestFragment = AnswerSuggestFragment()
Expand Down
7 changes: 2 additions & 5 deletions app/src/main/java/com/teambeme/beme/home/view/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,14 @@ class HomeFragment : BindingFragment<FragmentHomeBinding>(R.layout.fragment_home
if (resultCode == RESULT_OK) {
val position = data!!.getIntExtra("position", -1)
val answerList = homeViewModel.answerList.value!!.toMutableList()
answerList[position].content = data!!.getStringExtra("content")
answerList[position].content = data.getStringExtra("content")
homeViewModel.refreshList(answerList)
}
}
}

private fun transformDateFormat(date: String): String {
return if (date.length > DATE_LENGTH)
date.substring(0, DATE_LENGTH)
else
date
return if (date.length > DATE_LENGTH) date.substring(0, DATE_LENGTH) else date
}

companion object {
Expand Down
49 changes: 28 additions & 21 deletions app/src/main/res/layout/activity_answer.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
</data>

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraint_answer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/background_white"
android:scrollbars="vertical"
tools:context=".answer.view.AnswerActivity">

<androidx.appcompat.widget.Toolbar
Expand Down Expand Up @@ -102,32 +104,36 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/txt_answer_data" />

<ScrollView
android:id="@+id/scrollview_answer_answer"
<!-- <ScrollView-->
<!-- android:id="@+id/scrollview_answer_answer"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="0dp"-->
<!-- android:layout_marginHorizontal="28dp"-->
<!-- android:layout_marginTop="30dp"-->
<!-- android:layout_marginBottom="100dp"-->
<!-- android:overScrollMode="never"-->
<!-- android:scrollbars="vertical"-->
<!-- app:layout_constraintBottom_toTopOf="@id/linear_answer_public"-->
<!-- app:layout_constraintTop_toBottomOf="@id/divider_answer_top">-->

<!-- -->
<!-- </ScrollView>-->
<EditText
android:id="@+id/txt_answer_answer"
android:layout_width="match_parent"
android:overScrollMode="never"
android:layout_height="0dp"
android:layout_marginHorizontal="28dp"
android:layout_marginTop="30dp"
android:layout_marginBottom="10dp"
android:layout_marginBottom="30dp"
android:background="@null"
android:gravity="top"
android:hint="답변을 써주세요"
android:text="@={answerViewModel.answer}"
android:textColor="@color/answer_text_black"
android:textColorHint="@color/answer_text_gray"
android:textSize="14sp"
app:layout_constraintBottom_toTopOf="@id/linear_answer_public"
app:layout_constraintTop_toBottomOf="@id/divider_answer_top">

<EditText
android:id="@+id/txt_answer_answer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:gravity="top"
android:hint="답변을 써주세요"
android:text="@={answerViewModel.answer}"
android:textColor="@color/answer_text_black"
android:textColorHint="@color/answer_text_gray"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintTop_toBottomOf="@+id/divider_answer_top" />
</ScrollView>

app:layout_constraintTop_toBottomOf="@id/divider_answer_top" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/linear_answer_public"
Expand Down Expand Up @@ -216,4 +222,5 @@
</androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

</layout>

0 comments on commit 083bd0f

Please sign in to comment.