Skip to content

Commit

Permalink
[feat] #125 Modify View & MyInfoView API Connection
Browse files Browse the repository at this point in the history
  • Loading branch information
sodock00 committed Mar 29, 2022
1 parent f0cd800 commit 55168f6
Show file tree
Hide file tree
Showing 12 changed files with 198 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import android.util.Log
import android.widget.Toast
import androidx.navigation.findNavController
import androidx.navigation.fragment.findNavController
import com.example.infraandroid.BuildConfig
//import com.example.infraandroid.BuildConfig
import com.example.infraandroid.util.InfraApplication
import com.example.infraandroid.R
import com.example.infraandroid.databinding.FragmentLoginBinding
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,16 @@ class MyInfoFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)

//함수로 간단하게 묶기
// 어떻게 하면 더 깔끔하게 코드를 정리할 수 있을까..! 데이터 바인딩..?
mBinding!!.myInfoMyInfoLayout.setOnClickListener {
mBinding!!.myInfoMyInfoLinearlayout.setOnClickListener {
it.findNavController().navigate(R.id.action_my_info_fragment_to_my_info_modify_fragment)
}
mBinding!!.myInfoIntroPageLayout.setOnClickListener {
/* mBinding!!.myInfoIntroPageLayout.setOnClickListener {
it.findNavController().navigate(R.id.action_my_info_fragment_to_myInfoInformationFragment)
}
}*/
mBinding!!.myInfoMyIdeaLinearlayout.setOnClickListener {
it.findNavController().navigate(R.id.action_my_info_fragment_to_myInfoMyIdeaFragment)
}
mBinding!!.myInfoEvaluationLinearlayout.setOnClickListener {
/* mBinding!!.myInfoEvaluationLinearlayout.setOnClickListener {
it.findNavController().navigate(R.id.action_my_info_fragment_to_myInfoTeamMemberEvaluationFragment)
}
mBinding!!.myInfoInterestLinearlayout.setOnClickListener {
Expand All @@ -62,7 +60,7 @@ class MyInfoFragment : Fragment() {
}
mBinding!!.myInfoHashtagAlarmLinearlayout.setOnClickListener {
it.findNavController().navigate(R.id.action_my_info_fragment_to_hashTagAlarmFragment)
}
}*/
mBinding!!.myInfoUserGuideLinearlayout.setOnClickListener {
it.findNavController().navigate(R.id.action_my_info_fragment_to_userGuideFragment)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ data class ResponseViewMyInfoData(
val isSuccess: Boolean,
val code: Int,
val message: String,
val result: ArrayList<ResponseViewMyInfoData.Result>?,
val result: Result,
){
data class Result(
val user_nickname: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,50 +20,49 @@ import com.example.infraandroid.R
import com.example.infraandroid.databinding.FragmentMyInfoModifyBinding
import com.example.infraandroid.myinfo.myinfomodify.model.RequestModifyMyInfoData
import com.example.infraandroid.myinfo.myinfomodify.model.ResponseViewMyInfoData
import com.example.infraandroid.util.BaseFragment
import com.example.infraandroid.util.InfraApplication
import com.example.infraandroid.util.ServiceCreator
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

//내 정보 > 내 정보 .kt
class MyInfoModifyFragment : Fragment() {
private var mBinding : FragmentMyInfoModifyBinding? = null
class MyInfoModifyFragment : BaseFragment<FragmentMyInfoModifyBinding>(R.layout.fragment_my_info_modify) {
/*private var mBinding : FragmentMyInfoModifyBinding? = null*/
private var isChecked = false
private var userNickname : String ?= null
private var userPrPhoto : String ?= null

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val binding = FragmentMyInfoModifyBinding.inflate(inflater, container, false)

mBinding = binding

return mBinding?.root
override fun FragmentMyInfoModifyBinding.onCreateView() {
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
override fun FragmentMyInfoModifyBinding.onViewCreated() {

val inputNicknameEditText = binding.inputNicknameEditText as EditText
val myInfoModifyBackButton = binding.myInfoModifyBackButton as ImageView
val myInfoModifyUserProfileLayout = binding.myInfoModifyUserProfileLayout as ConstraintLayout
val overlapCheckButton = binding.overlapCheckButton as AppCompatButton
val modifyCompletedButton = binding.modifyCompletedButton as TextView
val doNotUseThisNicknameTextView = binding.doNotUseThisNicknameTextView as TextView

val inputNicknameEditText = mBinding?.inputNicknameEditText as EditText
val myInfoModifyBackButton = mBinding?.myInfoModifyBackButton as ImageView
val myInfoModifyUserProfileLayout = mBinding?.myInfoModifyUserProfileLayout as ConstraintLayout
val overlapCheckButton = mBinding?.overlapCheckButton as AppCompatButton
val modifyCompletedButton = mBinding?.modifyCompletedButton as TextView
val doNotUseThisNicknameTextView = mBinding?.doNotUseThisNicknameTextView as TextView

//내 정보 보기 서버 연결
val viewcall: Call<ResponseViewMyInfoData> = ServiceCreator.myinfoService
.viewMyInfo("jwt","userId")
/*.viewMyInfo(InfraApplication.prefs.getString("jwt","null"),InfraApplication.prefs.getString("userId","null"))*/
.viewMyInfo(InfraApplication.prefs.getString("jwt","null"),InfraApplication.prefs.getString("userId","null"))
/* .viewMyInfo("jwt","userId")*/

viewcall.enqueue(object : Callback<ResponseViewMyInfoData> {
override fun onResponse(
call: Call<ResponseViewMyInfoData>,
response: Response<ResponseViewMyInfoData>
) {
val body = response.body()
if(response.isSuccessful){
when(response.body()?.code){
1000 -> { binding.myInfoModify = response.body()?.result
userNickname = response.body()?.result?.user_nickname
userPrPhoto = response.body()?.result?.user_prPhoto
}
}
}

Expand Down Expand Up @@ -119,7 +118,7 @@ class MyInfoModifyFragment : Fragment() {
}

override fun afterTextChanged(p0: Editable?) {
//얘네는 나중에 수정 필요
/*inputNicknameEditText.length() < 12 && inputNicknameEditText.length()>0*/
if (inputNicknameEditText.length() < 12) {
overlapCheckButton.isEnabled = true
} else {
Expand All @@ -137,6 +136,31 @@ class MyInfoModifyFragment : Fragment() {
}
})

//수정 완료 버튼 활성화 설정
inputNicknameEditText.addTextChangedListener(object: TextWatcher{
override fun beforeTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
modifyCompletedButton.isEnabled = false
}

override fun afterTextChanged(p0: Editable?) {
/*inputNicknameEditText.length() < 12 && inputNicknameEditText.length()>0*/
if (inputNicknameEditText.length() < 12) {
modifyCompletedButton.isEnabled = true
} else {
Toast.makeText(requireActivity(), "12자 이하로 입력해주세요.", Toast.LENGTH_SHORT).show()
}
}

override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) {
//얘네는 나중에 수정 필요
if (inputNicknameEditText.length() < 12) {
modifyCompletedButton.isEnabled = true
} else {
Toast.makeText(requireActivity(), "12자 이하로 입력해주세요.", Toast.LENGTH_SHORT).show()
}
}
})

//닉네임 중복 서버 연결 필요
//닉네임 중복 버튼 누르면
overlapCheckButton.setOnClickListener {
Expand All @@ -145,18 +169,13 @@ class MyInfoModifyFragment : Fragment() {
isChecked = true
doNotUseThisNicknameTextView.isVisible = false
inputNicknameEditText.setBackgroundResource(R.drawable.can_use_this_id_background)
mBinding?.canUseIconImageView?.isVisible = true
binding.canUseIconImageView?.isVisible = true
} else {
doNotUseThisNicknameTextView.isVisible = true
inputNicknameEditText.setBackgroundResource(R.drawable.double_check_id_background)
mBinding?.canUseIconImageView?.isVisible = false
binding.canUseIconImageView?.isVisible = false
}
}
}


override fun onDestroyView() {
mBinding = null
super.onDestroyView()
}
}
3 changes: 2 additions & 1 deletion app/src/main/res/layout/fragment_category_idea.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
android:layout_marginTop="16dp"
android:gravity="left"/>

<!--아이디어 목록 개발, 공모전, 스터디, 기타
<Button
android:id="@+id/idea_list_develop_button"
android:layout_width="match_parent"
Expand Down Expand Up @@ -231,7 +232,7 @@
app:layout_constraintBottom_toBottomOf="parent"
android:includeFontPadding="false"
android:layout_marginBottom="12dp"
android:gravity="left"/>
android:gravity="left"/>-->


</androidx.constraintlayout.widget.ConstraintLayout>
Expand Down
10 changes: 6 additions & 4 deletions app/src/main/res/layout/fragment_home.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
app:layout_constraintStart_toEndOf="@id/home_user_characteristic1_tv"
app:layout_constraintTop_toTopOf="@id/home_user_characteristic1_tv" />

<!--우체국 알람
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand All @@ -80,7 +81,7 @@
app:layout_constraintRight_toRightOf="parent"
android:layout_marginTop="18dp"
android:layout_marginRight="20dp"
android:padding="10dp" />
android:padding="10dp" />-->

<!-- 이미지 완료되면 텍스트 뷰 새로 만들기-->
<ImageView
Expand Down Expand Up @@ -158,6 +159,7 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/home_search_constraintlayout">

<!--해시태그 부분
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Expand Down Expand Up @@ -231,19 +233,19 @@
android:fontFamily="@font/noto_sans_kr_regular"
android:textColor="@color/infra_blue_c"
android:includeFontPadding="false" />
</LinearLayout>
</LinearLayout>-->

</HorizontalScrollView>

<ImageView
android:id="@+id/home_background_iv"
android:layout_width="match_parent"
android:layout_height="310dp"
android:layout_height="match_parent"
android:scaleType="centerCrop"
android:src="@drawable/ic_recommed_project_back"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/home_search_constraintlayout"
android:layout_marginTop="70dp"
android:layout_marginTop="24dp"
app:layout_constraintHorizontal_bias="1.0" />

<TextView
Expand Down
Loading

0 comments on commit 55168f6

Please sign in to comment.