Skip to content

Commit

Permalink
#210 갤러리 사진 넣기 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
tgyuuAn committed Aug 21, 2023
1 parent 3d19ec0 commit f90e66a
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>

<uses-feature android:name="android.hardware.camera.autofocus" />

<uses-feature
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
package com.android.mediproject.feature.mypage

import android.app.Activity.RESULT_OK
import android.content.Intent
import android.os.Bundle
import android.text.SpannableStringBuilder
import android.view.View
import androidx.activity.result.ActivityResultLauncher
import androidx.activity.result.contract.ActivityResultContracts
import androidx.fragment.app.viewModels
import androidx.recyclerview.widget.LinearLayoutManager
import com.android.mediproject.core.common.bindingadapter.GlideApp
Expand Down Expand Up @@ -35,6 +39,7 @@ class MyPageFragment :
override val fragmentViewModel: MyPageViewModel by viewModels()
private val myCommentListAdapter: MyPageMyCommentAdapter by lazy { MyPageMyCommentAdapter() }
private var myPageMoreBottomSheet: MyPageMoreBottomSheetFragment? = null
private var userImageUri : String = ""

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
Expand Down Expand Up @@ -125,7 +130,7 @@ class MyPageFragment :
}
}

private fun updateUserInformation(newUserData: User) =binding.apply{
private fun updateUserInformation(newUserData: User) = binding.apply {
user = newUserData
if (newUserData.profileUrl.isEmpty()) {
userImageIV.setImageResource(com.android.mediproject.core.common.R.drawable.default_user_image)
Expand Down Expand Up @@ -198,11 +203,28 @@ class MyPageFragment :
MyPageMoreBottomSheetFragment.BottomSheetFlag.WITHDRAWAL.value -> showMyPageMoreDialog(MyPageMoreDialogFragment.DialogType.WITHDRAWAL)
MyPageMoreBottomSheetFragment.BottomSheetFlag.LOGOUT.value -> showMyPageMoreDialog(MyPageMoreDialogFragment.DialogType.LOGOUT)

MyPageMoreBottomSheetFragment.BottomSheetFlag.CHANGE_IMAGE.value -> {}
MyPageMoreBottomSheetFragment.BottomSheetFlag.CHANGE_IMAGE.value -> navigateToGallery()
MyPageMoreBottomSheetFragment.BottomSheetFlag.REMOVE_IMAGE.value -> {}
}
}

private fun navigateToGallery() {
val intenet = Intent(Intent.ACTION_GET_CONTENT)
intenet.type = "image/*"
activityResult.launch(intenet)
}

private val activityResult: ActivityResultLauncher<Intent> = registerForActivityResult(ActivityResultContracts.StartActivityForResult()) {
if (it.resultCode == RESULT_OK && it.data != null) {
userImageUri = it.data!!.data

Glide.with(requireContext())
.load(uri)
.circleCrop()
.into(binding.userImageIV)
}
}

private fun showMyPageMoreDialog(dialogType: MyPageMoreDialogFragment.DialogType) {
MyPageMoreDialogFragment(dialogType).show(
requireActivity().supportFragmentManager,
Expand Down

0 comments on commit f90e66a

Please sign in to comment.