Skip to content

Commit

Permalink
[feat] #105 Project View Server Connection
Browse files Browse the repository at this point in the history
  • Loading branch information
peter-j0y committed Mar 22, 2022
1 parent 26c24a3 commit d31a800
Show file tree
Hide file tree
Showing 10 changed files with 576 additions and 444 deletions.
17 changes: 0 additions & 17 deletions .idea/deploymentTargetDropDown.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ interface ProjectService {

@POST("/project/apply")
fun postApplyProject(
@Header("X-ACCESS-TOKEN") jwt: String,
@Header("X-REFRESH-TOKEN") refreshToken: Int,
@Body body : RequestApplyProjectData
): Call<ResponseApplyProjectData>

@GET("/project/contact")
fun viewProject(
@Header("X-ACCESS-TOKEN") jwt: String,
@Header("X-REFRESH-TOKEN") refreshToken: String,
@Header("X-REFRESH-TOKEN") refreshToken: Int,
@Query("pj_num") projectNum : Int,
@Query("user_id") userId : String
): Call<ResponseViewIdeaData>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package com.example.infraandroid.category.model

import org.w3c.dom.Comment

data class ResponseApplyProjectData(
val isSuccess: Boolean,
val code: Int,
val message: String,
val result: Comment?
val result: Result?
){
data class Comment(
data class Result(
val comment: String,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,24 @@ data class ResponseViewIdeaData(
val result: Result
){
data class Result(
val hashtag: List<String>,
val hashtag: ArrayList<String>,
val pjLikeCount: Int,
val pj_categoryName: String,
val pj_content: String,
val pj_deadline: String,
val pj_endTerm: String,
val pj_header: String,
val pj_progress: String,
val pj_recruit: String,
val pj_recruitPerson: String,
val pj_startTerm: String,
val pj_subCategoryName: String,
val pj_totalPerson: String,
val pj_views: Int,
val user_id: String,
val user_nickname: String,
val user_prPhoto: String
val user_prPhoto: String,
val pj_photo: ArrayList<String>,
val pj_like: Int
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import androidx.recyclerview.widget.RecyclerView
import com.example.infraandroid.util.ImageRound
import com.example.infraandroid.R
import com.example.infraandroid.category.model.ResponseLookUpAllProjectData
import com.example.infraandroid.category.view.fragment.IdeaListFragmentDirections
import com.example.infraandroid.databinding.ItemIdeaListRecyclerviewBinding

class IdeaListAdapter(): RecyclerView.Adapter<RecyclerView.ViewHolder>() {
Expand Down Expand Up @@ -34,8 +35,8 @@ class IdeaListAdapter(): RecyclerView.Adapter<RecyclerView.ViewHolder>() {
ImageRound.roundAll(binding.projectImageView, 36f)
binding.projectList = ideaListInfo
itemView.setOnClickListener {
it.findNavController().navigate(R.id.action_idea_list_fragment_to_categoryViewIdeaFragment)

val action = IdeaListFragmentDirections.actionIdeaListFragmentToCategoryViewIdeaFragment(ideaListInfo.pj_num)
it.findNavController().navigate(action)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ import android.view.ViewGroup
import android.widget.Toast
import androidx.appcompat.widget.AppCompatButton
import androidx.fragment.app.Fragment
import androidx.navigation.fragment.navArgs
import com.example.infraandroid.R
import com.example.infraandroid.category.model.RequestApplyProjectData
import com.example.infraandroid.category.model.ResponseApplyProjectData
import com.example.infraandroid.category.model.ResponseViewIdeaData
import com.example.infraandroid.databinding.FragmentViewIdeaBinding
import com.example.infraandroid.id.viewmodel.SignUpViewModel.Companion.TAG
import com.example.infraandroid.util.BaseFragment
import com.example.infraandroid.util.InfraApplication
import com.example.infraandroid.util.ServiceCreator
import retrofit2.Call
Expand All @@ -20,31 +24,54 @@ import retrofit2.Response

// 다른 사람의 아이디어를 눌렀을 때 볼 수 있는 자세히 보기 뷰

class CategoryViewIdeaFragment : Fragment(){
private var mBinding : FragmentViewIdeaBinding? = null
class CategoryViewIdeaFragment : BaseFragment<FragmentViewIdeaBinding>(R.layout.fragment_view_idea){

override fun FragmentViewIdeaBinding.onCreateView(){

override fun onCreateView(
inflater: LayoutInflater,
container: ViewGroup?,
savedInstanceState: Bundle?
): View? {
val binding = FragmentViewIdeaBinding.inflate(inflater, container, false)
mBinding = binding
return mBinding?.root
}

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
override fun FragmentViewIdeaBinding.onViewCreated() {
val args: CategoryViewIdeaFragmentArgs by navArgs()
val projectNum = args.projectNum
Log.d(TAG, "onViewCreated: $projectNum")

val call: Call<ResponseViewIdeaData> = ServiceCreator.projectService
.viewProject(InfraApplication.prefs.getString("jwt", "null"),
InfraApplication.prefs.getString("refreshToken", "null").toInt(),
projectNum,
InfraApplication.prefs.getString("userId", "null")
)

call.enqueue(object:Callback<ResponseViewIdeaData>{
override fun onResponse(
call: Call<ResponseViewIdeaData>,
response: Response<ResponseViewIdeaData>
) {
if(response.isSuccessful){
when(response.body()?.code){
1000 -> {
Log.d(TAG, "onResponse: "+"접속연결성공!")
binding.viewIdea = response.body()?.result }
}
}
}

val applyButton = mBinding?.teamIdeaApplyButton as AppCompatButton
override fun onFailure(call: Call<ResponseViewIdeaData>, t: Throwable) {
Log.d(TAG, "onFailure: $t")
}

})


val applyButton = binding.teamIdeaApplyButton as AppCompatButton
applyButton.setOnClickListener {
val requestApplyProjectData = RequestApplyProjectData(
projectNum = 1,
projectNum = projectNum,
userId = InfraApplication.prefs.getString("userId", "null")
)

val call: Call<ResponseApplyProjectData> = ServiceCreator.projectService
.postApplyProject(requestApplyProjectData)
.postApplyProject(InfraApplication.prefs.getString("jwt","null"), InfraApplication.prefs.getString("refreshToken", "null").toInt(), requestApplyProjectData)
call.enqueue(object:Callback<ResponseApplyProjectData>{
override fun onResponse(
call: Call<ResponseApplyProjectData>,
Expand All @@ -65,9 +92,4 @@ class CategoryViewIdeaFragment : Fragment(){
})
}
}

override fun onDestroyView() {
mBinding = null
super.onDestroyView()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ data class ResponseLoginData(
val userName : String,
@SerializedName("user_nickname")
val userNickName : String,
@SerializedName("jwtRefreshIdx")
val refreshToken : Int
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ class LoginFragment : BaseFragment<FragmentLoginBinding>(R.layout.fragment_login
when(code){
1000 -> {
InfraApplication.prefs.setString("jwt", response.body()?.result?.jwt.toString())
InfraApplication.prefs.setString("refreshToken", response.body()?.result?.refreshToken.toString())
InfraApplication.prefs.setString("userId", response.body()?.result?.userId.toString())
InfraApplication.prefs.setString("userNickName", response.body()?.result?.userNickName.toString())
Toast.makeText(requireActivity(),"요청에 성공하셨습니다.", Toast.LENGTH_SHORT).show()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,50 @@ import androidx.core.view.isVisible
import androidx.databinding.BindingAdapter
import com.bumptech.glide.Glide
import com.example.infraandroid.R
import org.w3c.dom.Text

object BindingConversions {
@JvmStatic
@BindingAdapter("loadImg")
fun loadImage(imageView: ImageView, url: String){
fun loadImage(imageView: ImageView, url: String?){
Glide.with(imageView.context).load(url)
.error(R.drawable.ic_infra_logo)
.into(imageView)
}

@JvmStatic
@BindingAdapter("projectImg")
fun projectImg(imageView: ImageView, url: String?){
if(url==null){
imageView.isGone = true
}
else{
Glide.with(imageView.context).load(url)
.into(imageView)
}
}

@JvmStatic
@BindingAdapter("makingTerm")
fun makingTerm(textView: TextView, startDate: String, endDate: String){
val startYear = startDate.substring(0 until 5).toInt()
val startMonth = startDate.substring(5 until 7).toInt()
val startDay = startDate.substring(9 until 11).toInt()
val endYear = startDate.substring(0 until 5).toInt()
val endMonth = startDate.substring(5 until 7).toInt()
val endDay = startDate.substring(9 until 11).toInt()
textView.text = "${startYear}${startMonth}${startDay}일-${endYear}${endMonth}${endDay}"
}

@JvmStatic
@BindingAdapter("loadCircleImg")
fun loadCircleImg(imageView: ImageView, url: String?){
Glide.with(imageView.context).load(url)
.circleCrop()
.error(R.drawable.ic_infra_logo)
.into(imageView)
}

@JvmStatic
@BindingAdapter("getStringFromInt")
fun getStringFromInt(textView: TextView, num: Int){
Expand Down Expand Up @@ -48,12 +82,32 @@ object BindingConversions {

@JvmStatic
@BindingAdapter("deadline")
fun setDeadlineText(textView: TextView, comment: String){
fun setDeadlineText(textView: TextView, comment: String?){
textView.text = comment
when(comment){
"마감" -> textView.setTextColor(Color.parseColor("#8F8F8F"))
"마감임박" -> textView.setTextColor(Color.parseColor("#9277F8"))
"모집중" -> textView.setTextColor(Color.parseColor("#4B8EFF"))
}
}

@JvmStatic
@BindingAdapter(value = ["endRecruitDate", "status"], requireAll = true)
fun setEndRecruitText(textView: TextView, endRecruitDate: String, status: String){
val year = endRecruitDate.substring(0 until 5).toInt()
val month = endRecruitDate.substring(5 until 7).toInt()
val day = endRecruitDate.substring(9 until 11).toInt()
textView.text = "{$year}년 {$month}월 {$day}일까지 모집"
when(status){
"마감" -> textView.setTextColor(Color.parseColor("#8F8F8F"))
"마감임박" -> textView.setTextColor(Color.parseColor("#9277F8"))
"모집중" -> textView.setTextColor(Color.parseColor("#4B8EFF"))
}
}

@JvmStatic
@BindingAdapter("intToString")
fun intToString(textView: TextView, number: Int){
textView.text = number.toString()
}
}
Loading

0 comments on commit d31a800

Please sign in to comment.